Load campaign and session imports from their sources
This commit is contained in:
@@ -8,32 +8,20 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSingleSourceDocumentsRejectConfigKitDirectives(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
campaignPath := filepath.Join(dir, "campaign.yml")
|
||||
if err := os.WriteFile(campaignPath, []byte("config:\n imports: []\ncampaign_id: sample\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
load func() error
|
||||
}{
|
||||
{name: "campaign", load: func() error { _, err := LoadCampaign(campaignPath); return err }},
|
||||
{name: "session", load: func() error {
|
||||
_, err := LoadSessionBytesWithOptions("session.yml", []byte("config:\n imports: []\nsession_id: sample\n"), SessionLoadOptions{})
|
||||
func TestContextlessDocumentsRejectImports(t *testing.T) {
|
||||
for _, load := range []func() error{
|
||||
func() error {
|
||||
_, err := LoadSessionBytesWithOptions("remote", []byte("config:\n imports: []\nsession_id: sample\n"), SessionLoadOptions{})
|
||||
return err
|
||||
}},
|
||||
{name: "party", load: func() error {
|
||||
},
|
||||
func() error {
|
||||
_, err := ParseParty([]byte("config:\n imports: []\nschema_version: narratio.party.v1\ncharacters: {}\n"))
|
||||
return err
|
||||
}},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if err := test.load(); err == nil || !strings.Contains(err.Error(), "import.disabled") {
|
||||
t.Fatalf("load error = %v, want disabled-import diagnostic", err)
|
||||
}
|
||||
})
|
||||
},
|
||||
} {
|
||||
if err := load(); err == nil || !strings.Contains(err.Error(), "import.disabled") {
|
||||
t.Fatalf("load error = %v, want disabled-import diagnostic", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user