MCPcopy
hub / github.com/ossf/scorecard / Test_getRepoCommitHashLocal

Function Test_getRepoCommitHashLocal

pkg/scorecard/scorecard_test.go:84–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func Test_getRepoCommitHashLocal(t *testing.T) {
85 t.Parallel()
86 tests := []struct {
87 name string
88 path string
89 want string
90 wantErr bool
91 }{
92 {
93 name: "local directory",
94 path: "testdata",
95 want: "unknown",
96 wantErr: false,
97 },
98 }
99
100 for _, tt := range tests {
101 t.Run(tt.name, func(t *testing.T) {
102 t.Parallel()
103 logger := log.NewLogger(log.DebugLevel)
104 localDirClient := localdir.CreateLocalDirClient(t.Context(), logger)
105 localRepo, err := localdir.MakeLocalDirRepo("testdata")
106 if err != nil {
107 t.Errorf("MakeLocalDirRepo: %v", err)
108 return
109 }
110 if err := localDirClient.InitRepo(localRepo, clients.HeadSHA, 0); err != nil {
111 t.Errorf("InitRepo: %v", err)
112 return
113 }
114
115 got, err := getRepoCommitHash(localDirClient)
116 if (err != nil) != tt.wantErr {
117 t.Errorf("getRepoCommitHash() error = %v, wantErr %v", err, tt.wantErr)
118 return
119 }
120 if got != tt.want {
121 t.Errorf("getRepoCommitHash() got = %v, want %v", got, tt.want)
122 }
123 })
124 }
125}
126
127func TestRun(t *testing.T) {
128 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewLoggerFunction · 0.92
CreateLocalDirClientFunction · 0.92
MakeLocalDirRepoFunction · 0.92
getRepoCommitHashFunction · 0.85
RunMethod · 0.65
InitRepoMethod · 0.65

Tested by

no test coverage detected