Debian Codegraph @

tests/thirdparty/config_test.go

raw symbols SCIP
1 package thirdpartyscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.18 bytes/"
5 "reflectscip-go gomod github.com/golang/go/src go1.18 reflect/"
6 "stringsscip-go gomod github.com/golang/go/src go1.18 strings/"
7 "testingscip-go gomod github.com/golang/go/src go1.18 testing/"
8 )
9
10 func TestValidateErrorsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/TestValidateErrors().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
11 cases := []struct {
12 Name string
13 Item interface{ Validate() error }
14 ErrorSubstring string
15 }{
16 {
17 Name: "step_missing_name",
18 Item: &Stepscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Step#{},
19 ErrorSubstring: "missing name",
20 },
21 {
22 Name: "step_missing_commands",
23 Item: &Stepscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Step#{
24 Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Step#Name.: "Setup",
25 },
26 ErrorSubstring: "missing commands",
27 },
28 {
29 Name: "project_missing_default_branch",
30 Item: &Projectscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#{
31 Repositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Repository.: GithubRepositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#{Ownerscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Owner.: "octocat", Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Name.: "hello-world"},
32 },
33 ErrorSubstring: "missing default branch",
34 },
35 {
36 Name: "project_missing_version",
37 Item: &Projectscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#{
38 Repositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Repository.: GithubRepositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#{Ownerscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Owner.: "octocat", Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Name.: "hello-world"},
39 DefaultBranchscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#DefaultBranch.: "main",
40 },
41 ErrorSubstring: "missing version",
42 },
43 {
44 Name: "project_missing_packages",
45 Item: &Projectscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#{
46 Repositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Repository.: GithubRepositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#{Ownerscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Owner.: "octocat", Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Name.: "hello-world"},
47 DefaultBranchscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#DefaultBranch.: "main",
48 Versionscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Version.: "v0.1.1",
49 },
50 ErrorSubstring: "missing packages",
51 },
52 {
53 Name: "project_package_error",
54 Item: &Projectscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#{
55 Repositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Repository.: GithubRepositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#{Ownerscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Owner.: "octocat", Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Name.: "hello-world"},
56 DefaultBranchscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#DefaultBranch.: "main",
57 Versionscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Version.: "v0.1.1",
58 Packagesscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Packages.: []*Packagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#{
59 {},
60 },
61 },
62 ErrorSubstring: "package root: missing module",
63 },
64 {
65 Name: "package_missing_module",
66 Item: &Packagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#{},
67 ErrorSubstring: "missing module",
68 },
69 {
70 Name: "package_no_generate_commands",
71 Item: &Packagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#{
72 Modulescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#Module.: "avo/go.mod",
73 },
74 ErrorSubstring: "no generate commands",
75 },
76 {
77 Name: "package_invalid_generate_commands",
78 Item: &Packagescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#{
79 Modulescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#Module.: "avo/go.mod",
80 Generatescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#Generate.: []*Stepscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Step#{
81 {},
82 },
83 },
84 ErrorSubstring: "generate step: missing name",
85 },
86 {
87 Name: "projects_invalid_package",
88 Item: Projectsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Projects#{
89 {
90 Repositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Repository.: GithubRepositoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#{Ownerscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Owner.: "octocat", Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/GithubRepository#Name.: "hello-world"},
91 },
92 },
93 ErrorSubstring: "missing default branch",
94 },
95 }
96 for _, c := range cases {
97 c := c // scopelint
98 t.Runscip-go gomod github.com/golang/go/src go1.18 testing/T#Run().(c.Name, func(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
99 err := c.Item.Validate()
100 if err == nil {
101 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("expected error; got nil")
102 }
103 if !stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Containsscip-go gomod github.com/golang/go/src go1.18 strings/Contains().(err.Error(), c.ErrorSubstring) {
104 t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("expected error message to contain %q; got %q", c.ErrorSubstring, err)
105 }
106 })
107 }
108 }
109
110 func TestLoadSuiteBadscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/TestLoadSuiteBad().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
111 r := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.NewReaderscip-go gomod github.com/golang/go/src go1.18 strings/NewReader().(`[{"unknown_field": "value"}]`)
112 _, err := LoadSuitescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/LoadSuite().(r)
113 if err == nil {
114 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("expected non-nil error")
115 }
116 }
117
118 func TestLoadSuiteFileNotExistscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/TestLoadSuiteFileNotExist().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
119 s, err := LoadSuiteFilescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/LoadSuiteFile().("does_not_exist")
120 if s != nil {
121 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("expected nil return")
122 }
123 if err == nil {
124 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("expected non-nil error")
125 }
126 }
127
128 func TestSuiteFileValidscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/TestSuiteFileValid().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
129 s, err := LoadSuiteFilescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/LoadSuiteFile().("suite.json")
130 if err != nil {
131 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err)
132 }
133 for _, prj := range s.Projectsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Suite#Projects. {
134 t.Logfscip-go gomod github.com/golang/go/src go1.18 testing/common#Logf().("read: %s", prj.IDscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#ID().())
135 }
136 if len(s.Projectsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Suite#Projects.) == 0 {
137 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("no packages loaded")
138 }
139 if err := s.Validatescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Suite#Validate().(); err != nil {
140 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err)
141 }
142 }
143
144 func TestSuiteFileStepsValidscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/TestSuiteFileStepsValid().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
145 suite, err := LoadSuiteFilescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/LoadSuiteFile().("suite.json")
146 if err != nil {
147 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err)
148 }
149 c := &Contextscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Context#{
150 AvoDirectoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Context#AvoDirectory.: "avo",
151 RepositoryDirectoryscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Context#RepositoryDirectory.: "repo",
152 }
153 for _, prj := range suite.Projectsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Suite#Projects. {
154 for _, pkg := range prj.Packagesscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#Packages. {
155 for _, s := range pkg.Stepsscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#Steps().(c) {
156 if err := s.Validatescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Step#Validate().(); err != nil {
157 t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("project %s: package %s: %s", prj.IDscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Project#ID().(), pkg.Namescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/Package#Name().(), err)
158 }
159 }
160 }
161 }
162 }
163
164 func TestSuiteFileRoundtripscip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/TestSuiteFileRoundtrip().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) {
165 s, err := LoadSuiteFilescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/LoadSuiteFile().("suite.json")
166 if err != nil {
167 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err)
168 }
169
170 // Write and read back.
171 buf := bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.18 bytes/NewBuffer().(nil)
172 if err := StoreSuitescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/StoreSuite().(buf, s); err != nil {
173 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err)
174 }
175
176 roundtrip, err := LoadSuitescip-go gomod github.com/mmcloughlin/avo . `github.com/mmcloughlin/avo/tests/thirdparty`/LoadSuite().(buf)
177 if err != nil {
178 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err)
179 }
180
181 // Should be identical.
182 if !reflectscip-go gomod github.com/golang/go/src go1.18 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.18 reflect/DeepEqual().(s, roundtrip) {
183 t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("roundtrip mismatch")
184 }
185 }