text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
func TestRangesEqual(t *testing.T) {
for _, test := range []struct {
rs Ranges
bs Ranges
want bool
}{
{
rs: Ranges(nil),
bs: Ranges(nil),
want: true,
},
{
rs: Ranges{},
bs: Ranges(nil),
want: true,
},
{
rs: Ranges(nil),
bs: Ranges{},
want: true,
},
{
rs: Ranges{},
bs: Ranges{},
want: true,
},
{
rs: Ranges{
{Pos: 0, Size: 1},
},
bs: Ranges{},
want: false,
},
{
rs: Ranges{
{Pos: 0, Size: 1},
},
bs: Ranges{
{Pos: 0, Size: 1},
},
want: true,
},
{
rs: Ranges{
{Pos: 0, Size: 1},
{Pos: 10, Size: 9},
{Pos: 20, Size: 21},
},
bs: Ranges{
{Pos: 0, Size: 1},
{Pos: 10, Size: 9},
{Pos: 20, Size: 22},
},
want: false,
},
{
rs: Ranges{
{Pos: 0, Size: 1},
{Pos: 10, Size: 9},
{Pos: 20, Size: 21},
},
bs: Ranges{
{Pos: 0, Size: 1},
{Pos: 10, Size: 9},
{Pos: 20, Size: 21},
},
want: true,
},
} {
got := test.rs.Equal(test.bs)
what := fmt.Sprintf("test rs=%v, bs=%v", test.rs, test.bs)
assert.Equal(t, test.want, got, what)
checkRanges(t, test.bs, what)
checkRanges(t, test.rs, what)
}
} | explode_data.jsonl/2645 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 700
} | [
2830,
3393,
74902,
2993,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
41231,
256,
431,
5520,
198,
197,
93801,
256,
431,
5520,
198,
197,
50780,
1807,
198,
197,
59403,
197,
197,
515,
298,
41231,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNodesFromProfile(t *testing.T) {
region := "fra1"
p := &profile.Profile{
Provider: clouds.DigitalOcean,
Region: region,
MasterProfiles: []profile.NodeProfile{
{
"image": "ubuntu-16-04-x64",
"size": "s-1vcpu-2gb",
},
},
NodesProfiles: []profile.NodeProfile{
{
"image": "ubuntu-16-04-x64",
"size": "s-2vcpu-4gb",
},
{
"image": "ubuntu-16-04-x64",
"size": "s-2vcpu-4gb",
},
},
}
cfg := &steps.Config{
ClusterName: "test",
}
masterTasks, nodeTasks := []*workflows.Task{{ID: "1234"}}, []*workflows.Task{{ID: "5678"}, {ID: "4321"}}
masters, nodes := nodesFromProfile(cfg.ClusterName, masterTasks, nodeTasks, p)
if len(masters) != len(p.MasterProfiles) {
t.Errorf("Wrong master node count expected %d actual %d",
len(p.MasterProfiles), len(masters))
}
if len(nodes) != len(p.NodesProfiles) {
t.Errorf("Wrong node count expected %d actual %d",
len(p.NodesProfiles), len(nodes))
}
} | explode_data.jsonl/66059 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 440
} | [
2830,
3393,
12288,
3830,
8526,
1155,
353,
8840,
836,
8,
341,
197,
3943,
1669,
330,
42289,
16,
1837,
3223,
1669,
609,
5365,
59872,
515,
197,
197,
5179,
25,
29514,
909,
10233,
96183,
345,
197,
197,
14091,
25,
256,
5537,
345,
197,
9209,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestControlAddresses(t *testing.T) {
actor := newHarness(t, 0)
builder := builderForHarness(actor)
t.Run("get addresses", func(t *testing.T) {
rt := builder.Build(t)
actor.constructAndVerify(rt)
o, w := actor.controlAddresses(rt)
assert.Equal(t, actor.owner, o)
assert.Equal(t, actor.worker, w)
})
// TODO: test changing worker (with delay), changing peer id
// https://github.com/filecoin-project/specs-actors/issues/479
} | explode_data.jsonl/43141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
3273,
52290,
1155,
353,
8840,
836,
8,
341,
93410,
1669,
501,
74248,
1155,
11,
220,
15,
340,
44546,
1669,
7363,
2461,
74248,
65451,
692,
3244,
16708,
445,
455,
14230,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
55060,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
// This test ensures that when replying to a root post made by a user who has since left the channel, the reply
// post completes successfully. This is a regression test for PLT-6523.
th := Setup(t).InitBasic()
defer th.TearDown()
channel := th.BasicChannel
userInChannel := th.BasicUser2
userNotInChannel := th.BasicUser
rootPost := th.BasicPost
_, err := th.App.AddUserToChannel(userInChannel, channel, false)
require.Nil(t, err)
err = th.App.RemoveUserFromChannel(th.Context, userNotInChannel.Id, "", channel)
require.Nil(t, err)
replyPost := model.Post{
Message: "asd",
ChannelId: channel.Id,
RootId: rootPost.Id,
ParentId: rootPost.Id,
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
UserId: userInChannel.Id,
CreateAt: 0,
}
_, err = th.App.CreatePostAsUser(th.Context, &replyPost, "", true)
require.Nil(t, err)
} | explode_data.jsonl/26428 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 375
} | [
2830,
3393,
4133,
20841,
1249,
4133,
9064,
8439,
95077,
5415,
9629,
1155,
353,
8840,
836,
8,
341,
197,
322,
1096,
1273,
25351,
429,
979,
2064,
6711,
311,
264,
3704,
1736,
1865,
553,
264,
1196,
879,
702,
2474,
2115,
279,
5496,
11,
279,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGlobKey(t *testing.T) {
t.Parallel()
app := Server{}
app.Silence = true
app.Start("localhost:0")
defer app.Close(os.Interrupt)
u := url.URL{Scheme: "ws", Host: app.Address, Path: "/ws/test/*"}
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
app.Console.Err(err)
require.NotNil(t, c)
require.NoError(t, err)
c.Close()
} | explode_data.jsonl/67700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
38,
1684,
1592,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
28236,
1669,
8422,
16094,
28236,
808,
321,
763,
284,
830,
198,
28236,
12101,
445,
8301,
25,
15,
1138,
16867,
906,
10421,
9638,
7371,
10579,
340,
10676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNone(t *testing.T) {
ctx := framework.NewTestCtx(t)
defer ctx.Cleanup()
namespace, err := ctx.GetNamespace()
if err != nil {
t.Fatalf("could not get namespace: %v", err)
}
err = framework.AddToFrameworkScheme(apis.AddToScheme, &gitopsv1alpha1.GitOpsConfigList{})
if err != nil {
t.Fatal(err)
}
// Check if the CRD has been created
err = framework.Global.Client.Get(
goctx.TODO(),
types.NamespacedName{Name: "gitops-simple", Namespace: namespace},
&gitopsv1alpha1.GitOpsConfig{})
if err == nil {
t.Error("expected error, got nil")
}
gitops := &v1alpha1.GitOpsConfig{
TypeMeta: metav1.TypeMeta{
Kind: "GitOpsConfig",
APIVersion: "eunomia.kohls.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "gitops-none",
Namespace: namespace,
},
Spec: gitopsv1alpha1.GitOpsConfigSpec{
TemplateSource: gitopsv1alpha1.GitConfig{
URI: "https://",
Ref: "master",
ContextDir: "/",
},
ParameterSource: gitopsv1alpha1.GitConfig{
URI: "https://",
Ref: "master",
ContextDir: "/",
},
Triggers: []gitopsv1alpha1.GitOpsTrigger{
{Type: "Change"},
},
ResourceDeletionMode: "None",
ResourceHandlingMode: "None",
ServiceAccountRef: "eunomia-operator",
},
}
err = framework.Global.Client.Create(
goctx.TODO(),
gitops,
&framework.CleanupOptions{TestContext: ctx, Timeout: timeout, RetryInterval: retryInterval})
if err != nil {
t.Fatal(err)
}
// Check if the CRD has been created
err = framework.Global.Client.Get(
goctx.TODO(),
types.NamespacedName{Name: "gitops-none", Namespace: namespace},
&gitopsv1alpha1.GitOpsConfig{})
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/726 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 760
} | [
2830,
3393,
4064,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
12626,
7121,
2271,
23684,
1155,
340,
16867,
5635,
727,
60639,
2822,
56623,
11,
1848,
1669,
5635,
2234,
22699,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
28077,
537... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestTraceKVStoreGet(t *testing.T) {
testCases := []struct {
key []byte
expectedValue []byte
expectedOut string
}{
{
key: []byte{},
expectedValue: nil,
expectedOut: "{\"operation\":\"read\",\"key\":\"\",\"value\":\"\",\"metadata\":{\"blockHeight\":64}}\n",
},
{
key: kvPairs[0].Key,
expectedValue: kvPairs[0].Value,
expectedOut: "{\"operation\":\"read\",\"key\":\"a2V5MDAwMDAwMDE=\",\"value\":\"dmFsdWUwMDAwMDAwMQ==\",\"metadata\":{\"blockHeight\":64}}\n",
},
{
key: []byte("does-not-exist"),
expectedValue: nil,
expectedOut: "{\"operation\":\"read\",\"key\":\"ZG9lcy1ub3QtZXhpc3Q=\",\"value\":\"\",\"metadata\":{\"blockHeight\":64}}\n",
},
}
for _, tc := range testCases {
var buf bytes.Buffer
store := newTraceKVStore(&buf)
buf.Reset()
value := store.Get(tc.key)
require.Equal(t, tc.expectedValue, value)
require.Equal(t, tc.expectedOut, buf.String())
}
} | explode_data.jsonl/52003 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 444
} | [
2830,
3393,
6550,
82707,
6093,
1949,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
23634,
1843,
3056,
3782,
198,
197,
42400,
1130,
3056,
3782,
198,
197,
42400,
2662,
256,
914,
198,
197,
59403,
197,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPruneInitContainers(t *testing.T) {
fakeRuntime, _, m, err := createTestRuntimeManager()
assert.NoError(t, err)
init1 := makeTestContainer("init1", "busybox")
init2 := makeTestContainer("init2", "busybox")
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "12345678",
Name: "foo",
Namespace: "new",
},
Spec: v1.PodSpec{
InitContainers: []v1.Container{init1, init2},
},
}
templates := []containerTemplate{
{pod: pod, container: &init1, attempt: 3, createdAt: 3, state: runtimeapi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init1, attempt: 2, createdAt: 2, state: runtimeapi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init2, attempt: 1, createdAt: 1, state: runtimeapi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init1, attempt: 1, createdAt: 1, state: runtimeapi.ContainerState_CONTAINER_UNKNOWN},
{pod: pod, container: &init2, attempt: 0, createdAt: 0, state: runtimeapi.ContainerState_CONTAINER_EXITED},
{pod: pod, container: &init1, attempt: 0, createdAt: 0, state: runtimeapi.ContainerState_CONTAINER_EXITED},
}
fakes := makeFakeContainers(t, m, templates)
fakeRuntime.SetFakeContainers(fakes)
podStatus, err := m.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
assert.NoError(t, err)
m.pruneInitContainersBeforeStart(pod, podStatus)
expectedContainers := sets.NewString(fakes[0].Id, fakes[2].Id)
if actual, ok := verifyFakeContainerList(fakeRuntime, expectedContainers); !ok {
t.Errorf("expected %v, got %v", expectedContainers, actual)
}
} | explode_data.jsonl/13376 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 579
} | [
2830,
3393,
3533,
2886,
3803,
74632,
1155,
353,
8840,
836,
8,
341,
1166,
726,
15123,
11,
8358,
296,
11,
1848,
1669,
1855,
2271,
15123,
2043,
741,
6948,
35699,
1155,
11,
1848,
692,
28248,
16,
1669,
1281,
2271,
4502,
445,
2327,
16,
497,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAlbums(t *testing.T) {
Convey("get Albums", t, func() {
_, _, _, err := dao.Albums(ctx(), 27515258, 1, 20)
err = nil
So(err, ShouldBeNil)
})
} | explode_data.jsonl/51613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
32378,
82,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
455,
86723,
497,
259,
11,
2915,
368,
341,
197,
197,
6878,
8358,
8358,
1848,
1669,
24775,
9636,
5377,
82,
7502,
1507,
220,
17,
22,
20,
16,
20,
17,
20,
23,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPulumiToTerraformName(t *testing.T) {
assert.Equal(t, "", PulumiToTerraformName("", nil, nil))
assert.Equal(t, "test", PulumiToTerraformName("test", nil, nil))
assert.Equal(t, "test_name", PulumiToTerraformName("testName", nil, nil))
assert.Equal(t, "test_name_pascal", PulumiToTerraformName("TestNamePascal", nil, nil))
assert.Equal(t, "test_name", PulumiToTerraformName("test_name", nil, nil))
assert.Equal(t, "test_name_", PulumiToTerraformName("testName_", nil, nil))
assert.Equal(t, "t_e_s_t_n_a_m_e", PulumiToTerraformName("TESTNAME", nil, nil))
} | explode_data.jsonl/36104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
47,
65482,
1249,
51,
13886,
627,
675,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
7342,
393,
65482,
1249,
51,
13886,
627,
675,
19814,
2092,
11,
2092,
1171,
6948,
12808,
1155,
11,
330,
1944,
497,
393,
65482,
1249,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPostgresqlSqlScript(t *testing.T) {
q := query{{
Script: "testdata/test.sql",
Version: 901,
Withdbname: false,
Tagvalue: "",
}}
p := &Postgresql{
Log: testutil.Logger{},
Service: postgresql.Service{
Address: fmt.Sprintf(
"host=%s user=postgres sslmode=disable",
testutil.GetLocalHost(),
),
IsPgBouncer: false,
},
Databases: []string{"postgres"},
Query: q,
}
var acc testutil.Accumulator
p.Start(&acc)
p.Init()
require.NoError(t, acc.GatherError(p.Gather))
} | explode_data.jsonl/20138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
4133,
81624,
8269,
5910,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
3239,
90,
515,
197,
197,
5910,
25,
257,
330,
92425,
12697,
10045,
756,
197,
77847,
25,
262,
220,
24,
15,
16,
345,
197,
197,
2354,
35265,
25,
895,
345,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMultiReturnWithStringArray(t *testing.T) {
const definition = `[{"name" : "multi", "outputs": [{"name": "","type": "uint256[3]"},{"name": "","type": "address"},{"name": "","type": "string[2]"},{"name": "","type": "bool"}]}]`
abi, err := JSON(strings.NewReader(definition))
if err != nil {
t.Fatal(err)
}
buff := new(bytes.Buffer)
buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000005c1b78ea0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000001a055690d9db80000000000000000000000000000ab1257528b3782fb40d7ed5f72e624b744dffb2f00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000008457468657265756d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001048656c6c6f2c20457468657265756d2100000000000000000000000000000000"))
temp, _ := big.NewInt(0).SetString("30000000000000000000", 10)
ret1, ret1Exp := new([3]*big.Int), [3]*big.Int{big.NewInt(1545304298), big.NewInt(6), temp}
ret2, ret2Exp := new(common.Address), common.HexToAddress("ab1257528b3782fb40d7ed5f72e624b744dffb2f")
ret3, ret3Exp := new([2]string), [2]string{"Ethereum", "Hello, Ethereum!"}
ret4, ret4Exp := new(bool), false
if err := abi.Unpack(&[]interface{}{ret1, ret2, ret3, ret4}, "multi", buff.Bytes()); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(*ret1, ret1Exp) {
t.Error("big.Int array result", *ret1, "!= Expected", ret1Exp)
}
if !reflect.DeepEqual(*ret2, ret2Exp) {
t.Error("address result", *ret2, "!= Expected", ret2Exp)
}
if !reflect.DeepEqual(*ret3, ret3Exp) {
t.Error("string array result", *ret3, "!= Expected", ret3Exp)
}
if !reflect.DeepEqual(*ret4, ret4Exp) {
t.Error("bool result", *ret4, "!= Expected", ret4Exp)
}
} | explode_data.jsonl/22756 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 657
} | [
2830,
3393,
20358,
5598,
52342,
1857,
1155,
353,
8840,
836,
8,
341,
4777,
7271,
284,
77644,
4913,
606,
1,
549,
330,
26268,
497,
330,
41006,
788,
61753,
606,
788,
330,
2198,
1313,
788,
330,
2496,
17,
20,
21,
58,
18,
60,
36509,
606,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestDrainWorkQueue(t *testing.T) {
size := 2
work := make(chan *v1.Node, size)
node := &v1.Node{}
work <- node
close(work)
drainWorkQueue(work)
_, ok := <-work
assert.False(t, ok)
} | explode_data.jsonl/62011 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
8847,
466,
6776,
7554,
1155,
353,
8840,
836,
8,
341,
13832,
1669,
220,
17,
198,
97038,
1669,
1281,
35190,
353,
85,
16,
21714,
11,
1379,
340,
20831,
1669,
609,
85,
16,
21714,
16094,
97038,
9119,
2436,
198,
27873,
31470,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestFillNameAndAge(t *testing.T) {
settings := map[string]interface{}{"Name": "Mike", "Age": 40}
e := Employee{}
if err := fillBySettings(&e, settings); err != nil {
t.Fatal(err)
}
t.Log(e)
c := new(Customer)
if err := fillBySettings(c, settings); err != nil {
t.Fatal(err)
}
t.Log(*c)
} | explode_data.jsonl/34895 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
14449,
675,
3036,
16749,
1155,
353,
8840,
836,
8,
341,
62930,
1669,
2415,
14032,
31344,
6257,
4913,
675,
788,
330,
34441,
497,
330,
16749,
788,
220,
19,
15,
532,
7727,
1669,
16850,
16094,
743,
1848,
1669,
5155,
1359,
6086,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDataSourceConfigure(t *testing.T) {
appendMockSource()
tests := []struct {
TestName string
RawBytes []byte
ExpectedError string
}{
{
TestName: "basic_valid_config",
RawBytes: []byte(`
mode: cat
labels:
test: foobar
log_level: info
source: mock
toto: test_value1
`),
},
{
TestName: "basic_debug_config",
RawBytes: []byte(`
mode: cat
labels:
test: foobar
log_level: debug
source: mock
toto: test_value1
`),
},
{
TestName: "basic_tailmode_config",
RawBytes: []byte(`
mode: tail
labels:
test: foobar
log_level: debug
source: mock
toto: test_value1
`),
},
{
TestName: "bad_mode_config",
RawBytes: []byte(`
mode: ratata
labels:
test: foobar
log_level: debug
source: mock
toto: test_value1
`),
ExpectedError: "failed to configure datasource mock: mode ratata is not supported",
},
{
TestName: "bad_type_config",
RawBytes: []byte(`
mode: cat
labels:
test: foobar
log_level: debug
source: tutu
`),
ExpectedError: "cannot find source tutu",
},
{
TestName: "mismatch_config",
RawBytes: []byte(`
mode: cat
labels:
test: foobar
log_level: debug
source: mock
wowo: ajsajasjas
`),
ExpectedError: "field wowo not found in type acquisition.MockSource",
},
{
TestName: "cant_run_error",
RawBytes: []byte(`
mode: cat
labels:
test: foobar
log_level: debug
source: mock_cant_run
wowo: ajsajasjas
`),
ExpectedError: "datasource mock_cant_run cannot be run: can't run bro",
},
}
for _, test := range tests {
common := configuration.DataSourceCommonCfg{}
yaml.Unmarshal(test.RawBytes, &common)
ds, err := DataSourceConfigure(common)
if test.ExpectedError != "" {
if err == nil {
t.Fatalf("expected error %s, got none", test.ExpectedError)
}
if !strings.Contains(err.Error(), test.ExpectedError) {
t.Fatalf("%s : expected error '%s' in '%s'", test.TestName, test.ExpectedError, err.Error())
}
continue
}
if err != nil {
t.Fatalf("%s : unexpected error '%s'", test.TestName, err)
}
switch test.TestName {
case "basic_valid_config":
mock := (*ds).Dump().(*MockSource)
assert.Equal(t, mock.Toto, "test_value1")
assert.Equal(t, mock.Mode, "cat")
assert.Equal(t, mock.logger.Logger.Level, log.InfoLevel)
assert.DeepEqual(t, mock.Labels, map[string]string{"test": "foobar"})
case "basic_debug_config":
mock := (*ds).Dump().(*MockSource)
assert.Equal(t, mock.Toto, "test_value1")
assert.Equal(t, mock.Mode, "cat")
assert.Equal(t, mock.logger.Logger.Level, log.DebugLevel)
assert.DeepEqual(t, mock.Labels, map[string]string{"test": "foobar"})
case "basic_tailmode_config":
mock := (*ds).Dump().(*MockSource)
assert.Equal(t, mock.Toto, "test_value1")
assert.Equal(t, mock.Mode, "tail")
assert.Equal(t, mock.logger.Logger.Level, log.DebugLevel)
assert.DeepEqual(t, mock.Labels, map[string]string{"test": "foobar"})
}
}
} | explode_data.jsonl/29479 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1246
} | [
2830,
3393,
17173,
28560,
1155,
353,
8840,
836,
8,
341,
82560,
11571,
3608,
741,
78216,
1669,
3056,
1235,
341,
197,
73866,
675,
414,
914,
198,
197,
11143,
672,
7078,
414,
3056,
3782,
198,
197,
197,
18896,
1454,
914,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestMetric_Int64DataPoints(t *testing.T) {
ms := NewMetric()
ms.InitEmpty()
assert.EqualValues(t, NewInt64DataPointSlice(), ms.Int64DataPoints())
fillTestInt64DataPointSlice(ms.Int64DataPoints())
testValInt64DataPoints := generateTestInt64DataPointSlice()
assert.EqualValues(t, testValInt64DataPoints, ms.Int64DataPoints())
} | explode_data.jsonl/19512 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
54310,
32054,
21,
19,
1043,
11411,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
54310,
741,
47691,
26849,
3522,
741,
6948,
12808,
6227,
1155,
11,
1532,
1072,
21,
19,
1043,
2609,
33236,
1507,
9829,
7371,
21,
19,
1043,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDefaultErrorHandlerWritesExistingHTTPErrorIfNotAlreadyWritten(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mr := NewMockResponseWriter(ctrl)
mr.EXPECT().Len().Return(0)
mc := NewMockContext(ctrl)
mc.EXPECT().Response().Return(mr)
status := http.StatusBadRequest
err := NewHTTPErrorStatus(status)
mc.EXPECT().WriteJSON(gomock.Any(), gomock.Any()).Return(nil).Do(func(st int, er error) {
assert.Equal(t, status, st)
assert.Equal(t, err, er)
})
defaultErrorHandler(mc, err)
} | explode_data.jsonl/18941 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
3675,
66673,
93638,
53067,
9230,
1454,
2679,
2623,
38370,
35624,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
741,
2109,
81,
1669,
1532,
11571,
2582,
6492,
62100,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWebhookInput_ToApplicationWebhook(t *testing.T) {
// given
applicationID := "foo"
id := "bar"
tenant := "baz"
template := `{}`
webhookMode := model.WebhookModeSync
webhookURL := "foourl"
testCases := []struct {
Name string
Input *model.WebhookInput
Expected *model.Webhook
}{
{
Name: "All properties given",
Input: &model.WebhookInput{
Type: model.WebhookTypeConfigurationChanged,
URL: &webhookURL,
Auth: &model.AuthInput{
AdditionalHeaders: map[string][]string{
"foo": {"foo", "bar"},
"bar": {"bar", "foo"},
},
},
Mode: &webhookMode,
URLTemplate: &template,
InputTemplate: &template,
HeaderTemplate: &template,
OutputTemplate: &template,
},
Expected: &model.Webhook{
ApplicationID: &applicationID,
ID: id,
TenantID: str.Ptr(tenant),
Type: model.WebhookTypeConfigurationChanged,
URL: &webhookURL,
Auth: &model.Auth{
AdditionalHeaders: map[string][]string{
"foo": {"foo", "bar"},
"bar": {"bar", "foo"},
},
},
Mode: &webhookMode,
URLTemplate: &template,
InputTemplate: &template,
HeaderTemplate: &template,
OutputTemplate: &template,
},
},
{
Name: "Empty",
Input: &model.WebhookInput{},
Expected: &model.Webhook{
ApplicationID: &applicationID,
ID: id,
TenantID: str.Ptr(tenant),
},
},
{
Name: "Nil",
Input: nil,
Expected: nil,
},
}
for i, testCase := range testCases {
t.Run(fmt.Sprintf("%d: %s", i, testCase.Name), func(t *testing.T) {
// when
result := testCase.Input.ToApplicationWebhook(id, str.Ptr(tenant), applicationID)
// then
assert.Equal(t, testCase.Expected, result)
})
}
} | explode_data.jsonl/24848 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 856
} | [
2830,
3393,
5981,
20873,
2505,
38346,
4988,
5981,
20873,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
197,
5132,
915,
1669,
330,
7975,
698,
15710,
1669,
330,
2257,
698,
197,
43919,
1669,
330,
42573,
698,
22832,
1669,
1565,
6257,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_generateIPSetName(t *testing.T) {
g := NewWithT(t)
postfix := "alongpostfix"
t.Run("name with postfix", func(t *testing.T) {
chaosName := "test"
networkChaos := &v1alpha1.NetworkChaos{
ObjectMeta: metav1.ObjectMeta{
Name: chaosName,
},
}
name := GenerateIPSetName(networkChaos, postfix)
g.Expect(name).Should(Equal(chaosName + "_" + postfix))
})
t.Run("length equal 27", func(t *testing.T) {
networkChaos := &v1alpha1.NetworkChaos{
ObjectMeta: metav1.ObjectMeta{
Name: "test-metav1object",
},
}
name := GenerateIPSetName(networkChaos, postfix)
g.Expect(len(name)).Should(Equal(27))
})
} | explode_data.jsonl/15085 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
48851,
3298,
69778,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
340,
51172,
5743,
1669,
330,
38293,
2203,
5743,
1837,
3244,
16708,
445,
606,
448,
68122,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadToken(t *testing.T) {
f := writeTestTokenFile(t, "testloadtoken", MockTokenJSON)
defer os.Remove(f.Name())
expectedToken := TestToken
actualToken, err := LoadToken(f.Name())
if err != nil {
t.Fatalf("azure: unexpected error loading token from file: %v", err)
}
if *actualToken != expectedToken {
t.Fatalf("azure: failed to decode properly expected(%v) actual(%v)", expectedToken, *actualToken)
}
// test that LoadToken closes the file properly
err = SaveToken(f.Name(), 0600, *actualToken)
if err != nil {
t.Fatalf("azure: could not save token after LoadToken: %v", err)
}
} | explode_data.jsonl/14991 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
5879,
3323,
1155,
353,
8840,
836,
8,
972,
1166,
1669,
3270,
2271,
3323,
1703,
1155,
11,
330,
1944,
1078,
5839,
497,
14563,
3323,
5370,
1218,
16867,
2643,
13270,
955,
2967,
79189,
42400,
3323,
1669,
3393,
3323,
319,
88814,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestMaxBlockGasLimits(t *testing.T) {
gasGranted := uint64(10)
anteOpt := func(bapp *BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasGranted))
defer func() {
if r := recover(); r != nil {
switch rType := r.(type) {
case sdk.ErrorOutOfGas:
err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
default:
panic(r)
}
}
}()
count := tx.(*txTest).Counter
newCtx.GasMeter().ConsumeGas(uint64(count), "counter-ante")
return
})
}
routerOpt := func(bapp *BaseApp) {
bapp.Router().AddRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
return &sdk.Result{}, nil
})
}
app := setupBaseApp(t, anteOpt, routerOpt)
app.InitChain(abci.RequestInitChain{
ConsensusParams: &abci.ConsensusParams{
Block: &abci.BlockParams{
MaxGas: 100,
},
},
})
testCases := []struct {
tx *txTest
numDelivers int
gasUsedPerDeliver uint64
fail bool
failAfterDeliver int
}{
{newTxCounter(0, 0), 0, 0, false, 0},
{newTxCounter(9, 1), 2, 10, false, 0},
{newTxCounter(10, 0), 3, 10, false, 0},
{newTxCounter(10, 0), 10, 10, false, 0},
{newTxCounter(2, 7), 11, 9, false, 0},
{newTxCounter(10, 0), 10, 10, false, 0}, // hit the limit but pass
{newTxCounter(10, 0), 11, 10, true, 10},
{newTxCounter(10, 0), 15, 10, true, 10},
{newTxCounter(9, 0), 12, 9, true, 11}, // fly past the limit
}
for i, tc := range testCases {
tx := tc.tx
// reset the block gas
header := abci.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
// execute the transaction multiple times
for j := 0; j < tc.numDelivers; j++ {
_, result, err := app.Deliver(tx)
ctx := app.getState(runTxModeDeliver).ctx
// check for failed transactions
if tc.fail && (j+1) > tc.failAfterDeliver {
require.Error(t, err, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err))
require.Nil(t, result, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err))
space, code, _ := sdkerrors.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err)
require.True(t, ctx.BlockGasMeter().IsOutOfGas())
} else {
// check gas used and wanted
blockGasUsed := ctx.BlockGasMeter().GasConsumed()
expBlockGasUsed := tc.gasUsedPerDeliver * uint64(j+1)
require.Equal(
t, expBlockGasUsed, blockGasUsed,
fmt.Sprintf("%d,%d: %v, %v, %v, %v", i, j, tc, expBlockGasUsed, blockGasUsed, result),
)
require.NotNil(t, result, fmt.Sprintf("tc #%d; currDeliver: %d, result: %v, err: %s", i, j, result, err))
require.False(t, ctx.BlockGasMeter().IsPastLimit())
}
}
}
} | explode_data.jsonl/67060 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1348
} | [
2830,
3393,
5974,
4713,
58728,
94588,
1155,
353,
8840,
836,
8,
341,
3174,
300,
55481,
1669,
2622,
21,
19,
7,
16,
15,
340,
197,
4942,
21367,
1669,
2915,
1883,
676,
353,
3978,
2164,
8,
341,
197,
2233,
676,
4202,
17117,
68,
3050,
18552... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDateTime(t *testing.T) {
t.Parallel()
t.Run("Binary", func(t *testing.T) {
t.Parallel()
testBinary(t, dateTimeTestCases, func() bsontype { return new(DateTime) })
})
t.Run("JSON", func(t *testing.T) {
t.Parallel()
testJSON(t, dateTimeTestCases, func() bsontype { return new(DateTime) })
})
} | explode_data.jsonl/21679 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
7689,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3244,
16708,
445,
21338,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
41288,
7957,
741,
197,
18185,
21338,
1155,
11,
34608,
2271,
37302,
11,
2915,
368,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConfigCache(t *testing.T) {
configFile, err := ioutil.TempFile("", "sysregistriesv2-test")
require.NoError(t, err)
defer os.Remove(configFile.Name())
defer configFile.Close()
err = ioutil.WriteFile(configFile.Name(), []byte(`
[[registry]]
location = "registry.com"
[[registry.mirror]]
location = "mirror-1.registry.com"
[[registry.mirror]]
location = "mirror-2.registry.com"
[[registry]]
location = "blocked.registry.com"
blocked = true
[[registry]]
location = "insecure.registry.com"
insecure = true
[[registry]]
location = "untrusted.registry.com"
insecure = true`), 0600)
require.NoError(t, err)
ctx := &types.SystemContext{SystemRegistriesConfPath: configFile.Name()}
InvalidateCache()
registries, err := GetRegistries(ctx)
assert.Nil(t, err)
assert.Equal(t, 4, len(registries))
// empty the config, but use the same SystemContext to show that the
// previously specified registries are in the cache
err = ioutil.WriteFile(configFile.Name(), []byte{}, 0600)
require.NoError(t, err)
registries, err = GetRegistries(ctx)
assert.Nil(t, err)
assert.Equal(t, 4, len(registries))
} | explode_data.jsonl/62234 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 407
} | [
2830,
3393,
2648,
8233,
1155,
353,
8840,
836,
8,
341,
25873,
1703,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
7791,
53287,
4019,
85,
17,
16839,
1138,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
13270,
8754,
1703,
2967,
2398,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVtctlAuthClient(t *testing.T) {
ts := vtctlclienttest.CreateTopoServer(t)
// Listen on a random port
listener, err := net.Listen("tcp", ":0")
if err != nil {
t.Fatalf("Cannot listen: %v", err)
}
port := listener.Addr().(*net.TCPAddr).Port
// Create a gRPC server and listen on the port
// add auth interceptors
var opts []grpc.ServerOption
opts = append(opts, grpc.StreamInterceptor(servenv.FakeAuthStreamInterceptor))
opts = append(opts, grpc.UnaryInterceptor(servenv.FakeAuthUnaryInterceptor))
server := grpc.NewServer(opts...)
vtctlservicepb.RegisterVtctlServer(server, grpcvtctlserver.NewVtctlServer(ts))
go server.Serve(listener)
authJSON := `{
"Username": "valid",
"Password": "valid"
}`
f, err := ioutil.TempFile("", "static_auth_creds.json")
if err != nil {
t.Fatal(err)
}
defer os.Remove(f.Name())
if _, err := io.WriteString(f, authJSON); err != nil {
t.Fatal(err)
}
if err := f.Close(); err != nil {
t.Fatal(err)
}
flag.Set("grpc_auth_static_client_creds", f.Name())
// Create a VtctlClient gRPC client to talk to the fake server
client, err := gRPCVtctlClientFactory(fmt.Sprintf("localhost:%v", port))
if err != nil {
t.Fatalf("Cannot create client: %v", err)
}
defer client.Close()
vtctlclienttest.TestSuite(t, ts, client)
} | explode_data.jsonl/31888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 534
} | [
2830,
3393,
53,
83,
12373,
5087,
2959,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
39105,
12373,
2972,
1944,
7251,
5366,
78,
5475,
1155,
692,
197,
322,
32149,
389,
264,
4194,
2635,
198,
14440,
798,
11,
1848,
1669,
4179,
68334,
445,
271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestSortedSetRemRangeByLex(t *testing.T) {
testRaw(t, func(c *client) {
c.Do("ZADD", "z",
"12", "zero kelvin",
"12", "minusfour",
"12", "one",
"12", "oneone",
"12", "two",
"12", "zwei",
"12", "three",
"12", "drei",
"12", "inf",
)
c.Do("ZRANGEBYLEX", "z", "-", "+")
c.Do("ZREMRANGEBYLEX", "z", "[o", "(t")
c.Do("ZRANGEBYLEX", "z", "-", "+")
c.Do("ZREMRANGEBYLEX", "z", "-", "+")
c.Do("ZRANGEBYLEX", "z", "-", "+")
// failure cases
c.Error("wrong number", "ZREMRANGEBYLEX")
c.Error("wrong number", "ZREMRANGEBYLEX", "key")
c.Error("wrong number", "ZREMRANGEBYLEX", "key", "[a")
c.Error("wrong number", "ZREMRANGEBYLEX", "key", "[a", "[b", "c")
c.Error("not valid string range", "ZREMRANGEBYLEX", "key", "!a", "[b")
c.Do("SET", "str", "I am a string")
c.Error("wrong kind", "ZREMRANGEBYLEX", "str", "[a", "[b")
})
} | explode_data.jsonl/23344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 440
} | [
2830,
3393,
51051,
1649,
6590,
6046,
1359,
47778,
1155,
353,
8840,
836,
8,
341,
18185,
20015,
1155,
11,
2915,
1337,
353,
2972,
8,
341,
197,
1444,
33596,
445,
57,
15665,
497,
330,
89,
756,
298,
197,
1,
16,
17,
497,
330,
14154,
48228,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadLibraryEx(t *testing.T) {
use, have, flags := runtime.LoadLibraryExStatus()
if use {
return // success.
}
if wantLoadLibraryEx() {
t.Fatalf("Expected LoadLibraryEx+flags to be available. (LoadLibraryEx=%v; flags=%v)",
have, flags)
}
t.Skipf("LoadLibraryEx not usable, but not expected. (LoadLibraryEx=%v; flags=%v)",
have, flags)
} | explode_data.jsonl/82621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
5879,
16915,
840,
1155,
353,
8840,
836,
8,
341,
41819,
11,
614,
11,
8042,
1669,
15592,
13969,
16915,
840,
2522,
741,
743,
990,
341,
197,
853,
442,
2393,
624,
197,
532,
743,
1366,
5879,
16915,
840,
368,
341,
197,
3244,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSupervisor(t *testing.T) {
var testSupervisors = []SupervisorTest{
SupervisorTest{
shouldFail: false,
proc: Supervisor{
Name: "supervisor-test-sleep",
BinPath: "/bin/sh",
RunDir: ".",
Args: []string{"-c", "sleep 1s"},
},
},
SupervisorTest{
shouldFail: false,
proc: Supervisor{
Name: "supervisor-test-fail",
BinPath: "/bin/sh",
RunDir: ".",
Args: []string{"-c", "false"},
},
},
SupervisorTest{
shouldFail: true,
proc: Supervisor{
Name: "supervisor-test-non-executable",
BinPath: "/tmp",
RunDir: ".",
},
},
SupervisorTest{
shouldFail: true,
proc: Supervisor{
Name: "supervisor-test-rundir-fail",
BinPath: "/tmp",
RunDir: "/bin/sh/foo/bar",
},
},
}
for _, s := range testSupervisors {
err := s.proc.Supervise()
if err != nil && !s.shouldFail {
t.Errorf("Failed to start %s: %v", s.proc.Name, err)
} else if err == nil && s.shouldFail {
t.Errorf("%s should fail but didn't", s.proc.Name)
}
err = s.proc.Stop()
if err != nil {
t.Errorf("Failed to stop %s: %v", s.proc.Name, err)
}
}
} | explode_data.jsonl/52871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 542
} | [
2830,
3393,
10048,
31396,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
10048,
648,
41214,
284,
3056,
10048,
31396,
2271,
515,
197,
7568,
454,
31396,
2271,
515,
298,
197,
5445,
19524,
25,
895,
345,
298,
197,
15782,
25,
57107,
515,
571,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestReadInput(t *testing.T) {
expected := "value"
scan = func() string {
return expected
}
value := readInput("text", "", false)
assert.Equal(t, expected, value)
} | explode_data.jsonl/67957 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
4418,
2505,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
330,
957,
698,
1903,
4814,
284,
2915,
368,
914,
341,
197,
853,
3601,
198,
197,
532,
16309,
1669,
1349,
2505,
445,
1318,
497,
7342,
895,
692,
6948,
12808,
1155,
11,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestFlagPrepareEvaluation(t *testing.T) {
t.Run("happy code path", func(t *testing.T) {
f := GenFixtureFlag()
assert.NoError(t, f.PrepareEvaluation())
assert.NotNil(t, f.FlagEvaluation.VariantsMap)
assert.NotNil(t, f.Tags)
})
} | explode_data.jsonl/36837 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
12135,
50590,
82363,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
56521,
2038,
1815,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1166,
1669,
9316,
18930,
12135,
741,
197,
6948,
35699,
1155,
11,
282,
28770,
3380,
82363,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStartVMMOnce(t *testing.T) {
socketPath := filepath.Join("testdata", "TestStartVMMOnce.sock")
defer os.Remove(socketPath)
cfg := Config{
SocketPath: socketPath,
DisableValidation: true,
KernelImagePath: getVmlinuxPath(t),
MachineCfg: models.MachineConfiguration{
VcpuCount: Int64(1),
MemSizeMib: Int64(64),
CPUTemplate: models.CPUTemplate(models.CPUTemplateT2),
HtEnabled: Bool(false),
},
}
ctx := context.Background()
cmd := VMCommandBuilder{}.
WithSocketPath(cfg.SocketPath).
WithBin(getFirecrackerBinaryPath()).
Build(ctx)
m, err := NewMachine(ctx, cfg, WithProcessRunner(cmd), WithLogger(fctesting.NewLogEntry(t)))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
timeout, cancel := context.WithTimeout(ctx, 250*time.Millisecond)
defer cancel()
err = m.Start(timeout)
if err != nil {
t.Fatalf("startVMM failed: %s", err)
}
defer m.StopVMM()
err = m.Start(timeout)
assert.Error(t, err, "should return an error when Start is called multiple times")
assert.Equal(t, ErrAlreadyStarted, err, "should be ErrAlreadyStarted")
select {
case <-timeout.Done():
if timeout.Err() == context.DeadlineExceeded {
t.Log("firecracker ran for 250ms")
t.Run("TestStopVMM", func(t *testing.T) { testStopVMM(ctx, t, m) })
} else {
t.Errorf("startVMM returned %s", m.Wait(ctx))
}
}
} | explode_data.jsonl/70437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 548
} | [
2830,
3393,
3479,
53,
8035,
12522,
1155,
353,
8840,
836,
8,
341,
58279,
1820,
1669,
26054,
22363,
445,
92425,
497,
330,
2271,
3479,
53,
8035,
12522,
68171,
1138,
16867,
2643,
13270,
27050,
1820,
692,
50286,
1669,
5532,
515,
197,
7568,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNoNewline(t *testing.T) {
in := "GOPASS-SECRET-1.0\nFoo: bar"
sec, err := ParseMIME([]byte(in))
require.NoError(t, err)
assert.Equal(t, "", sec.GetBody())
assert.Equal(t, "bar", sec.Get("Foo"))
assert.Equal(t, in+"\n", string(sec.Bytes()))
} | explode_data.jsonl/27744 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
2753,
3564,
1056,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
330,
98733,
4939,
12,
65310,
12,
16,
13,
15,
1699,
40923,
25,
3619,
698,
197,
5024,
11,
1848,
1669,
14775,
44,
5660,
10556,
3782,
5900,
1171,
17957,
35699,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddDimensionToInstanceReturnsUnauthorized(t *testing.T) {
t.Parallel()
Convey("Add a dimension to a instance returns unauthorized", t, func() {
json := strings.NewReader(`{"value":"24", "code_list":"123-456", "dimension": "test"}`)
r, err := http.NewRequest("POST", "http://localhost:21800/instances/123/dimensions", json)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
mockedDataStore := &storetest.StorerMock{}
datasetAPI := getAPIWithCMDMocks(testContext, mockedDataStore, &mocks.DownloadsGeneratorMock{})
datasetAPI.Router.ServeHTTP(w, r)
So(w.Code, ShouldEqual, http.StatusUnauthorized)
So(w.Body.String(), ShouldContainSubstring, "unauthenticated request")
})
} | explode_data.jsonl/20837 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
2212,
26121,
1249,
2523,
16446,
51181,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
93070,
5617,
445,
2212,
264,
12871,
311,
264,
2867,
4675,
44471,
497,
259,
11,
2915,
368,
341,
197,
30847,
1669,
9069,
68587,
5809,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExamplesDatabaseSelection(t *testing.T) {
driver := dbserver.GetDbServer().Driver()
defer driver.Close()
// tag::database-selection[]
session := driver.NewSession(neo4j.SessionConfig{DatabaseName: "example"})
// end::database-selection[]
defer session.Close()
} | explode_data.jsonl/46939 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
40381,
5988,
11177,
1155,
353,
8840,
836,
8,
341,
33652,
1669,
2927,
4030,
2234,
7994,
5475,
1005,
11349,
741,
16867,
5579,
10421,
741,
197,
322,
4772,
486,
12216,
75705,
19536,
25054,
1669,
5579,
7121,
5283,
48405,
78,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestHandshakeServerAESGCM(t *testing.T) {
test := &serverTest{
name: "RSA-AES-GCM",
command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "ECDHE-RSA-AES128-GCM-SHA256"},
}
runServerTestTLS12(t, test)
} | explode_data.jsonl/36327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
2314,
29661,
5475,
69168,
38,
9985,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
609,
4030,
2271,
515,
197,
11609,
25,
262,
330,
73564,
6691,
1570,
12010,
9985,
756,
197,
45566,
25,
3056,
917,
4913,
53612,
497,
330,
82,
8179... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWindow_GetEarliestBounds(t *testing.T) {
var testcases = []struct {
name string
w execute.Window
t execute.Time
want execute.Bounds
}{
{
name: "simple",
w: MustWindow(
values.ConvertDuration(5*time.Minute),
values.ConvertDuration(5*time.Minute),
values.ConvertDuration(0)),
t: execute.Time(6 * time.Minute),
want: execute.Bounds{
Start: execute.Time(5 * time.Minute),
Stop: execute.Time(10 * time.Minute),
},
},
{
name: "simple with offset",
w: MustWindow(
values.ConvertDuration(5*time.Minute),
values.ConvertDuration(5*time.Minute),
values.ConvertDuration(30*time.Second)),
t: execute.Time(5 * time.Minute),
want: execute.Bounds{
Start: execute.Time(30 * time.Second),
Stop: execute.Time(5*time.Minute + 30*time.Second),
},
},
{
name: "underlapping",
w: MustWindow(
values.ConvertDuration(2*time.Minute),
values.ConvertDuration(1*time.Minute),
values.ConvertDuration(30*time.Second)),
t: execute.Time(3 * time.Minute),
want: execute.Bounds{
Start: execute.Time(3*time.Minute + 30*time.Second),
Stop: execute.Time(4*time.Minute + 30*time.Second),
},
},
{
name: "underlapping not contained",
w: MustWindow(
values.ConvertDuration(2*time.Minute),
values.ConvertDuration(1*time.Minute),
values.ConvertDuration(30*time.Second)),
t: execute.Time(2*time.Minute + 45*time.Second),
want: execute.Bounds{
Start: execute.Time(3*time.Minute + 30*time.Second),
Stop: execute.Time(4*time.Minute + 30*time.Second),
},
},
{
name: "overlapping",
w: MustWindow(
values.ConvertDuration(1*time.Minute),
values.ConvertDuration(2*time.Minute),
values.ConvertDuration(30*time.Second)),
t: execute.Time(30 * time.Second),
want: execute.Bounds{
Start: execute.Time(-30 * time.Second),
Stop: execute.Time(1*time.Minute + 30*time.Second),
},
},
{
name: "partially overlapping",
w: MustWindow(
values.ConvertDuration(1*time.Minute),
values.ConvertDuration(3*time.Minute+30*time.Second),
values.ConvertDuration(30*time.Second)),
t: execute.Time(5*time.Minute + 45*time.Second),
want: execute.Bounds{
Start: execute.Time(3 * time.Minute),
Stop: execute.Time(6*time.Minute + 30*time.Second),
},
},
{
name: "partially overlapping (t on boundary)",
w: MustWindow(
values.ConvertDuration(1*time.Minute),
values.ConvertDuration(3*time.Minute+30*time.Second),
values.ConvertDuration(30*time.Second)),
t: execute.Time(5 * time.Minute),
want: execute.Bounds{
Start: execute.Time(2 * time.Minute),
Stop: execute.Time(5*time.Minute + 30*time.Second),
},
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
got := tc.w.GetEarliestBounds(tc.t)
if !cmp.Equal(tc.want, got) {
t.Errorf("did not get expected bounds; -want/+got:\n%v\n", cmp.Diff(tc.want, got))
}
})
}
} | explode_data.jsonl/17076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1318
} | [
2830,
3393,
4267,
13614,
17813,
23138,
11394,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
23910,
284,
3056,
1235,
341,
197,
11609,
914,
198,
197,
6692,
262,
9026,
23622,
198,
197,
3244,
262,
9026,
16299,
198,
197,
50780,
9026,
72133,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_GodogBuild(t *testing.T) {
t.Run("WithSourceNotInGoPath", testWithSourceNotInGoPath)
t.Run("WithoutSourceNotInGoPath", testWithoutSourceNotInGoPath)
t.Run("WithoutTestSourceNotInGoPath", testWithoutTestSourceNotInGoPath)
t.Run("WithinGopath", testWithinGopath)
t.Run("WithVendoredGodogWithoutModule", testWithVendoredGodogWithoutModule)
t.Run("WithVendoredGodogAndMod", testWithVendoredGodogAndMod)
t.Run("WithModule", func(t *testing.T) {
t.Parallel()
t.Run("OutsideGopathAndHavingOnlyFeature", testOutsideGopathAndHavingOnlyFeature)
t.Run("OutsideGopath", testOutsideGopath)
t.Run("OutsideGopathWithXTest", testOutsideGopathWithXTest)
t.Run("InsideGopath", testInsideGopath)
})
} | explode_data.jsonl/55514 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
2646,
347,
538,
11066,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2354,
3608,
2623,
641,
10850,
1820,
497,
1273,
2354,
3608,
2623,
641,
10850,
1820,
340,
3244,
16708,
445,
26040,
3608,
2623,
641,
10850,
1820,
497,
1273,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNoMainModule(t *testing.T) {
mt := setup(t, `
-- x.go --
package x
`, "")
defer mt.cleanup()
if _, err := mt.env.invokeGo("mod", "download", "rsc.io/quote@v1.5.1"); err != nil {
t.Fatal(err)
}
mt.assertScanFinds("rsc.io/quote", "quote")
} | explode_data.jsonl/72942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
2753,
6202,
3332,
1155,
353,
8840,
836,
8,
341,
2109,
83,
1669,
6505,
1155,
11,
22074,
313,
856,
18002,
39514,
1722,
856,
198,
7808,
14676,
16867,
11965,
87689,
741,
743,
8358,
1848,
1669,
11965,
9265,
27110,
10850,
445,
259... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUpdateGoDaddyARecord(t *testing.T) {
type args struct {
client *http.Client
domainName string
publicIP net.IP
apiKey string
secretKey string
}
tests := []struct {
name string
args args
hasError bool
}{
{"Should return err if nil IP is given", args{mockHTTPClient(0, "ignored", `[]`), "some.domain.com", nil, "apiKey", "secretKey"}, true},
{"Should return err if non 200 http status code", args{mockHTTPClient(404, "404 Bad request", `[]`), "some.domain.com", nil, "apiKey", "secretKey"}, true},
{"Should return err if invalid subdomain given", args{mockHTTPClient(200, "200 OK", `[]`), "invalid", net.ParseIP("1.1.1.1"), "apiKey", "secretKey"}, true},
{"Shouldn't return err if valid request", args{mockHTTPClient(200, "200 OK", `ignored`), "some.domain.com", net.ParseIP("1.1.1.1"), "apiKey", "secretKey"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := UpdateGoDaddyARecord(tt.args.client, tt.args.domainName, tt.args.publicIP, tt.args.apiKey, tt.args.secretKey)
if tt.hasError && err == nil {
t.Errorf("Expected UpdateGoDaddyARecord() to return an error")
}
if !tt.hasError && err != nil {
t.Errorf("UpdateGoDaddyARecord() returned an error")
}
})
}
} | explode_data.jsonl/72054 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 503
} | [
2830,
3393,
4289,
10850,
35,
22478,
32,
6471,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
25291,
257,
353,
1254,
11716,
198,
197,
2698,
3121,
675,
914,
198,
197,
1219,
3298,
256,
4179,
46917,
198,
197,
54299,
1592,
257,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestValidateDestinationRule(t *testing.T) {
cases := []struct {
name string
in proto.Message
valid bool
}{
{name: "simple destination rule", in: &networking.DestinationRule{
Host: "reviews",
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"}},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: true},
{name: "missing destination name", in: &networking.DestinationRule{
Host: "",
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"}},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: false},
{name: "missing subset name", in: &networking.DestinationRule{
Host: "reviews",
Subsets: []*networking.Subset{
{Name: "", Labels: map[string]string{"version": "v1"}},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: false},
{name: "valid traffic policy, top level", in: &networking.DestinationRule{
Host: "reviews",
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"}},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: true},
{name: "invalid traffic policy, top level", in: &networking.DestinationRule{
Host: "reviews",
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"}},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: false},
{name: "valid traffic policy, subset level", in: &networking.DestinationRule{
Host: "reviews",
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"},
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: true},
{name: "invalid traffic policy, subset level", in: &networking.DestinationRule{
Host: "reviews",
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"},
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: false},
{name: "valid traffic policy, both levels", in: &networking.DestinationRule{
Host: "reviews",
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
Subsets: []*networking.Subset{
{Name: "v1", Labels: map[string]string{"version": "v1"},
TrafficPolicy: &networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 30,
},
},
},
{Name: "v2", Labels: map[string]string{"version": "v2"}},
},
}, valid: true},
}
for _, c := range cases {
if got := ValidateDestinationRule(someName, someNamespace, c.in); (got == nil) != c.valid {
t.Errorf("ValidateDestinationRule failed on %v: got valid=%v but wanted valid=%v: %v",
c.name, got == nil, c.valid, got)
}
}
} | explode_data.jsonl/56922 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2420
} | [
2830,
3393,
17926,
33605,
11337,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
17430,
262,
18433,
8472,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
47006,
25,
330,
22944,
9106,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUnmarshalPreservesUnexportedFields(t *testing.T) {
toml := `
exported = "visible"
unexported = "ignored"
[nested1]
exported1 = "visible1"
unexported1 = "ignored1"
[nested2]
exported1 = "visible2"
unexported1 = "ignored2"
[nested3]
exported1 = "visible3"
unexported1 = "ignored3"
[[slice1]]
exported1 = "visible3"
[[slice1]]
exported1 = "visible4"
[[slice2]]
exported1 = "visible5"
`
t.Run("unexported field should not be set from toml", func(t *testing.T) {
var actual unexportedFieldPreservationTest
err := Unmarshal([]byte(toml), &actual)
if err != nil {
t.Fatal("did not expect an error")
}
expect := unexportedFieldPreservationTest{
Exported: "visible",
unexported: "",
Nested1: unexportedFieldPreservationTestNested{"visible1", ""},
Nested2: &unexportedFieldPreservationTestNested{"visible2", ""},
Nested3: &unexportedFieldPreservationTestNested{"visible3", ""},
Slice1: []unexportedFieldPreservationTestNested{
{Exported1: "visible3"},
{Exported1: "visible4"},
},
Slice2: []*unexportedFieldPreservationTestNested{
{Exported1: "visible5"},
},
}
if !reflect.DeepEqual(actual, expect) {
t.Fatalf("%+v did not equal %+v", actual, expect)
}
})
t.Run("unexported field should be preserved", func(t *testing.T) {
actual := unexportedFieldPreservationTest{
Exported: "foo",
unexported: "bar",
Nested1: unexportedFieldPreservationTestNested{"baz", "bax"},
Nested2: nil,
Nested3: &unexportedFieldPreservationTestNested{"baz", "bax"},
}
err := Unmarshal([]byte(toml), &actual)
if err != nil {
t.Fatal("did not expect an error")
}
expect := unexportedFieldPreservationTest{
Exported: "visible",
unexported: "bar",
Nested1: unexportedFieldPreservationTestNested{"visible1", "bax"},
Nested2: &unexportedFieldPreservationTestNested{"visible2", ""},
Nested3: &unexportedFieldPreservationTestNested{"visible3", "bax"},
Slice1: []unexportedFieldPreservationTestNested{
{Exported1: "visible3"},
{Exported1: "visible4"},
},
Slice2: []*unexportedFieldPreservationTestNested{
{Exported1: "visible5"},
},
}
if !reflect.DeepEqual(actual, expect) {
t.Fatalf("%+v did not equal %+v", actual, expect)
}
})
} | explode_data.jsonl/46356 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 963
} | [
2830,
3393,
1806,
27121,
14367,
13280,
1806,
1533,
291,
8941,
1155,
353,
8840,
836,
8,
341,
3244,
316,
75,
1669,
22074,
59440,
291,
284,
330,
12601,
698,
20479,
1533,
291,
284,
330,
58471,
1837,
197,
7669,
9980,
16,
921,
59440,
291,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_StrStrMap_Clone(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
//clone 方法是深克隆
m := gmap.NewStrStrMapFrom(map[string]string{"a": "a", "b": "b", "c": "c"})
m_clone := m.Clone()
m.Remove("a")
//修改原 map,clone 后的 map 不影响
t.AssertIN("a", m_clone.Keys())
m_clone.Remove("b")
//修改clone map,原 map 不影响
t.AssertIN("b", m.Keys())
})
} | explode_data.jsonl/36010 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
46171,
2580,
2227,
85110,
603,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
197,
322,
19982,
81454,
20412,
99194,
99316,
100767,
198,
197,
2109,
1669,
342,
2186,
7121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMqttFunc_Apply2(t *testing.T) {
var tests = []struct {
sql string
data xsql.JoinTupleSets
result []map[string]interface{}
}{
{
sql: "SELECT id1, mqtt(src1.topic) AS a, mqtt(src2.topic) as b FROM src1 LEFT JOIN src2 ON src1.id1 = src2.id1",
data: xsql.JoinTupleSets{
xsql.JoinTuple{
Tuples: []xsql.Tuple{
{Emitter: "src1", Message: xsql.Message{"id1": "1", "f1": "v1"}, Metadata: xsql.Metadata{"topic": "devices/type1/device001"}},
{Emitter: "src2", Message: xsql.Message{"id2": "1", "f2": "w1"}, Metadata: xsql.Metadata{"topic": "devices/type2/device001"}},
},
},
},
result: []map[string]interface{}{{
"id1": "1",
"a": "devices/type1/device001",
"b": "devices/type2/device001",
}},
},
}
fmt.Printf("The test bucket size is %d.\n\n", len(tests))
contextLogger := common.Log.WithField("rule", "TestMqttFunc_Apply2")
ctx := contexts.WithValue(contexts.Background(), contexts.LoggerKey, contextLogger)
for i, tt := range tests {
stmt, err := xsql.NewParser(strings.NewReader(tt.sql)).Parse()
if err != nil || stmt == nil {
t.Errorf("parse sql %s error %v", tt.sql, err)
}
pp := &ProjectOp{Fields: stmt.Fields}
pp.isTest = true
fv, afv := xsql.NewFunctionValuersForOp(nil)
result := pp.Apply(ctx, tt.data, fv, afv)
var mapRes []map[string]interface{}
if v, ok := result.([]byte); ok {
err := json.Unmarshal(v, &mapRes)
if err != nil {
t.Errorf("Failed to parse the input into map.\n")
continue
}
//fmt.Printf("%t\n", mapRes["rengine_field_0"])
if !reflect.DeepEqual(tt.result, mapRes) {
t.Errorf("%d. %q\n\nresult mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", i, tt.sql, tt.result, mapRes)
}
} else {
t.Errorf("The returned result is not type of []byte\n")
}
}
} | explode_data.jsonl/447 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 837
} | [
2830,
3393,
44,
32267,
9626,
36117,
398,
17,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
30633,
262,
914,
198,
197,
8924,
256,
856,
3544,
22363,
28681,
30175,
198,
197,
9559,
3056,
2186,
14032,
31344,
16094,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSetExternalTagsNotTuple(t *testing.T) {
// Reset memory counters
helpers.ResetMemoryStats()
code := `
datadog_agent.set_external_tags([{}, {}])
`
out, err := run(code)
if err != nil {
t.Fatal(err)
}
if out != "TypeError: external host tags list must contain only tuples" {
t.Errorf("Unexpected printed value: '%s'", out)
}
// Check for leaks
helpers.AssertMemoryUsage(t)
} | explode_data.jsonl/24553 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
1649,
25913,
15930,
2623,
28681,
1155,
353,
8840,
836,
8,
341,
197,
322,
16932,
4938,
31532,
198,
197,
21723,
36660,
10642,
16635,
2822,
43343,
1669,
22074,
2698,
266,
329,
538,
25730,
980,
47432,
16333,
2561,
22655,
4687,
254... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSystemVerify(t *testing.T) {
if runtime.GOOS != "windows" {
t.Skipf("skipping verify test using system APIs on %q", runtime.GOOS)
}
for _, test := range verifyTests {
t.Run(test.name, func(t *testing.T) {
if test.systemSkip {
t.SkipNow()
}
testVerify(t, test, true)
})
}
} | explode_data.jsonl/29001 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
2320,
32627,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
961,
330,
27077,
1,
341,
197,
3244,
57776,
69,
445,
4886,
5654,
10146,
1273,
1667,
1849,
33356,
389,
1018,
80,
497,
15592,
97574,
3126,
340,
197,
630,
202... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCAConfigSoftVerifyFlag(t *testing.T) {
backend, err := config.FromFile(configTestFilePath)()
if err != nil {
t.Fatal("Failed to get config backend")
}
customBackend := getCustomBackend(backend...)
cryptoConfig := ConfigFromBackend(customBackend).(*Config)
// Test SoftVerify flag
val, ok := customBackend.Lookup("client.BCCSP.security.softVerify")
if !ok || val == nil {
t.Fatal("expected valid value")
}
if val.(bool) != cryptoConfig.SoftVerify() {
t.Fatal("Incorrect BCCSP Ephemeral flag")
}
} | explode_data.jsonl/58380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
5049,
2648,
30531,
32627,
12135,
1155,
353,
8840,
836,
8,
341,
197,
20942,
11,
1848,
1669,
2193,
11439,
1703,
8754,
2271,
19090,
8,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
9408,
311,
633,
2193,
19163,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestStrings(t *testing.T) {
app := New("", "")
app.Arg("a", "").Required().String()
app.Arg("b", "").Required().String()
c := app.Arg("c", "").Required().Strings()
app.Parse([]string{"a", "b", "a", "b"})
assert.Equal(t, []string{"a", "b"}, *c)
} | explode_data.jsonl/56731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
20859,
1155,
353,
8840,
836,
8,
341,
28236,
1669,
1532,
19814,
14676,
28236,
18979,
445,
64,
497,
35229,
8164,
1005,
703,
741,
28236,
18979,
445,
65,
497,
35229,
8164,
1005,
703,
741,
1444,
1669,
906,
18979,
445,
66,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNormalizeVariant(t *testing.T) {
type TNormData struct {
ecode int
chrom uint8
pos uint32
epos uint32
sizeref uint8
sizealt uint8
esizeref uint8
esizealt uint8
eref string
ealt string
ref string
alt string
}
var ndata = []TNormData{
{-2, 1, 26, 26, 1, 1, 1, 1, "A", "C", "A", "C"}, // invalid position
{-1, 1, 0, 0, 1, 1, 1, 1, "J", "C", "J", "C"}, // invalid reference
{4, 1, 0, 0, 1, 1, 1, 1, "A", "C", "T", "G"}, // flip
{0, 1, 0, 0, 1, 1, 1, 1, "A", "C", "A", "C"}, // OK
{32, 13, 2, 3, 3, 2, 2, 1, "DE", "D", "CDE", "CD"}, // left trim
{48, 13, 2, 3, 3, 3, 1, 1, "D", "F", "CDE", "CFE"}, // left trim + right trim
{48, 1, 0, 2, 6, 6, 1, 1, "C", "K", "aBCDEF", "aBKDEF"}, // left trim + right trim
{0, 1, 0, 0, 1, 0, 1, 0, "A", "", "A", ""}, // OK
{8, 1, 3, 2, 1, 0, 2, 1, "CD", "C", "D", ""}, // left extend
{0, 1, 24, 24, 1, 2, 1, 2, "Y", "CK", "Y", "CK"}, // OK
{2, 1, 0, 0, 1, 1, 1, 1, "A", "G", "G", "A"}, // swap
{6, 1, 0, 0, 1, 1, 1, 1, "A", "C", "G", "T"}, // swap + flip
}
for _, v := range ndata {
v := v
t.Run("", func(t *testing.T) {
t.Parallel()
code, npos, nref, nalt, nsizeref, nsizealt := gref.NormalizeVariant(v.chrom, v.pos, v.ref, v.alt)
if code != v.ecode {
t.Errorf("The return code is different, got: %#v expected %#v", code, v.ecode)
}
if npos != v.epos {
t.Errorf("The POS value is different, got: %#v expected %#v", npos, v.epos)
}
if nsizeref != v.esizeref {
t.Errorf("The REF size is different, got: %#v expected %#v", nsizeref, v.esizeref)
}
if nsizealt != v.esizealt {
t.Errorf("The ALT size is different, got: %#v expected %#v", nsizealt, v.esizealt)
}
if nref != v.eref {
t.Errorf("The REF is different, got: %#v expected %#v", nref, v.eref)
}
if nalt != v.ealt {
t.Errorf("The ALT is different, got: %#v expected %#v", nalt, v.ealt)
}
})
}
} | explode_data.jsonl/40556 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1112
} | [
2830,
3393,
87824,
20746,
1155,
353,
8840,
836,
8,
341,
13158,
350,
24993,
1043,
2036,
341,
197,
197,
757,
534,
262,
526,
198,
197,
23049,
441,
262,
2622,
23,
198,
197,
28164,
414,
2622,
18,
17,
198,
197,
96626,
436,
257,
2622,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestOrderedWeightedEdgesIterate(t *testing.T) {
for _, test := range orderedWeightedEdgesTests {
for i := 0; i < 2; i++ {
it := iterator.NewOrderedWeightedEdges(test.edges)
if it.Len() != len(test.edges) {
t.Errorf("unexpected iterator length for round %d: got:%d want:%d", i, it.Len(), len(test.edges))
}
var got []graph.WeightedEdge
for it.Next() {
got = append(got, it.WeightedEdge())
}
want := test.edges
if !reflect.DeepEqual(got, want) {
t.Errorf("unexpected iterator output for round %d: got:%#v want:%#v", i, got, want)
}
it.Reset()
}
}
} | explode_data.jsonl/67499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
54384,
8295,
291,
41122,
8537,
349,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
11457,
8295,
291,
41122,
18200,
341,
197,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
17,
26,
600,
1027,
341,
298,
23374,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestMemory_ParseMemory(t *testing.T) {
tests := []struct {
in string
out Memory
err error
}{
{"1", 1, nil},
{"1KB", 1024, nil},
{"1MB", 1048576, nil},
{"1GB", 1073741824, nil},
{"1.00GB", 1073741824, nil},
{"1.25GB", 1342177280, nil},
{"1kB", 1024, nil},
{"1kb", 1024, nil},
{"1Kb", 1024, nil},
{"", 0, ErrInvalidMemory},
{"f", 0, ErrInvalidMemory},
{"shitGB", 0, ErrInvalidMemory},
{"1SHITB", 0, ErrInvalidMemory},
}
for i, tt := range tests {
m, err := ParseMemory(tt.in)
if err != tt.err {
t.Fatalf("#%d: err => %v; want %v", i, err, tt.err)
}
if tt.err != nil {
continue
}
if got, want := m, tt.out; got != want {
t.Fatalf("#%d: Memory => %d; want %d", i, got, want)
}
}
} | explode_data.jsonl/64517 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
10642,
77337,
10642,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
220,
914,
198,
197,
13967,
13850,
198,
197,
9859,
1465,
198,
197,
59403,
197,
197,
4913,
16,
497,
220,
16,
11,
2092,
1583,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestExpiredField(t *testing.T) {
// the middleware to test
authMiddleware, _ := New(&GinJWTMiddleware{
Realm: "test zone",
Key: key,
Timeout: time.Hour,
Authenticator: defaultAuthenticator,
})
handler := ginHandler(authMiddleware)
r := gofight.New()
token := jwt.New(jwt.GetSigningMethod("HS256"))
claims := token.Claims.(jwt.MapClaims)
claims["identity"] = "admin"
claims["orig_iat"] = 0
tokenString, _ := token.SignedString(key)
r.GET("/auth/hello").
SetHeader(gofight.H{
"Authorization": "Bearer " + tokenString,
}).
Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
message := gjson.Get(r.Body.String(), "message")
assert.Equal(t, ErrMissingExpField.Error(), message.String())
assert.Equal(t, http.StatusBadRequest, r.Code)
})
// wrong format
claims["exp"] = "test"
tokenString, _ = token.SignedString(key)
r.GET("/auth/hello").
SetHeader(gofight.H{
"Authorization": "Bearer " + tokenString,
}).
Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
message := gjson.Get(r.Body.String(), "message")
assert.Equal(t, ErrWrongFormatOfExp.Error(), message.String())
assert.Equal(t, http.StatusBadRequest, r.Code)
})
} | explode_data.jsonl/64455 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 510
} | [
2830,
3393,
54349,
1877,
1155,
353,
8840,
836,
8,
341,
197,
322,
279,
29679,
311,
1273,
198,
78011,
24684,
11,
716,
1669,
1532,
2099,
38,
258,
55172,
24684,
515,
197,
197,
64290,
25,
260,
330,
1944,
10143,
756,
197,
55242,
25,
1843,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetOrder(t *testing.T) {
t.Parallel()
if h.APIKey == "" || h.APISecret == "" || h.APIAuthPEMKey == "" {
t.Skip()
}
_, err := h.GetOrder(1337)
if err == nil {
t.Error("Test failed - Huobi TestCancelOrder: Invalid orderID returned true")
}
} | explode_data.jsonl/24339 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
1949,
4431,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
743,
305,
24922,
1592,
621,
1591,
1369,
305,
29837,
1637,
50856,
621,
1591,
1369,
305,
24922,
5087,
1740,
44,
1592,
621,
1591,
341,
197,
3244,
57776,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestNodeHandlerList(t *testing.T) {
tests := []struct {
name string
opts map[string]string
reqBody string
expCode int
expBody string
}{
{
name: "Request to list nodes should return not implemented.",
reqBody: "",
opts: map[string]string{},
expCode: 500,
expBody: `{"error":"not implemented"}`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert := assert.New(t)
// Mocks.
mcv1 := &mcliclusterv1.NodeClientInterface{}
nh := webapiclusterv1.NewNodeHandler(serializer.DefaultSerializer, mcv1)
b := bytes.NewBufferString(test.reqBody)
r := httptest.NewRequest("POST", "http://test", b)
w := httptest.NewRecorder()
nh.List(w, r, test.opts)
assert.Equal(test.expCode, w.Code)
assert.Equal(test.expBody, strings.TrimSuffix(w.Body.String(), "\n"))
})
}
} | explode_data.jsonl/62163 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 371
} | [
2830,
3393,
1955,
3050,
852,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
64734,
262,
2415,
14032,
30953,
198,
197,
24395,
5444,
914,
198,
197,
48558,
2078,
526,
198,
197,
48558,
5444,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnmarshalWithNull(t *testing.T) {
result := interface{}(nil)
err := phpserialize.Unmarshal(inputNull, &result)
if err == nil {
t.Errorf("expected error")
}
} | explode_data.jsonl/27023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
1806,
27121,
2354,
3280,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
3749,
6257,
7,
8385,
340,
9859,
1669,
24362,
24166,
38097,
5384,
3280,
11,
609,
1382,
692,
743,
1848,
621,
2092,
341,
197,
3244,
13080,
445,
7325,
1465,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestValidate_UniqueOperationNames_MultipleOperationsOfSameName(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.UniqueOperationNamesRule, `
query Foo {
fieldA
}
query Foo {
fieldB
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`There can only be one operation named "Foo".`, 2, 13, 5, 13),
})
} | explode_data.jsonl/23173 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
17926,
62,
22811,
8432,
7980,
1245,
12229,
35120,
2124,
19198,
675,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
81893,
37,
6209,
11337,
1155,
11,
48865,
87443,
8432,
7980,
11337,
11,
22074,
414,
3239,
33428,
341,
286,
2070,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandleReceivedMsg(t *testing.T) {
smr, err := MakeSmr(t)
if err != nil {
t.Error("TestHandleReceivedMsg MakeSmr error", err)
return
}
netMsg, err := MakeProposalMsg(t)
err = smr.handleReceivedMsg(netMsg)
if err != nil {
t.Error("TestHandleReceivedMsg handleReceivedMsg error", err)
return
}
} | explode_data.jsonl/33025 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
6999,
23260,
6611,
1155,
353,
8840,
836,
8,
341,
1903,
20946,
11,
1848,
1669,
7405,
10673,
81,
1155,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
445,
2271,
6999,
23260,
6611,
7405,
10673,
81,
1465,
497,
1848,
340,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAuthProviderStaticFile(t *testing.T) {
is := is.New(t)
logger := testLogger()
dir, err := ioutil.TempDir("", "")
is.NoErr(err)
defer os.RemoveAll(dir)
file := filepath.Join(dir, "auth.yaml")
is.NoErr(ioutil.WriteFile(file, []byte(authData), 0644))
done := make(chan struct{})
interval := 1 * time.Second
a, err := NewAuthProviderStaticFile(logger, file, interval)
is.NoErr(err)
go a.Run(done)
defer close(done)
c, err := a.CredsForKey("apikey")
is.NoErr(err)
is.True(c.AllowMetric("metric1"))
is.False(c.AllowMetric("metric3"))
_, err = a.CredsForKey("apikey2")
is.Equal(err, ErrCredentialsNotFound)
time.Sleep(1 * time.Second)
is.NoErr(ioutil.WriteFile(file, []byte(authData2), 0644))
time.Sleep(2 * interval)
c, err = a.CredsForKey("apikey")
is.NoErr(err)
is.True(c.AllowMetric("metric1"))
is.True(c.AllowMetric("metric3"))
} | explode_data.jsonl/26105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 385
} | [
2830,
3393,
96443,
11690,
1703,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
374,
7121,
1155,
340,
17060,
1669,
1273,
7395,
2822,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
19907,
16766,
7747,
3964,
340,
16867,
2643,
84427,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestControlPlaneOutsideWatchedNamespaceIsAlwaysAllowed(t *testing.T) {
controlPlane := newControlPlaneWithVersion("my-smcp", "not-watched", versions.V2_2.String())
validator, _, _ := createControlPlaneValidatorTestFixture()
validator.namespaceFilter = "watched-namespace"
response := validator.Handle(ctx, createCreateRequest(controlPlane))
assert.True(response.Allowed, "Expected validator to allow ServiceMeshControlPlane whose namespace isn't watched", t)
} | explode_data.jsonl/10231 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
3273,
34570,
41365,
14247,
291,
22699,
3872,
37095,
35382,
1155,
353,
8840,
836,
8,
341,
82786,
34570,
1669,
501,
3273,
34570,
2354,
5637,
445,
2408,
4668,
4672,
497,
330,
1921,
2630,
34244,
497,
10795,
5058,
17,
62,
17,
643... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCancelMultipleSpotOrders(t *testing.T) {
TestSetRealOrderDefaults(t)
request := okgroup.CancelMultipleSpotOrdersRequest{
InstrumentID: spotCurrency,
OrderIDs: []int64{1, 2, 3, 4},
}
cancellations, err := o.CancelMultipleSpotOrders(request)
testStandardErrorHandling(t, err)
for _, cancellationsPerCurrency := range cancellations {
for _, cancellation := range cancellationsPerCurrency {
if !cancellation.Result {
t.Error(cancellation.Error)
}
}
}
} | explode_data.jsonl/30161 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
9269,
32089,
47049,
24898,
1155,
353,
8840,
836,
8,
341,
73866,
1649,
12768,
4431,
16273,
1155,
340,
23555,
1669,
5394,
4074,
36491,
32089,
47049,
24898,
1900,
515,
197,
197,
56324,
915,
25,
7702,
26321,
345,
197,
197,
4431,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestChangefeedEnvelope(t *testing.T) {
defer leaktest.AfterTest(t)()
testFn := func(t *testing.T, db *gosql.DB, f cdctest.TestFeedFactory) {
sqlDB := sqlutils.MakeSQLRunner(db)
sqlDB.Exec(t, `CREATE TABLE foo (a INT PRIMARY KEY, b STRING)`)
sqlDB.Exec(t, `INSERT INTO foo VALUES (1, 'a')`)
t.Run(`envelope=row`, func(t *testing.T) {
foo := feed(t, f, `CREATE CHANGEFEED FOR foo WITH envelope='row'`)
defer closeFeed(t, foo)
assertPayloads(t, foo, []string{`foo: [1]->{"a": 1, "b": "a"}`})
})
t.Run(`envelope=deprecated_row`, func(t *testing.T) {
foo := feed(t, f, `CREATE CHANGEFEED FOR foo WITH envelope='deprecated_row'`)
defer closeFeed(t, foo)
assertPayloads(t, foo, []string{`foo: [1]->{"a": 1, "b": "a"}`})
})
t.Run(`envelope=key_only`, func(t *testing.T) {
foo := feed(t, f, `CREATE CHANGEFEED FOR foo WITH envelope='key_only'`)
defer closeFeed(t, foo)
assertPayloads(t, foo, []string{`foo: [1]->`})
})
t.Run(`envelope=wrapped`, func(t *testing.T) {
foo := feed(t, f, `CREATE CHANGEFEED FOR foo WITH envelope='wrapped'`)
defer closeFeed(t, foo)
assertPayloads(t, foo, []string{`foo: [1]->{"after": {"a": 1, "b": "a"}}`})
})
t.Run(`envelope=wrapped,key_in_value`, func(t *testing.T) {
foo := feed(t, f, `CREATE CHANGEFEED FOR foo WITH key_in_value, envelope='wrapped'`)
defer closeFeed(t, foo)
assertPayloads(t, foo, []string{`foo: [1]->{"after": {"a": 1, "b": "a"}, "key": [1]}`})
})
}
t.Run(`sinkless`, sinklessTest(testFn))
t.Run(`enterprise`, enterpriseTest(testFn))
} | explode_data.jsonl/7034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 713
} | [
2830,
3393,
1143,
524,
823,
12051,
62712,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
18185,
24911,
1669,
2915,
1155,
353,
8840,
836,
11,
2927,
353,
34073,
1470,
22537,
11,
282,
15307,
67880,
8787,
2891... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMaxAttrID(t *testing.T) {
tests := []struct {
input interface{}
want uint16
}{
{
struct{}{},
0,
},
{
struct {
a uint32 `netlink:"attr:65535"`
}{},
65535,
},
{
struct {
a uint8 `netlink:"attr:1"`
b uint16 `netlink:"attr:2"`
c uint32 `netlink:"attr:3"`
}{},
3,
},
{
struct {
c uint32 `netlink:"attr:3"`
b uint16 `netlink:"attr:2"`
a uint8 `netlink:"attr:1"`
}{},
3,
},
{
struct {
a uint8 `netlink:"attr:1"`
b uint16 `netlink:"attr:2"`
c uint32 `netlink:"attr:3"`
x struct {
d string `netlink:"attr:5"`
}
}{},
5,
},
{
struct {
a uint8 `netlink:"attr:1"`
b uint16 `netlink:"attr:2"`
c uint32 `netlink:"attr:3"`
x struct {
d string `netlink:"attr:5"`
} `netlink:"attr:4"`
}{},
4,
},
}
for i, test := range tests {
got, err := structMaxAttrID(reflect.ValueOf(test.input))
if err != nil {
t.Errorf("%d: got error: %v", i, err)
continue
}
if got != test.want {
t.Errorf("%d: got %d, want %d", i, got, test.want)
}
}
} | explode_data.jsonl/45413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 609
} | [
2830,
3393,
5974,
13371,
915,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
3749,
16094,
197,
50780,
220,
2622,
16,
21,
198,
197,
59403,
197,
197,
515,
298,
6472,
6257,
38837,
298,
197,
15,
345,
197,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFileHelper_GetPathFromPathFileName_03(t *testing.T) {
fh := FileHelper{}
commonDir := fh.AdjustPathSlash("D:\\go\\work\\src\\MikeAustin71\\pathfilego\\" +
"003_filehelper\\common\\xt_dirmgr_01_test.go")
expectedDir := fh.AdjustPathSlash("D:\\go\\work\\src\\MikeAustin71\\pathfilego\\" +
"003_filehelper\\common")
result, isEmpty, err := fh.GetPathFromPathFileName(commonDir)
if err != nil {
t.Errorf("Error returned from fh.GetPathFromPathFileName(commonDir). commonDir='%v' Error='%v'", commonDir, err.Error())
}
if isEmpty != false {
t.Errorf("Expected isEmpty GetPathFromPathFileName for valid file extension to return 'false', instead isEmpty='%v' ", isEmpty)
}
if result != expectedDir {
t.Errorf("Expected GetPathFromPathFileName to return path == '%v' for valid file name. Instead path='%v'", expectedDir, result)
}
} | explode_data.jsonl/14461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 314
} | [
2830,
3393,
1703,
5511,
13614,
1820,
3830,
1820,
10903,
62,
15,
18,
1155,
353,
8840,
836,
8,
341,
220,
36075,
1669,
2887,
5511,
31483,
220,
4185,
6184,
1669,
36075,
17865,
4250,
1820,
88004,
445,
35,
23817,
3346,
3422,
1778,
3422,
3548,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestConcatSeries(t *testing.T) {
assert := assert.New(t)
s1 := ContinuousSeries{
XValues: Sequence.Float64(1.0, 10.0),
YValues: Sequence.Float64(1.0, 10.0),
}
s2 := ContinuousSeries{
XValues: Sequence.Float64(11, 20.0),
YValues: Sequence.Float64(10.0, 1.0),
}
s3 := ContinuousSeries{
XValues: Sequence.Float64(21, 30.0),
YValues: Sequence.Float64(1.0, 10.0),
}
cs := ConcatSeries([]Series{s1, s2, s3})
assert.Equal(30, cs.Len())
x0, y0 := cs.GetValue(0)
assert.Equal(1.0, x0)
assert.Equal(1.0, y0)
xm, ym := cs.GetValue(19)
assert.Equal(20.0, xm)
assert.Equal(1.0, ym)
xn, yn := cs.GetValue(29)
assert.Equal(30.0, xn)
assert.Equal(10.0, yn)
} | explode_data.jsonl/6709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
78440,
25544,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
1903,
16,
1669,
68967,
25544,
515,
197,
22123,
6227,
25,
28871,
29794,
21,
19,
7,
16,
13,
15,
11,
220,
16,
15,
13,
15,
1326,
197,
65322,
62... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHistWalk_Accept(t *testing.T) {
f := startHistwalkTest(t)
defer f.Cleanup()
f.TTYCtrl.Inject(term.K(ui.Right))
f.TestTTY(t,
"~> echo a", Styles,
" vvvv ", term.DotHere,
)
} | explode_data.jsonl/51733 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
63057,
48849,
1566,
66,
1484,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
1191,
63057,
19059,
2271,
1155,
340,
16867,
282,
727,
60639,
2822,
1166,
836,
22098,
15001,
41046,
44654,
11352,
26230,
17565,
1171,
1166,
8787,
55544,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTaskExecutionPatchPrepare(t *testing.T) {
Convey("With handler and a project context and user", t, func() {
tep := &taskExecutionPatchHandler{}
projCtx := serviceModel.Context{
Task: &task.Task{
Id: "testTaskId",
Priority: 0,
Activated: false,
},
}
u := user.DBUser{
Id: "testUser",
}
ctx := context.Background()
Convey("then should error on empty body", func() {
req, err := http.NewRequest("PATCH", "task/testTaskId", &bytes.Buffer{})
So(err, ShouldBeNil)
ctx = gimlet.AttachUser(ctx, &u)
ctx = context.WithValue(ctx, RequestContext, &projCtx)
err = tep.Parse(ctx, req)
So(err, ShouldNotBeNil)
expectedErr := gimlet.ErrorResponse{
Message: "No request body sent",
StatusCode: http.StatusBadRequest,
}
So(err, ShouldResemble, expectedErr)
})
Convey("then should error on body with wrong type", func() {
str := "nope"
badBod := &struct {
Activated *string
}{
Activated: &str,
}
res, err := json.Marshal(badBod)
So(err, ShouldBeNil)
buf := bytes.NewBuffer(res)
req, err := http.NewRequest("PATCH", "task/testTaskId", buf)
So(err, ShouldBeNil)
ctx = gimlet.AttachUser(ctx, &u)
ctx = context.WithValue(ctx, RequestContext, &projCtx)
err = tep.Parse(ctx, req)
So(err, ShouldNotBeNil)
expectedErr := gimlet.ErrorResponse{
Message: fmt.Sprintf("Incorrect type given, expecting '%s' "+
"but receieved '%s'",
"bool", "string"),
StatusCode: http.StatusBadRequest,
}
So(err, ShouldResemble, expectedErr)
})
Convey("then should error when fields not set", func() {
badBod := &struct {
Activated *string
}{}
res, err := json.Marshal(badBod)
So(err, ShouldBeNil)
buf := bytes.NewBuffer(res)
req, err := http.NewRequest("PATCH", "task/testTaskId", buf)
So(err, ShouldBeNil)
ctx = gimlet.AttachUser(ctx, &u)
ctx = context.WithValue(ctx, RequestContext, &projCtx)
err = tep.Parse(ctx, req)
So(err, ShouldNotBeNil)
expectedErr := gimlet.ErrorResponse{
Message: "Must set 'activated' or 'priority'",
StatusCode: http.StatusBadRequest,
}
So(err, ShouldResemble, expectedErr)
})
Convey("then should set it's Activated and Priority field when set", func() {
goodBod := &struct {
Activated bool
Priority int
}{
Activated: true,
Priority: 100,
}
res, err := json.Marshal(goodBod)
So(err, ShouldBeNil)
buf := bytes.NewBuffer(res)
req, err := http.NewRequest("PATCH", "task/testTaskId", buf)
So(err, ShouldBeNil)
ctx = gimlet.AttachUser(ctx, &u)
ctx = context.WithValue(ctx, RequestContext, &projCtx)
err = tep.Parse(ctx, req)
So(err, ShouldBeNil)
So(*tep.Activated, ShouldBeTrue)
So(*tep.Priority, ShouldEqual, 100)
Convey("and task and user should be set", func() {
So(tep.task, ShouldNotBeNil)
So(tep.task.Id, ShouldEqual, "testTaskId")
So(tep.user.Username(), ShouldEqual, "testUser")
})
})
})
} | explode_data.jsonl/9568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1310
} | [
2830,
3393,
6262,
20294,
43622,
50590,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2354,
7013,
323,
264,
2390,
2266,
323,
1196,
497,
259,
11,
2915,
368,
341,
197,
197,
90898,
1669,
609,
8202,
20294,
43622,
3050,
31483,
197,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeleteBucket(t *testing.T) {
t.Run("delete-empty", func(t *testing.T) {
ts := newTestServer(t, withoutInitialBuckets())
defer ts.Close()
svc := ts.s3Client()
ts.backendCreateBucket("test")
ts.OKAll(svc.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String("test"),
}))
})
t.Run("delete-fails-if-not-empty", func(t *testing.T) {
ts := newTestServer(t, withoutInitialBuckets())
defer ts.Close()
svc := ts.s3Client()
ts.backendCreateBucket("test")
ts.backendPutString("test", "test", nil, "test")
_, err := svc.DeleteBucket(&s3.DeleteBucketInput{
Bucket: aws.String("test"),
})
if !hasErrorCode(err, gofakes3.ErrBucketNotEmpty) {
t.Fatal("expected ErrBucketNotEmpty, found", err)
}
})
} | explode_data.jsonl/22259 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
6435,
36018,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4542,
39433,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
57441,
1669,
501,
2271,
5475,
1155,
11,
2041,
6341,
33,
38551,
2398,
197,
16867,
10591,
10421,
741,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntSum_DataPoints(t *testing.T) {
ms := NewIntSum()
assert.EqualValues(t, NewIntDataPointSlice(), ms.DataPoints())
fillTestIntDataPointSlice(ms.DataPoints())
testValDataPoints := generateTestIntDataPointSlice()
assert.EqualValues(t, testValDataPoints, ms.DataPoints())
} | explode_data.jsonl/32696 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
1072,
9190,
17817,
11411,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
1072,
9190,
741,
6948,
12808,
6227,
1155,
11,
1532,
1072,
1043,
2609,
33236,
1507,
9829,
3336,
11411,
2398,
65848,
2271,
1072,
1043,
2609,
33236,
35680... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClient_HealthChecker(t *testing.T) {
ctx := context.Background()
timePriorHealthCheck := time.Now()
path := "/health"
Convey("given clienter.Do returns an error", t, func() {
clientError := errors.New("disciples of the watch obey")
httpClient := createHTTPClientMockErr(clientError)
searchClient := newSearchClient(httpClient)
check := initialState
Convey("when searchClient.Checker is called", func() {
err := searchClient.Checker(ctx, &check)
So(err, ShouldBeNil)
Convey("then the expected check is returned", func() {
So(check.Name(), ShouldEqual, service)
So(check.Status(), ShouldEqual, healthcheck.StatusCritical)
So(check.StatusCode(), ShouldEqual, 0)
So(check.Message(), ShouldEqual, clientError.Error())
So(*check.LastChecked(), ShouldHappenAfter, timePriorHealthCheck)
So(check.LastSuccess(), ShouldBeNil)
So(*check.LastFailure(), ShouldHappenAfter, timePriorHealthCheck)
})
Convey("and client.Do should be called once with the expected parameters", func() {
doCalls := httpClient.DoCalls()
So(doCalls, ShouldHaveLength, 1)
So(doCalls[0].Req.URL.Path, ShouldEqual, path)
})
})
})
Convey("given clienter.Do returns 400 response", t, func() {
httpClient := createHTTPClientMock(http.StatusBadRequest, []byte(""))
searchClient := newSearchClient(httpClient)
check := initialState
Convey("when searchClient.Checker is called", func() {
err := searchClient.Checker(ctx, &check)
So(err, ShouldBeNil)
Convey("then the expected check is returned", func() {
So(check.Name(), ShouldEqual, service)
So(check.Status(), ShouldEqual, healthcheck.StatusCritical)
So(check.StatusCode(), ShouldEqual, 400)
So(check.Message(), ShouldEqual, service+health.StatusMessage[healthcheck.StatusCritical])
So(*check.LastChecked(), ShouldHappenAfter, timePriorHealthCheck)
So(check.LastSuccess(), ShouldBeNil)
So(*check.LastFailure(), ShouldHappenAfter, timePriorHealthCheck)
})
Convey("and client.Do should be called once with the expected parameters", func() {
doCalls := httpClient.DoCalls()
So(doCalls, ShouldHaveLength, 1)
So(doCalls[0].Req.URL.Path, ShouldEqual, path)
})
})
})
Convey("given clienter.Do returns 500 response", t, func() {
httpClient := createHTTPClientMock(http.StatusInternalServerError, []byte(""))
searchClient := newSearchClient(httpClient)
check := initialState
Convey("when searchClient.Checker is called", func() {
err := searchClient.Checker(ctx, &check)
So(err, ShouldBeNil)
Convey("then the expected check is returned", func() {
So(check.Name(), ShouldEqual, service)
So(check.Status(), ShouldEqual, healthcheck.StatusCritical)
So(check.StatusCode(), ShouldEqual, 500)
So(check.Message(), ShouldEqual, service+health.StatusMessage[healthcheck.StatusCritical])
So(*check.LastChecked(), ShouldHappenAfter, timePriorHealthCheck)
So(check.LastSuccess(), ShouldBeNil)
So(*check.LastFailure(), ShouldHappenAfter, timePriorHealthCheck)
})
Convey("and client.Do should be called once with the expected parameters", func() {
doCalls := httpClient.DoCalls()
So(doCalls, ShouldHaveLength, 1)
So(doCalls[0].Req.URL.Path, ShouldEqual, path)
})
})
})
} | explode_data.jsonl/75479 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1167
} | [
2830,
3393,
2959,
62,
14542,
35188,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
21957,
49471,
14542,
3973,
1669,
882,
13244,
741,
26781,
1669,
3521,
12120,
1837,
93070,
5617,
445,
41968,
2943,
261,
33596,
4675,
458,
1465,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVerifyOneToManyComplexSaveJoinCache(t *testing.T) {
pers, address, city, one2m, err := simpleOneToMany()
city.UseRecordPrimaryKeys = true
if err != nil {
t.Fatal(err)
}
err = pers.CreateTables(city, address)
if err != nil {
t.Fatal(err)
}
cityRec1, err := makeCityRecord1(city, City1PK)
if err != nil {
t.Fatal(err)
}
addressRec1, err := makeAddressRecord1(address, Address1PK)
err = addressRec1.AddRelationRecord(one2m, cityRec1)
if err != nil {
t.Fatal(err)
}
log.Println("Saving address 1")
err = pers.Save(addressRec1)
if err != nil {
t.Fatal(err)
}
// cityRec2, err := makeCityRecord1(city, City1PK)
// if err != nil {
// t.Fatal(err)
// }
addressRec2, err := makeAddressRecord1(address, Address2PK)
err = addressRec2.AddRelationRecord(one2m, cityRec1)
if err != nil {
t.Fatal(err)
}
log.Println("Saving address 2")
err = pers.Save(addressRec2)
if err != nil {
t.Fatal(err)
}
////
defer pers.Done()
} | explode_data.jsonl/61920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 407
} | [
2830,
3393,
32627,
57482,
31137,
8784,
12292,
8233,
1155,
353,
8840,
836,
8,
341,
3223,
388,
11,
2621,
11,
3283,
11,
825,
17,
76,
11,
1848,
1669,
4285,
57482,
741,
1444,
487,
9046,
6471,
15972,
8850,
284,
830,
198,
743,
1848,
961,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestValidatePodSpec(t *testing.T) {
activeDeadlineSeconds := int64(30)
successCases := []api.PodSpec{
{ // Populate basic fields, leave defaults for most.
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
{ // Populate all fields.
Volumes: []api.Volume{
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
RestartPolicy: api.RestartPolicyAlways,
NodeSelector: map[string]string{
"key": "value",
},
NodeName: "foobar",
DNSPolicy: api.DNSClusterFirst,
ActiveDeadlineSeconds: &activeDeadlineSeconds,
ServiceAccountName: "acct",
},
{ // Populate HostNetwork.
Containers: []api.Container{
{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", Ports: []api.ContainerPort{
{HostPort: 8080, ContainerPort: 8080, Protocol: "TCP"}},
},
},
HostNetwork: true,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
}
for i := range successCases {
if errs := ValidatePodSpec(&successCases[i]); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
activeDeadlineSeconds = int64(0)
failureCases := map[string]api.PodSpec{
"bad volume": {
Volumes: []api.Volume{{}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
},
"no containers": {
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
"bad container": {
Containers: []api.Container{{}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
"bad DNS policy": {
DNSPolicy: api.DNSPolicy("invalid"),
RestartPolicy: api.RestartPolicyAlways,
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
},
"bad service account name": {
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
ServiceAccountName: "invalidName",
},
"bad restart policy": {
RestartPolicy: "UnknowPolicy",
DNSPolicy: api.DNSClusterFirst,
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
},
"with hostNetwork hostPort not equal to containerPort": {
Containers: []api.Container{
{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", Ports: []api.ContainerPort{
{HostPort: 8080, ContainerPort: 2600, Protocol: "TCP"}},
},
},
HostNetwork: true,
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
"bad-active-deadline-seconds": {
Volumes: []api.Volume{
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
Containers: []api.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent"}},
RestartPolicy: api.RestartPolicyAlways,
NodeSelector: map[string]string{
"key": "value",
},
NodeName: "foobar",
DNSPolicy: api.DNSClusterFirst,
ActiveDeadlineSeconds: &activeDeadlineSeconds,
},
}
for k, v := range failureCases {
if errs := ValidatePodSpec(&v); len(errs) == 0 {
t.Errorf("expected failure for %q", k)
}
}
} | explode_data.jsonl/62796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1550
} | [
2830,
3393,
17926,
23527,
8327,
1155,
353,
8840,
836,
8,
341,
74770,
83593,
15343,
1669,
526,
21,
19,
7,
18,
15,
340,
30553,
37302,
1669,
3056,
2068,
88823,
8327,
515,
197,
197,
90,
442,
70938,
6770,
5043,
11,
5274,
16674,
369,
1429,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestLocalTemporaryTableInsertOnDuplicateKeyUpdate(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create temporary table tmp1 (id int primary key auto_increment, u int unique, v int)")
tk.MustExec("insert into tmp1 values(1, 11, 101)")
tk.MustExec("insert into tmp1 values(2, 12, 102)")
// test outside transaction
tk.MustExec("insert ignore into tmp1 values(1, 100, 1000) on duplicate key update u=12")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1062 Duplicate entry '12' for key 'u'"))
tk.MustQuery("select * from tmp1 where id=1").Check(testkit.Rows("1 11 101"))
tk.MustExec("insert into tmp1 values(2, 100, 1000) on duplicate key update v=202")
tk.MustQuery("show warnings").Check(testkit.Rows())
tk.MustQuery("select * from tmp1 where id=2").Check(testkit.Rows("2 12 202"))
tk.MustExec("insert into tmp1 values(3, 13, 103) on duplicate key update v=203")
tk.MustQuery("show warnings").Check(testkit.Rows())
tk.MustQuery("select * from tmp1 where id=3").Check(testkit.Rows("3 13 103"))
// test in transaction and rollback
tk.MustExec("begin")
tk.MustExec("insert ignore into tmp1 values(1, 100, 1000) on duplicate key update u=12")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1062 Duplicate entry '12' for key 'u'"))
tk.MustQuery("select * from tmp1 where id=1").Check(testkit.Rows("1 11 101"))
tk.MustExec("insert into tmp1 values(2, 100, 1000) on duplicate key update v=302")
tk.MustQuery("show warnings").Check(testkit.Rows())
tk.MustQuery("select * from tmp1 where id=2").Check(testkit.Rows("2 12 302"))
tk.MustExec("insert into tmp1 values(4, 14, 104) on duplicate key update v=204")
tk.MustQuery("show warnings").Check(testkit.Rows())
tk.MustQuery("select * from tmp1 where id=4").Check(testkit.Rows("4 14 104"))
tk.MustExec("rollback")
tk.MustQuery("select * from tmp1").Check(testkit.Rows("1 11 101", "2 12 202", "3 13 103"))
// test commit
tk.MustExec("begin")
tk.MustExec("insert ignore into tmp1 values(1, 100, 1000) on duplicate key update u=12")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1062 Duplicate entry '12' for key 'u'"))
tk.MustExec("insert into tmp1 values(2, 100, 1000) on duplicate key update v=302")
tk.MustExec("insert into tmp1 values(4, 14, 104) on duplicate key update v=204")
tk.MustExec("commit")
tk.MustQuery("select * from tmp1").Check(testkit.Rows("1 11 101", "2 12 302", "3 13 103", "4 14 104"))
} | explode_data.jsonl/5724 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 868
} | [
2830,
3393,
7319,
59362,
2556,
13780,
1925,
53979,
1592,
4289,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestServer_ImageConvert(t *testing.T) {
// create image
imgName, downImg := models.NewImageForTest(t)
tf, err := os.Open(imgName)
assert.Nil(t, err)
defer tf.Close()
// create token
token, trx, down, err := models.NewArbitrarilyTokenForTest(nil, t)
rootPath := models.NewTempDirForTest()
assert.Nil(t, err)
defer func() {
down(t)
downImg(t)
if util.IsDir(rootPath) {
os.RemoveAll(rootPath)
}
}()
testDbConn = trx
testRootPath = &rootPath
file, err := models.CreateFileFromReader(&token.App, "/random/r.bytes", tf, int8(0), testRootPath, trx)
assert.Nil(t, err)
// create server
const bufSize = 1024 * 1024
lis := bufconn.Listen(bufSize)
s := grpc.NewServer()
RegisterImageConvertServer(s, &Server{})
go func() { _ = s.Serve(lis) }()
dialer := func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}
ctx := newContext(context.Background())
// create client
conn, err := grpc.DialContext(ctx, "bufnet", grpc.WithContextDialer(dialer), grpc.WithInsecure())
assert.Nil(t, err)
client := NewImageConvertClient(conn)
req := &ImageConvertRequest{Token: token.UID, FileUid: file.UID, Width: 100, Height: 100, Type: "zoom"}
streamClient, err := client.ImageConvert(ctx, req)
assert.Nil(t, err)
header, err := streamClient.Header()
assert.Nil(t, err)
headerSize, err := strconv.Atoi(header.Get("size")[0])
assert.Nil(t, err)
dataBuffer := new(bytes.Buffer)
for {
if resp, err := streamClient.Recv(); err != nil {
if err != io.EOF {
t.Fatal(err)
} else {
break
}
} else {
_, err = dataBuffer.Write(resp.Content)
assert.Nil(t, err)
}
}
dataHash, err := util.Sha256Hash2String(dataBuffer.Bytes())
assert.Nil(t, err)
assert.Equal(t, dataBuffer.Len(), headerSize)
assert.Equal(t, header.Get("hash")[0], dataHash)
req.Token = ""
streamClient, err = client.ImageConvert(ctx, req)
assert.Nil(t, err)
_, err = streamClient.Recv()
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "record not found")
req.Token = token.UID
req.FileUid = ""
streamClient, err = client.ImageConvert(ctx, req)
assert.Nil(t, err)
_, err = streamClient.Recv()
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "record not found")
req.FileUid = file.UID
assert.Nil(t, trx.Model(token).Update("path", "/hello").Error)
streamClient, err = client.ImageConvert(ctx, req)
assert.Nil(t, err)
_, err = streamClient.Recv()
assert.NotNil(t, err)
statusError, ok := status.FromError(err)
assert.True(t, ok)
assert.Contains(t, statusError.Message(), models.ErrAccessDenied.Error())
} | explode_data.jsonl/30086 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1034
} | [
2830,
3393,
5475,
45949,
12012,
1155,
353,
8840,
836,
8,
341,
197,
322,
1855,
2168,
198,
39162,
675,
11,
1495,
13033,
1669,
4119,
7121,
1906,
2461,
2271,
1155,
340,
3244,
69,
11,
1848,
1669,
2643,
12953,
11022,
675,
340,
6948,
59678,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestADS1x15StartAndHalt(t *testing.T) {
d, _ := initTestADS1015DriverWithStubbedAdaptor()
gobottest.Assert(t, d.Start(), nil)
gobottest.Refute(t, d.Connection(), nil)
gobottest.Assert(t, d.Halt(), nil)
} | explode_data.jsonl/42581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
49541,
16,
87,
16,
20,
3479,
3036,
39,
3145,
1155,
353,
8840,
836,
8,
341,
2698,
11,
716,
1669,
2930,
2271,
49541,
16,
15,
16,
20,
11349,
2354,
33838,
2721,
2589,
32657,
741,
3174,
674,
1716,
477,
11711,
1155,
11,
294,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSecureRouteInNodePort(t *testing.T) {
g := gomega.NewGomegaWithT(t)
integrationtest.SetNodePortMode()
defer integrationtest.SetClusterIPMode()
nodeIP := "10.1.1.2"
integrationtest.CreateNode(t, "testNodeNP", nodeIP)
defer integrationtest.DeleteNode(t, "testNodeNP")
SetUpTestForRouteInNodePort(t, DefaultModelName)
routeExample := FakeRoute{Path: "/foo"}.SecureRoute()
_, err := OshiftClient.RouteV1().Routes(DefaultNamespace).Create(routeExample)
if err != nil {
t.Fatalf("error in adding route: %v", err)
}
aviModel := ValidateSniModel(t, g, DefaultModelName)
g.Expect(aviModel.(*avinodes.AviObjectGraph).GetAviVS()[0].SniNodes).To(gomega.HaveLen(1))
sniVS := aviModel.(*avinodes.AviObjectGraph).GetAviVS()[0].SniNodes[0]
g.Eventually(func() string {
sniVS = aviModel.(*avinodes.AviObjectGraph).GetAviVS()[0].SniNodes[0]
return sniVS.VHDomainNames[0]
}, 50*time.Second).Should(gomega.Equal(DefaultHostname))
VerifySniNode(g, sniVS)
VerifySecureRouteDeletion(t, g, DefaultModelName, 0, 0)
TearDownTestForRouteInNodePort(t, DefaultModelName)
} | explode_data.jsonl/46184 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 430
} | [
2830,
3393,
49813,
4899,
641,
1955,
7084,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
2084,
17376,
1944,
4202,
1955,
7084,
3636,
741,
16867,
17590,
1944,
4202,
28678,
3298,
3636,
741,
2083... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetRotationRequest_Validate(t *testing.T) {
getRequest := &GetRotationRequest{}
err := getRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Schedule identifier cannot be empty.").Error())
getRequest.ScheduleIdentifierType = Name
getRequest.ScheduleIdentifierValue = "test"
err = getRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Rotation Id cannot be empty.").Error())
} | explode_data.jsonl/64420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
1949,
18440,
1900,
62,
17926,
1155,
353,
8840,
836,
8,
341,
10366,
1900,
1669,
609,
1949,
18440,
1900,
16094,
9859,
1669,
78731,
47667,
741,
6948,
12808,
1155,
11,
1848,
6141,
1507,
5975,
7121,
445,
32210,
12816,
4157,
387,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEvalCloseProvider(t *testing.T) {
n := &EvalCloseProvider{
Addr: addrs.ProviderConfig{Type: "foo"},
}
provider := &MockProvider{}
ctx := &MockEvalContext{CloseProviderProvider: provider}
if _, err := n.Eval(ctx); err != nil {
t.Fatalf("err: %s", err)
}
if !ctx.CloseProviderCalled {
t.Fatal("should be called")
}
if ctx.CloseProviderAddr.String() != "provider.foo" {
t.Fatalf("wrong provider address %s", ctx.CloseProviderAddr)
}
} | explode_data.jsonl/3214 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
54469,
7925,
5179,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
609,
54469,
7925,
5179,
515,
197,
197,
13986,
25,
912,
5428,
36208,
2648,
90,
929,
25,
330,
7975,
7115,
197,
532,
197,
19979,
1669,
609,
11571,
5179,
16094,
2098... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestNewProgressReader(t *testing.T) {
type args struct {
r io.Reader
progressFunc func(float64)
}
tests := []struct {
name string
args args
want *ProgressReader
wantErr bool
}{
{
name: "",
args: args{
r: strings.NewReader("one\ntwo\nthree\n"),
progressFunc: nil,
},
want: &ProgressReader{
strings.NewReader("one\ntwo\nthree\n"),
0,
0,
nil,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewProgressReader(tt.args.r, tt.args.progressFunc)
if (err != nil) != tt.wantErr {
t.Errorf("NewProgressReader() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewProgressReader() got = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/56819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
3564,
9496,
5062,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
7000,
310,
6399,
47431,
198,
197,
88971,
9626,
2915,
8268,
21,
19,
340,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDockerBuildDescription(t *testing.T) {
artifact := &latest.Artifact{
ArtifactType: latest.ArtifactType{
DockerArtifact: &latest.DockerArtifact{
DockerfilePath: "Dockerfile",
BuildArgs: map[string]*string{
"arg1": util.StringPtr("value1"),
"arg2": nil,
},
},
},
}
builder := Builder{
GoogleCloudBuild: &latest.GoogleCloudBuild{
DockerImage: "docker/docker",
DiskSizeGb: 100,
MachineType: "n1-standard-1",
Timeout: "10m",
},
}
desc, err := builder.buildDescription(artifact, "nginx", "bucket", "object")
expected := cloudbuild.Build{
LogsBucket: "bucket",
Source: &cloudbuild.Source{
StorageSource: &cloudbuild.StorageSource{
Bucket: "bucket",
Object: "object",
},
},
Steps: []*cloudbuild.BuildStep{{
Name: "docker/docker",
Args: []string{"build", "--tag", "nginx", "-f", "Dockerfile", "--build-arg", "arg1=value1", "--build-arg", "arg2", "."},
}},
Images: []string{"nginx"},
Options: &cloudbuild.BuildOptions{
DiskSizeGb: 100,
MachineType: "n1-standard-1",
},
Timeout: "10m",
}
testutil.CheckErrorAndDeepEqual(t, false, err, expected, *desc)
} | explode_data.jsonl/1806 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
35,
13659,
11066,
5009,
1155,
353,
8840,
836,
8,
341,
197,
63722,
1669,
609,
19350,
50064,
20754,
515,
197,
197,
85578,
929,
25,
5535,
50064,
20754,
929,
515,
298,
10957,
13659,
85578,
25,
609,
19350,
909,
13659,
85578,
515,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConsumersRestoreIPAllocation(t *testing.T) {
stopCh := make(chan struct{})
defer close(stopCh)
eip := newExternalIPPool("eip1", "", "10.10.10.2", "10.10.10.10")
controller := newController([]runtime.Object{eip})
controller.AddEventHandler(func(ippool string) {})
controller.AddEventHandler(func(ippool string) {})
controller.crdInformerFactory.Start(stopCh)
controller.crdInformerFactory.WaitForCacheSync(stopCh)
go controller.Run(stopCh)
require.True(t, cache.WaitForCacheSync(stopCh, controller.HasSynced))
allocatedIPCh := make(chan string)
go func() {
allocatedIPs := []IPAllocation{
{
IPPoolName: "eip1",
IP: net.ParseIP("10.10.10.2"),
},
}
restored := controller.RestoreIPAllocations(allocatedIPs)
assert.Equal(t, allocatedIPs, restored)
ip, err := controller.AllocateIPFromPool("eip1")
assert.NoError(t, err)
allocatedIPCh <- ip.String()
}()
go func() {
allocatedIPs := []IPAllocation{
{
IPPoolName: "eip1",
IP: net.ParseIP("10.10.10.3"),
},
}
restored := controller.RestoreIPAllocations(allocatedIPs)
assert.Equal(t, allocatedIPs, restored)
ip, err := controller.AllocateIPFromPool("eip1")
assert.NoError(t, err)
allocatedIPCh <- ip.String()
}()
var allocated [2]string
for idx := 0; idx < len(allocated); idx++ {
allocated[idx] = <-allocatedIPCh
}
sort.Strings(allocated[:])
assert.Equal(t, "10.10.10.4", allocated[0])
assert.Equal(t, "10.10.10.5", allocated[1])
} | explode_data.jsonl/10262 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 617
} | [
2830,
3393,
41966,
388,
56284,
3298,
78316,
1155,
353,
8840,
836,
8,
341,
62644,
1143,
1669,
1281,
35190,
2036,
37790,
16867,
3265,
60170,
1143,
340,
7727,
573,
1669,
501,
25913,
3298,
10551,
445,
68,
573,
16,
497,
7342,
330,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUpdateRelease_NestedReuseValues(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()
installReq := &services.InstallReleaseRequest{
Namespace: "spaced",
Chart: &chart.Chart{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "templates/hello", Data: []byte("hello: world")},
},
Values: &chart.Config{Raw: "defaultFoo: defaultBar"},
},
Values: &chart.Config{Raw: `
foo: bar
root:
nested: nestedValue
anotherNested: anotherNestedValue
`},
}
installResp, err := rs.InstallRelease(c, installReq)
if err != nil {
t.Fatal(err)
}
rel := installResp.Release
req := &services.UpdateReleaseRequest{
Name: rel.Name,
Chart: &chart.Chart{
Metadata: &chart.Metadata{Name: "hello"},
Templates: []*chart.Template{
{Name: "templates/hello", Data: []byte("hello: world")},
},
Values: &chart.Config{Raw: "defaultFoo: defaultBar"},
},
Values: &chart.Config{Raw: `
root:
nested: newNestedValue
`},
ReuseValues: true,
}
res, err := rs.UpdateRelease(c, req)
if err != nil {
t.Fatalf("Failed updated: %s", err)
}
expect, _ := chartutil.ReadValues([]byte(`
foo: bar
root:
nested: newNestedValue
anotherNested: anotherNestedValue
`))
requestConfig, err := chartutil.ReadValues([]byte(res.Release.Config.Raw))
if err != nil {
t.Errorf("Request config could not be parsed: %v", err)
}
if !reflect.DeepEqual(expect, requestConfig) {
t.Errorf("Expected request config to be %v, got %v", expect, requestConfig)
}
} | explode_data.jsonl/82236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 584
} | [
2830,
3393,
4289,
16077,
1604,
9980,
38081,
6227,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
33765,
7121,
1972,
741,
41231,
1669,
10036,
18930,
2822,
197,
12248,
27234,
1669,
609,
12779,
71207,
541,
16077,
1900,
515,
197,
90823,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestSnapshotClear(t *testing.T) {
c := cache.NewSnapshotCache(true, group{}, logger{t: t})
if err := c.SetSnapshot(key, snapshot); err != nil {
t.Fatal(err)
}
c.ClearSnapshot(key)
if empty := c.GetStatusInfo(key); empty != nil {
t.Errorf("cache should be cleared")
}
if keys := c.GetStatusKeys(); len(keys) != 0 {
t.Errorf("keys should be empty")
}
} | explode_data.jsonl/6685 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
15009,
14008,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
6500,
7121,
15009,
8233,
3715,
11,
1874,
22655,
5925,
90,
83,
25,
259,
3518,
743,
1848,
1669,
272,
4202,
15009,
4857,
11,
16295,
1215,
1848,
961,
2092,
341,
197,
3244... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestOwners_UpdateOwnerPassword(t *testing.T) {
m := NewClient(os.Getenv("MNUBO_CLIENT_ID"), os.Getenv("MNUBO_CLIENT_SECRET"), os.Getenv("MNUBO_HOST"))
id := uuid.New().String()
o := SimpleOwner{
Username: id,
}
var results interface{}
e1, e2 := m.Owners.Create(o, &results), m.Owners.UpdateOwnerPassword(id, "test")
if e1 != nil {
t.Errorf("client call failed: %+v", e1)
}
if e2 != nil {
t.Errorf("client call failed: %+v", e2)
}
} | explode_data.jsonl/81386 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
57762,
47393,
13801,
4876,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
2959,
9638,
64883,
445,
44,
3926,
4677,
22521,
3450,
3975,
2643,
64883,
445,
44,
3926,
4677,
22521,
31408,
3975,
2643,
64883,
445,
44,
3926,
4677,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAStar(t *testing.T) {
for _, test := range aStarTests {
pt, _ := path.AStar(concrete.Node(test.s), concrete.Node(test.t), test.g, test.heuristic)
p, cost := pt.To(concrete.Node(test.t))
if !topo.IsPathIn(test.g, p) {
t.Error("got path that is not path in input graph for %q", test.name)
}
bfp, ok := path.BellmanFordFrom(concrete.Node(test.s), test.g)
if !ok {
t.Fatalf("unexpected negative cycle in %q", test.name)
}
if want := bfp.WeightTo(concrete.Node(test.t)); cost != want {
t.Errorf("unexpected cost for %q: got:%v want:%v", test.name, cost, want)
}
var got = make([]int, 0, len(p))
for _, n := range p {
got = append(got, n.ID())
}
if test.wantPath != nil && !reflect.DeepEqual(got, test.wantPath) {
t.Errorf("unexpected result for %q:\ngot: %v\nwant:%v", test.name, got, test.wantPath)
}
}
} | explode_data.jsonl/34427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
32,
12699,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
264,
12699,
18200,
341,
197,
60796,
11,
716,
1669,
1815,
875,
12699,
17868,
9353,
21714,
8623,
514,
701,
14175,
21714,
8623,
734,
701,
1273,
1302,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestUnionFindSet(t *testing.T) {
initUnionFindSet(10)
printUnionFindSet()
merge(0, 1)
merge(0, 2)
merge(3, 4)
merge(3, 1)
merge(5, 7)
merge(7, 8)
merge(7, 8)
printUnionFindSet()
fmt.Println("count:", count())
} | explode_data.jsonl/58680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
32658,
9885,
1649,
1155,
353,
8840,
836,
8,
341,
28248,
32658,
9885,
1649,
7,
16,
15,
340,
6900,
32658,
9885,
1649,
2822,
197,
19052,
7,
15,
11,
220,
16,
340,
197,
19052,
7,
15,
11,
220,
17,
340,
197,
19052,
7,
18,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQueryAggregate(t *testing.T) {
setupServer()
defer teardownServer()
mux.HandleFunc("/url", func(w http.ResponseWriter, r *http.Request) {
assertBody(t, `{"aggregation":[{"bah":{"name":"foo"}}]}`, r.Body)
fmt.Fprintf(w, `"body"`)
})
req := URL("http://example.com/url")
req.Aggregate("foo", "bah")
if err := req.Post(); err != nil {
t.Error(err)
}
assertTextualBody(t, `"body"`, req.Response.Body)
assertMethod(t, "POST", req.Request.Method)
} | explode_data.jsonl/24768 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
2859,
64580,
1155,
353,
8840,
836,
8,
341,
84571,
5475,
741,
16867,
49304,
5475,
2822,
2109,
2200,
63623,
4283,
1085,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6948,
5444,
1155,
11,
1565,
4913,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReqMustRevalidate(t *testing.T) {
resetTest()
// not paying attention to request setting max-stale means never returning stale
// responses, so always acting as if must-revalidate is set
respHeaders := http.Header{}
reqHeaders := http.Header{}
reqHeaders.Set("Cache-Control", "must-revalidate")
if getFreshness(respHeaders, reqHeaders) != stale {
t.Fatal("freshness isn't stale")
}
} | explode_data.jsonl/77630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
27234,
31776,
693,
7067,
1155,
353,
8840,
836,
8,
341,
70343,
2271,
741,
197,
322,
537,
12515,
6529,
311,
1681,
6243,
1932,
5477,
1574,
3363,
2581,
13451,
50351,
198,
197,
322,
14507,
11,
773,
2677,
15358,
438,
421,
1969,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIsDocumentation(t *testing.T) {
tests := []struct {
name string
path string
expected bool
}{
{name: "TestIsDocumentation_1", path: "foo", expected: false},
{name: "TestIsDocumentation_2", path: "README", expected: true},
}
for _, test := range tests {
is := IsDocumentation(test.path)
assert.Equal(t, is, test.expected, fmt.Sprintf("%v: is = %v, expected: %v", test.name, is, test.expected))
}
} | explode_data.jsonl/20380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
3872,
64334,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
26781,
257,
914,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
47006,
25,
330,
2271,
3872,
64334,
62,
16,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReference_String(t *testing.T) {
t.Parallel()
cases := []struct {
name string
ref *Reference
exp string
}{
{
"sm_plain",
&Reference{project: "project", name: "secret", typ: ReferenceTypeSecretManager},
"sm://project/secret",
},
{
"sm_version",
&Reference{project: "project", name: "secret", version: "123", typ: ReferenceTypeSecretManager},
"sm://project/secret#123",
},
{
"berglas_plain",
&Reference{bucket: "bucket", object: "secret", typ: ReferenceTypeStorage},
"berglas://bucket/secret",
},
{
"berglas_generation",
&Reference{bucket: "bucket", object: "secret", generation: 1234567890, typ: ReferenceTypeStorage},
"berglas://bucket/secret#1234567890",
},
}
for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
act, exp := tc.ref.String(), tc.exp
if act != tc.exp {
t.Errorf("expected %#v to be %#v", act, exp)
}
})
}
} | explode_data.jsonl/20805 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
8856,
31777,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
59504,
220,
353,
8856,
198,
197,
48558,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCountingSort(t *testing.T) {
for _, table := range testTable {
got := CountingSort(table.input, 10) // instead of 10, this should be the largest element in the array
for idx := range got {
if table.expected[idx] != got[idx] {
t.Errorf("CountingSort(%v), expected: %v, got: %v", table.input, table.expected, got)
break
}
}
}
} | explode_data.jsonl/9277 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
2507,
287,
10231,
1155,
353,
8840,
836,
8,
314,
715,
2023,
8358,
1965,
1669,
2088,
1273,
2556,
341,
197,
3174,
354,
1669,
4504,
287,
10231,
15761,
10046,
11,
220,
16,
15,
8,
442,
4518,
315,
220,
16,
15,
11,
419,
1265,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestHandleNewValidator(t *testing.T) {
// initial setup
ctx, ck, sk, _, keeper := createTestInput(t, keeperTestParams())
addr, val := addrs[0], pks[0]
amt := sdk.TokensFromTendermintPower(100)
sh := staking.NewHandler(sk)
// 1000 first blocks not a validator
ctx = ctx.WithBlockHeight(keeper.SignedBlocksWindow(ctx) + 1)
// Validator created
got := sh(ctx, NewTestMsgCreateValidator(addr, val, amt))
require.True(t, got.IsOK())
staking.EndBlocker(ctx, sk)
require.Equal(
t, ck.GetCoins(ctx, sdk.AccAddress(addr)),
sdk.Coins{sdk.NewCoin(sk.GetParams(ctx).BondDenom, initCoins.Sub(amt))},
)
require.Equal(t, amt, sk.Validator(ctx, addr).GetBondedTokens())
// Now a validator, for two blocks
keeper.handleValidatorSignature(ctx, val.Address(), 100, true)
ctx = ctx.WithBlockHeight(keeper.SignedBlocksWindow(ctx) + 2)
keeper.handleValidatorSignature(ctx, val.Address(), 100, false)
info, found := keeper.getValidatorSigningInfo(ctx, sdk.ConsAddress(val.Address()))
require.True(t, found)
require.Equal(t, keeper.SignedBlocksWindow(ctx)+1, info.StartHeight)
require.Equal(t, int64(2), info.IndexOffset)
require.Equal(t, int64(1), info.MissedBlocksCounter)
require.Equal(t, time.Unix(0, 0).UTC(), info.JailedUntil)
// validator should be bonded still, should not have been jailed or slashed
validator, _ := sk.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(val))
require.Equal(t, sdk.Bonded, validator.GetStatus())
pool := sk.GetPool(ctx)
expTokens := sdk.TokensFromTendermintPower(100)
require.Equal(t, expTokens, pool.BondedTokens)
} | explode_data.jsonl/44698 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 589
} | [
2830,
3393,
6999,
3564,
14256,
1155,
353,
8840,
836,
8,
341,
197,
322,
2856,
6505,
198,
20985,
11,
38613,
11,
1901,
11,
8358,
53416,
1669,
1855,
2271,
2505,
1155,
11,
53416,
2271,
4870,
2398,
53183,
11,
1044,
1669,
912,
5428,
58,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFleetResourceValidation(t *testing.T) {
t.Parallel()
ctx := context.Background()
client := framework.AgonesClient.AgonesV1()
// check two Containers in Gameserver Spec Template validation
flt := defaultFleet(framework.Namespace)
containerName := "container2"
resources := corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("30m"),
corev1.ResourceMemory: resource.MustParse("32Mi"),
},
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("30m"),
corev1.ResourceMemory: resource.MustParse("32Mi"),
},
}
flt.Spec.Template.Spec.Template =
corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{Name: "container", Image: framework.GameServerImage, Resources: *(resources.DeepCopy())},
{Name: containerName, Image: framework.GameServerImage, Resources: *(resources.DeepCopy())},
},
},
}
mi128 := resource.MustParse("128Mi")
m50 := resource.MustParse("50m")
flt.Spec.Template.Spec.Container = containerName
containers := flt.Spec.Template.Spec.Template.Spec.Containers
containers[1].Resources.Limits[corev1.ResourceMemory] = resource.MustParse("64Mi")
containers[1].Resources.Requests[corev1.ResourceMemory] = mi128
_, err := client.Fleets(framework.Namespace).Create(ctx, flt.DeepCopy(), metav1.CreateOptions{})
assert.NotNil(t, err)
statusErr, ok := err.(*k8serrors.StatusError)
assert.True(t, ok)
assert.Len(t, statusErr.Status().Details.Causes, 1)
assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[0].Type)
assert.Equal(t, "container", statusErr.Status().Details.Causes[0].Field)
containers[0].Resources.Limits[corev1.ResourceCPU] = resource.MustParse("-50m")
_, err = client.Fleets(framework.Namespace).Create(ctx, flt.DeepCopy(), metav1.CreateOptions{})
assert.NotNil(t, err)
statusErr, ok = err.(*k8serrors.StatusError)
assert.True(t, ok)
assert.Len(t, statusErr.Status().Details.Causes, 3)
assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[0].Type)
assert.Equal(t, "container", statusErr.Status().Details.Causes[0].Field)
causes := statusErr.Status().Details.Causes
assertCausesContainsString(t, causes, "Request must be less than or equal to cpu limit")
assertCausesContainsString(t, causes, "Resource cpu limit value must be non negative")
assertCausesContainsString(t, causes, "Request must be less than or equal to memory limit")
containers[1].Resources.Limits[corev1.ResourceMemory] = mi128
containers[0].Resources.Limits[corev1.ResourceCPU] = m50
flt, err = client.Fleets(framework.Namespace).Create(ctx, flt.DeepCopy(), metav1.CreateOptions{})
if assert.NoError(t, err) {
defer client.Fleets(framework.Namespace).Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint:errcheck
}
containers = flt.Spec.Template.Spec.Template.Spec.Containers
assert.Equal(t, mi128, containers[1].Resources.Limits[corev1.ResourceMemory])
assert.Equal(t, m50, containers[0].Resources.Limits[corev1.ResourceCPU])
} | explode_data.jsonl/15433 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1103
} | [
2830,
3393,
37,
18973,
4783,
13799,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
2266,
19047,
2822,
25291,
1669,
12626,
49850,
3154,
2959,
49850,
3154,
53,
16,
2822,
197,
322,
1779,
1378,
98293,
304,
11610,
2836,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTerminalSetSize(t *testing.T) {
for _, setSize := range setSizeTests {
c := &MockTerminal{
toSend: []byte("password\r\x1b[A\r"),
bytesPerRead: 1,
}
ss := NewTerminal(c, "> ")
ss.SetSize(setSize.width, setSize.height)
pw, _ := ss.ReadPassword("Password: ")
if pw != "password" {
t.Fatalf("failed to read password, got %s", pw)
}
if string(c.received) != "Password: \r\n" {
t.Errorf("failed to set the temporary prompt expected %q, got %q", "Password: ", c.received)
}
}
} | explode_data.jsonl/34110 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
47890,
1649,
1695,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
83859,
1669,
2088,
83859,
18200,
341,
197,
1444,
1669,
609,
11571,
47890,
515,
298,
31709,
11505,
25,
981,
3056,
3782,
445,
3833,
12016,
3462,
16,
65,
22519,
12016... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestMetaMapDeserialization(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendNil(b)
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Nil(t, s.Meta)
})
t.Run("Empty", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 0)
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Nil(t, s.Meta)
})
t.Run("StrType", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 1)
b = msgp.AppendString(b, "key")
b = msgp.AppendString(b, "value")
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Equal(t, map[string]string{"key": "value"}, s.Meta)
})
t.Run("BinType", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 1)
b = msgp.AppendBytes(b, []byte("key"))
b = msgp.AppendBytes(b, []byte("value"))
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Equal(t, map[string]string{"key": "value"}, s.Meta)
})
t.Run("StrType_InvalidUTF8", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 1)
b = msgp.AppendString(b, "key")
b = msgp.AppendString(b, "op\x99\xbf")
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Equal(t, map[string]string{"key": "op��"}, s.Meta)
})
t.Run("BinType_InvalidUTF8", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 1)
b = msgp.AppendBytes(b, []byte("key"))
b = msgp.AppendBytes(b, []byte("op\x99\xbf"))
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Equal(t, map[string]string{"key": "op��"}, s.Meta)
})
t.Run("Nil_key", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 1)
b = msgp.AppendNil(b)
b = msgp.AppendString(b, "val")
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Equal(t, map[string]string{"": "val"}, s.Meta)
})
t.Run("Nil_val", func(t *testing.T) {
b := newEmptyMessage()
b = msgp.AppendString(b, "meta")
b = msgp.AppendMapHeader(b, 1)
b = msgp.AppendString(b, "key")
b = msgp.AppendNil(b)
s, err := decodeBytes(b)
assert.Nil(t, err)
assert.Equal(t, map[string]string{"key": ""}, s.Meta)
})
} | explode_data.jsonl/53255 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1130
} | [
2830,
3393,
12175,
2227,
4896,
50563,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
19064,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2233,
1669,
501,
3522,
2052,
741,
197,
2233,
284,
3750,
79,
8982,
703,
1883,
11,
330,
5490,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestYoutube_DownloadWithHighQualityFails(t *testing.T) {
tests := []struct {
name string
formats []youtube.Format
message string
}{
{
name: "video format not found",
formats: []youtube.Format{{ItagNo: 140}},
message: "no video format found after filtering",
},
{
name: "audio format not found",
formats: []youtube.Format{{ItagNo: 137, Quality: "hd1080", MimeType: "video/mp4", AudioChannels: 0}},
message: "no audio format found after filtering",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
video := &youtube.Video{
Formats: tt.formats,
}
err := testDownloader.DownloadComposite(context.Background(), "", video, "hd1080", "")
assert.EqualError(t, err, tt.message)
})
}
} | explode_data.jsonl/66734 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 306
} | [
2830,
3393,
91667,
1557,
37702,
2354,
11976,
33074,
37,
6209,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
37410,
1862,
3056,
43978,
9978,
198,
197,
24753,
914,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWithDefaults(t *testing.T) {
for name, testcase := range map[string]struct {
build config.Build
targets []string
goBinary string
}{
"full": {
build: config.Build{
ID: "foo",
Binary: "foo",
Goos: []string{
"linux",
"windows",
"darwin",
},
Goarch: []string{
"amd64",
"arm",
"mips",
},
Goarm: []string{
"6",
},
Gomips: []string{
"softfloat",
},
GoBinary: "go1.2.3",
},
targets: []string{
"linux_amd64",
"linux_mips_softfloat",
"darwin_amd64",
"windows_amd64",
"windows_arm_6",
"linux_arm_6",
},
goBinary: "go1.2.3",
},
"empty": {
build: config.Build{
ID: "foo2",
Binary: "foo",
},
targets: []string{
"linux_amd64",
"linux_386",
"linux_arm64",
"darwin_amd64",
"darwin_arm64",
},
goBinary: "go",
},
"custom targets": {
build: config.Build{
ID: "foo3",
Binary: "foo",
Targets: []string{
"linux_386",
"darwin_amd64",
},
},
targets: []string{
"linux_386",
"darwin_amd64",
},
goBinary: "go",
},
} {
t.Run(name, func(t *testing.T) {
config := config.Project{
Builds: []config.Build{
testcase.build,
},
}
ctx := context.New(config)
ctx.Git.CurrentTag = "5.6.7"
build, err := Default.WithDefaults(ctx.Config.Builds[0])
require.NoError(t, err)
require.ElementsMatch(t, build.Targets, testcase.targets)
require.EqualValues(t, testcase.goBinary, build.GoBinary)
})
}
} | explode_data.jsonl/54139 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 846
} | [
2830,
3393,
2354,
16273,
1155,
353,
8840,
836,
8,
341,
2023,
829,
11,
70080,
1669,
2088,
2415,
14032,
60,
1235,
341,
197,
69371,
262,
2193,
25212,
198,
197,
28861,
82,
220,
3056,
917,
198,
197,
30680,
21338,
914,
198,
197,
59403,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCalVotesThreshold(t *testing.T) {
s := DefaultSaftyRules{}
sum := 3
if s.CalVotesThreshold(1, sum) {
t.Error("TestCalVotesThreshold error 1")
}
sum = 4
if !s.CalVotesThreshold(3, sum) {
t.Error("TestCalVotesThreshold error 2")
}
if s.CalVotesThreshold(0, sum) {
t.Error("TestCalVotesThreshold error 0")
}
} | explode_data.jsonl/52167 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
8851,
75535,
37841,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
7899,
52279,
36958,
26008,
16094,
31479,
1669,
220,
18,
198,
743,
274,
727,
278,
75535,
37841,
7,
16,
11,
2629,
8,
341,
197,
3244,
6141,
445,
2271,
8851,
75535,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestWithPadding(t *testing.T) {
type scenario struct {
str string
padding int
expected string
}
scenarios := []scenario{
{
"hello world !",
1,
"hello world !",
},
{
"hello world !",
14,
"hello world ! ",
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, WithPadding(s.str, s.padding))
}
} | explode_data.jsonl/11570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
2354,
21616,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
11355,
414,
914,
198,
197,
40512,
220,
526,
198,
197,
42400,
914,
198,
197,
630,
29928,
60494,
1669,
3056,
61422,
515,
197,
197,
515,
298,
197,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRateSetter_Submit(t *testing.T) {
localID := identity.GenerateLocalIdentity()
localNode := identity.New(localID.PublicKey())
tangle := newTestTangle(Identity(localID), RateSetterConfig(testRateSetterParams))
defer tangle.Shutdown()
rateSetter := NewRateSetter(tangle)
defer rateSetter.Shutdown()
msg := newMessage(localNode.PublicKey())
assert.NoError(t, rateSetter.Issue(msg))
time.Sleep(100 * time.Millisecond)
} | explode_data.jsonl/39583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
11564,
44294,
36359,
1763,
1155,
353,
8840,
836,
8,
341,
8854,
915,
1669,
9569,
57582,
7319,
18558,
741,
8854,
1955,
1669,
9569,
7121,
18082,
915,
49139,
1592,
12367,
3244,
4044,
1669,
501,
2271,
51,
4044,
7,
18558,
18082,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWriteFile(t *testing.T) {
// path := "examples/IM-0001-0001.dcm"
//testWriteFile(t, "examples/CT-MONO2-16-ort.dcm", dicomuid.ExplicitVRBigEndian)
//testWriteFile(t, "examples/CT-MONO2-16-ort.dcm", dicomuid.ImplicitVRLittleEndian)
testWriteFile(t, "examples/CT-MONO2-16-ort.dcm", dicomuid.ExplicitVRLittleEndian)
} | explode_data.jsonl/22623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
7985,
1703,
1155,
353,
8840,
836,
8,
341,
197,
322,
1815,
1669,
330,
51668,
14,
1791,
12,
15,
15,
15,
16,
12,
15,
15,
15,
16,
950,
6226,
698,
197,
322,
1944,
7985,
1703,
1155,
11,
330,
51668,
14,
1162,
5251,
96685,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAuthorizer(t *testing.T) {
tests := []struct {
roles []*rbac.Role
roleBindings []*rbac.RoleBinding
clusterRoles []*rbac.ClusterRole
clusterRoleBindings []*rbac.ClusterRoleBinding
shouldPass []authorizer.Attributes
shouldFail []authorizer.Attributes
}{
{
clusterRoles: []*rbac.ClusterRole{
newClusterRole("admin", newRule("*", "*", "*", "*")),
},
roleBindings: []*rbac.RoleBinding{
newRoleBinding("ns1", "admin", bindToClusterRole, "User:admin", "Group:admins"),
},
shouldPass: []authorizer.Attributes{
&defaultAttributes{"admin", "", "get", "Pods", "", "ns1", ""},
&defaultAttributes{"admin", "", "watch", "Pods", "", "ns1", ""},
&defaultAttributes{"admin", "group1", "watch", "Foobar", "", "ns1", ""},
&defaultAttributes{"joe", "admins", "watch", "Foobar", "", "ns1", ""},
&defaultAttributes{"joe", "group1,admins", "watch", "Foobar", "", "ns1", ""},
},
shouldFail: []authorizer.Attributes{
&defaultAttributes{"admin", "", "GET", "Pods", "", "ns2", ""},
&defaultAttributes{"admin", "", "GET", "Nodes", "", "", ""},
&defaultAttributes{"admin", "admins", "GET", "Pods", "", "ns2", ""},
&defaultAttributes{"admin", "admins", "GET", "Nodes", "", "", ""},
},
},
{
// Non-resource-url tests
clusterRoles: []*rbac.ClusterRole{
newClusterRole("non-resource-url-getter", newRule("get", "", "", "/apis")),
newClusterRole("non-resource-url", newRule("*", "", "", "/apis")),
newClusterRole("non-resource-url-prefix", newRule("get", "", "", "/apis/*")),
},
clusterRoleBindings: []*rbac.ClusterRoleBinding{
newClusterRoleBinding("non-resource-url-getter", "User:foo", "Group:bar"),
newClusterRoleBinding("non-resource-url", "User:admin", "Group:admin"),
newClusterRoleBinding("non-resource-url-prefix", "User:prefixed", "Group:prefixed"),
},
shouldPass: []authorizer.Attributes{
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "foo"}, Verb: "get", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"bar"}}, Verb: "get", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "admin"}, Verb: "get", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"admin"}}, Verb: "get", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "admin"}, Verb: "watch", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"admin"}}, Verb: "watch", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "prefixed"}, Verb: "get", Path: "/apis/v1"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"prefixed"}}, Verb: "get", Path: "/apis/v1"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "prefixed"}, Verb: "get", Path: "/apis/v1/foobar"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"prefixed"}}, Verb: "get", Path: "/apis/v1/foorbar"},
},
shouldFail: []authorizer.Attributes{
// wrong verb
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "foo"}, Verb: "watch", Path: "/apis"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"bar"}}, Verb: "watch", Path: "/apis"},
// wrong path
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "foo"}, Verb: "get", Path: "/api/v1"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"bar"}}, Verb: "get", Path: "/api/v1"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "admin"}, Verb: "get", Path: "/api/v1"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"admin"}}, Verb: "get", Path: "/api/v1"},
// not covered by prefix
authorizer.AttributesRecord{User: &user.DefaultInfo{Name: "prefixed"}, Verb: "get", Path: "/api/v1"},
authorizer.AttributesRecord{User: &user.DefaultInfo{Groups: []string{"prefixed"}}, Verb: "get", Path: "/api/v1"},
},
},
{
// test subresource resolution
clusterRoles: []*rbac.ClusterRole{
newClusterRole("admin", newRule("*", "*", "pods", "*")),
},
roleBindings: []*rbac.RoleBinding{
newRoleBinding("ns1", "admin", bindToClusterRole, "User:admin", "Group:admins"),
},
shouldPass: []authorizer.Attributes{
&defaultAttributes{"admin", "", "get", "pods", "", "ns1", ""},
},
shouldFail: []authorizer.Attributes{
&defaultAttributes{"admin", "", "get", "pods", "status", "ns1", ""},
},
},
{
// test subresource resolution
clusterRoles: []*rbac.ClusterRole{
newClusterRole("admin", newRule("*", "*", "pods/status", "*")),
},
roleBindings: []*rbac.RoleBinding{
newRoleBinding("ns1", "admin", bindToClusterRole, "User:admin", "Group:admins"),
},
shouldPass: []authorizer.Attributes{
&defaultAttributes{"admin", "", "get", "pods", "status", "ns1", ""},
},
shouldFail: []authorizer.Attributes{
&defaultAttributes{"admin", "", "get", "pods", "", "ns1", ""},
},
},
}
for i, tt := range tests {
ruleResolver, _ := validation.NewTestRuleResolver(tt.roles, tt.roleBindings, tt.clusterRoles, tt.clusterRoleBindings)
a := RBACAuthorizer{ruleResolver}
for _, attr := range tt.shouldPass {
if authorized, _, _ := a.Authorize(attr); !authorized {
t.Errorf("case %d: incorrectly restricted %s", i, attr)
}
}
for _, attr := range tt.shouldFail {
if authorized, _, _ := a.Authorize(attr); authorized {
t.Errorf("case %d: incorrectly passed %s", i, attr)
}
}
}
} | explode_data.jsonl/18348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2215
} | [
2830,
3393,
7133,
3135,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
14643,
2290,
29838,
10681,
580,
35955,
198,
197,
197,
5778,
52843,
286,
29838,
10681,
580,
35955,
15059,
198,
197,
197,
18855,
25116,
286,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestDft03(tst *testing.T) {
//verbose()
chk.PrintTitle("Dft03. FFT and inverse FFT")
// function
π := math.Pi
f := func(x float64) float64 { return math.Sin(x / 2.0) }
// data
N := 4 // number of terms
U := make([]complex128, N)
Ucopy := make([]complex128, N)
// run with 3 places for performing normalisation
for place := 1; place <= 3; place++ {
// message
io.Pf("\n\n~~~~~~~~~~~~~~~~~~~~ place = %v ~~~~~~~~~~~~~~~~~~~~~~~~\n", place)
// f @ points
for i := 0; i < N; i++ {
x := 2.0 * π * float64(i) / float64(N)
U[i] = complex(f(x), 0)
Ucopy[i] = U[i]
}
io.Pf("before: U = %.3f\n", U)
switch place {
// normalise at the beginning
case 1:
// normalise
for i := 0; i < N; i++ {
U[i] /= complex(float64(N), 0)
}
io.Pfblue2("normalised\n")
// execute FFT
Dft1d(U, false)
io.Pforan("FFT(U) = %.3f\n", U)
// execute inverse FFT
Dft1d(U, true)
io.Pf("invFFT(U) = %.3f\n", U)
chk.ArrayC(tst, "U", 1e-15, U, Ucopy)
// normalise after direct FFT
case 2:
// execute FFT
Dft1d(U, false)
io.Pforan("FFT(U) = %.3f\n", U)
// normalise
for i := 0; i < N; i++ {
U[i] /= complex(float64(N), 0)
}
io.Pfblue2("normalised\n")
// execute inverse FFT
Dft1d(U, true)
io.Pf("invFFT(U) = %.3f\n", U)
chk.ArrayC(tst, "U", 1e-15, U, Ucopy)
// normalise after inverse FFT
case 3:
// execute FFT
Dft1d(U, false)
io.Pforan("FFT(U) = %.3f\n", U)
// execute inverse FFT
Dft1d(U, true)
io.Pf("invFFT(U) = %.3f\n", U)
// normalise
for i := 0; i < N; i++ {
U[i] /= complex(float64(N), 0)
}
io.Pfblue2("normalised\n")
// check
chk.ArrayC(tst, "U", 1e-15, U, Ucopy)
}
}
} | explode_data.jsonl/43539 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 888
} | [
2830,
3393,
35,
723,
15,
18,
1155,
267,
353,
8840,
836,
8,
1476,
197,
322,
14883,
741,
23049,
74,
7918,
3851,
445,
35,
723,
15,
18,
13,
60036,
323,
27949,
60036,
5130,
197,
322,
729,
198,
197,
48245,
1669,
6888,
1069,
72,
198,
116... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.