Skip to content

Commit

Permalink
Merge pull request #12 from devops-kung-fu/codefix
Browse files Browse the repository at this point in the history
Fixes tests
  • Loading branch information
mirxcle authored Mar 11, 2024
2 parents 5c6e176 + 33fa732 commit c69eb1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func (c *Converter) Convert(filename string) error {
return err
}

filename = path.Join(c.OutputFolder, filename)
return c.writeToFile(kissbom, c.OutputFormat, filename)
c.OutputFileName = path.Join(c.OutputFolder, filename)
return c.writeToFile(kissbom)
}

// transform takes a byte slice representing a CycloneDX Bill of Materials (BOM) in JSON format,
Expand Down Expand Up @@ -81,7 +81,7 @@ func (c *Converter) buildOutputFilename(cdx *cyclonedx.BOM) string {
subject := cdx.Metadata.Component.Name
publisher := cdx.Metadata.Component.Publisher
timestamp := cdx.Metadata.Timestamp
c.OutputFileName = fmt.Sprintf("%s_%s_%s", subject, publisher, timestamp)
return fmt.Sprintf("%s_%s_%s", subject, publisher, timestamp)
}
t := time.Now()
return fmt.Sprint(t.Format("20060102150405"))
Expand Down
3 changes: 1 addition & 2 deletions lib/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestConvert_Success(t *testing.T) {
return err
}()

assert.NoError(t,e)
assert.NoError(t, e)
converter.OutputFormat = "csv" // Choose a valid output format for testing
err = converter.Convert("test.json")
assert.Error(t, err, "Expected no error")
Expand Down Expand Up @@ -139,7 +139,6 @@ func TestTransform_Success(t *testing.T) {
assert.NoError(t, err, "Expected no error")
assert.NotNil(t, kissBom, "Expected KissBOM object to be not nil")
assert.NotEmpty(t, converter.OutputFileName, "Expected filename to be not empty")
assert.Equal(t, converter.OutputFileName, "test")
assert.Len(t, kissBom.Packages, 1)
assert.Equal(t, kissBom.Packages[0].Purl, "pkg:pypi/[email protected]")
}
Expand Down

0 comments on commit c69eb1c

Please sign in to comment.