github.com/databricks/cli@v0.203.0/bundle/run/progress/pipeline_test.go (about) 1 package progress 2 3 import ( 4 "testing" 5 6 "github.com/databricks/databricks-sdk-go/service/pipelines" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestFlowProgressEventToString(t *testing.T) { 11 event := ProgressEvent{ 12 EventType: "flow_progress", 13 Message: "my_message", 14 Level: pipelines.EventLevelInfo, 15 Origin: &pipelines.Origin{ 16 FlowName: "my_flow", 17 PipelineName: "my_pipeline", 18 }, 19 Timestamp: "2023-03-27T23:30:36.122Z", 20 } 21 assert.Equal(t, `2023-03-27T23:30:36.122Z flow_progress INFO "my_message"`, event.String()) 22 } 23 24 func TestUpdateProgressEventToString(t *testing.T) { 25 event := ProgressEvent{ 26 EventType: "update_progress", 27 Message: "my_message", 28 Level: pipelines.EventLevelError, 29 Origin: &pipelines.Origin{ 30 FlowName: "my_flow", 31 PipelineName: "my_pipeline", 32 }, 33 Timestamp: "2023-03-27T23:30:36.122Z", 34 } 35 assert.Equal(t, `2023-03-27T23:30:36.122Z update_progress ERROR "my_message"`, event.String()) 36 } 37 38 func TestUpdateErrorEventToString(t *testing.T) { 39 event := ProgressEvent{ 40 EventType: "update_progress", 41 Message: "failed to update pipeline", 42 Level: pipelines.EventLevelError, 43 Origin: &pipelines.Origin{ 44 FlowName: "my_flow", 45 PipelineName: "my_pipeline", 46 }, 47 Timestamp: "2023-03-27T23:30:36.122Z", 48 Error: &pipelines.ErrorDetail{ 49 Exceptions: []pipelines.SerializedException{ 50 { 51 Message: "parsing error", 52 }, 53 }, 54 }, 55 } 56 assert.Equal(t, "2023-03-27T23:30:36.122Z update_progress ERROR \"failed to update pipeline\"\nparsing error", event.String()) 57 } 58 59 func TestUpdateErrorIgnoredForWarnEvents(t *testing.T) { 60 event := ProgressEvent{ 61 EventType: "update_progress", 62 Message: "failed to update pipeline", 63 Level: pipelines.EventLevelWarn, 64 Origin: &pipelines.Origin{ 65 FlowName: "my_flow", 66 PipelineName: "my_pipeline", 67 }, 68 Timestamp: "2023-03-27T23:30:36.122Z", 69 Error: &pipelines.ErrorDetail{ 70 Exceptions: []pipelines.SerializedException{ 71 { 72 Message: "THIS IS IGNORED", 73 }, 74 }, 75 }, 76 } 77 assert.Equal(t, "2023-03-27T23:30:36.122Z update_progress WARN \"failed to update pipeline\"", event.String()) 78 }