Init commit
Some checks failed
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Test (push) Has been cancelled
CI/CD Pipeline / Build (arm64, windows, linkbeam-windows-arm64.exe) (push) Has been cancelled
CI/CD Pipeline / Build (386, linux, linkbeam-linux-386) (push) Has been cancelled
CI/CD Pipeline / Lint (push) Has been cancelled
CI/CD Pipeline / Build (amd64, linux, linkbeam-linux-amd64) (push) Has been cancelled
CI/CD Pipeline / Build (arm, 7, linux, linkbeam-linux-armv7) (push) Has been cancelled
CI/CD Pipeline / Build (386, windows, linkbeam-windows-386.exe) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, windows, linkbeam-windows-amd64.exe) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, darwin, linkbeam-darwin-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, linux, linkbeam-linux-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, darwin, linkbeam-darwin-amd64) (push) Has been cancelled
CI/CD Pipeline / Create Release (push) Has been cancelled
Some checks failed
CI/CD Pipeline / Build Docker Image (push) Has been cancelled
CI/CD Pipeline / Test (push) Has been cancelled
CI/CD Pipeline / Build (arm64, windows, linkbeam-windows-arm64.exe) (push) Has been cancelled
CI/CD Pipeline / Build (386, linux, linkbeam-linux-386) (push) Has been cancelled
CI/CD Pipeline / Lint (push) Has been cancelled
CI/CD Pipeline / Build (amd64, linux, linkbeam-linux-amd64) (push) Has been cancelled
CI/CD Pipeline / Build (arm, 7, linux, linkbeam-linux-armv7) (push) Has been cancelled
CI/CD Pipeline / Build (386, windows, linkbeam-windows-386.exe) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, windows, linkbeam-windows-amd64.exe) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, darwin, linkbeam-darwin-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (arm64, linux, linkbeam-linux-arm64) (push) Has been cancelled
CI/CD Pipeline / Build (amd64, darwin, linkbeam-darwin-amd64) (push) Has been cancelled
CI/CD Pipeline / Create Release (push) Has been cancelled
This commit is contained in:
98
internal/config/config_test.go
Normal file
98
internal/config/config_test.go
Normal file
@@ -0,0 +1,98 @@
|
||||
// config_test.go
|
||||
|
||||
/*
|
||||
* Copyright (c) - All Rights Reserved.
|
||||
*
|
||||
* See the LICENSE file for more information.
|
||||
*/
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func loadTestConfig(t *testing.T) *Config {
|
||||
t.Helper()
|
||||
cfg, err := Load("testdata/config.yaml")
|
||||
if err != nil {
|
||||
t.Fatalf("load config: %v", err)
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func TestLoad(t *testing.T) {
|
||||
cfg := loadTestConfig(t)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
got interface{}
|
||||
want interface{}
|
||||
}{
|
||||
{"name", cfg.Name, "Ada Lovelace"},
|
||||
{"links count", len(cfg.Links), 2},
|
||||
{"first link URL", cfg.Links[0].URL, "https://ada.blog"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
if tt.got != tt.want {
|
||||
t.Errorf("%s: got %v, want %v", tt.name, tt.got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestThemeValidation(t *testing.T) {
|
||||
cfg := loadTestConfig(t)
|
||||
if cfg.Theme != "light" && cfg.Theme != "dark" && cfg.Theme != "auto" {
|
||||
t.Errorf("invalid theme: %s", cfg.Theme)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinksCountMethod(t *testing.T) {
|
||||
cfg := loadTestConfig(t)
|
||||
if got, want := cfg.LinksCount(), 2; got != want {
|
||||
t.Errorf("LinksCount() = %d, want %d", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFooterBlocks(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
cfg Config
|
||||
want int
|
||||
}{
|
||||
{
|
||||
name: "with footer blocks",
|
||||
cfg: Config{
|
||||
Name: "Test",
|
||||
Footer: []FooterBlock{
|
||||
{Text: "© 2025 Test"},
|
||||
{Text: "Made with LinkBeam"},
|
||||
},
|
||||
},
|
||||
want: 2,
|
||||
},
|
||||
{
|
||||
name: "empty footer",
|
||||
cfg: Config{Name: "Test", Footer: []FooterBlock{}},
|
||||
want: 0,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := len(tt.cfg.Footer); got != tt.want {
|
||||
t.Errorf("Footer length = %d, want %d", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFooterBlockText(t *testing.T) {
|
||||
block := FooterBlock{Text: "Test Footer"}
|
||||
want := "Test Footer"
|
||||
|
||||
if block.Text != want {
|
||||
t.Errorf("FooterBlock.Text = %q, want %q", block.Text, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user