Skip to content

Commit

Permalink
Using default platform when platform is ANY (fixes aerokube#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
vania-pooh committed Dec 15, 2018
1 parent 8957bfa commit e605e19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ type ggrBrowsers struct {
Browsers
}

const anyPlatform = "ANY"

func (b *ggrBrowsers) find(browser, version string, platform string, excludedHosts set, excludedRegions set) (Hosts, string, set) {
var hosts Hosts
for _, b := range b.Browsers.Browsers {
if b.Name == browser {
if version == "" {
version = b.DefaultVersion
}
if platform == "" {
if platform == "" || platform == anyPlatform {
platform = b.DefaultPlatform
}
for _, v := range b.Versions {
Expand Down
7 changes: 7 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ func TestFindWithDefaultPlatform(t *testing.T) {
AssertThat(t, hosts[0].Name, EqualTo{"browser-2.0-linux"})
}

func TestFindWithAnyPlatform(t *testing.T) {
hosts, version, _ := browsersWithMultiplePlatforms.find("browser", "2.0", "ANY", newSet(), newSet())
AssertThat(t, version, EqualTo{"2.0"})
AssertThat(t, len(hosts), EqualTo{1})
AssertThat(t, hosts[0].Name, EqualTo{"browser-2.0-linux"})
}

func TestFindWithPlatform(t *testing.T) {
hosts, version, _ := browsersWithMultiplePlatforms.find("browser", "2.0", "LINUX", newSet(), newSet())
AssertThat(t, version, EqualTo{"2.0"})
Expand Down

0 comments on commit e605e19

Please sign in to comment.