-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
217 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Package lib contains core functionality to load Software Bill of Materials and contains common functions | ||
package lib | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSetupSpinner(t *testing.T) { | ||
// Create a mock Scanner instance | ||
scanner := Scanner{} | ||
|
||
// Call the setupSpinner function | ||
spinner := scanner.setupSpinner([]string{"ecosystem1", "ecosystem2"}, []string{"package1", "package2"}) | ||
|
||
// Assert that the returned spinner is not nil | ||
assert.NotNil(t, spinner, "Expected non-nil spinner, got nil") | ||
} | ||
|
||
// func TestExitWithCodeIfRequired(t *testing.T) { | ||
|
||
// _ = os.Exit | ||
|
||
// // Create a mock Scanner instance | ||
// scanner := &Scanner{ | ||
// ExitCode: true, | ||
// } | ||
|
||
// // Mock results with a specific severity | ||
// severitySummary := models.Summary{ | ||
// Unspecified: 1, | ||
// Low: 2, | ||
// Moderate: 3, | ||
// High: 4, | ||
// Critical: 5, | ||
// } | ||
|
||
// results := models.Results{ | ||
// Summary: severitySummary, | ||
// } | ||
|
||
// // Mock the log.Printf function | ||
// var logOutput string | ||
// log.SetOutput(&mockLogger{&logOutput}) | ||
|
||
// // Call the exitWithCodeIfRequired method | ||
// scanner.exitWithCodeIfRequired(results) | ||
|
||
// // Assert the log output contains the expected message | ||
// require.Contains(t, logOutput, "fail severity: 5", "Log output does not contain expected message") | ||
// } | ||
|
||
// // mockLogger is a simple implementation of io.Writer to capture log output | ||
// type mockLogger struct { | ||
// output *string | ||
// } | ||
|
||
// func (m *mockLogger) Write(p []byte) (n int, err error) { | ||
// *m.output += string(p) | ||
// return len(p), nil | ||
// } |