-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: import `pxapi` as `pveSDK` * refactor: rename folder
- Loading branch information
1 parent
21d0e9e
commit d2d69cd
Showing
13 changed files
with
262 additions
and
262 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package tags | ||
|
||
import ( | ||
"testing" | ||
|
||
pveSDK "github.com/Telmate/proxmox-api-go/proxmox" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_RemoveDuplicates(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input *[]pveSDK.Tag | ||
output *[]pveSDK.Tag | ||
}{ | ||
{name: `nil`}, | ||
{name: `empty`, input: &[]pveSDK.Tag{}}, | ||
{name: `single`, input: &[]pveSDK.Tag{"a"}, output: &[]pveSDK.Tag{"a"}}, | ||
{name: `multiple`, input: &[]pveSDK.Tag{"b", "a", "c"}, output: &[]pveSDK.Tag{"a", "b", "c"}}, | ||
{name: `duplicate`, input: &[]pveSDK.Tag{"b", "a", "c", "b", "a"}, output: &[]pveSDK.Tag{"a", "b", "c"}}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
require.Equal(t, test.output, sortArray(RemoveDuplicates(test.input))) | ||
}) | ||
} | ||
} | ||
|
||
func Test_sort(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input *[]pveSDK.Tag | ||
output *[]pveSDK.Tag | ||
}{ | ||
{name: `nil`}, | ||
{name: `empty`, input: &[]pveSDK.Tag{}}, | ||
{name: `single`, input: &[]pveSDK.Tag{"a"}, output: &[]pveSDK.Tag{"a"}}, | ||
{name: `multiple`, input: &[]pveSDK.Tag{"b", "a", "c"}, output: &[]pveSDK.Tag{"a", "b", "c"}}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
require.Equal(t, test.output, sortArray(test.input)) | ||
}) | ||
} | ||
} | ||
|
||
func Test_Split(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
output *[]pveSDK.Tag | ||
}{ | ||
{name: `empty`, output: &[]pveSDK.Tag{}}, | ||
{name: `single`, input: "a", output: &[]pveSDK.Tag{"a"}}, | ||
{name: `multiple ,`, input: "b,a,c", output: &[]pveSDK.Tag{"b", "a", "c"}}, | ||
{name: `multiple ;`, input: "b;a;c", output: &[]pveSDK.Tag{"b", "a", "c"}}, | ||
{name: `multiple mixed`, input: "b,a;c,d;e", output: &[]pveSDK.Tag{"b", "a", "c", "d", "e"}}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
require.Equal(t, test.output, Split(test.input)) | ||
}) | ||
} | ||
} | ||
|
||
func Test_String(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input *[]pveSDK.Tag | ||
output string | ||
}{ | ||
{name: `nil`}, | ||
{name: `empty`, input: &[]pveSDK.Tag{}}, | ||
{name: `single`, input: &[]pveSDK.Tag{"a"}, output: "a"}, | ||
{name: `multiple`, input: &[]pveSDK.Tag{"b", "a", "c"}, output: "b;a;c"}, | ||
} | ||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
require.Equal(t, test.output, String(test.input)) | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.