33 lines
741 B
Go
33 lines
741 B
Go
package scripts
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDeployLocalBuildsItsSelectedSourceAndVerifiesVersion(t *testing.T) {
|
|
data, err := os.ReadFile("deploy-local.sh")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
source := string(data)
|
|
if strings.Contains(source, `root="/home/zheromiku/dobotai-platform"`) {
|
|
t.Fatal("deploy script must not hard-code the production checkout")
|
|
}
|
|
for _, fragment := range []string{
|
|
`BASH_SOURCE[0]`,
|
|
`DOBOTAI_SOURCE_ROOT`,
|
|
`git -C "$root" status --porcelain`,
|
|
`git -C "$root" rev-parse HEAD`,
|
|
`main.version`,
|
|
`main.commitSHA`,
|
|
`main.buildTime`,
|
|
`http://127.0.0.1:8090/version`,
|
|
} {
|
|
if !strings.Contains(source, fragment) {
|
|
t.Errorf("deploy script missing %q", fragment)
|
|
}
|
|
}
|
|
}
|