Debian Codegraph @

get_test.go

raw symbols SCIP
1 // Copyright (c) Bartłomiej Płotka @bwplotka
2 // Licensed under the Apache License 2.0.
3
4 package mainscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo`/
5
6 import (
7 "testingscip-go gomod github.com/golang/go/src go1.24.9 testing/"
8
9 "github.com/efficientgo/core/errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/"
10 "github.com/efficientgo/core/testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/"
11 )
12
13 func TestParseTargetscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo`/TestParseTarget().(t *testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.Tscip-go gomod github.com/golang/go/src go1.24.9 testing/T#) {
14 for _, tcase := range []struct {
15 target string
16
17 expectedName string
18 expectedPkgPath string
19 expectedVersions []string
20 expectedErr error
21 }{
22 {
23 target: "",
24 expectedErr: errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/.Newscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/New().("target is empty, this should be filtered earlier"),
25 },
26 {
27 target: "tool",
28 expectedName: "tool",
29 expectedVersions: []string{""},
30 },
31 {
32 target: "github.com/bwplotka/bingo",
33 expectedName: "bingo", expectedPkgPath: "github.com/bwplotka/bingo",
34 expectedVersions: []string{""},
35 },
36 {
37 target: "sigs.k8s.io/kustomize/kustomize",
38 expectedName: "kustomize", expectedPkgPath: "sigs.k8s.io/kustomize/kustomize",
39 expectedVersions: []string{""},
40 },
41 {
42 target: "sigs.k8s.io/kustomize/kustomize/v3",
43 expectedName: "kustomize", expectedPkgPath: "sigs.k8s.io/kustomize/kustomize/v3",
44 expectedVersions: []string{""},
45 },
46 {
47 target: "github.com/bwplotka/bingo/v21314213532",
48 expectedName: "bingo", expectedPkgPath: "github.com/bwplotka/bingo/v21314213532",
49 expectedVersions: []string{""},
50 },
51 {
52 target: "tool@version1",
53 expectedName: "tool", expectedVersions: []string{"version1"},
54 },
55 {
56 target: "tool@version1123,version3,version1241",
57 expectedName: "tool", expectedVersions: []string{"version1123", "version3", "version1241"},
58 },
59 {
60 target: "tool@none",
61 expectedName: "tool", expectedVersions: []string{"none"},
62 },
63 {
64 target: "tool@version1123,version13,version1123",
65 expectedErr: errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/.Newscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/New().("version duplicates are not allowed, got: [version1123 version13 version1123]"),
66 },
67 {
68 target: "tool@version1123,version13,none",
69 expectedErr: errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/.Newscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/New().("none is not allowed when there are more than one specified Version, got: [version1123 version13 none]"),
70 },
71 {
72 target: "github.com/bwplotka/bingo/[email protected],bb92924b84d060515f8eb35f428a8fd816c1d938,version1241",
73 expectedName: "bingo", expectedPkgPath: "github.com/bwplotka/bingo/v2", expectedVersions: []string{"v0.2.5-rc.1214", "bb92924b84d060515f8eb35f428a8fd816c1d938", "version1241"},
74 },
75 } {
76 t.Runscip-go gomod github.com/golang/go/src go1.24.9 testing/T#Run().("", func(t *testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.Tscip-go gomod github.com/golang/go/src go1.24.9 testing/T#) {
77 n, p, v, err := parseTargetscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo`/parseTarget().(tcase.target)
78 if tcase.expectedErr != nil {
79 testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.NotOkscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/NotOk().(t, err)
80 testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, tcase.expectedErr.Error(), err.Error())
81 return
82 }
83
84 testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err)
85 testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, tcase.expectedName, n)
86 testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, tcase.expectedPkgPath, p)
87 testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, tcase.expectedVersions, v)
88 })
89 }
90
91 }