1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/cmd/schema_test.go

26 lines
582 B
Go
Raw Normal View History

package cmd
import (
"encoding/json"
"os"
"path"
"testing"
"github.com/stretchr/testify/require"
)
func TestGenerateSchema(t *testing.T) {
cmd := newSchemaCmd().cmd
dir := t.TempDir()
destination := path.Join(dir, "schema.json")
cmd.SetArgs([]string{"--output", destination})
require.NoError(t, cmd.Execute())
outFile, err := os.Open(destination)
require.NoError(t, err)
schema := map[string]interface{}{}
require.NoError(t, json.NewDecoder(outFile).Decode(&schema))
require.Equal(t, "https://json-schema.org/draft/2020-12/schema", schema["$schema"].(string))
}