feat(deploy): WIP setting fetch & test before build

This commit is contained in:
pakintada@gmail.com 2024-09-09 17:23:04 +07:00
parent 07ec247b53
commit 283088648a
3 changed files with 68 additions and 13 deletions

View file

@ -20,8 +20,8 @@ WORKDIR /app
RUN apk update && apk add --no-cache sqlite curl
COPY --from=builder /app/recipe-manager .
# COPY --from=builder /app/app.env .
# COPY --from=builder /app/client_secret.json .
COPY --from=builder /app/app.env .
COPY --from=builder /app/client_secret.json .
# run the service on container startup.
CMD ["/app/recipe-manager"]

48
server/main_test.go Normal file
View file

@ -0,0 +1,48 @@
package main
import (
"recipe-manager/config"
"reflect"
"testing"
)
func Test_loadConfig(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want *config.ServerConfig
wantErr bool
}{
// TODO: Add test cases.
{
name: "Test Config Local",
args: args{
".",
},
want: &config.ServerConfig{
ServerPort: 8080,
ServerDomain: "http://localhost:8080",
AllowedOrigins: "http://localhost:4200,http://localhost:8080,http://localhost:3001",
ClientRedirectURL: "http://localhost:4200/callback",
APIKey: "AIzaSyDBdJMFN210IcJVmEGJ4AaPQm0FN50iH0s",
Debug: true,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := loadConfig(tt.args.path)
if (err != nil) != tt.wantErr {
t.Errorf("loadConfig() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("loadConfig() = %v, want %v", got, tt.want)
}
})
}
}