Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Jun 27, 2022
1 parent 4ede455 commit dc3518f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion options/options.go
Expand Up @@ -97,6 +97,7 @@ func New() (*Options, error) {

// Validate validates the scorecard configuration.
func (o *Options) Validate() error {
fmt.Println("EnvGithubAuthToken:", EnvGithubAuthToken, os.Getenv(EnvGithubAuthToken))
if os.Getenv(EnvGithubAuthToken) == "" {
fmt.Printf("%s variable is empty.\n", EnvGithubAuthToken)
if o.IsForkStr == trueStr {
Expand Down Expand Up @@ -147,7 +148,7 @@ func (o *Options) setScorecardOpts() {
inputToken := os.Getenv(EnvInputRepoToken)
if inputToken == "" {
fmt.Printf("The 'repo_token' variable is empty.\n")
fmt.Printf("Using the %s instead.\n", EnvInputInternalRepoToken)
fmt.Printf("Using the '%s' variable instead.\n", EnvInputInternalRepoToken)
inputToken := os.Getenv(EnvInputInternalRepoToken)
os.Setenv(EnvGithubAuthToken, inputToken)
}
Expand Down
3 changes: 3 additions & 0 deletions options/options_test.go
Expand Up @@ -241,6 +241,9 @@ func TestNew(t *testing.T) {
os.Setenv(EnvInputResultsFormat, tt.resultsFormat)
defer os.Unsetenv(EnvInputResultsFormat)

os.Setenv(EnvInputRepoToken, "token-value-123456")
defer os.Unsetenv(EnvInputRepoToken)

if tt.unsetResultsPath {
os.Unsetenv(EnvInputResultsFile)
} else {
Expand Down

0 comments on commit dc3518f

Please sign in to comment.