From 5ac64b2d97c6e013c83a6618c6bece2e70dedd98 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Tue, 23 Nov 2021 16:04:41 +0000 Subject: [PATCH] chore: set version in unit-tests Refs #4576. Signed-off-by: Alexey Palazhchenko --- Dockerfile | 10 ++++++++-- .../pkg/controllers/cluster/local_affiliate_test.go | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 924dc4917..49426294d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -570,7 +570,10 @@ RUN unlink /etc/ssl COPY --from=rootfs / / ARG TESTPKGS ENV PLATFORM container -RUN --security=insecure --mount=type=cache,id=testspace,target=/tmp --mount=type=cache,target=/.cache go test -v -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 -p 4 ${TESTPKGS} +ARG GO_LDFLAGS +RUN --security=insecure --mount=type=cache,id=testspace,target=/tmp --mount=type=cache,target=/.cache go test -v \ + -ldflags "${GO_LDFLAGS}" \ + -covermode=atomic -coverprofile=coverage.txt -coverpkg=${TESTPKGS} -count 1 -p 4 ${TESTPKGS} FROM scratch AS unit-tests COPY --from=unit-tests-runner /src/coverage.txt /coverage.txt @@ -582,7 +585,10 @@ COPY --from=rootfs / / ARG TESTPKGS ENV PLATFORM container ENV CGO_ENABLED 1 -RUN --security=insecure --mount=type=cache,id=testspace,target=/tmp --mount=type=cache,target=/.cache go test -v -race -count 1 -p 4 ${TESTPKGS} +ARG GO_LDFLAGS +RUN --security=insecure --mount=type=cache,id=testspace,target=/tmp --mount=type=cache,target=/.cache go test -v \ + -ldflags "${GO_LDFLAGS}" \ + -race -count 1 -p 4 ${TESTPKGS} # The integration-test targets builds integration test binary. diff --git a/internal/app/machined/pkg/controllers/cluster/local_affiliate_test.go b/internal/app/machined/pkg/controllers/cluster/local_affiliate_test.go index b3b254307..4b611375c 100644 --- a/internal/app/machined/pkg/controllers/cluster/local_affiliate_test.go +++ b/internal/app/machined/pkg/controllers/cluster/local_affiliate_test.go @@ -23,6 +23,7 @@ import ( "github.com/talos-systems/talos/pkg/machinery/resources/k8s" "github.com/talos-systems/talos/pkg/machinery/resources/kubespan" "github.com/talos-systems/talos/pkg/machinery/resources/network" + "github.com/talos-systems/talos/pkg/version" ) type LocalAffiliateSuite struct { @@ -67,7 +68,7 @@ func (suite *LocalAffiliateSuite) TestGeneration() { suite.Assert().Equal("example1", spec.Hostname) suite.Assert().Equal("example1.com", spec.Nodename) suite.Assert().Equal(machine.TypeWorker, spec.MachineType) - suite.Assert().Equal(" ()", spec.OperatingSystem) // build tags are not set for unit-tests + suite.Assert().Equal("Talos ("+version.Tag+")", spec.OperatingSystem) suite.Assert().Equal(cluster.KubeSpanAffiliateSpec{}, spec.KubeSpan) return nil