diff --git a/cmd/crc/cmd/status.go b/cmd/crc/cmd/status.go index c294ceb6a6..93cc30fa87 100644 --- a/cmd/crc/cmd/status.go +++ b/cmd/crc/cmd/status.go @@ -195,12 +195,7 @@ func (s *status) prettyPrintTo(writer io.Writer) error { {"CRC VM", s.CrcStatus}, } - if s.Preset == preset.OpenShift { - lines = append(lines, line{"OpenShift", openshiftStatus(s)}) - } - if s.Preset == preset.Microshift { - lines = append(lines, line{"MicroShift", openshiftStatus(s)}) - } + lines = append(lines, line{s.Preset.ForDisplay(), openshiftStatus(s)}) if s.RAMSize != -1 && s.RAMUsage != -1 { lines = append(lines, line{"RAM Usage", fmt.Sprintf( diff --git a/cmd/crc/cmd/status_test.go b/cmd/crc/cmd/status_test.go index 925a1539b4..75a7a1b102 100644 --- a/cmd/crc/cmd/status_test.go +++ b/cmd/crc/cmd/status_test.go @@ -190,3 +190,41 @@ Cache Directory: %s ` assert.Equal(t, fmt.Sprintf(expected, cacheDir), out.String()) } + +func TestCrcStatusShouldLogInformationForConfiguredPresets(t *testing.T) { + tests := []struct { + name string + preset preset.Preset + statusLog string + }{ + {"OpenShift preset should log OpenShift", preset.OpenShift, "OpenShift: Running (v4.5.1)"}, + {"OKD preset should log OKD", preset.OKD, "OKD: Running (v4.5.1)"}, + {"MicroShift preset should log MicroShift", preset.Microshift, "MicroShift: Running (v4.5.1)"}, + {"Unknown preset should log OpenShift", preset.ParsePreset("unknown"), "OpenShift: Running (v4.5.1)"}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Given + cacheDir := t.TempDir() + out := new(bytes.Buffer) + client := mocks.NewClient(t) + require.NoError(t, os.WriteFile(filepath.Join(cacheDir, "crc.qcow2"), make([]byte, 10000), 0600)) + client.On("Status").Return(apiClient.ClusterStatusResult{ + CrcStatus: string(state.Running), + OpenshiftStatus: string(types.OpenshiftRunning), + OpenshiftVersion: "4.5.1", + Preset: tt.preset, + }, nil) + + // When + err := runStatus(out, &daemonclient.Client{ + APIClient: client, + }, cacheDir, "", false) + + // Then + assert.NoError(t, err) + assert.Contains(t, out.String(), tt.statusLog) + }) + } +}