Files
netbird-kubernetes-operator/internal/version/version_test.go
T
Philip LaineandGitHub f8a383f533 Pin the default client image with digest (#227)
This changes the default client image from latest to a pinned digest. It
also enforces that the default image version tag matches the version of
the Netbird dependency.

This makes testing a lot easier and also ensures that we wont get
untested behavior introduced if the client makes a breaking change.

Signed-off-by: Philip Laine <philip.laine@gmail.com>
2026-05-05 11:12:37 +02:00

34 lines
741 B
Go

package version
import (
"os"
"slices"
"strings"
"testing"
"golang.org/x/mod/modfile"
"github.com/go-openapi/testify/v2/require"
)
func TestClientImage(t *testing.T) {
t.Parallel()
b, err := os.ReadFile("../../go.mod")
require.NoError(t, err)
f, err := modfile.Parse("go.mod", b, nil)
require.NoError(t, err)
idx := slices.IndexFunc(f.Require, func(r *modfile.Require) bool {
return r.Mod.Path == "github.com/netbirdio/netbird"
})
require.GreaterT(t, idx, -1)
modVersion := strings.TrimPrefix(f.Require[idx].Mod.Version, "v")
clientImg := ClientImage()
start := strings.Index(clientImg, ":") + 1
end := strings.Index(clientImg, "@")
imgVersion := clientImg[start:end]
require.EqualT(t, modVersion, imgVersion)
}