-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3657 from kinarashah/rke1
[v1.6] Fixes for generating data.json
- Loading branch information
Showing
5 changed files
with
110 additions
and
54,893 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
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,66 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/rancher/rke/metadata" | ||
) | ||
|
||
func TestGetURL(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
envVar string | ||
tag string | ||
expectedURL string | ||
}{ | ||
{ | ||
name: "No Metadata URL and TAG is release version", | ||
envVar: "", | ||
tag: "v1.0.0", | ||
expectedURL: defaultReleaseURL, | ||
}, | ||
{ | ||
name: "No Metadata URL and TAG is pre-release version", | ||
envVar: "", | ||
tag: "v1.0.0-alpha", | ||
expectedURL: defaultDevURL, | ||
}, | ||
{ | ||
name: "Metadata URL set", | ||
envVar: "https://example.com", | ||
tag: "v1.0.0", | ||
expectedURL: "https://example.com", | ||
}, | ||
{ | ||
name: "Invalid TAG", | ||
envVar: "", | ||
tag: "invalid-tag", | ||
expectedURL: defaultDevURL, | ||
}, | ||
{ | ||
name: "No TAG", | ||
envVar: "", | ||
tag: "", | ||
expectedURL: defaultDevURL, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
// Set the environment variables | ||
os.Setenv(metadata.RancherMetadataURLEnv, tt.envVar) | ||
os.Setenv("TAG", tt.tag) | ||
defer func() { | ||
os.Unsetenv(metadata.RancherMetadataURLEnv) | ||
os.Unsetenv("TAG") | ||
}() | ||
|
||
result := getURL() | ||
|
||
if result != tt.expectedURL { | ||
t.Errorf("expected %s, got %s", tt.expectedURL, result) | ||
} | ||
}) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.