Skip to content

Commit

Permalink
Move template as internal
Browse files Browse the repository at this point in the history
  • Loading branch information
vit1251 committed Dec 17, 2024
1 parent 008814a commit 3efbacd
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 17 deletions.
File renamed without changes.
42 changes: 42 additions & 0 deletions internal/tmpl/Template_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package tmpl

import (
"testing"
"strings"
)

func TestMessageReplyTransformer1(t *testing.T) {

tmpl := NewTemplate()

str := "Golden/{GOLDEN_PLATFORM}-{GOLDEN_ARCH} {GOLDEN_VERSION} {GOLDEN_RELEASE_DATE} ({GOLDEN_RELEASE_HASH})"
newVal, err := tmpl.Render(str)
if err != nil {
t.Fatalf("expected=* got=%q error=%q", newVal, err)
}

if !strings.Contains(newVal, "Golden") {
t.Fatalf("expected=Golden* got=%q", newVal)
}

if strings.Contains(newVal, "{GOLDEN_PLATFORM}") {
t.Fatalf("expected=!{GOLDEN_PLATFORM} got=%q", newVal)
}

if strings.Contains(newVal, "{GOLDEN_ARCH}") {
t.Fatalf("expected=!{GOLDEN_ARCH} got=%q", newVal)
}

if strings.Contains(newVal, "{GOLDEN_VERSION}") {
t.Fatalf("expected=!{GOLDEN_VERSION} got=%q", newVal)
}

if strings.Contains(newVal, "{GOLDEN_RELEASE_DATE}") {
t.Fatalf("expected=!{GOLDEN_RELEASE_DATE} got=%q", newVal)
}

if strings.Contains(newVal, "{GOLDEN_RELEASE_HASH}") {
t.Fatalf("expected=!{GOLDEN_RELEASE_HASH} got=%q", newVal)
}

}
16 changes: 0 additions & 16 deletions pkg/tmpl/Template_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/tosser/TosserManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/vit1251/golden/pkg/mapper"
"github.com/vit1251/golden/pkg/packet"
"github.com/vit1251/golden/pkg/registry"
"github.com/vit1251/golden/pkg/tmpl"
"github.com/vit1251/golden/internal/tmpl"
"hash/crc32"
"io"
"io/ioutil"
Expand Down
31 changes: 31 additions & 0 deletions scripts/make-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

SCRIPT_DIR="$(readlink -f $(dirname "$0"))"
SRC_DIR="$(dirname "${SCRIPT_DIR}")"

echo "=== Golden Point Compile Script ==="

# Step 0. Prepare environemnt
export GOOS="linux"
export GOARCH="amd64"
export CGO_ENABLED="1"
#
echo " Src: ${SRC_DIR}"
echo " OS: ${GOOS}"
echo "Arch: ${GOARCH}"

# Step 1. Get Go modules
#
echo "==> Step 1. Get Go modules..."
go get -v ${SRC_DIR}/...

# Step 2. Generate assets
#
echo "==> Step 2. Generate assets..."
go generate

# Step 3. Run unittest
#
echo "==> Step 3. Run unittest..."
go test ${SRC_DIR}/...

0 comments on commit 3efbacd

Please sign in to comment.