Add container publishing and env-based runtime
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -93,6 +94,44 @@ func TestExtractLikeLiveMissingTable(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAlmaCredsFromEnv(t *testing.T) {
|
||||
t.Setenv("ALMA_USERNAME", "student")
|
||||
t.Setenv("ALMA_PASSWORD", "secret")
|
||||
|
||||
got, err := loadAlmaCreds("")
|
||||
if err != nil {
|
||||
t.Fatalf("loadAlmaCreds returned error: %v", err)
|
||||
}
|
||||
if got["username"] != "student" || got["password"] != "secret" {
|
||||
t.Fatalf("unexpected creds: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAlmaCredsRequiresPasswordWithEnvUsername(t *testing.T) {
|
||||
t.Setenv("ALMA_USERNAME", "student")
|
||||
t.Setenv("ALMA_PASSWORD", "")
|
||||
|
||||
if _, err := loadAlmaCreds(""); err == nil {
|
||||
t.Fatal("expected error when ALMA_PASSWORD is missing")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAlmaCredsFromFile(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := dir + "/alma.creds"
|
||||
if err := os.WriteFile(path, []byte("username: student\npassword: secret\n"), 0o600); err != nil {
|
||||
t.Fatalf("write creds file: %v", err)
|
||||
}
|
||||
|
||||
got, err := loadAlmaCreds(path)
|
||||
if err != nil {
|
||||
t.Fatalf("loadAlmaCreds returned error: %v", err)
|
||||
}
|
||||
if got["username"] != "student" || got["password"] != "secret" {
|
||||
t.Fatalf("unexpected creds: %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func mustParseHTML(text string) *html.Node {
|
||||
doc, err := html.Parse(strings.NewReader(text))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user