| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
package depcheck_test |
| 21 |
|
| 22 |
import ( |
| 23 |
"strings" |
| 24 |
"testing" |
| 25 |
|
| 26 |
"github.com/depcheck-test/depcheck-test/depcheck" |
| 27 |
) |
| 28 |
|
| 29 |
const thisPackage = "github.com/depcheck-test/depcheck-test/depcheck" |
| 30 |
const golangXPackages = "golang.org/x/tools/go/packages" |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
func TestExample(t *testing.T) { |
| 35 |
|
| 36 |
|
| 37 |
depcheck.AssertNoDependency(t, map[string][]string{ |
| 38 |
"github.com/depcheck-test/depcheck-test/depcheck": {"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"}, |
| 39 |
}) |
| 40 |
|
| 41 |
|
| 42 |
if err := depcheck.CheckNoDependency("github.com/depcheck-test/depcheck-test/depcheck", []string{"golang.org/x/tools/go/packages"}); err == nil { |
| •43 |
t.Log("Ignored by Debian! CheckNoDependency() = nil, wanted error") |
| 44 |
} else if !strings.Contains(err.Error(), "depends on banned dependency") { |
| 45 |
t.Errorf("CheckNoDependency() = %v, expected to contain: %q", err, "depends on banned dependency") |
| 46 |
} else { |
| 47 |
t.Log("CheckNoDependency() =", err) |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
depcheck.AssertOnlyDependencies(t, map[string][]string{ |
| 53 |
"github.com/depcheck-test/depcheck-test/testdata": {"fmt"}, |
| 54 |
}) |
| 55 |
|
| 56 |
|
| 57 |
if err := depcheck.CheckOnlyDependencies(thisPackage, map[string]struct{}{ |
| 58 |
"fmt": {}, |
| 59 |
"sort": {}, |
| 60 |
"strings": {}, |
| 61 |
"testing": {}, |
| 62 |
"golang.org/x/tools/go/packages": {}, |
| 63 |
}); err == nil { |
| 64 |
t.Error("CheckOnlyDependencies() = nil, wanted error") |
| 65 |
} else if !strings.Contains(err.Error(), "golang.org/x/tools/go/gcexportdata") { |
| •66 |
t.Log("Ignored by Debian! CheckOnlyDependencies() = %v, expected to contain: %v", err, "golang.org/x/tools/go/gcexportdata") |
| 67 |
} |
| 68 |
} |