minio/cmd/iam-etcd-store_test.go

40 lines
1.3 KiB
Go
Raw Normal View History

/*
* MinIO Cloud Storage, (C) 2016 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cmd
import (
"testing"
)
func TestExtractPrefixAndSuffix(t *testing.T) {
specs := []struct {
path, prefix, suffix string
expected string
}{
{"config/iam/groups/foo.json", "config/iam/groups/", ".json", "foo"},
{"config/iam/groups/./foo.json", "config/iam/groups/", ".json", "foo"},
{"config/iam/groups/foo/config.json", "config/iam/groups/", "/config.json", "foo"},
{"config/iam/groups/foo/config.json", "config/iam/groups/", "config.json", "foo"},
}
for i, test := range specs {
result := extractPathPrefixAndSuffix(test.path, test.prefix, test.suffix)
if result != test.expected {
t.Errorf("unexpected result on test[%v]: expected[%s] but had [%s]", i, test.expected, result)
}
}
}