1
0
mirror of https://github.com/ChristianSch/gitea-release-drafter.git synced 2025-12-26 17:04:38 +00:00
gitea-release-drafter/src/template_test.go
2023-03-06 17:05:18 +01:00

46 lines
839 B
Go

package src
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestReplaceVariables(t *testing.T) {
// Given
// valid variable values
v := TemplateVariables{
ReleaseVersion: "1.2.3",
}
// and a string containing all variables we have
str := "tag-v$RESOLVED_VERSION-foo"
// When
// filling the variables
res := FillVariables(str, v)
// Then
// the string should've been filled as expected
assert.Equal(t, "tag-v1.2.3-foo", res)
}
func TestReplaceVariablesShouldSkipIfVarsAreAbsent(t *testing.T) {
// Given
// valid variable values
v := TemplateVariables{
ReleaseVersion: "1.2.3",
}
// and a string containing no variables
str := "tag-v-foo"
// When
// filling the variables
res := FillVariables(str, v)
// Then
// the string should'nt have been filled
assert.Equal(t, "tag-v-foo", res)
}