summaryrefslogtreecommitdiff
path: root/testx/create.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-22 18:29:37 +0200
committerewy <ewy0@protonmail.com>2026-04-22 18:29:37 +0200
commit374ed5e1a4dc635c42e33e4133729d40cf3e0e35 (patch)
tree01f12ca3eea0154b61afde3d1ee27df2094644e1 /testx/create.go
parentee481fa406bb685a16d8b568fca0c9f592c06180 (diff)
work on tests
also replace the annoying search return with a struct
Diffstat (limited to 'testx/create.go')
-rw-r--r--testx/create.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/testx/create.go b/testx/create.go
index 306e50a..62960fd 100644
--- a/testx/create.go
+++ b/testx/create.go
@@ -11,8 +11,9 @@ import (
"testing"
)
-func TTarget(name string) model.Target {
- return TestTarget{Identifier: name}
+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 {
@@ -32,10 +33,18 @@ func TState(sources ...*model.Source) *model.State {
}
type TestTarget struct {
- runner.BaseTarget
- Identifier string
- SubValue []string
- Tags model.Tags
+ runner.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 {
@@ -52,11 +61,7 @@ func (t TestTarget) Sub() []string {
}
func (t TestTarget) Label() string {
- return t.Identifier
-}
-
-func (t TestTarget) Matches(input string) bool {
- return input == t.Identifier
+ return t.Id.Full
}
func (t TestTarget) Create(s *model.Source) *exec.Cmd {
@@ -70,8 +75,10 @@ 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)
}