package resolution import ( "encoding/json" "strings" "testing" mcat "git.novox.be/novox/mesh-sdk/go/catalogue" ) const handedNotifier = `{"module":"notify","version":"1", "config":{"width":{"type":"number","description":"How wide a notification is, in pixels.","default":250}}, "build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]}, "resources":[ {"id":"configuration-dir","type":"directory","path":"${machine:account-home}/.config/notify","owner":"${machine:account}","mode":"0755"}, {"id":"configuration","type":"file","path":"${machine:account-home}/.config/notify/rc","owner":"${machine:account}","mode":"0644","template":"files/rc"}, {"id":"legacy","type":"file","path":"/etc/notify.conf","content":"plain = yes\n"}, {"id":"notifier","type":"service","unit":"notify.service","scope":"user","user":"${machine:account}","reload-on":["configuration"]}]}` const notifierText = "width = ${config:width}\nhome = ${machine:account-home}\n" func notifierMoved() string { return strings.Replace(handedNotifier, `"version":"1",`, `"version":"1","moved":true,`, 1) } func builtNotifier() []mcat.Built { return []mcat.Built{{Name: "files", Kind: mcat.ArtifactArchive, Reference: mcat.ArtifactStoreScheme + "notify/files/blobs/sha256:" + strings.Repeat("d", 64), Digest: "sha256:" + strings.Repeat("d", 64), Texts: map[string]string{"rc": notifierText}}} } func notifierOn(t *testing.T, m mcat.Manifest) mcat.Resolution { t.Helper() r, err := Resolve(shelf(m), []string{m.Module}, workstation(), mcat.World{}) if err != nil { t.Fatal(err) } r.Account = "op" return r } func composeWith(t *testing.T, r mcat.Resolution, with mcat.Rendering) (mcat.Composed, string) { t.Helper() c, err := Compose(r, with) if err != nil { t.Fatal(err) } raw, err := json.Marshal(c.Resources) if err != nil { t.Fatal(err) } return c, string(raw) } func handingTo(store string) mcat.Rendering { return mcat.Rendering{Hands: true, Provisioner: "mesh-provisioner-client", ArtifactStore: store} }