@@ -21,6 +21,12 @@ import (
21
21
//go:embed testdata/memdbtables.json
22
22
var memDBPackageJSON string
23
23
24
+ //go:embed testdata/source_spec_schema.json
25
+ var sourceSpecSchema string
26
+
27
+ //go:embed testdata/destination_spec_schema.json
28
+ var destinationSpecSchema string
29
+
24
30
func TestPluginPackage_Source (t * testing.T ) {
25
31
_ , filename , _ , ok := runtime .Caller (0 )
26
32
if ! ok {
@@ -39,6 +45,7 @@ func TestPluginPackage_Source(t *testing.T) {
39
45
}),
40
46
plugin .WithKind ("source" ),
41
47
plugin .WithTeam ("test-team" ),
48
+ plugin .WithJSONSchema (sourceSpecSchema ),
42
49
)
43
50
msg := `Test message
44
51
with multiple lines and **markdown**`
@@ -78,6 +85,7 @@ with multiple lines and **markdown**`
78
85
"package.json" ,
79
86
"plugin-test-plugin-v1.2.3-linux-amd64.zip" ,
80
87
"plugin-test-plugin-v1.2.3-windows-amd64.zip" ,
88
+ "spec_json_schema.json" ,
81
89
"tables.json" ,
82
90
}
83
91
if diff := cmp .Diff (expect , fileNames (files )); diff != "" {
@@ -112,6 +120,7 @@ with multiple lines and **markdown**`
112
120
}
113
121
checkDocs (t , filepath .Join (distDir , "docs" ), expectDocs )
114
122
checkTables (t , distDir )
123
+ checkFileContent (t , filepath .Join (distDir , "spec_json_schema.json" ), sourceSpecSchema )
115
124
})
116
125
}
117
126
}
@@ -134,6 +143,7 @@ func TestPluginPackage_Destination(t *testing.T) {
134
143
}),
135
144
plugin .WithKind ("destination" ),
136
145
plugin .WithTeam ("test-team" ),
146
+ plugin .WithJSONSchema (destinationSpecSchema ),
137
147
)
138
148
msg := `Test message
139
149
with multiple lines and **markdown**`
@@ -173,6 +183,7 @@ with multiple lines and **markdown**`
173
183
"package.json" ,
174
184
"plugin-test-plugin-v1.2.3-darwin-amd64.zip" ,
175
185
"plugin-test-plugin-v1.2.3-windows-amd64.zip" ,
186
+ "spec_json_schema.json" ,
176
187
}
177
188
if diff := cmp .Diff (expect , fileNames (files )); diff != "" {
178
189
t .Fatalf ("unexpected files in dist directory (-want +got):\n %s" , diff )
@@ -205,6 +216,7 @@ with multiple lines and **markdown**`
205
216
"overview.md" ,
206
217
}
207
218
checkDocs (t , filepath .Join (distDir , "docs" ), expectDocs )
219
+ checkFileContent (t , filepath .Join (distDir , "spec_json_schema.json" ), destinationSpecSchema )
208
220
})
209
221
}
210
222
}
@@ -327,6 +339,21 @@ func checkPackageJSONContents(t *testing.T, filename string, expect PackageJSON)
327
339
}
328
340
}
329
341
342
+ func checkFileContent (t * testing.T , filename string , expect string ) {
343
+ f , err := os .Open (filename )
344
+ if err != nil {
345
+ t .Fatalf ("failed to open %s: %v" , filename , err )
346
+ }
347
+ defer f .Close ()
348
+ b , err := io .ReadAll (f )
349
+ if err != nil {
350
+ t .Fatalf ("failed to read %s: %v" , filename , err )
351
+ }
352
+ if diff := cmp .Diff (expect , string (b )); diff != "" {
353
+ t .Fatalf ("%s contents mismatch (-want +got):\n %s" , filename , diff )
354
+ }
355
+ }
356
+
330
357
func fileNames (files []os.DirEntry ) []string {
331
358
names := make ([]string , 0 , len (files ))
332
359
for _ , file := range files {
0 commit comments