mirror of https://github.com/docker/buildx.git
lint: enable testifylint
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
5937ba0e00
commit
d2c512a95b
|
@ -23,6 +23,7 @@ linters:
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
|
- testifylint
|
||||||
- typecheck
|
- typecheck
|
||||||
- unused
|
- unused
|
||||||
- whitespace
|
- whitespace
|
||||||
|
@ -81,6 +82,14 @@ linters-settings:
|
||||||
- G115 # integer overflow conversion (TODO: verify these)
|
- G115 # integer overflow conversion (TODO: verify these)
|
||||||
config:
|
config:
|
||||||
G306: "0644"
|
G306: "0644"
|
||||||
|
testifylint:
|
||||||
|
disable:
|
||||||
|
# disable rules that reduce the test condition
|
||||||
|
- "empty"
|
||||||
|
- "bool-compare"
|
||||||
|
- "len"
|
||||||
|
- "negative-positive"
|
||||||
|
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-files:
|
exclude-files:
|
||||||
|
|
|
@ -59,8 +59,8 @@ target "webapp" {
|
||||||
t.Run("InvalidTargetOverrides", func(t *testing.T) {
|
t.Run("InvalidTargetOverrides", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
_, _, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"nosuchtarget.context=foo"}, nil)
|
_, _, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"nosuchtarget.context=foo"}, nil)
|
||||||
require.NotNil(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, err.Error(), "could not find any target matching 'nosuchtarget'")
|
require.Equal(t, "could not find any target matching 'nosuchtarget'", err.Error())
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("ArgsOverrides", func(t *testing.T) {
|
t.Run("ArgsOverrides", func(t *testing.T) {
|
||||||
|
@ -116,7 +116,7 @@ target "webapp" {
|
||||||
t.Run("ContextOverride", func(t *testing.T) {
|
t.Run("ContextOverride", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
_, _, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.context"}, nil)
|
_, _, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.context"}, nil)
|
||||||
require.NotNil(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
m, g, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.context=foo"}, nil)
|
m, g, err := ReadTargets(ctx, []File{fp}, []string{"webapp"}, []string{"webapp.context=foo"}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -203,8 +203,8 @@ target "webapp" {
|
||||||
// NOTE: I am unsure whether failing to match should always error out
|
// NOTE: I am unsure whether failing to match should always error out
|
||||||
// instead of simply skipping that override.
|
// instead of simply skipping that override.
|
||||||
// Let's enforce the error and we can relax it later if users complain.
|
// Let's enforce the error and we can relax it later if users complain.
|
||||||
require.NotNil(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, err.Error(), "could not find any target matching 'nomatch*'")
|
require.Equal(t, "could not find any target matching 'nomatch*'", err.Error())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,18 +49,18 @@ func TestHCLBasic(t *testing.T) {
|
||||||
require.Equal(t, []string{"db", "webapp"}, c.Groups[0].Targets)
|
require.Equal(t, []string{"db", "webapp"}, c.Groups[0].Targets)
|
||||||
|
|
||||||
require.Equal(t, 4, len(c.Targets))
|
require.Equal(t, 4, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "db")
|
require.Equal(t, "db", c.Targets[0].Name)
|
||||||
require.Equal(t, "./db", *c.Targets[0].Context)
|
require.Equal(t, "./db", *c.Targets[0].Context)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[1].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[1].Name)
|
||||||
require.Equal(t, 1, len(c.Targets[1].Args))
|
require.Equal(t, 1, len(c.Targets[1].Args))
|
||||||
require.Equal(t, ptrstr("123"), c.Targets[1].Args["buildno"])
|
require.Equal(t, ptrstr("123"), c.Targets[1].Args["buildno"])
|
||||||
|
|
||||||
require.Equal(t, c.Targets[2].Name, "cross")
|
require.Equal(t, "cross", c.Targets[2].Name)
|
||||||
require.Equal(t, 2, len(c.Targets[2].Platforms))
|
require.Equal(t, 2, len(c.Targets[2].Platforms))
|
||||||
require.Equal(t, []string{"linux/amd64", "linux/arm64"}, c.Targets[2].Platforms)
|
require.Equal(t, []string{"linux/amd64", "linux/arm64"}, c.Targets[2].Platforms)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[3].Name, "webapp-plus")
|
require.Equal(t, "webapp-plus", c.Targets[3].Name)
|
||||||
require.Equal(t, 1, len(c.Targets[3].Args))
|
require.Equal(t, 1, len(c.Targets[3].Args))
|
||||||
require.Equal(t, map[string]*string{"IAMCROSS": ptrstr("true")}, c.Targets[3].Args)
|
require.Equal(t, map[string]*string{"IAMCROSS": ptrstr("true")}, c.Targets[3].Args)
|
||||||
}
|
}
|
||||||
|
@ -109,18 +109,18 @@ func TestHCLBasicInJSON(t *testing.T) {
|
||||||
require.Equal(t, []string{"db", "webapp"}, c.Groups[0].Targets)
|
require.Equal(t, []string{"db", "webapp"}, c.Groups[0].Targets)
|
||||||
|
|
||||||
require.Equal(t, 4, len(c.Targets))
|
require.Equal(t, 4, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "db")
|
require.Equal(t, "db", c.Targets[0].Name)
|
||||||
require.Equal(t, "./db", *c.Targets[0].Context)
|
require.Equal(t, "./db", *c.Targets[0].Context)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[1].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[1].Name)
|
||||||
require.Equal(t, 1, len(c.Targets[1].Args))
|
require.Equal(t, 1, len(c.Targets[1].Args))
|
||||||
require.Equal(t, ptrstr("123"), c.Targets[1].Args["buildno"])
|
require.Equal(t, ptrstr("123"), c.Targets[1].Args["buildno"])
|
||||||
|
|
||||||
require.Equal(t, c.Targets[2].Name, "cross")
|
require.Equal(t, "cross", c.Targets[2].Name)
|
||||||
require.Equal(t, 2, len(c.Targets[2].Platforms))
|
require.Equal(t, 2, len(c.Targets[2].Platforms))
|
||||||
require.Equal(t, []string{"linux/amd64", "linux/arm64"}, c.Targets[2].Platforms)
|
require.Equal(t, []string{"linux/amd64", "linux/arm64"}, c.Targets[2].Platforms)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[3].Name, "webapp-plus")
|
require.Equal(t, "webapp-plus", c.Targets[3].Name)
|
||||||
require.Equal(t, 1, len(c.Targets[3].Args))
|
require.Equal(t, 1, len(c.Targets[3].Args))
|
||||||
require.Equal(t, map[string]*string{"IAMCROSS": ptrstr("true")}, c.Targets[3].Args)
|
require.Equal(t, map[string]*string{"IAMCROSS": ptrstr("true")}, c.Targets[3].Args)
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func TestHCLWithFunctions(t *testing.T) {
|
||||||
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("124"), c.Targets[0].Args["buildno"])
|
require.Equal(t, ptrstr("124"), c.Targets[0].Args["buildno"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func TestHCLWithUserDefinedFunctions(t *testing.T) {
|
||||||
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("124"), c.Targets[0].Args["buildno"])
|
require.Equal(t, ptrstr("124"), c.Targets[0].Args["buildno"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ func TestHCLWithVariables(t *testing.T) {
|
||||||
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("123"), c.Targets[0].Args["buildno"])
|
require.Equal(t, ptrstr("123"), c.Targets[0].Args["buildno"])
|
||||||
|
|
||||||
t.Setenv("BUILD_NUMBER", "456")
|
t.Setenv("BUILD_NUMBER", "456")
|
||||||
|
@ -218,7 +218,7 @@ func TestHCLWithVariables(t *testing.T) {
|
||||||
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
require.Equal(t, []string{"webapp"}, c.Groups[0].Targets)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("456"), c.Targets[0].Args["buildno"])
|
require.Equal(t, ptrstr("456"), c.Targets[0].Args["buildno"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ func TestHCLWithVariablesInFunctions(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[0].Name)
|
||||||
require.Equal(t, []string{"user/repo:v1"}, c.Targets[0].Tags)
|
require.Equal(t, []string{"user/repo:v1"}, c.Targets[0].Tags)
|
||||||
|
|
||||||
t.Setenv("REPO", "docker/buildx")
|
t.Setenv("REPO", "docker/buildx")
|
||||||
|
@ -250,7 +250,7 @@ func TestHCLWithVariablesInFunctions(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "webapp")
|
require.Equal(t, "webapp", c.Targets[0].Name)
|
||||||
require.Equal(t, []string{"docker/buildx:v1"}, c.Targets[0].Tags)
|
require.Equal(t, []string{"docker/buildx:v1"}, c.Targets[0].Tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ func TestHCLMultiFileSharedVariables(t *testing.T) {
|
||||||
}, nil)
|
}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre-abc"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre-abc"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("abc-post"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("abc-post"), c.Targets[0].Args["v2"])
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ func TestHCLMultiFileSharedVariables(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre-def"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre-def"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("def-post"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("def-post"), c.Targets[0].Args["v2"])
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ func TestHCLVarsWithVars(t *testing.T) {
|
||||||
}, nil)
|
}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre--ABCDEF-"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre--ABCDEF-"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("ABCDEF-post"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("ABCDEF-post"), c.Targets[0].Args["v2"])
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ func TestHCLVarsWithVars(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre--NEWDEF-"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre--NEWDEF-"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("NEWDEF-post"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("NEWDEF-post"), c.Targets[0].Args["v2"])
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ func TestHCLTypedVariables(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("lower"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("lower"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("yes"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("yes"), c.Targets[0].Args["v2"])
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ func TestHCLTypedVariables(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("higher"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("higher"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("no"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("no"), c.Targets[0].Args["v2"])
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ func TestHCLAttrs(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("attr-abcdef"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("attr-abcdef"), c.Targets[0].Args["v1"])
|
||||||
|
|
||||||
// env does not apply if no variable
|
// env does not apply if no variable
|
||||||
|
@ -484,7 +484,7 @@ func TestHCLAttrs(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("attr-abcdef"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("attr-abcdef"), c.Targets[0].Args["v1"])
|
||||||
// attr-multifile
|
// attr-multifile
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ func TestHCLAttrsCustomType(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, []string{"linux/arm64", "linux/amd64"}, c.Targets[0].Platforms)
|
require.Equal(t, []string{"linux/arm64", "linux/amd64"}, c.Targets[0].Platforms)
|
||||||
require.Equal(t, ptrstr("linux/arm64"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("linux/arm64"), c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
@ -618,7 +618,7 @@ func TestHCLMultiFileAttrs(t *testing.T) {
|
||||||
}, nil)
|
}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre-def"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre-def"), c.Targets[0].Args["v1"])
|
||||||
|
|
||||||
t.Setenv("FOO", "ghi")
|
t.Setenv("FOO", "ghi")
|
||||||
|
@ -630,7 +630,7 @@ func TestHCLMultiFileAttrs(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre-ghi"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre-ghi"), c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +653,7 @@ func TestHCLMultiFileGlobalAttrs(t *testing.T) {
|
||||||
}, nil)
|
}, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, "pre-def", *c.Targets[0].Args["v1"])
|
require.Equal(t, "pre-def", *c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,12 +839,12 @@ func TestHCLRenameMultiFile(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, 2, len(c.Targets))
|
require.Equal(t, 2, len(c.Targets))
|
||||||
|
|
||||||
require.Equal(t, c.Targets[0].Name, "bar")
|
require.Equal(t, "bar", c.Targets[0].Name)
|
||||||
require.Equal(t, *c.Targets[0].Dockerfile, "x")
|
require.Equal(t, "x", *c.Targets[0].Dockerfile)
|
||||||
require.Equal(t, *c.Targets[0].Target, "z")
|
require.Equal(t, "z", *c.Targets[0].Target)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[1].Name, "foo")
|
require.Equal(t, "foo", c.Targets[1].Name)
|
||||||
require.Equal(t, *c.Targets[1].Context, "y")
|
require.Equal(t, "y", *c.Targets[1].Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHCLMatrixBasic(t *testing.T) {
|
func TestHCLMatrixBasic(t *testing.T) {
|
||||||
|
@ -862,10 +862,10 @@ func TestHCLMatrixBasic(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 2, len(c.Targets))
|
require.Equal(t, 2, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "x")
|
require.Equal(t, "x", c.Targets[0].Name)
|
||||||
require.Equal(t, c.Targets[1].Name, "y")
|
require.Equal(t, "y", c.Targets[1].Name)
|
||||||
require.Equal(t, *c.Targets[0].Dockerfile, "x.Dockerfile")
|
require.Equal(t, "x.Dockerfile", *c.Targets[0].Dockerfile)
|
||||||
require.Equal(t, *c.Targets[1].Dockerfile, "y.Dockerfile")
|
require.Equal(t, "y.Dockerfile", *c.Targets[1].Dockerfile)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Groups))
|
require.Equal(t, 1, len(c.Groups))
|
||||||
require.Equal(t, "default", c.Groups[0].Name)
|
require.Equal(t, "default", c.Groups[0].Name)
|
||||||
|
@ -948,9 +948,9 @@ func TestHCLMatrixMaps(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 2, len(c.Targets))
|
require.Equal(t, 2, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "aa")
|
require.Equal(t, "aa", c.Targets[0].Name)
|
||||||
require.Equal(t, c.Targets[0].Args["target"], ptrstr("valbb"))
|
require.Equal(t, c.Targets[0].Args["target"], ptrstr("valbb"))
|
||||||
require.Equal(t, c.Targets[1].Name, "cc")
|
require.Equal(t, "cc", c.Targets[1].Name)
|
||||||
require.Equal(t, c.Targets[1].Args["target"], ptrstr("valdd"))
|
require.Equal(t, c.Targets[1].Args["target"], ptrstr("valdd"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ func TestJSONAttributes(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre-abc-def"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre-abc-def"), c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1166,7 @@ func TestJSONFunctions(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("pre-<FOO-abc>"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("pre-<FOO-abc>"), c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,7 +1184,7 @@ func TestJSONInvalidFunctions(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr(`myfunc("foo")`), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr(`myfunc("foo")`), c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,7 +1212,7 @@ func TestHCLFunctionInAttr(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("FOO <> [baz]"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("FOO <> [baz]"), c.Targets[0].Args["v1"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1243,7 +1243,7 @@ services:
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, ptrstr("foo"), c.Targets[0].Args["v1"])
|
require.Equal(t, ptrstr("foo"), c.Targets[0].Args["v1"])
|
||||||
require.Equal(t, ptrstr("bar"), c.Targets[0].Args["v2"])
|
require.Equal(t, ptrstr("bar"), c.Targets[0].Args["v2"])
|
||||||
require.Equal(t, "dir", *c.Targets[0].Context)
|
require.Equal(t, "dir", *c.Targets[0].Context)
|
||||||
|
@ -1266,7 +1266,7 @@ func TestHCLBuiltinVars(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, 1, len(c.Targets))
|
require.Equal(t, 1, len(c.Targets))
|
||||||
require.Equal(t, c.Targets[0].Name, "app")
|
require.Equal(t, "app", c.Targets[0].Name)
|
||||||
require.Equal(t, "foo", *c.Targets[0].Context)
|
require.Equal(t, "foo", *c.Targets[0].Context)
|
||||||
require.Equal(t, "test", *c.Targets[0].Dockerfile)
|
require.Equal(t, "test", *c.Targets[0].Dockerfile)
|
||||||
}
|
}
|
||||||
|
@ -1332,17 +1332,17 @@ target "b" {
|
||||||
|
|
||||||
require.Equal(t, 4, len(c.Targets))
|
require.Equal(t, 4, len(c.Targets))
|
||||||
|
|
||||||
require.Equal(t, c.Targets[0].Name, "metadata-a")
|
require.Equal(t, "metadata-a", c.Targets[0].Name)
|
||||||
require.Equal(t, []string{"app/a:1.0.0", "app/a:latest"}, c.Targets[0].Tags)
|
require.Equal(t, []string{"app/a:1.0.0", "app/a:latest"}, c.Targets[0].Tags)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[1].Name, "metadata-b")
|
require.Equal(t, "metadata-b", c.Targets[1].Name)
|
||||||
require.Equal(t, []string{"app/b:1.0.0", "app/b:latest"}, c.Targets[1].Tags)
|
require.Equal(t, []string{"app/b:1.0.0", "app/b:latest"}, c.Targets[1].Tags)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[2].Name, "a")
|
require.Equal(t, "a", c.Targets[2].Name)
|
||||||
require.Equal(t, ".", *c.Targets[2].Context)
|
require.Equal(t, ".", *c.Targets[2].Context)
|
||||||
require.Equal(t, "a", *c.Targets[2].Target)
|
require.Equal(t, "a", *c.Targets[2].Target)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[3].Name, "b")
|
require.Equal(t, "b", c.Targets[3].Name)
|
||||||
require.Equal(t, ".", *c.Targets[3].Context)
|
require.Equal(t, ".", *c.Targets[3].Context)
|
||||||
require.Equal(t, "b", *c.Targets[3].Target)
|
require.Equal(t, "b", *c.Targets[3].Target)
|
||||||
}
|
}
|
||||||
|
@ -1389,10 +1389,10 @@ target "two" {
|
||||||
|
|
||||||
require.Equal(t, 2, len(c.Targets))
|
require.Equal(t, 2, len(c.Targets))
|
||||||
|
|
||||||
require.Equal(t, c.Targets[0].Name, "one")
|
require.Equal(t, "one", c.Targets[0].Name)
|
||||||
require.Equal(t, map[string]*string{"a": ptrstr("pre-ghi-jkl")}, c.Targets[0].Args)
|
require.Equal(t, map[string]*string{"a": ptrstr("pre-ghi-jkl")}, c.Targets[0].Args)
|
||||||
|
|
||||||
require.Equal(t, c.Targets[1].Name, "two")
|
require.Equal(t, "two", c.Targets[1].Name)
|
||||||
require.Equal(t, map[string]*string{"b": ptrstr("pre-jkl")}, c.Targets[1].Args)
|
require.Equal(t, map[string]*string{"b": ptrstr("pre-jkl")}, c.Targets[1].Args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ func setupTest(tb testing.TB) {
|
||||||
gitutil.GitInit(c, tb)
|
gitutil.GitInit(c, tb)
|
||||||
|
|
||||||
df := []byte("FROM alpine:latest\n")
|
df := []byte("FROM alpine:latest\n")
|
||||||
assert.NoError(tb, os.WriteFile("Dockerfile", df, 0644))
|
require.NoError(tb, os.WriteFile("Dockerfile", df, 0644))
|
||||||
|
|
||||||
gitutil.GitAdd(c, tb, "Dockerfile")
|
gitutil.GitAdd(c, tb, "Dockerfile")
|
||||||
gitutil.GitCommit(c, tb, "initial commit")
|
gitutil.GitCommit(c, tb, "initial commit")
|
||||||
|
@ -32,7 +32,7 @@ func setupTest(tb testing.TB) {
|
||||||
|
|
||||||
func TestGetGitAttributesNotGitRepo(t *testing.T) {
|
func TestGetGitAttributesNotGitRepo(t *testing.T) {
|
||||||
_, err := getGitAttributes(context.Background(), t.TempDir(), "Dockerfile")
|
_, err := getGitAttributes(context.Background(), t.TempDir(), "Dockerfile")
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetGitAttributesBadGitRepo(t *testing.T) {
|
func TestGetGitAttributesBadGitRepo(t *testing.T) {
|
||||||
|
@ -47,7 +47,7 @@ func TestGetGitAttributesNoContext(t *testing.T) {
|
||||||
setupTest(t)
|
setupTest(t)
|
||||||
|
|
||||||
addGitAttrs, err := getGitAttributes(context.Background(), "", "Dockerfile")
|
addGitAttrs, err := getGitAttributes(context.Background(), "", "Dockerfile")
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
var so client.SolveOpt
|
var so client.SolveOpt
|
||||||
addGitAttrs(&so)
|
addGitAttrs(&so)
|
||||||
assert.Empty(t, so.FrontendAttrs)
|
assert.Empty(t, so.FrontendAttrs)
|
||||||
|
@ -195,8 +195,8 @@ func TestLocalDirsSub(t *testing.T) {
|
||||||
gitutil.GitInit(c, t)
|
gitutil.GitInit(c, t)
|
||||||
|
|
||||||
df := []byte("FROM alpine:latest\n")
|
df := []byte("FROM alpine:latest\n")
|
||||||
assert.NoError(t, os.MkdirAll("app", 0755))
|
require.NoError(t, os.MkdirAll("app", 0755))
|
||||||
assert.NoError(t, os.WriteFile("app/Dockerfile", df, 0644))
|
require.NoError(t, os.WriteFile("app/Dockerfile", df, 0644))
|
||||||
|
|
||||||
gitutil.GitAdd(c, t, "app/Dockerfile")
|
gitutil.GitAdd(c, t, "app/Dockerfile")
|
||||||
gitutil.GitCommit(c, t, "initial commit")
|
gitutil.GitCommit(c, t, "initial commit")
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func generateRandomData(size int) []byte {
|
func generateRandomData(size int) []byte {
|
||||||
|
@ -57,7 +56,7 @@ func TestSyncMultiReaderParallel(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
require.NoError(t, err, "Reader %d error", readerId)
|
assert.NoError(t, err, "Reader %d error", readerId)
|
||||||
|
|
||||||
if mathrand.Intn(1000) == 0 { //nolint:gosec
|
if mathrand.Intn(1000) == 0 { //nolint:gosec
|
||||||
t.Logf("Reader %d closing", readerId)
|
t.Logf("Reader %d closing", readerId)
|
||||||
|
|
|
@ -138,7 +138,7 @@ func TestToBuildkitExtraHosts(t *testing.T) {
|
||||||
actualOut, actualErr := toBuildkitExtraHosts(context.TODO(), tc.input, nil)
|
actualOut, actualErr := toBuildkitExtraHosts(context.TODO(), tc.input, nil)
|
||||||
if tc.expectedErr == "" {
|
if tc.expectedErr == "" {
|
||||||
require.Equal(t, tc.expectedOut, actualOut)
|
require.Equal(t, tc.expectedOut, actualOut)
|
||||||
require.Nil(t, actualErr)
|
require.NoError(t, actualErr)
|
||||||
} else {
|
} else {
|
||||||
require.Zero(t, actualOut)
|
require.Zero(t, actualOut)
|
||||||
require.Error(t, actualErr, tc.expectedErr)
|
require.Error(t, actualErr, tc.expectedErr)
|
||||||
|
|
|
@ -19,13 +19,13 @@ func TestCsvToMap(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Contains(t, r, "tolerations")
|
require.Contains(t, r, "tolerations")
|
||||||
require.Equal(t, r["tolerations"], "key=foo,value=bar;key=foo2,value=bar2")
|
require.Equal(t, "key=foo,value=bar;key=foo2,value=bar2", r["tolerations"])
|
||||||
|
|
||||||
require.Contains(t, r, "replicas")
|
require.Contains(t, r, "replicas")
|
||||||
require.Equal(t, r["replicas"], "1")
|
require.Equal(t, "1", r["replicas"])
|
||||||
|
|
||||||
require.Contains(t, r, "namespace")
|
require.Contains(t, r, "namespace")
|
||||||
require.Equal(t, r["namespace"], "default")
|
require.Equal(t, "default", r["namespace"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseBuildkitdFlags(t *testing.T) {
|
func TestParseBuildkitdFlags(t *testing.T) {
|
||||||
|
|
|
@ -191,7 +191,7 @@ func checkClientConfig(t *testing.T, ep Endpoint, server, namespace string, ca,
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, proxyURLString, proxyURL.String())
|
assert.Equal(t, proxyURLString, proxyURL.String())
|
||||||
} else {
|
} else {
|
||||||
assert.True(t, cfg.Proxy == nil, "expected proxy to be nil, but is not nil instead")
|
assert.Nil(t, cfg.Proxy, "expected proxy to be nil, but is not nil instead")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ func TestSaveLoadGKEConfig(t *testing.T) {
|
||||||
persistedMetadata, err := store.GetMetadata("gke-context")
|
persistedMetadata, err := store.GetMetadata("gke-context")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
persistedEPMeta := EndpointFromContext(persistedMetadata)
|
persistedEPMeta := EndpointFromContext(persistedMetadata)
|
||||||
assert.True(t, persistedEPMeta != nil)
|
assert.NotNil(t, persistedEPMeta)
|
||||||
persistedEP, err := persistedEPMeta.WithTLSData(store, "gke-context")
|
persistedEP, err := persistedEPMeta.WithTLSData(store, "gke-context")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
persistedCfg := persistedEP.KubernetesConfig()
|
persistedCfg := persistedEP.KubernetesConfig()
|
||||||
|
@ -249,7 +249,7 @@ func TestSaveLoadEKSConfig(t *testing.T) {
|
||||||
persistedMetadata, err := store.GetMetadata("eks-context")
|
persistedMetadata, err := store.GetMetadata("eks-context")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
persistedEPMeta := EndpointFromContext(persistedMetadata)
|
persistedEPMeta := EndpointFromContext(persistedMetadata)
|
||||||
assert.True(t, persistedEPMeta != nil)
|
assert.NotNil(t, persistedEPMeta)
|
||||||
persistedEP, err := persistedEPMeta.WithTLSData(store, "eks-context")
|
persistedEP, err := persistedEPMeta.WithTLSData(store, "eks-context")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
persistedCfg := persistedEP.KubernetesConfig()
|
persistedCfg := persistedEP.KubernetesConfig()
|
||||||
|
@ -274,14 +274,14 @@ func TestSaveLoadK3SConfig(t *testing.T) {
|
||||||
persistedMetadata, err := store.GetMetadata("k3s-context")
|
persistedMetadata, err := store.GetMetadata("k3s-context")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
persistedEPMeta := EndpointFromContext(persistedMetadata)
|
persistedEPMeta := EndpointFromContext(persistedMetadata)
|
||||||
assert.True(t, persistedEPMeta != nil)
|
assert.NotNil(t, persistedEPMeta)
|
||||||
persistedEP, err := persistedEPMeta.WithTLSData(store, "k3s-context")
|
persistedEP, err := persistedEPMeta.WithTLSData(store, "k3s-context")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
persistedCfg := persistedEP.KubernetesConfig()
|
persistedCfg := persistedEP.KubernetesConfig()
|
||||||
actualCfg, err := persistedCfg.ClientConfig()
|
actualCfg, err := persistedCfg.ClientConfig()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.True(t, len(actualCfg.Username) > 0)
|
assert.Greater(t, len(actualCfg.Username), 0)
|
||||||
assert.True(t, len(actualCfg.Password) > 0)
|
assert.Greater(t, len(actualCfg.Password), 0)
|
||||||
assert.Equal(t, expectedCfg.Username, actualCfg.Username)
|
assert.Equal(t, expectedCfg.Username, actualCfg.Username)
|
||||||
assert.Equal(t, expectedCfg.Password, actualCfg.Password)
|
assert.Equal(t, expectedCfg.Password, actualCfg.Password)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ func TestNodeGroupUpdate(t *testing.T) {
|
||||||
err = ng.Update("foo1", "foo1", []string{"linux/arm64", "linux/arm/v7"}, true, true, nil, "", nil)
|
err = ng.Update("foo1", "foo1", []string{"linux/arm64", "linux/arm/v7"}, true, true, nil, "", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, len(ng.Nodes), 2)
|
require.Equal(t, 2, len(ng.Nodes))
|
||||||
|
|
||||||
// update
|
// update
|
||||||
err = ng.Update("foo", "foo2", []string{"linux/amd64", "linux/arm"}, true, false, nil, "", nil)
|
err = ng.Update("foo", "foo2", []string{"linux/amd64", "linux/arm"}, true, false, nil, "", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, len(ng.Nodes), 2)
|
require.Equal(t, 2, len(ng.Nodes))
|
||||||
require.Equal(t, []string{"linux/amd64", "linux/arm/v7"}, platformutil.Format(ng.Nodes[0].Platforms))
|
require.Equal(t, []string{"linux/amd64", "linux/arm/v7"}, platformutil.Format(ng.Nodes[0].Platforms))
|
||||||
require.Equal(t, []string{"linux/arm64"}, platformutil.Format(ng.Nodes[1].Platforms))
|
require.Equal(t, []string{"linux/arm64"}, platformutil.Format(ng.Nodes[1].Platforms))
|
||||||
|
|
||||||
|
@ -39,6 +39,6 @@ func TestNodeGroupUpdate(t *testing.T) {
|
||||||
err = ng.Leave("foo")
|
err = ng.Leave("foo")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, len(ng.Nodes), 1)
|
require.Equal(t, 1, len(ng.Nodes))
|
||||||
require.Equal(t, []string{"linux/arm64"}, platformutil.Format(ng.Nodes[0].Platforms))
|
require.Equal(t, []string{"linux/arm64"}, platformutil.Format(ng.Nodes[0].Platforms))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/buildx/util/confutil"
|
"github.com/docker/buildx/util/confutil"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ func TestNodeLocking(t *testing.T) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
_, release, err := s.Txn()
|
_, release, err := s.Txn()
|
||||||
require.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
release()
|
release()
|
||||||
close(ready)
|
close(ready)
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -126,7 +126,7 @@ RUN echo "Hello ${HELLO}"
|
||||||
require.Equal(t, "Dockerfile", *def.Target["build"].Dockerfile)
|
require.Equal(t, "Dockerfile", *def.Target["build"].Dockerfile)
|
||||||
require.Equal(t, map[string]*string{"HELLO": ptrstr("foo")}, def.Target["build"].Args)
|
require.Equal(t, map[string]*string{"HELLO": ptrstr("foo")}, def.Target["build"].Args)
|
||||||
|
|
||||||
require.Equal(t, `{
|
require.JSONEq(t, `{
|
||||||
"group": {
|
"group": {
|
||||||
"default": {
|
"default": {
|
||||||
"targets": [
|
"targets": [
|
||||||
|
|
|
@ -471,7 +471,7 @@ RUN echo foo > /bar`)
|
||||||
cmd := buildxCmd(sb, withArgs("build", "--output=type=cacheonly", dir))
|
cmd := buildxCmd(sb, withArgs("build", "--output=type=cacheonly", dir))
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
require.NoError(t, err, string(out))
|
require.NoError(t, err, string(out))
|
||||||
require.False(t, buildDetailsPattern.MatchString(string(out)), fmt.Sprintf("build details link not expected in output, got %q", out))
|
require.False(t, buildDetailsPattern.MatchString(string(out)), "build details link not expected in output, got %q", out)
|
||||||
|
|
||||||
// create desktop-build .lastaccess file
|
// create desktop-build .lastaccess file
|
||||||
home, err := os.UserHomeDir() // TODO: sandbox should create a temp home dir and expose it through its interface
|
home, err := os.UserHomeDir() // TODO: sandbox should create a temp home dir and expose it through its interface
|
||||||
|
@ -491,7 +491,7 @@ RUN echo foo > /bar`)
|
||||||
cmd = buildxCmd(sb, withArgs("build", "--output=type=cacheonly", dir))
|
cmd = buildxCmd(sb, withArgs("build", "--output=type=cacheonly", dir))
|
||||||
out, err = cmd.CombinedOutput()
|
out, err = cmd.CombinedOutput()
|
||||||
require.NoError(t, err, string(out))
|
require.NoError(t, err, string(out))
|
||||||
require.True(t, buildDetailsPattern.MatchString(string(out)), fmt.Sprintf("expected build details link in output, got %q", out))
|
require.True(t, buildDetailsPattern.MatchString(string(out)), "expected build details link in output, got %q", out)
|
||||||
|
|
||||||
// build erroneous dockerfile
|
// build erroneous dockerfile
|
||||||
dockerfile = []byte(`FROM busybox:latest
|
dockerfile = []byte(`FROM busybox:latest
|
||||||
|
@ -500,7 +500,7 @@ RUN exit 1`)
|
||||||
cmd = buildxCmd(sb, withArgs("build", "--output=type=cacheonly", dir))
|
cmd = buildxCmd(sb, withArgs("build", "--output=type=cacheonly", dir))
|
||||||
out, err = cmd.CombinedOutput()
|
out, err = cmd.CombinedOutput()
|
||||||
require.Error(t, err, string(out))
|
require.Error(t, err, string(out))
|
||||||
require.True(t, buildDetailsPattern.MatchString(string(out)), fmt.Sprintf("expected build details link in output, got %q", out))
|
require.True(t, buildDetailsPattern.MatchString(string(out)), "expected build details link in output, got %q", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBuildProgress(t *testing.T, sb integration.Sandbox) {
|
func testBuildProgress(t *testing.T, sb integration.Sandbox) {
|
||||||
|
@ -578,7 +578,7 @@ func testBuildBuildArgNoKey(t *testing.T, sb integration.Sandbox) {
|
||||||
cmd := buildxCmd(sb, withArgs("build", "--build-arg", "=TEST_STRING", dir))
|
cmd := buildxCmd(sb, withArgs("build", "--build-arg", "=TEST_STRING", dir))
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
require.Error(t, err, string(out))
|
require.Error(t, err, string(out))
|
||||||
require.Equal(t, strings.TrimSpace(string(out)), `ERROR: invalid key-value pair "=TEST_STRING": empty key`)
|
require.Equal(t, `ERROR: invalid key-value pair "=TEST_STRING": empty key`, strings.TrimSpace(string(out)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBuildLabelNoKey(t *testing.T, sb integration.Sandbox) {
|
func testBuildLabelNoKey(t *testing.T, sb integration.Sandbox) {
|
||||||
|
@ -586,7 +586,7 @@ func testBuildLabelNoKey(t *testing.T, sb integration.Sandbox) {
|
||||||
cmd := buildxCmd(sb, withArgs("build", "--label", "=TEST_STRING", dir))
|
cmd := buildxCmd(sb, withArgs("build", "--label", "=TEST_STRING", dir))
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
require.Error(t, err, string(out))
|
require.Error(t, err, string(out))
|
||||||
require.Equal(t, strings.TrimSpace(string(out)), `ERROR: invalid key-value pair "=TEST_STRING": empty key`)
|
require.Equal(t, `ERROR: invalid key-value pair "=TEST_STRING": empty key`, strings.TrimSpace(string(out)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBuildCacheExportNotSupported(t *testing.T, sb integration.Sandbox) {
|
func testBuildCacheExportNotSupported(t *testing.T, sb integration.Sandbox) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ func testCreateRemoteContainer(t *testing.T, sb integration.Sandbox) {
|
||||||
|
|
||||||
for _, line := range strings.Split(out, "\n") {
|
for _, line := range strings.Split(out, "\n") {
|
||||||
if v, ok := strings.CutPrefix(line, "Status:"); ok {
|
if v, ok := strings.CutPrefix(line, "Status:"); ok {
|
||||||
require.Equal(t, strings.TrimSpace(v), "running")
|
require.Equal(t, "running", strings.TrimSpace(v))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"github.com/moby/buildkit/util/progress/progressui"
|
"github.com/moby/buildkit/util/progress/progressui"
|
||||||
"github.com/moby/buildkit/util/testutil/integration"
|
"github.com/moby/buildkit/util/testutil/integration"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -57,7 +56,7 @@ func testDialStdio(t *testing.T, sb integration.Sandbox) {
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(10 * time.Second):
|
||||||
t.Error("timeout waiting for buildx command to exit")
|
t.Error("timeout waiting for buildx command to exit")
|
||||||
case <-chErr:
|
case <-chErr:
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsSubPath(t *testing.T) {
|
func TestIsSubPath(t *testing.T) {
|
||||||
|
@ -51,7 +52,7 @@ func TestIsSubPath(t *testing.T) {
|
||||||
tt := tt
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
ok, err := isSubPath(tt.basePath, tt.subPath)
|
ok, err := isSubPath(tt.basePath, tt.subPath)
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, tt.expected, ok)
|
assert.Equal(t, tt.expected, ok)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLoad(t *testing.T) {
|
func TestLoad(t *testing.T) {
|
||||||
|
@ -19,7 +20,7 @@ func TestLoad(t *testing.T) {
|
||||||
r := getImageNoAttestation()
|
r := getImageNoAttestation()
|
||||||
indexDigest := reflect.ValueOf(r.indexes).MapKeys()[0].String()
|
indexDigest := reflect.ValueOf(r.indexes).MapKeys()[0].String()
|
||||||
result, err := loader.Load(ctx, fmt.Sprintf("test@%s", indexDigest))
|
result, err := loader.Load(ctx, fmt.Sprintf("test@%s", indexDigest))
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
assert.Equal(t, 1, len(result.indexes))
|
assert.Equal(t, 1, len(result.indexes))
|
||||||
assert.Equal(t, 2, len(result.images))
|
assert.Equal(t, 2, len(result.images))
|
||||||
|
@ -32,7 +33,7 @@ func TestLoad(t *testing.T) {
|
||||||
r = getImageWithAttestation(plainSpdx)
|
r = getImageWithAttestation(plainSpdx)
|
||||||
indexDigest = reflect.ValueOf(r.indexes).MapKeys()[0].String()
|
indexDigest = reflect.ValueOf(r.indexes).MapKeys()[0].String()
|
||||||
result, err = loader.Load(ctx, fmt.Sprintf("test@%s", indexDigest))
|
result, err = loader.Load(ctx, fmt.Sprintf("test@%s", indexDigest))
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
assert.Equal(t, 1, len(result.indexes))
|
assert.Equal(t, 1, len(result.indexes))
|
||||||
assert.Equal(t, 2, len(result.images))
|
assert.Equal(t, 2, len(result.images))
|
||||||
|
@ -92,7 +93,7 @@ func TestSBOM(t *testing.T) {
|
||||||
r.assets["linux/amd64"] = a
|
r.assets["linux/amd64"] = a
|
||||||
actual, err := r.SBOM()
|
actual, err := r.SBOM()
|
||||||
|
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(actual))
|
assert.Equal(t, 1, len(actual))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -140,7 +141,7 @@ func TestProvenance(t *testing.T) {
|
||||||
r.assets["linux/amd64"] = a
|
r.assets["linux/amd64"] = a
|
||||||
actual, err := r.Provenance()
|
actual, err := r.Provenance()
|
||||||
|
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, 1, len(actual))
|
assert.Equal(t, 1, len(actual))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -167,7 +168,7 @@ func Test_isInTotoDSSE(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.mime, func(t *testing.T) {
|
t.Run(test.mime, func(t *testing.T) {
|
||||||
assert.Equal(t, isInTotoDSSE(test.mime), test.expected)
|
assert.Equal(t, test.expected, isInTotoDSSE(test.mime))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,19 +176,19 @@ func Test_isInTotoDSSE(t *testing.T) {
|
||||||
func Test_decodeDSSE(t *testing.T) {
|
func Test_decodeDSSE(t *testing.T) {
|
||||||
// Returns input when mime isn't a DSSE type
|
// Returns input when mime isn't a DSSE type
|
||||||
actual, err := decodeDSSE([]byte("foobar"), "application/vnd.in-toto+json")
|
actual, err := decodeDSSE([]byte("foobar"), "application/vnd.in-toto+json")
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, []byte("foobar"), actual)
|
assert.Equal(t, []byte("foobar"), actual)
|
||||||
|
|
||||||
// Returns the base64 decoded payload if is a DSSE
|
// Returns the base64 decoded payload if is a DSSE
|
||||||
payload := base64.StdEncoding.EncodeToString([]byte("hello world"))
|
payload := base64.StdEncoding.EncodeToString([]byte("hello world"))
|
||||||
envelope := fmt.Sprintf("{\"payload\":\"%s\"}", payload)
|
envelope := fmt.Sprintf("{\"payload\":\"%s\"}", payload)
|
||||||
actual, err = decodeDSSE([]byte(envelope), "application/vnd.in-toto.spdx+dsse")
|
actual, err = decodeDSSE([]byte(envelope), "application/vnd.in-toto.spdx+dsse")
|
||||||
assert.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "hello world", string(actual))
|
assert.Equal(t, "hello world", string(actual))
|
||||||
|
|
||||||
_, err = decodeDSSE([]byte("not a json"), "application/vnd.in-toto.spdx+dsse")
|
_, err = decodeDSSE([]byte("not a json"), "application/vnd.in-toto.spdx+dsse")
|
||||||
assert.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
_, err = decodeDSSE([]byte("{\"payload\": \"not base64\"}"), "application/vnd.in-toto.spdx+dsse")
|
_, err = decodeDSSE([]byte("{\"payload\": \"not base64\"}"), "application/vnd.in-toto.spdx+dsse")
|
||||||
assert.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package waitmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ func TestTimeout(t *testing.T) {
|
||||||
|
|
||||||
_, err := m.Get(ctx, "bar")
|
_, err := m.Get(ctx, "bar")
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.True(t, errors.Is(err, context.DeadlineExceeded))
|
require.ErrorIs(t, err, context.DeadlineExceeded)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBlocking(t *testing.T) {
|
func TestBlocking(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue