github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/runtime/setup/buildlog/messages_test.go (about) 1 package buildlog 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/go-openapi/strfmt" 8 "github.com/stretchr/testify/assert" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestArtifactProgressMessage(t *testing.T) { 13 prgMsg := `{"body": {"facility": "INFO", "msg": "message"}, "artifact_id": "00000000-0000-0000-0000-000000000001", "timestamp": "2021-06-24T21:27:31.487131", "type": "artifact_progress", "source": "builder", "pipe_name": "stdout"}` 14 15 var msg Message 16 err := json.Unmarshal([]byte(prgMsg), &msg) 17 require.NoError(t, err) 18 19 assert.Equal(t, ArtifactProgress, msg.MessageType()) 20 apm, ok := msg.messager.(ArtifactProgressMessage) 21 require.True(t, ok) 22 assert.Equal(t, "artifact_progress", apm.Type) 23 assert.Equal(t, "message", apm.Body.Message) 24 assert.Equal(t, "INFO", apm.Body.Facility) 25 assert.Equal(t, strfmt.UUID("00000000-0000-0000-0000-000000000001"), apm.ArtifactID) 26 assert.Equal(t, "2021-06-24T21:27:31.487131", apm.Timestamp) 27 }