-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jammy: handle multi version constraint on package dep
- Loading branch information
1 parent
a877b9d
commit a5b8c35
Showing
3 changed files
with
84 additions
and
5 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,71 @@ | ||
package deb | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/Azure/dalec" | ||
) | ||
|
||
func TestAppendConstraints(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
deps map[string]dalec.PackageConstraints | ||
want []string | ||
}{ | ||
{ | ||
name: "nil dependencies", | ||
deps: nil, | ||
want: nil, | ||
}, | ||
{ | ||
name: "empty dependencies", | ||
deps: map[string]dalec.PackageConstraints{}, | ||
want: []string{}, | ||
}, | ||
{ | ||
name: "single dependency without constraints", | ||
deps: map[string]dalec.PackageConstraints{ | ||
"packageA": {}, | ||
}, | ||
want: []string{"packageA"}, | ||
}, | ||
{ | ||
name: "single dependency with version constraints", | ||
deps: map[string]dalec.PackageConstraints{ | ||
"packageA": {Version: []string{">= 1.0", "< 2.0"}}, | ||
}, | ||
want: []string{"packageA (< 2.0) | packageA (>= 1.0)"}, | ||
}, | ||
{ | ||
name: "single dependency with architecture constraints", | ||
deps: map[string]dalec.PackageConstraints{ | ||
"packageA": {Arch: []string{"amd64", "arm64"}}, | ||
}, | ||
want: []string{"packageA [amd64 arm64]"}, | ||
}, | ||
{ | ||
name: "single dependency with version and architecture constraints", | ||
deps: map[string]dalec.PackageConstraints{ | ||
"packageA": {Version: []string{">= 1.0", "< 2.0"}, Arch: []string{"amd64", "arm64"}}, | ||
}, | ||
want: []string{"packageA (< 2.0) [amd64 arm64] | packageA (>= 1.0) [amd64 arm64]"}, | ||
}, | ||
{ | ||
name: "multiple dependencies with constraints", | ||
deps: map[string]dalec.PackageConstraints{ | ||
"packageB": {Version: []string{"= 1.0"}}, | ||
"packageA": {Arch: []string{"amd64"}}, | ||
}, | ||
want: []string{"packageA [amd64]", "packageB (= 1.0)"}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := appendConstraints(tt.deps); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("appendConstraints() = %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