30 lines
640 B
Go
30 lines
640 B
Go
package handlers
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"text/template"
|
|
)
|
|
|
|
func TestInstallTemplateExecute(t *testing.T) {
|
|
root, _ := filepath.Abs(filepath.Join("..", "..", ".."))
|
|
tmplPath := filepath.Join(root, "scripts", "install.sh.tpl")
|
|
b, err := os.ReadFile(tmplPath)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
tmpl, err := template.New("install.sh").Parse(string(b))
|
|
if err != nil {
|
|
t.Fatalf("parse: %v", err)
|
|
}
|
|
data := installData{
|
|
DeckURL: "http://localhost:8989", PublicKey: "abc", FleetSecret: "sec",
|
|
}
|
|
var buf bytes.Buffer
|
|
if err := tmpl.Execute(&buf, data); err != nil {
|
|
t.Fatalf("execute: %v", err)
|
|
}
|
|
}
|