restic/internal/backend/location/display_location_test.go

30 lines
708 B
Go
Raw Normal View History

package location_test
2020-03-20 22:52:27 +00:00
import (
"testing"
2020-03-20 22:52:27 +00:00
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/backend/location"
"github.com/restic/restic/internal/test"
)
2020-03-20 22:52:27 +00:00
func TestStripPassword(t *testing.T) {
registry := location.NewRegistry()
registry.Register(
location.NewHTTPBackendFactory[any, backend.Backend]("test", nil,
func(s string) string {
return "cleaned"
}, nil, nil,
),
)
t.Run("valid", func(t *testing.T) {
clean := location.StripPassword(registry, "test:secret")
test.Equals(t, "cleaned", clean)
})
t.Run("unknown", func(t *testing.T) {
clean := location.StripPassword(registry, "invalid:secret")
test.Equals(t, "invalid:secret", clean)
})
2020-03-20 22:52:27 +00:00
}