2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-04 18:10:50 +00:00
restic/internal/backend/location/display_location_test.go
Michael Eischer 3325a7c862 location: extract backend specific part of StripPassword
The tests for the rest backend now reside there.
2023-06-17 15:15:58 +02:00

30 lines
705 B
Go

package location_test
import (
"testing"
"github.com/restic/restic/internal/backend/location"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/test"
)
func TestStripPassword(t *testing.T) {
registry := location.NewRegistry()
registry.Register("test",
location.NewHTTPBackendFactory[any, restic.Backend](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)
})
}