diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71b0cd4..a85f6ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Version validation if: ${{ github.event_name == 'pull_request' }} - uses: mukunku/tag-exists-action@v1.2.0 + uses: mukunku/tag-exists-action@v1.5.0 id: checkTag with: tag: v${{ env.VERSION }} @@ -36,12 +36,12 @@ jobs: - name: Fail workflow if tag exists if: ${{ github.event_name == 'pull_request' && steps.checkTag.outputs.exists == 'true' }} - uses: actions/github-script@v6.4.0 + uses: actions/github-script@v7.0.1 with: script: core.setFailed('[ERROR] Tag already exists.') - name: Setup Go version - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '^1.20.7' diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 76ccd05..2b7632d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Login to Artifactory - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: splitio-docker.jfrog.io username: ${{ secrets.ARTIFACTORY_DOCKER_USER }} @@ -24,7 +24,7 @@ jobs: run: echo "VERSION=$(cat splitio/version.go | grep 'Version =' | awk '{print $4}' | tr -d '"')" >> $GITHUB_ENV - name: Docker build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: "infra/sidecar.Dockerfile" diff --git a/.github/workflows/unstable.yml b/.github/workflows/unstable.yml index f0c0c7d..9e0eead 100644 --- a/.github/workflows/unstable.yml +++ b/.github/workflows/unstable.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Login to Artifactory - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: splitio-docker-dev.jfrog.io username: ${{ secrets.ARTIFACTORY_DOCKER_USER }} @@ -23,7 +23,7 @@ jobs: run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Docker Build and Push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: "infra/sidecar.Dockerfile" diff --git a/splitio/sdk/sdk_test.go b/splitio/sdk/sdk_test.go index b28750b..15db214 100644 --- a/splitio/sdk/sdk_test.go +++ b/splitio/sdk/sdk_test.go @@ -218,27 +218,39 @@ func TestTreatmentsByFlagSet(t *testing.T) { }}). Once() - expectedImpressions := []dtos.Impression{ - {KeyName: "key1", BucketingKey: "", FeatureName: "f1", Treatment: "on", Label: "label1", ChangeNumber: 123}, - {KeyName: "key1", BucketingKey: "", FeatureName: "f2", Treatment: "on", Label: "label2", ChangeNumber: 124}, - {KeyName: "key1", BucketingKey: "", FeatureName: "f3", Treatment: "on", Label: "label3", ChangeNumber: 125}, + expectedImpressions := map[string]*dtos.Impression{ + "f1": {KeyName: "key1", BucketingKey: "", FeatureName: "f1", Treatment: "on", Label: "label1", ChangeNumber: 123}, + "f2": {KeyName: "key1", BucketingKey: "", FeatureName: "f2", Treatment: "on", Label: "label2", ChangeNumber: 124}, + "f3": {KeyName: "key1", BucketingKey: "", FeatureName: "f3", Treatment: "on", Label: "label3", ChangeNumber: 125}, } im := &mocks.ImpressionManagerMock{} im.On("ProcessSingle", mock.Anything). Run(func(args mock.Arguments) { - assertImpEq(t, &expectedImpressions[0], args.Get(0).(*dtos.Impression)) + imp, ok := args.Get(0).(*dtos.Impression) + if !ok { + t.Error("not an impression") + } + assertImpEq(t, expectedImpressions[imp.FeatureName], args.Get(0).(*dtos.Impression)) }). Return(true). Once() im.On("ProcessSingle", mock.Anything). Run(func(args mock.Arguments) { - assertImpEq(t, &expectedImpressions[1], args.Get(0).(*dtos.Impression)) + imp, ok := args.Get(0).(*dtos.Impression) + if !ok { + t.Error("not an impression") + } + assertImpEq(t, expectedImpressions[imp.FeatureName], args.Get(0).(*dtos.Impression)) }). Return(true). Once() im.On("ProcessSingle", mock.Anything). Run(func(args mock.Arguments) { - assertImpEq(t, &expectedImpressions[2], args.Get(0).(*dtos.Impression)) + imp, ok := args.Get(0).(*dtos.Impression) + if !ok { + t.Error("not an impression") + } + assertImpEq(t, expectedImpressions[imp.FeatureName], args.Get(0).(*dtos.Impression)) }). Return(true). Once() @@ -258,9 +270,9 @@ func TestTreatmentsByFlagSet(t *testing.T) { assert.Nil(t, res["f1"].Config) assert.Nil(t, res["f2"].Config) assert.Nil(t, res["f3"].Config) - assertImpEq(t, &expectedImpressions[0], res["f1"].Impression) - assertImpEq(t, &expectedImpressions[1], res["f2"].Impression) - assertImpEq(t, &expectedImpressions[2], res["f3"].Impression) + assertImpEq(t, expectedImpressions["f1"], res["f1"].Impression) + assertImpEq(t, expectedImpressions["f2"], res["f2"].Impression) + assertImpEq(t, expectedImpressions["f3"], res["f3"].Impression) err = is.RangeAndClear(func(md types.ClientMetadata, st *storage.LockingQueue[dtos.Impression]) { assert.Equal(t, types.ClientMetadata{ID: "some", SdkVersion: "go-1.2.3"}, md) @@ -271,9 +283,9 @@ func TestTreatmentsByFlagSet(t *testing.T) { assert.Nil(t, nil) assert.Equal(t, 3, n) assert.Equal(t, 3, len(imps)) - assertImpEq(t, &expectedImpressions[0], &imps[0]) - assertImpEq(t, &expectedImpressions[1], &imps[1]) - assertImpEq(t, &expectedImpressions[2], &imps[2]) + assertImpEq(t, expectedImpressions[imps[0].FeatureName], &imps[0]) + assertImpEq(t, expectedImpressions[imps[1].FeatureName], &imps[1]) + assertImpEq(t, expectedImpressions[imps[2].FeatureName], &imps[2]) n, err = st.Pop(1, &imps) assert.Equal(t, 0, n) assert.ErrorIs(t, err, storage.ErrQueueEmpty) @@ -295,27 +307,39 @@ func TestTreatmentsByFlagSets(t *testing.T) { }}). Once() - expectedImpressions := []dtos.Impression{ - {KeyName: "key1", BucketingKey: "", FeatureName: "f1", Treatment: "on", Label: "label1", ChangeNumber: 123}, - {KeyName: "key1", BucketingKey: "", FeatureName: "f2", Treatment: "on", Label: "label2", ChangeNumber: 124}, - {KeyName: "key1", BucketingKey: "", FeatureName: "f3", Treatment: "on", Label: "label3", ChangeNumber: 125}, + expectedImpressions := map[string]*dtos.Impression{ + "f1": {KeyName: "key1", BucketingKey: "", FeatureName: "f1", Treatment: "on", Label: "label1", ChangeNumber: 123}, + "f2": {KeyName: "key1", BucketingKey: "", FeatureName: "f2", Treatment: "on", Label: "label2", ChangeNumber: 124}, + "f3": {KeyName: "key1", BucketingKey: "", FeatureName: "f3", Treatment: "on", Label: "label3", ChangeNumber: 125}, } im := &mocks.ImpressionManagerMock{} im.On("ProcessSingle", mock.Anything). Run(func(args mock.Arguments) { - assertImpEq(t, &expectedImpressions[0], args.Get(0).(*dtos.Impression)) + imp, ok := args.Get(0).(*dtos.Impression) + if !ok { + t.Error("not an impression") + } + assertImpEq(t, expectedImpressions[imp.FeatureName], args.Get(0).(*dtos.Impression)) }). Return(true). Once() im.On("ProcessSingle", mock.Anything). Run(func(args mock.Arguments) { - assertImpEq(t, &expectedImpressions[1], args.Get(0).(*dtos.Impression)) + imp, ok := args.Get(0).(*dtos.Impression) + if !ok { + t.Error("not an impression") + } + assertImpEq(t, expectedImpressions[imp.FeatureName], args.Get(0).(*dtos.Impression)) }). Return(true). Once() im.On("ProcessSingle", mock.Anything). Run(func(args mock.Arguments) { - assertImpEq(t, &expectedImpressions[2], args.Get(0).(*dtos.Impression)) + imp, ok := args.Get(0).(*dtos.Impression) + if !ok { + t.Error("not an impression") + } + assertImpEq(t, expectedImpressions[imp.FeatureName], args.Get(0).(*dtos.Impression)) }). Return(true). Once() @@ -335,9 +359,9 @@ func TestTreatmentsByFlagSets(t *testing.T) { assert.Nil(t, res["f1"].Config) assert.Nil(t, res["f2"].Config) assert.Nil(t, res["f3"].Config) - assertImpEq(t, &expectedImpressions[0], res["f1"].Impression) - assertImpEq(t, &expectedImpressions[1], res["f2"].Impression) - assertImpEq(t, &expectedImpressions[2], res["f3"].Impression) + assertImpEq(t, expectedImpressions["f1"], res["f1"].Impression) + assertImpEq(t, expectedImpressions["f2"], res["f2"].Impression) + assertImpEq(t, expectedImpressions["f3"], res["f3"].Impression) err = is.RangeAndClear(func(md types.ClientMetadata, st *storage.LockingQueue[dtos.Impression]) { assert.Equal(t, types.ClientMetadata{ID: "some", SdkVersion: "go-1.2.3"}, md) @@ -348,9 +372,9 @@ func TestTreatmentsByFlagSets(t *testing.T) { assert.Nil(t, nil) assert.Equal(t, 3, n) assert.Equal(t, 3, len(imps)) - assertImpEq(t, &expectedImpressions[0], &imps[0]) - assertImpEq(t, &expectedImpressions[1], &imps[1]) - assertImpEq(t, &expectedImpressions[2], &imps[2]) + assertImpEq(t, expectedImpressions[imps[0].FeatureName], &imps[0]) + assertImpEq(t, expectedImpressions[imps[1].FeatureName], &imps[1]) + assertImpEq(t, expectedImpressions[imps[2].FeatureName], &imps[2]) n, err = st.Pop(1, &imps) assert.Equal(t, 0, n) assert.ErrorIs(t, err, storage.ErrQueueEmpty)