MCPcopy
hub / github.com/apache/devlake / TestVerifyScope

Function TestVerifyScope

backend/helpers/pluginhelper/api/scope_helper_test.go:126–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestVerifyScope(t *testing.T) {
127 apiHelper := createMockScopeHelper[TestFakeGithubRepo]("GithubId")
128 testCases := []struct {
129 name string
130 model TestModel
131 wantErr bool
132 }{
133 {
134 name: "valid case",
135 model: TestModel{
136 ID: 1,
137 Name: "test name",
138 },
139 wantErr: false,
140 },
141 {
142 name: "zero value",
143 model: TestModel{
144 ID: 0,
145 Name: "test name",
146 },
147 wantErr: true,
148 },
149 {
150 name: "nil value",
151 model: TestModel{
152 ID: 1,
153 Name: "",
154 },
155 wantErr: false,
156 },
157 }
158
159 for _, tc := range testCases {
160 err := apiHelper.verifyScope(&tc.model, validator.New())
161 if (err != nil) != tc.wantErr {
162 t.Errorf("unexpected error value - got: %v, want: %v", err, tc.wantErr)
163 }
164
165 }
166}
167
168type TestScopeConfig struct {
169 common.Model `mapstructure:"-"`

Callers

nothing calls this directly

Calls 2

verifyScopeMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected