Skip to content

Commit

Permalink
add coverage make target; add unit test for remapper
Browse files Browse the repository at this point in the history
  • Loading branch information
KarnerTh committed Dec 29, 2024
1 parent 7307edc commit e58225c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ test:
test-cleanup:
go clean -testcache

.PHONY: test-coverage
test-coverage:
go test -cover -coverprofile=coverage.out ./...; go tool cover -html=coverage.out -o coverage.html; rm coverage.out

.PHONY: publish
publish:
GOPROXY=proxy.golang.org go list -m github.com/KarnerTh/xogs@$(GIT_TAG)
21 changes: 21 additions & 0 deletions internal/aggregator/remapper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package aggregator

import (
"testing"

"github.com/KarnerTh/xogs/internal/config"
"github.com/stretchr/testify/assert"
)

func TestRemapper(t *testing.T) {
// Arrange
data := map[string]string{"before": "testValue"}

// Act
remap(data, "before", config.Remapper{TargetKey: "after"})

// Assert
assert.Contains(t, data, "after")
assert.NotContains(t, data, "before")
assert.Equal(t, "testValue", data["after"])
}

0 comments on commit e58225c

Please sign in to comment.