-
Notifications
You must be signed in to change notification settings - Fork 79
Add --host flag to docker model install-runner command #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,96 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestInstallRunnerHostFlag(t *testing.T) { | ||
| // Create the install-runner command | ||
| cmd := newInstallRunner() | ||
|
|
||
| // Verify the --host flag exists | ||
| hostFlag := cmd.Flags().Lookup("host") | ||
| if hostFlag == nil { | ||
| t.Fatal("--host flag not found") | ||
| } | ||
|
|
||
| // Verify the default value | ||
| if hostFlag.DefValue != "127.0.0.1" { | ||
| t.Errorf("Expected default host value to be '127.0.0.1', got '%s'", hostFlag.DefValue) | ||
| } | ||
|
|
||
| // Verify the flag type | ||
| if hostFlag.Value.Type() != "string" { | ||
| t.Errorf("Expected host flag type to be 'string', got '%s'", hostFlag.Value.Type()) | ||
| } | ||
|
|
||
| // Test setting the flag value | ||
| testCases := []struct { | ||
| name string | ||
| value string | ||
| }{ | ||
| {"localhost", "127.0.0.1"}, | ||
| {"all interfaces", "0.0.0.0"}, | ||
| {"specific IP", "192.168.1.100"}, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| // Reset the command for each test | ||
| cmd := newInstallRunner() | ||
| err := cmd.Flags().Set("host", tc.value) | ||
| if err != nil { | ||
| t.Errorf("Failed to set host flag to '%s': %v", tc.value, err) | ||
| } | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Verify the value was set | ||
| hostValue, err := cmd.Flags().GetString("host") | ||
| if err != nil { | ||
| t.Errorf("Failed to get host flag value: %v", err) | ||
| } | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if hostValue != tc.value { | ||
| t.Errorf("Expected host value to be '%s', got '%s'", tc.value, hostValue) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestInstallRunnerCommandFlags(t *testing.T) { | ||
| cmd := newInstallRunner() | ||
|
|
||
| // Verify all expected flags exist | ||
| expectedFlags := []string{"port", "host", "gpu", "do-not-track"} | ||
| for _, flagName := range expectedFlags { | ||
| if cmd.Flags().Lookup(flagName) == nil { | ||
| t.Errorf("Expected flag '--%s' not found", flagName) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestInstallRunnerCommandType(t *testing.T) { | ||
| cmd := newInstallRunner() | ||
|
|
||
| // Verify command properties | ||
| if cmd.Use != "install-runner" { | ||
| t.Errorf("Expected command Use to be 'install-runner', got '%s'", cmd.Use) | ||
| } | ||
|
|
||
| if cmd.Short != "Install Docker Model Runner (Docker Engine only)" { | ||
| t.Errorf("Unexpected command Short description: %s", cmd.Short) | ||
| } | ||
|
|
||
| // Verify RunE is set | ||
| if cmd.RunE == nil { | ||
| t.Error("Expected RunE to be set") | ||
| } | ||
| } | ||
|
|
||
| func TestInstallRunnerValidArgsFunction(t *testing.T) { | ||
| cmd := newInstallRunner() | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // The install-runner command should not accept any arguments | ||
| // So ValidArgsFunction should be set to handle no arguments | ||
| if cmd.ValidArgsFunction == nil { | ||
| t.Error("Expected ValidArgsFunction to be set") | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.