go-whisper-api/api/models_test.go
admin b5c083e06f
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
first commit
2026-06-04 18:10:52 +07:00

56 lines
1.5 KiB
Go

package api
import (
"os"
"path/filepath"
"testing"
)
func TestRegistry_List_excludesAuxiliaryDirs(t *testing.T) {
root := t.TempDir()
for _, name := range []string{"common.bin", "vad/vad.bin", "punctuation/model.onnx"} {
p := filepath.Join(root, name)
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(p, []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
}
r := NewRegistry(root)
list, err := r.List()
if err != nil {
t.Fatal(err)
}
if len(list) != 1 || list[0] != "common" {
t.Fatalf("list=%v want [common]", list)
}
}
func TestRegistry_List_excludesVADAtRoot(t *testing.T) {
root := t.TempDir()
if err := os.WriteFile(filepath.Join(root, "vad.bin"), []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(root, "ggml-small.bin"), []byte("x"), 0o644); err != nil {
t.Fatal(err)
}
list, err := NewRegistry(root).List()
if err != nil {
t.Fatal(err)
}
if len(list) != 1 || list[0] != "ggml-small" {
t.Fatalf("list=%v", list)
}
}
func TestRegistry_Path_rejectsReservedIDs(t *testing.T) {
root := t.TempDir()
r := NewRegistry(root)
for _, id := range []string{"vad", "punctuation"} {
if _, err := r.Path(id); err == nil {
t.Fatalf("expected error for %q", id)
}
}
}