Files
abra/pkg/app/compose_test.go
decentral1se 94624bb16d
All checks were successful
continuous-integration/drone/push Build is passing
WIP: feat: use compose-go
See #492
2026-04-04 19:39:24 +02:00

56 lines
1.1 KiB
Go

package app_test
import (
"testing"
appPkg "coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/test"
testPkg "coopcloud.tech/abra/pkg/test"
"github.com/stretchr/testify/assert"
)
func TestGetTimeoutFromLabel(t *testing.T) {
test.Setup()
t.Cleanup(func() { test.Teardown() })
tests := []struct {
configuredTimeout string
expectedTimeout int
}{
{"0", 0},
{"DOESNTEXIST", 0}, // NOTE(d1): test when missing from .env
{"80", 80},
{"120", 120},
}
for _, test := range tests {
app, err := appPkg.GetApp(expectedAppFiles, testPkg.AppName)
if err != nil {
t.Fatal(err)
}
if test.configuredTimeout != "DOESNTEXIST" {
app.Env["TIMEOUT"] = test.configuredTimeout
}
composeFiles, err := app.Recipe.GetComposeFiles(app.Env)
if err != nil {
t.Fatal(err)
}
app.Env["STACK_NAME"] = app.StackName()
compose, err := appPkg.GetAppComposeConfig(composeFiles, app.Env)
if err != nil {
t.Fatal(err)
}
timeout, err := appPkg.GetTimeoutFromLabel(compose, app.StackName())
if err != nil {
t.Fatal(err)
}
assert.Equal(t, timeout, test.expectedTimeout)
}
}