Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
36 lines
770 B
Go
36 lines
770 B
Go
package eprel
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
// stubFetcher verifies the Fetcher interface is usable from processing tests.
|
|
type stubFetcher struct {
|
|
enabled bool
|
|
data *Data
|
|
err error
|
|
calls int
|
|
lastID string
|
|
}
|
|
|
|
func (s *stubFetcher) Enabled() bool { return s.enabled }
|
|
|
|
func (s *stubFetcher) Fetch(_ context.Context, id string) (*Data, error) {
|
|
s.calls++
|
|
s.lastID = id
|
|
return s.data, s.err
|
|
}
|
|
|
|
func TestFetcherInterface(t *testing.T) {
|
|
var _ Fetcher = (*Client)(nil)
|
|
var _ Fetcher = Disabled{}
|
|
var _ Fetcher = (*stubFetcher)(nil)
|
|
|
|
st := &stubFetcher{enabled: true, data: &Data{ID: "1", Label: "L"}}
|
|
got, err := st.Fetch(context.Background(), "1")
|
|
if err != nil || got.ID != "1" || st.calls != 1 {
|
|
t.Fatalf("stub: %#v err=%v", got, err)
|
|
}
|
|
}
|