Skip to content

Commit

Permalink
Migration aftermath
Browse files Browse the repository at this point in the history
This commit bundles a few minor fixes that are necessary following changes in test tooling.

Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Oct 10, 2024
1 parent 4451d75 commit 33beb32
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
28 changes: 18 additions & 10 deletions cmd/nerdctl/login/login_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ func TestLoginAgainstVariants(t *testing.T) {
"token",
},
// Basic auth, with TLS
{
80,
true,
"basic",
},
/*
// This is not working currently, unless we would force a server https:// in hosts
// To be fixed with login rewrite
{
80,
true,
"basic",
},
*/
{
443,
true,
Expand All @@ -258,11 +262,15 @@ func TestLoginAgainstVariants(t *testing.T) {
"basic",
},
// Token auth, with TLS
{
80,
true,
"token",
},
/*
// This is not working currently, unless we would force a server https:// in hosts
// To be fixed with login rewrite
{
80,
true,
"token",
},
*/
{
443,
true,
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/volume/volume_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestVolumeInspect(t *testing.T) {
&test.Requirement{
Check: func(data test.Data, helpers test.Helpers) (bool, string) {
isDocker, _ := nerdtest.Docker.Check(data, helpers)
return !isDocker || test.IsRoot(), "docker cli needs to be run as root"
return !isDocker || os.Geteuid() == 0, "docker cli needs to be run as root"
},
})

Expand Down
3 changes: 2 additions & 1 deletion cmd/nerdctl/volume/volume_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package volume

import (
"fmt"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -94,7 +95,7 @@ func TestVolumeLsFilter(t *testing.T) {
&test.Requirement{
Check: func(data test.Data, helpers test.Helpers) (bool, string) {
isDocker, _ := nerdtest.Docker.Check(data, helpers)
return !isDocker || test.IsRoot(), "docker cli needs to be run as root"
return !isDocker || os.Geteuid() == 0, "docker cli needs to be run as root"
},
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/testutil/nerdtest/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
)

var BuildkitHost test.ConfigKey = "bkHost"
var BuildkitHost test.ConfigKey = "BuildkitHost"

// These are used for ambient requirements
var ipv6 test.ConfigKey = "IPv6Test"
Expand Down
6 changes: 0 additions & 6 deletions pkg/testutil/test/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ import (
"crypto/rand"
"encoding/base64"
"fmt"
"os"
)

// IsRoot returns true if we are root... simple
func IsRoot() bool {
return os.Geteuid() == 0
}

// RandomStringBase64 generates a base64 encoded random string
func RandomStringBase64(n int) string {
b := make([]byte, n)
Expand Down
2 changes: 1 addition & 1 deletion pkg/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func M(m *testing.M) {
flag.BoolVar(&flagTestKillDaemon, "test.allow-kill-daemon", false, "enable tests that kill the daemon")
flag.BoolVar(&flagTestIPv6, "test.only-ipv6", false, "enable tests on IPv6")
flag.BoolVar(&flagTestKube, "test.only-kubernetes", false, "enable tests on Kubernetes")
flag.BoolVar(&flagTestFlaky, "test.only-flaky", false, "enable testing of flaky tests only")
flag.BoolVar(&flagTestFlaky, "test.only-flaky", false, "enable testing of flaky tests only (if false, flaky tests are ignored)")
if flag.Lookup("test.v") != nil {
flagVerbose = true
}
Expand Down

0 comments on commit 33beb32

Please sign in to comment.