forked from Azure/azure-sdk-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkg_test.go
More file actions
48 lines (44 loc) · 1.16 KB
/
pkg_test.go
File metadata and controls
48 lines (44 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package cmd
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func TestName(t *testing.T) {
for _, test := range []struct {
modulePath, moduleRoot, pkgPath, want string
}{
{
modulePath: "test_package_name",
moduleRoot: "testdata/test_package_name/test_package_name@v1.0.0",
want: "test_package_name",
},
{
modulePath: "test_package_name",
moduleRoot: "testdata/test_package_name/test_package_name@v1.0.0",
pkgPath: "subpackage",
want: "test_package_name/subpackage",
},
{
modulePath: "test_subpackage",
moduleRoot: "testdata/test_subpackage",
want: "test_subpackage",
},
{
modulePath: "test_subpackage",
moduleRoot: "testdata/test_subpackage",
pkgPath: "subpackage",
want: "test_subpackage/subpackage",
},
} {
t.Run("", func(t *testing.T) {
d, err := filepath.Abs(test.moduleRoot)
require.NoError(t, err)
p, err := NewPkg(filepath.Join(d, test.pkgPath), test.modulePath, d)
require.NoError(t, err)
require.Equal(t, test.want, p.Name())
})
}
}