37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package contracts_test
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.ipao.vip/rogee/go-sip/contracts"
|
|
)
|
|
|
|
func TestRuntimeBundleExcludesHistoricalLocalContracts(t *testing.T) {
|
|
for _, name := range []string{
|
|
"local/v0.1/call-result-v0.1-proposal.schema.json",
|
|
"local/v0.2/config-read-v0.2.schema.json",
|
|
"local/v0.3/config-read-v0.3.schema.json",
|
|
"local/v0.4/call-execute-v0.4-proposal.schema.json",
|
|
} {
|
|
if _, err := contracts.Files.ReadFile(name); err == nil {
|
|
t.Fatalf("historical contract %s is still embedded in the active runtime", name)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestCurrentContractRead(t *testing.T) {
|
|
for _, name := range []string{"config-read.schema.json", "task-discovery.schema.json", "mq.schema.json", "mq-topology.json", "manifest.json"} {
|
|
data, err := contracts.ReadCurrent(name)
|
|
if err != nil || len(data) == 0 {
|
|
t.Fatalf("read %s: %v", name, err)
|
|
}
|
|
}
|
|
for _, name := range []string{"", "v0.4/task-discovery-v0.4-proposal.schema.json", "../upstream/v1/mq.schema.json", "examples/mq-execute.json", "arbitrary.json"} {
|
|
_, err := contracts.ReadCurrent(name)
|
|
if err == nil || !strings.Contains(err.Error(), "invalid") {
|
|
t.Fatalf("unexpected read of %q: %v", name, err)
|
|
}
|
|
}
|
|
}
|