diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-29 22:34:47 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-29 22:34:47 +0200 |
| commit | 42fb6efd01e3640ea9d15dc1e0a072c1ea8295b1 (patch) | |
| tree | ebf351b66f0288c8e9f879c529a962b025bebf15 /runner/create.go | |
| parent | 03a31799a872385d821130f46942fc13dae76774 (diff) | |
fix very embarrassing bug where -a didnt actually work
Diffstat (limited to 'runner/create.go')
| -rw-r--r-- | runner/create.go | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/runner/create.go b/runner/create.go new file mode 100644 index 0000000..4e9035b --- /dev/null +++ b/runner/create.go @@ -0,0 +1,83 @@ +//go:build test + +package runner + +import ( + "github.com/stretchr/testify/assert" + "os/exec" + "pik/identity" + "pik/model" + "testing" +) + +func TTarget(name string, sub ...string) model.Target { + t := TestTarget{Id: identity.New(name), MyTags: model.TagsFromFilename(name), SubValue: sub} + return &t +} + +func TSource(name string, targets ...string) *model.Source { + src := &model.Source{ + Path: name, + Identity: identity.New(name), + } + for _, t := range targets { + src.Targets = append(src.Targets, TTarget(t)) + } + return src +} + +func TState(sources ...*model.Source) *model.State { + return &model.State{ + Sources: sources, + } +} + +type TestTarget struct { + Stub + Id identity.Identity + SubValue []string + MyTags model.Tags +} + +func (t TestTarget) Invocation(src *model.Source) []string { + return []string{src.Identity.Reduced, t.Id.Reduced} +} + +func (t TestTarget) Matches(input string) bool { + return t.Id.Is(input) +} + +func (t TestTarget) Visible() bool { + return true +} + +func (t TestTarget) Hydrate(src *model.Source) (model.HydratedTarget, error) { + return HydratedStub{}, nil +} + +func (t TestTarget) Sub() []string { + return t.SubValue +} + +func (t TestTarget) Label() string { + return t.Id.Full +} + +func (t TestTarget) Create(s *model.Source) *exec.Cmd { + panic("whadafak") +} + +func AssertTargetIs(t *testing.T, input string, target model.Target) { + assert.Equal(t, input, target.Label()) +} +func AssertTargetIsNot(t *testing.T, input string, target model.Target) { + assert.NotEqual(t, input, target.Label()) +} +func AssertSourceIs(t *testing.T, input string, src *model.Source) { + assert.NotNil(t, src.Identity) + assert.Equal(t, input, src.Identity.Reduced) +} +func AssertSourceIsNot(t *testing.T, input string, src *model.Source) { + assert.NotNil(t, src.Identity) + assert.NotEqual(t, input, src.Identity.Reduced) +} |
