-
Notifications
You must be signed in to change notification settings - Fork 6
/
initialize_test.go
52 lines (41 loc) · 1.59 KB
/
initialize_test.go
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
49
50
51
52
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package alzlib
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFetchLibraryByGetterString(t *testing.T) {
ctx := context.Background()
dstDir := "test-library"
defer os.RemoveAll(filepath.Join(".alzlib", dstDir))
fs, err := FetchLibraryByGetterString(ctx, "./testdata/simple", dstDir)
assert.NoError(t, err)
assert.NotNil(t, fs)
}
func TestFetchLibraryWithDependencies(t *testing.T) {
ctx := context.Background()
require.NoError(t, os.RemoveAll(".alzlib"))
defer os.RemoveAll(".alzlib") // nolint: errcheck
libs, err := NewCustomLibraryReference("./testdata/dependent-libs/lib1").FetchWithDependencies(ctx)
assert.NoError(t, err)
assert.Len(t, libs, 2)
}
func TestFetchLibraryWithDependencies_MissingCustomDependency(t *testing.T) {
ctx := context.Background()
require.NoError(t, os.RemoveAll(".alzlib"))
defer os.RemoveAll(".alzlib") // nolint: errcheck
_, err := NewCustomLibraryReference("./testdata/dependent-libs/missing-dep-custom").FetchWithDependencies(ctx)
assert.ErrorContains(t, err, "could not fetch library member")
}
func TestFetchLibraryWithDependencies_MissingLibraryDependency(t *testing.T) {
ctx := context.Background()
require.NoError(t, os.RemoveAll(".alzlib"))
defer os.RemoveAll(".alzlib") // nolint: errcheck
_, err := NewCustomLibraryReference("./testdata/dependent-libs/missing-dep-library").FetchWithDependencies(ctx)
assert.ErrorContains(t, err, "could not fetch library member")
}