1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-27 01:33:39 +02:00
goreleaser/cmd/schema_test.go
Carlos Alexandro Becker 2bf08f11a6
ci: run build/test workflow on windows too (#5263)
Maybe 3rd time is the charm!

This makes the CI build run on windows too, and fix broken tests/featuers on Windows.

Most of the changes are related to ignoring certain tests on windows, or making sure to use the right path separators.

More work to do in the future, probably!

#4293

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-11-16 10:30:39 -03:00

29 lines
644 B
Go

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)
t.Cleanup(func() {
require.NoError(t, outFile.Close())
})
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))
}