mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-26 11:35:35 +00:00
e496451928
- Updates API to support renaming TailFS shares. - Adds a CLI rename subcommand for renaming a share. - Renames the CLI subcommand 'add' to 'set' to make it clear that this is an add or update. - Adds a unit test for TailFS in ipnlocal Updates tailscale/corp#16827 Signed-off-by: Percy Wegmann <percy@tailscale.com>
41 lines
773 B
Go
41 lines
773 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package ipnlocal
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestNormalizeShareName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
want string
|
|
err error
|
|
}{
|
|
{
|
|
name: " (_this is A 5 nAme )_ ",
|
|
want: "(_this is a 5 name )_",
|
|
},
|
|
{
|
|
name: "",
|
|
err: ErrInvalidShareName,
|
|
},
|
|
{
|
|
name: "generally good except for .",
|
|
err: ErrInvalidShareName,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(fmt.Sprintf("name %q", tt.name), func(t *testing.T) {
|
|
got, err := normalizeShareName(tt.name)
|
|
if tt.err != nil && err != tt.err {
|
|
t.Errorf("wanted error %v, got %v", tt.err, err)
|
|
} else if got != tt.want {
|
|
t.Errorf("wanted %q, got %q", tt.want, got)
|
|
}
|
|
})
|
|
}
|
|
}
|