github.com/goreleaser/goreleaser@v1.25.1/cmd/schema_test.go (about) 1 package cmd 2 3 import ( 4 "encoding/json" 5 "os" 6 "path" 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestGenerateSchema(t *testing.T) { 13 cmd := newSchemaCmd().cmd 14 dir := t.TempDir() 15 destination := path.Join(dir, "schema.json") 16 cmd.SetArgs([]string{"--output", destination}) 17 require.NoError(t, cmd.Execute()) 18 19 outFile, err := os.Open(destination) 20 require.NoError(t, err) 21 22 schema := map[string]interface{}{} 23 require.NoError(t, json.NewDecoder(outFile).Decode(&schema)) 24 require.Equal(t, "https://json-schema.org/draft/2020-12/schema", schema["$schema"].(string)) 25 }