Skip to content

Commit

Permalink
Merge branch 'main' into avbalter/support-nuget-unpinned-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon authored Apr 14, 2023
2 parents 3649d09 + ccb461c commit 87f0c1e
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
79 changes: 79 additions & 0 deletions checker/detail_logger_impl_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package checker

import (
"testing"
)

func Test_logger_Info(t *testing.T) {
l := &logger{
logs: []CheckDetail{},
}
l.Info(&LogMessage{Text: "test"})
if len(l.logs) != 1 && l.logs[0].Type != DetailInfo {
t.Errorf("expected 1 log, got %d", len(l.logs))
}
}

func Test_logger_Warn(t *testing.T) {
l := &logger{
logs: []CheckDetail{},
}
l.Warn(&LogMessage{Text: "test"})
if len(l.logs) != 1 && l.logs[0].Type != DetailWarn {
t.Errorf("expected 1 log, got %d", len(l.logs))
}
}

func Test_logger_Flush(t *testing.T) {
l := &logger{
logs: []CheckDetail{},
}
l.Warn(&LogMessage{Text: "test"})
ret := l.Flush()
if len(ret) != 1 {
t.Errorf("expected 1 log, got %d", len(ret))
}
if len(l.logs) != 0 {
t.Errorf("expected 0 log, got %d", len(l.logs))
}
}

func Test_logger_Logs(t *testing.T) {
l := &logger{
logs: []CheckDetail{},
}
l.Warn(&LogMessage{Text: "test"})
if len(l.Logs()) != 1 {
t.Errorf("expected 1 log, got %d", len(l.logs))
}
}

func Test_logger_Debug(t *testing.T) {
l := &logger{
logs: []CheckDetail{},
}
l.Debug(&LogMessage{Text: "test"})
if len(l.logs) != 1 && l.logs[0].Type != DetailDebug {
t.Errorf("expected 1 log, got %d", len(l.logs))
}
}

func TestNewLogger(t *testing.T) {
l := NewLogger()
if l == nil {
t.Errorf("expected non-nil logger, got nil")
}
}
6 changes: 3 additions & 3 deletions checker/raw_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type Package struct {
Runs []Run
}

// DependencyUseType reprensets a type of dependency use.
// DependencyUseType represents a type of dependency use.
type DependencyUseType string

const (
Expand Down Expand Up @@ -325,7 +325,7 @@ type DangerousWorkflow struct {
File File
}

// WorkflowJob reprresents a workflow job.
// WorkflowJob represents a workflow job.
type WorkflowJob struct {
Name *string
ID *string
Expand All @@ -350,7 +350,7 @@ const (
type PermissionLevel string

const (
// PermissionLevelUndeclared is an undecleared permission.
// PermissionLevelUndeclared is an undeclared permission.
PermissionLevelUndeclared PermissionLevel = "undeclared"
// PermissionLevelWrite is a permission set to `write` for a permission we consider potentially dangerous.
PermissionLevelWrite PermissionLevel = "write"
Expand Down

0 comments on commit 87f0c1e

Please sign in to comment.