Public source validation / validate (push) Failing after 3m8s
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package unraid
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestShareSourcePreservesReadOnlyUsageAndPolicy(t *testing.T) {
|
|
server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
_, _ = w.Write([]byte(`{"data":{"shares":[{"id":"share-1","name":"appdata","used":"64","size":"128","include":["disk1"],"exclude":[],"cache":true,"allocator":"high-water"}]}}`))
|
|
}))
|
|
defer server.Close()
|
|
client, err := New(server.URL, "test-token", server.Client())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
now := time.Date(2026, 8, 10, 4, 0, 0, 0, time.UTC)
|
|
snapshot, err := (ShareSource{Client: client, Now: func() time.Time { return now }}).Snapshot(context.Background())
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(snapshot.Shares) != 1 {
|
|
t.Fatalf("shares = %+v", snapshot.Shares)
|
|
}
|
|
item := snapshot.Shares[0]
|
|
if item.UsedBytes != 64*1024 || item.SizeState != "available" || item.StoragePolicy.CachePolicy != "enabled" || item.StoragePolicy.Allocation != "high-water" {
|
|
t.Fatalf("share mapping = %+v", item)
|
|
}
|
|
}
|