-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
cobbler "github.com/cobbler/cobblerclient" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewStatusCmd() *cobra.Command { | ||
statusCmd := &cobra.Command{ | ||
Use: "status", | ||
Short: "View installation status of Cobbler Profiles and Systems.", | ||
Long: `This command displays the current status of all Cobbler Profiles and Systems. All installations that | ||
run for longer then 100 minutes are considered stalled.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
err := generateCobblerClient() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
res, err := Client.GetStatus(cobbler.StatusText) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Fprintln(cmd.OutOrStdout(), res.(string)) | ||
|
||
return nil | ||
}, | ||
} | ||
return statusCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"github.com/cobbler/cobblerclient" | ||
"github.com/spf13/cobra" | ||
"testing" | ||
) | ||
|
||
func Test_StatusCmd(t *testing.T) { | ||
// Arrange | ||
cobra.OnInitialize(initConfig, setupLogger) | ||
rootCmd := NewRootCmd() | ||
rootCmd.SetArgs([]string{"--config", "../testing/.cobbler.yaml", "status"}) | ||
stdout := bytes.NewBufferString("") | ||
stderr := bytes.NewBufferString("") | ||
rootCmd.SetOut(stdout) | ||
rootCmd.SetErr(stderr) | ||
expectedResult := "ip |target |start |state" | ||
|
||
// Act | ||
err := rootCmd.Execute() | ||
|
||
// Assert | ||
cobblerclient.FailOnError(t, err) | ||
FailOnNonEmptyStream(t, stderr) | ||
if stdout.String() != expectedResult { | ||
t.Errorf("Expected %s, got %s", expectedResult, stdout.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters