diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-14 16:37:17 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-14 16:37:17 +0200 |
| commit | 45a297a8e526094e8fce6e2c5c0fd89b381d1765 (patch) | |
| tree | 852ebc3a0112c94dc9726d0b27ab057bf6383660 /testx/create.go | |
i have to commit at some point!
Diffstat (limited to 'testx/create.go')
| -rw-r--r-- | testx/create.go | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/testx/create.go b/testx/create.go new file mode 100644 index 0000000..7153e54 --- /dev/null +++ b/testx/create.go @@ -0,0 +1,75 @@ +//go:build test + +package testx + +import ( + "github.com/stretchr/testify/assert" + "os/exec" + "pik/identity" + "pik/model" + "testing" +) + +func TTarget(name string) model.Target { + return TestTarget{Identifier: name} +} + +func TSource(name string, targets ...string) *model.Source { + src := &model.Source{ + 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 { + Identifier string + SubValue []string + Tags model.Tags +} + +func (t TestTarget) Visible() bool { + return true +} + +func (t TestTarget) Hydrate(src *model.Source) (model.HydratedTarget, error) { + //TODO implement me + panic("implement me") +} + +func (t TestTarget) Sub() []string { + return t.SubValue +} + +func (t TestTarget) Label() string { + return t.Identifier +} + +func (t TestTarget) Matches(input string) bool { + return input == t.Identifier +} + +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.Equal(t, input, src.Identity.Reduced) +} +func AssertSourceIsNot(t *testing.T, input string, src *model.Source) { + assert.NotEqual(t, input, src.Identity.Reduced) +} |
