Closes #2
+40
-10
Diff
round #0
+1
-1
.tangled/workflows/test.yml
+1
-1
.tangled/workflows/test.yml
+1
-2
README.md
+1
-2
README.md
+9
provider_router.go
+9
provider_router.go
···
69
69
if wf == nil || wf.Name == "" {
70
70
continue
71
71
}
72
+
if wf.Engine != "tack" {
73
+
r.log.Error("workflow has wrong engine",
74
+
"err", fmt.Sprintf("expected engine %q, got %q", "tack", wf.Engine),
75
+
"knot", knot,
76
+
"pipeline_rkey", pipelineRkey,
77
+
"workflow", wf.Name,
78
+
)
79
+
continue
80
+
}
72
81
p, err := r.pick(wf.Raw)
73
82
if err != nil {
74
83
r.log.Error("route workflow",
+29
-7
provider_router_test.go
+29
-7
provider_router_test.go
···
100
100
101
101
r.Spawn(context.Background(), "knot", "rkey", "did:plc:actor", nil,
102
102
[]*tangled.Pipeline_Workflow{
103
-
{Name: "wf-a.yml", Raw: "tack:\n a: {}\n"},
104
-
{Name: "wf-b.yml", Raw: "tack:\n b: {}\n"},
103
+
{Name: "wf-a.yml", Engine: "tack", Raw: "tack:\n a: {}\n"},
104
+
{Name: "wf-b.yml", Engine: "tack", Raw: "tack:\n b: {}\n"},
105
105
},
106
106
)
107
107
···
123
123
// workflow even though both keys are registered.
124
124
r.Spawn(context.Background(), "knot", "rkey", "did:plc:actor", nil,
125
125
[]*tangled.Pipeline_Workflow{
126
-
{Name: "both.yml", Raw: "tack:\n b: {}\n a: {}\n"},
126
+
{Name: "both.yml", Engine: "tack", Raw: "tack:\n b: {}\n a: {}\n"},
127
127
},
128
128
)
129
129
···
144
144
r.Spawn(context.Background(), "knot", "rkey", "did:plc:actor", nil,
145
145
[]*tangled.Pipeline_Workflow{
146
146
// No `tack:` key at all.
147
-
{Name: "bare.yml", Raw: "steps: []\n"},
147
+
{Name: "bare.yml", Engine: "tack", Raw: "steps: []\n"},
148
148
// `tack:` present but with an unknown sub-key.
149
-
{Name: "unknown.yml", Raw: "tack:\n nope: {}\n"},
149
+
{Name: "unknown.yml", Engine: "tack", Raw: "tack:\n nope: {}\n"},
150
150
// Empty body — also unroutable.
151
-
{Name: "empty.yml", Raw: ""},
151
+
{Name: "empty.yml", Engine: "tack", Raw: ""},
152
152
// And one good one to prove the loop kept going.
153
-
{Name: "good.yml", Raw: "tack:\n a: {}\n"},
153
+
{Name: "good.yml", Engine: "tack", Raw: "tack:\n a: {}\n"},
154
154
},
155
155
)
156
156
···
162
162
}
163
163
}
164
164
165
+
// TestProviderRouterSpawnRejectsWrongEngine verifies that workflows
166
+
// without `engine: tack` are skipped.
167
+
func TestProviderRouterSpawnRejectsWrongEngine(t *testing.T) {
168
+
r, a, b := newRouterTest()
169
+
170
+
r.Spawn(context.Background(), "knot", "rkey", "did:plc:actor", nil,
171
+
[]*tangled.Pipeline_Workflow{
172
+
{Name: "wrong-engine.yml", Engine: "nixery", Raw: "tack:\n a: {}\n"},
173
+
{Name: "empty-engine.yml", Engine: "", Raw: "tack:\n a: {}\n"},
174
+
{Name: "correct.yml", Engine: "tack", Raw: "tack:\n b: {}\n"},
175
+
},
176
+
)
177
+
178
+
// Only "correct.yml" should reach a provider
179
+
if got := a.names(); len(got) != 0 {
180
+
t.Fatalf("provider a should not have been called; got %v", got)
181
+
}
182
+
if got, want := b.names(), []string{"correct.yml"}; !equalStrings(got, want) {
183
+
t.Fatalf("provider b got %v; want %v", got, want)
184
+
}
185
+
}
186
+
165
187
// TestProviderRouterLogsFanOut verifies that Logs walks the
166
188
// providers and returns the channel from the first one that doesn't
167
189
// say ErrLogsNotFound. We seed exactly one provider with a real