Explorar o código

cicd: Increase coverage (#280)

James Read %!s(int64=2) %!d(string=hai) anos
pai
achega
86b2187236

+ 1 - 1
internal/entityfiles/entityfiles.go

@@ -111,7 +111,7 @@ func updateEvmFromFile(entityname string, data []map[string]string) {
 
 	sv.RemoveKeysThatStartWith("entities." + entityname)
 
-	sv.Set("entities."+entityname+".count", fmt.Sprintf("%v", count))
+	sv.SetEntityCount(entityname, count)
 
 	for i, mapp := range data {
 		prefix := "entities." + entityname + "." + fmt.Sprintf("%v", i)

+ 4 - 0
internal/stringvariables/entities.go

@@ -61,3 +61,7 @@ func GetEntityCount(entityTitle string) int {
 
 	return count
 }
+
+func SetEntityCount(entityTitle string, count int) {
+	Set("entities."+entityTitle+".count", fmt.Sprintf("%v", count))
+}

+ 12 - 0
internal/stringvariables/entities_test.go

@@ -0,0 +1,12 @@
+package stringvariables
+
+import (
+	"github.com/stretchr/testify/assert"
+	"testing"
+)
+
+func TestEntityCount(t *testing.T) {
+	SetEntityCount("waffles", 3)
+
+	assert.Equal(t, 3, GetEntityCount("waffles"))
+}

+ 20 - 0
internal/stringvariables/map_test.go

@@ -0,0 +1,20 @@
+package stringvariables
+
+import (
+	"github.com/stretchr/testify/assert"
+	"testing"
+)
+
+func TestGetAndSet(t *testing.T) {
+	Set("foo", "bar")
+	Set("salutation", "hello")
+
+	assert.Equal(t, "bar", Get("foo"))
+	assert.Equal(t, "", Get("not exist"))
+}
+
+func TestGetall(t *testing.T) {
+	ret := GetAll()
+
+	assert.NotEmpty(t, ret)
+}