Some checks failed
CodeQL / Analyze (go) (push) Successful in 6m28s
Docker Image / build-docker (push) Failing after 13m26s
Lint and Testing / lint (push) Successful in 11m17s
Lint and Testing / test (push) Successful in 11m17s
Lint and Testing / golangci (push) Successful in 2m40s
36 lines
707 B
Go
36 lines
707 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestLoadFile(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "config.yaml")
|
|
err := os.WriteFile(path, []byte(`
|
|
api:
|
|
addr: ":9090"
|
|
models_dir: "/data/models"
|
|
language: ru
|
|
`), 0o644)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
cfg, err := LoadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cfg.API.Addr != ":9090" {
|
|
t.Fatalf("addr: got %q", cfg.API.Addr)
|
|
}
|
|
if cfg.API.ModelsDir != "/data/models" {
|
|
t.Fatalf("models_dir: got %q", cfg.API.ModelsDir)
|
|
}
|
|
if cfg.API.Language != "ru" {
|
|
t.Fatalf("language: got %q", cfg.API.Language)
|
|
}
|
|
}
|