feat: update schema id
Some checks failed
Test Branch / test (push) Has been cancelled

This commit is contained in:
Kevin Franklin Kim 2025-09-19 15:10:11 +02:00
parent 56c031a56c
commit c5222e30a8
No known key found for this signature in database
3 changed files with 42 additions and 31 deletions

41
schema_test.go Normal file
View File

@ -0,0 +1,41 @@
package squadron_test
import (
"encoding/json"
"errors"
"os"
"path"
"testing"
testingx "github.com/foomo/go/testing"
tagx "github.com/foomo/go/testing/tag"
"github.com/foomo/squadron/internal/config"
"github.com/invopop/jsonschema"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestSchema(t *testing.T) {
t.Parallel()
testingx.Tags(t, tagx.Short)
cwd, err := os.Getwd()
require.NoError(t, err)
reflector := new(jsonschema.Reflector)
require.NoError(t, reflector.AddGoComments("github.com/foomo/squadron", "./"))
schema := reflector.Reflect(&config.Config{})
schema.ID = "https://raw.githubusercontent.com/foomo/squadron/refs/heads/main/squadron.schema.json"
actual, err := json.MarshalIndent(schema, "", " ")
require.NoError(t, err)
filename := path.Join(cwd, "squadron.schema.json")
expected, err := os.ReadFile(filename)
if !errors.Is(err, os.ErrNotExist) {
require.NoError(t, err)
}
if !assert.Equal(t, string(expected), string(actual)) {
require.NoError(t, os.WriteFile(filename, actual, 0600))
}
}

View File

@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/foomo/squadron/internal/config/config",
"$id": "https://raw.githubusercontent.com/foomo/squadron/refs/heads/main/squadron.schema.json",
"$ref": "#/$defs/Config",
"$defs": {
"BakeTarget": {

View File

@ -1,48 +1,18 @@
package squadron_test
import (
"encoding/json"
"errors"
"os"
"path"
"testing"
testingx "github.com/foomo/go/testing"
tagx "github.com/foomo/go/testing/tag"
"github.com/foomo/squadron"
"github.com/foomo/squadron/internal/config"
"github.com/foomo/squadron/internal/testutils"
"github.com/foomo/squadron/internal/util"
"github.com/invopop/jsonschema"
"github.com/pterm/pterm"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestConfig(t *testing.T) {
t.Parallel()
testingx.Tags(t, tagx.Short)
cwd, err := os.Getwd()
require.NoError(t, err)
reflector := new(jsonschema.Reflector)
require.NoError(t, reflector.AddGoComments("github.com/foomo/squadron", "./"))
schema := reflector.Reflect(&config.Config{})
actual, err := json.MarshalIndent(schema, "", " ")
require.NoError(t, err)
filename := path.Join(cwd, "squadron.schema.json")
expected, err := os.ReadFile(filename)
if !errors.Is(err, os.ErrNotExist) {
require.NoError(t, err)
}
if !assert.Equal(t, string(expected), string(actual)) {
require.NoError(t, os.WriteFile(filename, actual, 0600))
}
}
func TestConfigSimpleSnapshot(t *testing.T) {
testingx.Tags(t, tagx.Short)