@@ -21,6 +21,12 @@ import (
2121//go:embed testdata/memdbtables.json
2222var memDBPackageJSON string
2323
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+
2430func TestPluginPackage_Source (t * testing.T ) {
2531 _ , filename , _ , ok := runtime .Caller (0 )
2632 if ! ok {
@@ -39,6 +45,7 @@ func TestPluginPackage_Source(t *testing.T) {
3945 }),
4046 plugin .WithKind ("source" ),
4147 plugin .WithTeam ("test-team" ),
48+ plugin .WithJSONSchema (sourceSpecSchema ),
4249 )
4350 msg := `Test message
4451with multiple lines and **markdown**`
@@ -78,6 +85,7 @@ with multiple lines and **markdown**`
7885 "package.json" ,
7986 "plugin-test-plugin-v1.2.3-linux-amd64.zip" ,
8087 "plugin-test-plugin-v1.2.3-windows-amd64.zip" ,
88+ "spec_json_schema.json" ,
8189 "tables.json" ,
8290 }
8391 if diff := cmp .Diff (expect , fileNames (files )); diff != "" {
@@ -112,6 +120,7 @@ with multiple lines and **markdown**`
112120 }
113121 checkDocs (t , filepath .Join (distDir , "docs" ), expectDocs )
114122 checkTables (t , distDir )
123+ checkFileContent (t , filepath .Join (distDir , "spec_json_schema.json" ), sourceSpecSchema )
115124 })
116125 }
117126}
@@ -134,6 +143,7 @@ func TestPluginPackage_Destination(t *testing.T) {
134143 }),
135144 plugin .WithKind ("destination" ),
136145 plugin .WithTeam ("test-team" ),
146+ plugin .WithJSONSchema (destinationSpecSchema ),
137147 )
138148 msg := `Test message
139149with multiple lines and **markdown**`
@@ -173,6 +183,7 @@ with multiple lines and **markdown**`
173183 "package.json" ,
174184 "plugin-test-plugin-v1.2.3-darwin-amd64.zip" ,
175185 "plugin-test-plugin-v1.2.3-windows-amd64.zip" ,
186+ "spec_json_schema.json" ,
176187 }
177188 if diff := cmp .Diff (expect , fileNames (files )); diff != "" {
178189 t .Fatalf ("unexpected files in dist directory (-want +got):\n %s" , diff )
@@ -205,6 +216,7 @@ with multiple lines and **markdown**`
205216 "overview.md" ,
206217 }
207218 checkDocs (t , filepath .Join (distDir , "docs" ), expectDocs )
219+ checkFileContent (t , filepath .Join (distDir , "spec_json_schema.json" ), destinationSpecSchema )
208220 })
209221 }
210222}
@@ -327,6 +339,21 @@ func checkPackageJSONContents(t *testing.T, filename string, expect PackageJSON)
327339 }
328340}
329341
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+
330357func fileNames (files []os.DirEntry ) []string {
331358 names := make ([]string , 0 , len (files ))
332359 for _ , file := range files {
0 commit comments