ff1db11db4
gates / gates (push) Successful in 29s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
35 lines
1.4 KiB
Go
35 lines
1.4 KiB
Go
package gitea
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
// R-840: a version WITHOUT a config bundle must answer "" — never the binary's sha (FileSHA256's fallback would).
|
|
func TestExactFileSHA256_NeverFallsBack(t *testing.T) {
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
switch r.URL.Path {
|
|
case "/api/v1/packages/admin/generic/felhom-agent/0.142.1/files":
|
|
w.Write([]byte(`[{"name":"felhom-agent","sha256":"aaaa"}]`))
|
|
case "/api/v1/packages/admin/generic/felhom-agent/0.143.0/files":
|
|
w.Write([]byte(`[{"name":"felhom-agent","sha256":"aaaa"},{"name":"felhom-config-bundle.json","sha256":"bbbb"}]`))
|
|
default:
|
|
http.NotFound(w, r)
|
|
}
|
|
}))
|
|
defer srv.Close()
|
|
c := New(srv.URL, "admin", "u", "t")
|
|
if got, err := c.ExactFileSHA256(context.Background(), "felhom-agent", "0.142.1", "felhom-config-bundle.json"); err != nil || got != "" {
|
|
t.Fatalf("no bundle: got %q %v, want \"\"", got, err)
|
|
}
|
|
if got, err := c.ExactFileSHA256(context.Background(), "felhom-agent", "0.143.0", "felhom-config-bundle.json"); err != nil || got != "bbbb" {
|
|
t.Fatalf("bundle: got %q %v", got, err)
|
|
}
|
|
if _, err := c.ExactFileSHA256(context.Background(), "felhom-agent", "9.9.9", "felhom-config-bundle.json"); err == nil {
|
|
t.Fatal("an unreadable listing must be an error, not \"no bundle\"")
|
|
}
|
|
}
|