-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support or mappers Fixed distributions
- Loading branch information
Showing
12 changed files
with
130 additions
and
38 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
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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package install | ||
|
||
import "github.com/devops-works/binenv/internal/mapping" | ||
|
||
// Direct installs directly downloaded binaries | ||
type Direct struct { | ||
filter string | ||
} | ||
|
||
// Install will move the binary from src to dst | ||
func (d Direct) Install(src, dst, version string) error { | ||
func (d Direct) Install(src, dst, version string, mapper mapping.Mapper) error { | ||
return installFile(src, dst) | ||
} |
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
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,53 @@ | ||
package mapping | ||
|
||
import "testing" | ||
|
||
func TestRemapper_MustInterpolate(t *testing.T) { | ||
|
||
tests := []struct { | ||
name string | ||
entries map[string]string | ||
k string | ||
want string | ||
}{ | ||
{name: "arch", entries: map[string]string{"amd64": "x86_64"}, k: "amd64", want: "x86_64"}, | ||
{name: "same when empty", entries: map[string]string{}, k: "amd64", want: "amd64"}, | ||
{name: "os+arch", entries: map[string]string{"linux": "Linux", "amd64": "x86_64"}, k: "amd64", want: "x86_64"}, | ||
{name: "os+arch", entries: map[string]string{"linux": "Linux", "amd64": "x86_64"}, k: "linux", want: "Linux"}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
r := Remapper(tt.entries) | ||
|
||
if got := r.MustInterpolate(tt.k); got != tt.want { | ||
t.Errorf("Remapper.MustInterpolate() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestRemapper_IsZero(t *testing.T) { | ||
type fields struct { | ||
Entries map[string]string | ||
} | ||
tests := []struct { | ||
name string | ||
entries map[string]string | ||
want bool | ||
}{ | ||
{name: "empty", entries: map[string]string{}, want: true}, | ||
{name: "nil", want: true}, | ||
{name: "not empty", entries: map[string]string{"amd64": "AMD64"}, want: false}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
r := Remapper(tt.entries) | ||
|
||
if got := r.IsZero(); got != tt.want { | ||
t.Errorf("Remapper.MustInterpolate() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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