Skip to content

Commit 760a2a4

Browse files
committed
template updates
1 parent 6c4a47f commit 760a2a4

File tree

2 files changed

+46
-18
lines changed

2 files changed

+46
-18
lines changed

cmd/pipelines/run_test.go

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ func TestDisplayPipelineUpdate(t *testing.T) {
1818
pipelineID string
1919
events []pipelines.PipelineEvent
2020
expected string
21-
wantErr bool
2221
}{
2322
{
2423
name: "comprehensive pipeline update with all fields",
@@ -50,14 +49,14 @@ func TestDisplayPipelineUpdate(t *testing.T) {
5049
EventType: "update_progress",
5150
},
5251
},
53-
expected: `Pipeline test-pipeline pipeline-789 completed successfully.
52+
expected: `Update for pipeline test-pipeline completed successfully. Pipeline ID: pipeline-789
5453
Started at 2022-01-01T00:00:00Z and completed at 2022-01-01T01:00:00Z.
5554
Pipeline configurations for this update:
5655
• All tables are fully refreshed
57-
Cause: Manual trigger
56+
Update cause: Manual trigger
5857
• Serverless compute
5958
• Channel: CURRENT
60-
• Continuous
59+
• Continuous pipeline
6160
• Development mode
6261
• Catalog: test_catalog
6362
• Schema: test_schema
@@ -70,7 +69,7 @@ Pipeline configurations for this update:
7069
},
7170
pipelineID: "pipeline-789",
7271
events: []pipelines.PipelineEvent{},
73-
expected: `Pipeline completed successfully.
72+
expected: `Update for pipeline completed successfully.
7473
Pipeline configurations for this update:
7574
• All tables are refreshed
7675
`,
@@ -89,10 +88,42 @@ Pipeline configurations for this update:
8988
EventType: "update_progress",
9089
},
9190
},
92-
expected: `Pipeline completed successfully.
91+
expected: `Update for pipeline completed successfully.
9392
Pipeline configurations for this update:
9493
• Refreshed [table1, table2]
9594
• Full refreshed [table3]
95+
`,
96+
},
97+
{
98+
name: "pipeline update with storage instead of catalog/schema",
99+
update: pipelines.UpdateInfo{
100+
UpdateId: "update-storage",
101+
Config: &pipelines.PipelineSpec{
102+
Name: "test-pipeline",
103+
Id: "pipeline-789",
104+
Storage: "test_storage",
105+
},
106+
},
107+
pipelineID: "pipeline-456",
108+
events: []pipelines.PipelineEvent{},
109+
expected: `Update for pipeline test-pipeline completed successfully. Pipeline ID: pipeline-789
110+
Pipeline configurations for this update:
111+
• All tables are refreshed
112+
• Storage: test_storage
113+
`,
114+
},
115+
{
116+
name: "pipeline update with classic compute and no config",
117+
update: pipelines.UpdateInfo{
118+
UpdateId: "update-classic",
119+
ClusterId: "cluster-123",
120+
},
121+
pipelineID: "pipeline-456",
122+
events: []pipelines.PipelineEvent{},
123+
expected: `Update for pipeline completed successfully.
124+
Pipeline configurations for this update:
125+
• All tables are refreshed
126+
• Classic compute: cluster-123
96127
`,
97128
},
98129
}
@@ -106,13 +137,8 @@ Pipeline configurations for this update:
106137
ctx = cmdio.InContext(ctx, cmdIO)
107138

108139
err := displayPipelineUpdate(ctx, tt.update, tt.pipelineID, tt.events)
109-
110-
if tt.wantErr {
111-
assert.Error(t, err)
112-
} else {
113-
assert.NoError(t, err)
114-
assert.Equal(t, tt.expected, buf.String())
115-
}
140+
assert.NoError(t, err)
141+
assert.Equal(t, tt.expected, buf.String())
116142
})
117143
}
118144
}

cmd/pipelines/templates.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package pipelines
22

3-
const pipelineUpdateTemplate = `Pipeline{{- if .Update.Config }} {{ .Update.Config.Name }}{{ end }}{{- if .Update.Config }} {{ .Update.Config.Id }}{{ end }} completed successfully.
3+
const pipelineUpdateTemplate = `Update for pipeline {{- if .Update.Config }} {{ .Update.Config.Name }}{{ end }} completed successfully.{{- if .Update.Config }} Pipeline ID: {{ .Update.Config.Id }}{{ end }}
44
{{- if and .Update.CreationTime .LastEventTime }}
55
Started at {{ .Update.CreationTime | pretty_UTC_date_from_millis }} and completed at {{ .LastEventTime }}.
66
{{- end }}
@@ -18,12 +18,12 @@ Pipeline configurations for this update:
1818
{{- end }}
1919
{{- end }}
2020
{{- if .Update.Cause }}
21-
Cause: {{ .Update.Cause }}
21+
Update cause: {{ .Update.Cause }}
2222
{{- end }}
2323
{{- if .Update.Config }}
2424
{{- if .Update.Config.Serverless }}
2525
• Serverless compute
26-
{{- else }}
26+
{{- else if .Update.ClusterId }}
2727
• Classic compute: {{ .Update.ClusterId }}
2828
{{- end }}
2929
{{- else if .Update.ClusterId }}
@@ -34,16 +34,18 @@ Pipeline configurations for this update:
3434
• Channel: {{ .Update.Config.Channel }}
3535
{{- end }}
3636
{{- if .Update.Config.Continuous }}
37-
• {{ if .Update.Config.Continuous }}Continuous{{ else }}Triggered{{ end }}
37+
• {{ if .Update.Config.Continuous }}Continuous{{ else }}Triggered{{ end }} pipeline
3838
{{- end }}
3939
{{- if .Update.Config.Development }}
4040
• {{ if .Update.Config.Development }}Development{{ else }}Production{{ end }} mode
4141
{{- end }}
4242
{{- if .Update.Config.Catalog }}
4343
• Catalog: {{ .Update.Config.Catalog }}
44-
{{- end }}
4544
{{- if .Update.Config.Schema }}
4645
• Schema: {{ .Update.Config.Schema }}
4746
{{- end }}
47+
{{- else if .Update.Config.Storage }}
48+
• Storage: {{ .Update.Config.Storage }}
49+
{{- end }}
4850
{{- end }}
4951
`

0 commit comments

Comments
 (0)