58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package configkit
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestReleaseKitProfile(t *testing.T) {
|
|
data, err := os.ReadFile("releasekit.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
var profile struct {
|
|
Product string `json:"product"`
|
|
Remote string `json:"remote"`
|
|
ExpectedPushURL string `json:"expected_push_url"`
|
|
Validation struct {
|
|
Go struct {
|
|
Race bool `json:"race"`
|
|
FullVet bool `json:"full_vet"`
|
|
CompileTargets []string `json:"compile_targets"`
|
|
} `json:"go"`
|
|
} `json:"validation"`
|
|
}
|
|
|
|
decoder := json.NewDecoder(bytes.NewReader(data))
|
|
decoder.DisallowUnknownFields()
|
|
if err := decoder.Decode(&profile); err != nil {
|
|
t.Fatalf("decode release profile: %v", err)
|
|
}
|
|
|
|
if profile.Product != "ConfigKit" {
|
|
t.Errorf("product = %q, want ConfigKit", profile.Product)
|
|
}
|
|
if profile.Remote != "origin" {
|
|
t.Errorf("remote = %q, want origin", profile.Remote)
|
|
}
|
|
wantPushURL := "https://gitea.maximumdirect.net/eric/ConfigKit.git"
|
|
if fixturePushURL := os.Getenv("CONFIGKIT_TEST_EXPECTED_PUSH_URL"); fixturePushURL != "" {
|
|
wantPushURL = fixturePushURL
|
|
}
|
|
if profile.ExpectedPushURL != wantPushURL {
|
|
t.Errorf("expected push URL = %q, want %q", profile.ExpectedPushURL, wantPushURL)
|
|
}
|
|
goValidation := profile.Validation.Go
|
|
if !goValidation.Race || !goValidation.FullVet {
|
|
t.Errorf("race and full vet must be selected: race=%t full_vet=%t", goValidation.Race, goValidation.FullVet)
|
|
}
|
|
wantTargets := []string{"linux/amd64", "linux/arm64"}
|
|
if !reflect.DeepEqual(goValidation.CompileTargets, wantTargets) {
|
|
t.Errorf("compile targets = %v, want %v", goValidation.CompileTargets, wantTargets)
|
|
}
|
|
}
|