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 TestNewBeacon(t *testing.T) {
r := require.New(t)
p := &mockPatternProvider{}
b := NewBeacon(p, 10, log.NewDefault(t.Name()))
r.Equal(p, b.patternProvider)
r.Equal(uint64(10), b.confidenceParam)
r.NotNil(p, b.cache)
} | explode_data.jsonl/60033 | {
"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,
3564,
3430,
22379,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1373,
7121,
1155,
340,
3223,
1669,
609,
16712,
15760,
5179,
16094,
2233,
1669,
1532,
3430,
22379,
1295,
11,
220,
16,
15,
11,
1487,
7121,
3675,
1155,
2967,
12145,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImagePullSecrets(t *testing.T) {
username, password := "foo", "bar"
specificUser, specificPass := "very", "specific"
client := fakeclient.NewSimpleClientset(&corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: "default",
Namespace: "ns",
},
}, &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "secret",
Namespace: "ns",
},
Type: corev1.SecretTypeDockercfg,
Data: map[string][]byte{
corev1.DockerConfigKey: []byte(
fmt.Sprintf(`{"fake.registry.io": {"auth": %q}, "fake.registry.io/more/specific": {"auth": %q}}`,
base64.StdEncoding.EncodeToString([]byte(username+":"+password)),
base64.StdEncoding.EncodeToString([]byte(specificUser+":"+specificPass))),
),
},
})
kc, err := New(client, Options{
Namespace: "ns",
ImagePullSecrets: []string{"secret"},
})
if err != nil {
t.Fatalf("New() = %v", err)
}
repo, err := name.NewRepository("fake.registry.io/more/specific", name.WeakValidation)
if err != nil {
t.Errorf("NewRegistry() = %v", err)
}
for _, tc := range []struct {
name string
auth authn.Authenticator
target authn.Resource
}{{
name: "registry",
auth: &authn.Basic{Username: username, Password: password},
target: repo.Registry,
}, {
name: "repo",
auth: &authn.Basic{Username: specificUser, Password: specificPass},
target: repo,
}} {
t.Run(tc.name, func(t *testing.T) {
tc := tc
auth, err := kc.Resolve(tc.target)
if err != nil {
t.Errorf("Resolve(%v) = %v", tc.target, err)
}
got, err := auth.Authorization()
if err != nil {
t.Errorf("Authorization() = %v", err)
}
want, err := tc.auth.Authorization()
if err != nil {
t.Errorf("Authorization() = %v", err)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Resolve() = %v, want %v", got, want)
}
})
}
} | explode_data.jsonl/76050 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 810
} | [
2830,
3393,
1906,
36068,
19773,
82,
1155,
353,
8840,
836,
8,
341,
72358,
11,
3552,
1669,
330,
7975,
497,
330,
2257,
698,
1903,
15564,
1474,
11,
3151,
12187,
1669,
330,
1204,
497,
330,
51240,
698,
25291,
1669,
12418,
2972,
7121,
16374,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSessionVarsWaitTimeout(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
tc := &TiDBContext{
Session: se,
stmts: make(map[int]*TiDBStatement),
}
cc := &clientConn{
connectionID: 1,
server: &Server{
capability: defaultCapability,
},
}
cc.setCtx(tc)
require.Equal(t, uint64(variable.DefWaitTimeout), cc.getSessionVarsWaitTimeout(context.Background()))
} | explode_data.jsonl/73151 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
1949,
5283,
28305,
14190,
7636,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
84686,
11,
1848,
1669,
3797,
7251,
5283,
19,
2271,
31200,
340,
17957,
35699,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLongestTraceSaved(t *testing.T) {
start := time.Date(2014, time.November, 28, 1, 1, 0, 0, time.UTC)
tr := &TxnData{}
tr.TxnTrace.Enabled = true
acfg := CreateAttributeConfig(sampleAttributeConfigInput, true)
attr := NewAttributes(acfg)
ht := newHarvestTraces()
ht.Witness(HarvestTrace{
TxnEvent: TxnEvent{
Start: start,
Duration: 3 * time.Second,
FinalName: "WebTransaction/Go/3",
CleanURL: "/url/3",
Attrs: attr,
},
Trace: tr.TxnTrace,
})
ht.Witness(HarvestTrace{
TxnEvent: TxnEvent{
Start: start,
Duration: 5 * time.Second,
FinalName: "WebTransaction/Go/5",
CleanURL: "/url/5",
Attrs: attr,
},
Trace: tr.TxnTrace,
})
ht.Witness(HarvestTrace{
TxnEvent: TxnEvent{
Start: start,
Duration: 4 * time.Second,
FinalName: "WebTransaction/Go/4",
CleanURL: "/url/4",
Attrs: attr,
},
Trace: tr.TxnTrace,
})
expect := CompactJSONString(`
[
"12345",
[
[
1417136460000000,5000,"WebTransaction/Go/5","/url/5",
[
0,{},{},
[0,5000,"ROOT",{},
[[0,5000,"WebTransaction/Go/5",{},[]]]
],
{
"agentAttributes":{},
"userAttributes":{},
"intrinsics":{}
}
],
"",null,false,null,""
]
]
]`)
js, err := ht.Data("12345", start)
if nil != err || string(js) != expect {
t.Error(err, string(js), expect)
}
} | explode_data.jsonl/8813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 670
} | [
2830,
3393,
6583,
477,
6550,
41133,
1155,
353,
8840,
836,
8,
341,
21375,
1669,
882,
8518,
7,
17,
15,
16,
19,
11,
882,
2067,
859,
1377,
11,
220,
17,
23,
11,
220,
16,
11,
220,
16,
11,
220,
15,
11,
220,
15,
11,
882,
87069,
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,
1... | 3 |
func TestIPFSCommit(t *testing.T) {
requiresIPFS(t)
// cgroup is required for nerdctl commit
if rootlessutil.IsRootless() && infoutil.CgroupsVersion() == "1" {
t.Skip("test skipped for rootless containers on cgroup v1")
}
testutil.DockerIncompatible(t)
base := testutil.NewBase(t)
ipfsCID := pushImageToIPFS(t, base, testutil.AlpineImage)
base.Env = append(os.Environ(), "CONTAINERD_SNAPSHOTTER=overlayfs")
base.Cmd("pull", ipfsCID).AssertOK()
base.Cmd("run", "--rm", ipfsCID, "echo", "hello").AssertOK()
tID := testutil.Identifier(t)
newContainer, newImg := tID, tID+":v1"
base.Cmd("run", "--name", newContainer, "-d", ipfsCID, "/bin/sh", "-c", "echo hello > /hello ; sleep 10000").AssertOK()
base.Cmd("commit", newContainer, newImg).AssertOK()
base.Cmd("stop", newContainer).AssertOK()
base.Cmd("rm", newContainer).AssertOK()
ipfsCID2 := cidOf(t, base.Cmd("push", "ipfs://"+newImg).OutLines())
rmiAll(base)
base.Cmd("pull", ipfsCID2).AssertOK()
base.Cmd("run", "--rm", ipfsCID2, "/bin/sh", "-c", "cat /hello").AssertOK()
} | explode_data.jsonl/28111 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 426
} | [
2830,
3393,
3298,
8485,
33441,
1155,
353,
8840,
836,
8,
341,
197,
41375,
3298,
8485,
1155,
340,
197,
322,
272,
4074,
374,
2567,
369,
72187,
12373,
5266,
198,
743,
3704,
1717,
1314,
4506,
8439,
1717,
368,
1009,
4132,
30158,
727,
16753,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetBackgroundImage(t *testing.T) {
// action
result, err := GetBackgroundImage(6)
// verify
verify.Ok(t, err)
verify.Equals(t, resourceBackgroundsnowJpg.Name(), result.Name())
// action
result, err = GetBackgroundImage(601)
// verify
verify.Ok(t, err)
verify.Equals(t, resourceBackgroundsnowJpg.Name(), result.Name())
// action
result, err = GetBackgroundImage(615)
// verify
verify.Ok(t, err)
verify.Equals(t, resourceBackgroundsnowJpg.Name(), result.Name())
} | explode_data.jsonl/36366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
1949,
8706,
1906,
1155,
353,
8840,
836,
8,
341,
197,
322,
1917,
198,
9559,
11,
1848,
1669,
2126,
8706,
1906,
7,
21,
340,
197,
322,
10146,
198,
93587,
54282,
1155,
11,
1848,
340,
93587,
16207,
1155,
11,
5101,
8706,
74478,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnalyzeProjectObjectModel(t *testing.T) {
report := reports.Report{}
dirname := "testdata/java/"
err := AnalyzeProjectObjectModel(dirname, "42", &report)
assert.Nil(t, err, "Unexpected error on AnalyzeProjectObjectModel: %v", err)
assert.NotEqual(t, report.Info.Name, "", "Should have found project name")
assert.NotEqual(t, report.Info.Version, "", "Should have found project version")
assert.NotEqual(t, len(report.Libraries), 0, "Should have found libraries")
} | explode_data.jsonl/42763 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
2082,
55856,
7849,
1190,
1712,
1155,
353,
8840,
836,
8,
341,
69931,
1669,
6682,
25702,
31483,
48532,
606,
1669,
330,
92425,
47200,
85312,
9859,
1669,
37427,
2986,
7849,
1190,
1712,
38802,
11,
330,
19,
17,
497,
609,
11736,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNextSeqBatch(t *testing.T) {
s := op.NewScope()
x, y, init := NextSeqBatch(s, "jabberwock.txt", 50, 3, 4, 42)
xid := ToCharByte(s.SubScope("x"), x)
yid := ToCharByte(s.SubScope("y"), y)
graph, err := s.Finalize()
if err != nil {
t.Fatal(err)
}
sess, err := tf.NewSession(graph, nil)
if err != nil {
t.Fatal(err)
}
_, err = sess.Run(nil, nil, []*tf.Operation{init})
if err != nil {
t.Fatal(err)
}
results, err := sess.Run(nil, []tf.Output{xid, yid}, nil)
if err != nil {
t.Fatal(err)
}
fmt.Println(results[0].Shape())
fmt.Println(string([]byte([]uint8(results[0].Value().([][]byte)[0]))))
} | explode_data.jsonl/82483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
5847,
20183,
21074,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1179,
7121,
10803,
741,
10225,
11,
379,
11,
2930,
1669,
9295,
20183,
21074,
1141,
11,
330,
38916,
652,
1126,
377,
3909,
497,
220,
20,
15,
11,
220,
18,
11,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseErrPosix(t *testing.T) {
t.Parallel()
p := NewParser(KeepComments, Variant(LangPOSIX))
i := 0
for _, c := range shellTests {
want := c.common
if c.posix != nil {
want = c.posix
}
if want == nil {
continue
}
t.Run(fmt.Sprintf("%03d", i), checkError(p, c.in, want.(string)))
i++
}
} | explode_data.jsonl/31436 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
14463,
7747,
4859,
941,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
1532,
6570,
7,
19434,
17373,
11,
39292,
4957,
524,
17456,
5396,
1171,
8230,
1669,
220,
15,
198,
2023,
8358,
272,
1669,
2088,
12528,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHipChatValid(t *testing.T) {
hc := &HipChat{}
if hc.Valid() {
t.Fatal("empty hipchat config shouldn't be valid")
}
hc.APIKey = "test"
if hc.Valid() {
t.Fatal("invalid hipchat config shouldn't be valid")
}
hc.Room = "test"
if hc.Valid() {
t.Fatal("invalid hipchat config shouldn't be valid")
}
hc.Host = "test"
if !hc.Valid() {
t.Fatal("valid hipchat config marked as invalid")
}
} | explode_data.jsonl/57697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 176
} | [
2830,
3393,
90538,
15672,
4088,
1155,
353,
8840,
836,
8,
341,
9598,
66,
1669,
609,
90538,
15672,
16094,
743,
50394,
47156,
368,
341,
197,
3244,
26133,
445,
3194,
18143,
9686,
2193,
13133,
944,
387,
2697,
1138,
197,
630,
9598,
66,
24922,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCorruptDB_UnrelatedKeys(t *testing.T) {
h := newDbCorruptHarness(t)
defer h.close()
h.build(10)
h.compactMem()
h.closeDB()
h.corrupt(storage.TypeTable, -1, 100, 1)
h.openDB()
h.put(string(tkey(1000)), string(tval(1000, ctValSize)))
h.getVal(string(tkey(1000)), string(tval(1000, ctValSize)))
h.compactMem()
h.getVal(string(tkey(1000)), string(tval(1000, ctValSize)))
} | explode_data.jsonl/45798 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
10580,
6585,
3506,
40687,
9721,
8850,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
7994,
10580,
6585,
74248,
1155,
340,
16867,
305,
4653,
2822,
9598,
13239,
7,
16,
15,
340,
9598,
39702,
531,
18816,
741,
9598,
4653,
3506,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDropAfterCreate(t *testing.T) {
log.UseTestLogger(t)
e := testEngine(t)
defer e.Stop()
err := parseAndExecuteQuery(t, e, "CREATE TABLE account (id INT, email TEXT)")
if err != nil {
t.Fatal(err)
}
err = parseAndExecuteQuery(t, e, "DROP TABLE account")
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/72340 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
19871,
6025,
4021,
1155,
353,
8840,
836,
8,
341,
6725,
9046,
2271,
7395,
1155,
692,
7727,
1669,
1273,
4571,
1155,
340,
16867,
384,
30213,
2822,
9859,
1669,
4715,
3036,
17174,
2859,
1155,
11,
384,
11,
330,
22599,
14363,
2692,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAlarmApi_Delete_All_Success(t *testing.T) {
var expectedUrl = "alarm/alarms"
var capturedUrl string
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
capturedUrl = r.URL.String()
w.WriteHeader(http.StatusNoContent)
}))
// given: A test server
defer ts.Close()
// and: the api as system under test
api := buildAlarmApi(ts.URL)
err := api.DeleteAll()
if err != nil {
t.Fatalf("DeleteAll() got an unexpected error: %s", err.Error())
}
if strings.HasSuffix(capturedUrl, expectedUrl) == false {
t.Errorf("DeleteAll(): Wrong target URL: %s - expected %s", capturedUrl, expectedUrl)
}
} | explode_data.jsonl/73322 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
43444,
6563,
57418,
53629,
87161,
1155,
353,
8840,
836,
8,
341,
2405,
3601,
2864,
284,
330,
56780,
14,
7934,
1011,
698,
2405,
17006,
2864,
914,
271,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadLocalMSP(t *testing.T) {
t.Run("Happy", func(t *testing.T) {
localMSPDir := configtest.GetDevMspDir()
localMSP := loadLocalMSP(
&localconfig.TopLevel{
General: localconfig.General{
LocalMSPDir: localMSPDir,
LocalMSPID: "SampleOrg",
BCCSP: &factory.FactoryOpts{
ProviderName: "SW",
SwOpts: &factory.SwOpts{
HashFamily: "SHA2",
SecLevel: 256,
Ephemeral: true,
},
},
},
},
)
require.NotNil(t, localMSP)
id, err := localMSP.GetIdentifier()
require.NoError(t, err)
require.Equal(t, id, "SampleOrg")
})
t.Run("Error", func(t *testing.T) {
oldLogger := logger
defer func() { logger = oldLogger }()
logger, _ = floggingtest.NewTestLogger(t)
assert.Panics(t, func() {
loadLocalMSP(
&localconfig.TopLevel{
General: localconfig.General{
LocalMSPDir: "",
LocalMSPID: "",
},
},
)
})
})
} | explode_data.jsonl/32654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 463
} | [
2830,
3393,
5879,
7319,
44,
4592,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
32847,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
8854,
44,
4592,
6184,
1669,
2193,
1944,
2234,
14592,
83816,
6184,
741,
197,
8854,
44,
4592,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSCTs(t *testing.T) {
testCases := []struct {
name string
sbMock Submitter
groups ctpolicy.LogPolicyData
ctx context.Context
resultTrail map[string]int
errRegexp *regexp.Regexp
}{
{
name: "singleGroupOneSCT",
sbMock: &mockSubmitter{firstLetterURLReqNumber: make(map[byte]int)},
groups: ctpolicy.LogPolicyData{
"a": {
Name: "a",
LogURLs: map[string]bool{"a1.com": true, "a2.com": true},
MinInclusions: 1,
IsBase: false,
},
},
ctx: context.Background(),
resultTrail: map[string]int{"a": 1},
},
{
name: "singleGroupMultiSCT",
sbMock: &mockSubmitter{firstLetterURLReqNumber: make(map[byte]int)},
groups: ctpolicy.LogPolicyData{
"a": {
Name: "a",
LogURLs: map[string]bool{"a1.com": true, "a2.com": true, "a3.com": true, "a4.com": true, "a5.com": true},
MinInclusions: 3,
IsBase: false,
},
},
ctx: context.Background(),
resultTrail: map[string]int{"a": 3},
},
{
name: "chromeLike",
sbMock: &mockSubmitter{firstLetterURLReqNumber: make(map[byte]int)},
groups: ctpolicy.LogPolicyData{
"a": {
Name: "a",
LogURLs: map[string]bool{"a1.com": true, "a2.com": true, "a3.com": true, "a4.com": true},
MinInclusions: 1,
IsBase: false,
},
"b": {
Name: "b",
LogURLs: map[string]bool{"b1.com": true, "b2.com": true, "b3.com": true, "b4.com": true},
MinInclusions: 1,
IsBase: false,
},
"Base": {
Name: "Base",
LogURLs: map[string]bool{"a1.com": true, "a2.com": true, "a3.com": true, "a4.com": true, "b1.com": true, "b2.com": true, "b3.com": true, "b4.com": true},
MinInclusions: 3,
IsBase: true,
},
},
ctx: context.Background(),
resultTrail: map[string]int{"a": 1, "b": 1, ctpolicy.BaseName: 3},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
res, err := GetSCTs(tc.ctx, tc.sbMock, []ct.ASN1Cert{{Data: []byte{0}}}, tc.groups)
if tc.resultTrail != nil {
evaluateSCTs(t, res, tc.resultTrail)
}
if tc.errRegexp != nil {
if !tc.errRegexp.MatchString(err.Error()) {
t.Errorf("Error %q did not match expected regexp %q", err, tc.errRegexp)
}
}
})
}
} | explode_data.jsonl/72079 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1263
} | [
2830,
3393,
1949,
50,
1162,
82,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
24842,
11571,
414,
3719,
16126,
198,
197,
44260,
82,
414,
272,
790,
8018,
5247,
13825,
1043,
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... | 4 |
func TestModifyOrderAndPage(t *testing.T) {
sql, p := order("select ? from x", "field1")
t.Log(sql)
sql = MysqlModifier.Page(sql, &PageInfo{Page: 1, PageSize: 2,})
t.Log(sql)
for _, v := range p {
t.Log(v)
}
if strings.TrimSpace(sql) != "select ? from x ORDER BY `test` ASC LIMIT 2, 2" {
t.Fail()
}
} | explode_data.jsonl/64350 | {
"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,
44427,
4431,
3036,
2665,
1155,
353,
8840,
836,
8,
341,
30633,
11,
281,
1669,
1973,
445,
1742,
937,
504,
856,
497,
330,
2566,
16,
1138,
3244,
5247,
13148,
692,
30633,
284,
386,
14869,
34405,
17558,
13148,
11,
609,
2665,
173... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuildResponseTrade(t *testing.T) {
setTestTradeConfig()
type TestData struct {
Instructions [][]string `json:"instructions"`
}
type TestResult = transaction.TxTokenVersion2
var testcases []Testcase
testcases = append(testcases, buildResponseTradeTestcases...)
var blankPrivateKey privacy.PrivateKey = make([]byte, 32)
// use a fixed, non-zero private key for testing
blankPrivateKey[3] = 10
var blankShardID byte = 0
for _, testcase := range testcases {
t.Run(testcase.Name, func(t *testing.T) {
var testdata TestData
err := json.Unmarshal(testcase.Data, &testdata)
NoError(t, err)
var expected TestResult
err = json.Unmarshal(testcase.Expected, &expected)
NoError(t, err)
myInstruction := testdata.Instructions[0]
metaType, err := strconv.Atoi(myInstruction[0])
NoError(t, err)
tx, err := (&TxBuilderV2{}).Build(
metaType,
myInstruction,
&blankPrivateKey,
blankShardID,
testDB,
10,
)
NoError(t, err)
txv2, ok := tx.(*transaction.TxTokenVersion2)
True(t, ok)
mintedCoin, ok := txv2.TokenData.Proof.GetOutputCoins()[0].(*privacy.CoinV2)
True(t, ok)
expectedMintedCoin, ok := expected.TokenData.Proof.GetOutputCoins()[0].(*privacy.CoinV2)
True(t, ok)
// check token id, receiver & value
Equal(t, expected.TokenData.PropertyID, txv2.TokenData.PropertyID)
True(t, bytes.Equal(expectedMintedCoin.GetPublicKey().ToBytesS(),
mintedCoin.GetPublicKey().ToBytesS()))
Equal(t, expectedMintedCoin.GetValue(), mintedCoin.GetValue())
})
}
} | explode_data.jsonl/16346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 680
} | [
2830,
3393,
11066,
2582,
39173,
1155,
353,
8840,
836,
8,
972,
8196,
2271,
39173,
2648,
3568,
13158,
93200,
2036,
972,
197,
197,
55291,
52931,
917,
1565,
2236,
2974,
62295,
39917,
319,
197,
2570,
13158,
3393,
2077,
284,
7745,
81362,
3323,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTraitsPropagation(t *testing.T) {
log := utils.NewLoggerForTests()
privateKey, publicKey, err := testauthority.New().GenerateKeyPair("")
require.NoError(t, err)
// Create root cluster.
rc := NewInstance(InstanceConfig{
ClusterName: "root.example.com",
HostID: uuid.New().String(),
NodeName: Host,
Priv: privateKey,
Pub: publicKey,
log: log,
})
// Create leaf cluster.
lc := NewInstance(InstanceConfig{
ClusterName: "leaf.example.com",
HostID: uuid.New().String(),
NodeName: Host,
Priv: privateKey,
Pub: publicKey,
log: log,
})
// Make root cluster config.
rcConf := service.MakeDefaultConfig()
rcConf.DataDir = t.TempDir()
rcConf.Auth.Enabled = true
rcConf.Auth.Preference.SetSecondFactor("off")
rcConf.Proxy.Enabled = true
rcConf.Proxy.DisableWebService = true
rcConf.Proxy.DisableWebInterface = true
rcConf.SSH.Enabled = true
rcConf.SSH.Addr.Addr = net.JoinHostPort(rc.Hostname, rc.GetPortSSH())
rcConf.SSH.Labels = map[string]string{"env": "integration"}
// Make leaf cluster config.
lcConf := service.MakeDefaultConfig()
lcConf.DataDir = t.TempDir()
lcConf.Auth.Enabled = true
lcConf.Auth.Preference.SetSecondFactor("off")
lcConf.Proxy.Enabled = true
lcConf.Proxy.DisableWebInterface = true
lcConf.SSH.Enabled = true
lcConf.SSH.Addr.Addr = net.JoinHostPort(lc.Hostname, lc.GetPortSSH())
lcConf.SSH.Labels = map[string]string{"env": "integration"}
// Create identical user/role in both clusters.
me, err := user.Current()
require.NoError(t, err)
role := services.NewImplicitRole()
role.SetName("test")
role.SetLogins(types.Allow, []string{me.Username})
// Users created by CreateEx have "testing: integration" trait.
role.SetNodeLabels(types.Allow, map[string]apiutils.Strings{"env": []string{"{{external.testing}}"}})
rc.AddUserWithRole(me.Username, role)
lc.AddUserWithRole(me.Username, role)
// Establish trust b/w root and leaf.
err = rc.CreateEx(t, lc.Secrets.AsSlice(), rcConf)
require.NoError(t, err)
err = lc.CreateEx(t, rc.Secrets.AsSlice(), lcConf)
require.NoError(t, err)
// Start both clusters.
require.NoError(t, rc.Start())
t.Cleanup(func() {
rc.StopAll()
})
require.NoError(t, lc.Start())
t.Cleanup(func() {
lc.StopAll()
})
// Update root's certificate authority on leaf to configure role mapping.
ca, err := lc.Process.GetAuthServer().GetCertAuthority(context.Background(), types.CertAuthID{
Type: types.UserCA,
DomainName: rc.Secrets.SiteName,
}, false)
require.NoError(t, err)
ca.SetRoles(nil) // Reset roles, otherwise they will take precedence.
ca.SetRoleMap(types.RoleMap{{Remote: role.GetName(), Local: []string{role.GetName()}}})
err = lc.Process.GetAuthServer().UpsertCertAuthority(ca)
require.NoError(t, err)
// Run command in root.
outputRoot, err := runCommand(t, rc, []string{"echo", "hello root"}, ClientConfig{
Login: me.Username,
Cluster: "root.example.com",
Host: Loopback,
Port: rc.GetPortSSHInt(),
}, 1)
require.NoError(t, err)
require.Equal(t, "hello root", strings.TrimSpace(outputRoot))
// Run command in leaf.
outputLeaf, err := runCommand(t, rc, []string{"echo", "hello leaf"}, ClientConfig{
Login: me.Username,
Cluster: "leaf.example.com",
Host: Loopback,
Port: lc.GetPortSSHInt(),
}, 1)
require.NoError(t, err)
require.Equal(t, "hello leaf", strings.TrimSpace(outputLeaf))
} | explode_data.jsonl/71198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1332
} | [
2830,
3393,
42820,
35172,
1155,
353,
8840,
836,
8,
341,
6725,
1669,
12439,
7121,
7395,
2461,
18200,
2822,
2455,
1592,
11,
69347,
11,
1848,
1669,
1273,
84454,
7121,
1005,
31115,
1592,
12443,
31764,
17957,
35699,
1155,
11,
1848,
692,
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 TestMenusPageSortByDate(t *testing.T) {
b := newTestSitesBuilder(t).WithSimpleConfigFile()
b.WithContent("blog/a.md", `
---
Title: A
date: 2019-01-01
menu:
main:
identifier: "a"
weight: 1
---
`)
b.WithContent("blog/b.md", `
---
Title: B
date: 2018-01-02
menu:
main:
parent: "a"
weight: 100
---
`)
b.WithContent("blog/c.md", `
---
Title: C
date: 2019-01-03
menu:
main:
parent: "a"
weight: 10
---
`)
b.WithTemplatesAdded("index.html", `{{ range .Site.Menus.main }}{{ .Title }}|Children:
{{- $children := sort .Children ".Page.Date" "desc" }}{{ range $children }}{{ .Title }}|{{ end }}{{ end }}
`)
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", "A|Children:C|B|")
} | explode_data.jsonl/51844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
77944,
2665,
10231,
1359,
1916,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
501,
2271,
93690,
3297,
1155,
568,
2354,
16374,
2648,
1703,
2822,
2233,
26124,
2762,
445,
11659,
14186,
21324,
497,
22074,
10952,
3851,
25,
362,
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... | 1 |
func Test_Execution_FetchDeploy_RootLockError(t *testing.T) {
release := models.MockRelease(t)
// Should retry a few times, then end in clean state as nothing was created
awsClients := models.MockAwsClients(release)
// Force a lock error by making it look like it was already aquired
awsClients.S3.AddGetObject(*release.RootLockPath(), `{"uuid": "already"}`, nil)
stateMachine := createTestStateMachine(t, awsClients)
exec, err := stateMachine.Execute(release)
output := exec.Output
assert.Error(t, err)
assert.Equal(t, "FailureClean", output["Error"])
assert.Equal(t, exec.Path(), []string{
"Validate",
"Lock",
"FailureClean",
})
} | explode_data.jsonl/3583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
62,
20294,
1400,
2995,
69464,
2568,
1905,
11989,
1454,
1155,
353,
8840,
836,
8,
341,
17200,
1623,
1669,
4119,
24664,
16077,
1155,
692,
197,
322,
12260,
22683,
264,
2421,
3039,
11,
1221,
835,
304,
4240,
1584,
438,
4302,
572,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileNoParam(t *testing.T) {
type config struct {
SecretKey string `env:"SECRET_KEY,file"`
}
defer os.Clearenv()
cfg := config{}
err := Parse(&cfg)
assert.NoError(t, err)
} | explode_data.jsonl/78803 | {
"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,
1703,
2753,
2001,
1155,
353,
8840,
836,
8,
341,
13158,
2193,
2036,
341,
197,
7568,
50856,
1592,
914,
1565,
3160,
2974,
65310,
6600,
57476,
8805,
197,
532,
16867,
2643,
727,
273,
9151,
85,
741,
50286,
1669,
2193,
16094,
9859,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessNormalMsg(t *testing.T) {
t.Run("Normal", func(t *testing.T) {
ms := &mockSystemChannelFilterSupport{
SequenceVal: 7,
OrdererConfigVal: newMockOrdererConfig(true, orderer.ConsensusType_STATE_NORMAL),
}
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
require.NoError(t, err)
cs, err := NewStandardChannel(ms, NewRuleSet([]Rule{AcceptRule}), cryptoProvider).ProcessNormalMsg(nil)
require.Equal(t, cs, ms.SequenceVal)
require.Nil(t, err)
})
t.Run("Maintenance", func(t *testing.T) {
ms := &mockSystemChannelFilterSupport{
SequenceVal: 7,
OrdererConfigVal: newMockOrdererConfig(true, orderer.ConsensusType_STATE_MAINTENANCE),
}
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
require.NoError(t, err)
_, err = NewStandardChannel(ms, NewRuleSet([]Rule{AcceptRule}), cryptoProvider).ProcessNormalMsg(nil)
require.EqualError(t, err, "normal transactions are rejected: maintenance mode")
})
} | explode_data.jsonl/65686 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 378
} | [
2830,
3393,
7423,
12206,
6611,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
12206,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
47691,
1669,
609,
16712,
2320,
9629,
5632,
7916,
515,
298,
197,
14076,
2208,
25,
414,
220,
22,
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 TestNoProxyingRequests(t *testing.T) {
c := newFakeKeycloakConfig()
c.Resources = []*Resource{
{
URL: "/*",
Methods: allHTTPMethods,
},
}
requests := []fakeRequest{
{ // check for escaping
URI: "/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/etc/passwd",
Redirects: true,
ExpectedCode: http.StatusSeeOther,
},
{ // check for escaping
URI: "/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/",
Redirects: true,
ExpectedCode: http.StatusSeeOther,
},
{ // check for escaping
URI: "/../%2e",
Redirects: true,
ExpectedCode: http.StatusSeeOther,
},
{ // check for escaping
URI: "",
Redirects: true,
ExpectedCode: http.StatusSeeOther,
},
}
newFakeProxy(c).RunTests(t, requests)
} | explode_data.jsonl/14752 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 395
} | [
2830,
3393,
2753,
16219,
287,
35295,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
501,
52317,
1592,
88751,
2648,
741,
1444,
21703,
284,
29838,
4783,
515,
197,
197,
515,
298,
79055,
25,
257,
330,
1057,
756,
298,
197,
17856,
25,
678,
9230,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSYNRetransmit(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
// Create TCP endpoint.
var err tcpip.Error
c.EP, err = c.Stack().NewEndpoint(tcp.ProtocolNumber, ipv4.ProtocolNumber, &c.WQ)
if err != nil {
t.Fatalf("NewEndpoint failed: %s", err)
}
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %s", err)
}
// Start listening.
if err := c.EP.Listen(10); err != nil {
t.Fatalf("Listen failed: %s", err)
}
// Send the same SYN packet multiple times. We should still get a valid SYN-ACK
// reply.
irs := seqnum.Value(context.TestInitialSequenceNumber)
for i := 0; i < 5; i++ {
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagSyn,
SeqNum: irs,
RcvWnd: 30000,
})
}
// Receive the SYN-ACK reply.
tcpCheckers := []checker.TransportChecker{
checker.SrcPort(context.StackPort),
checker.DstPort(context.TestPort),
checker.TCPFlags(header.TCPFlagAck | header.TCPFlagSyn),
checker.TCPAckNum(uint32(irs) + 1),
}
checker.IPv4(t, c.GetPacket(), checker.TCP(tcpCheckers...))
} | explode_data.jsonl/76011 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 500
} | [
2830,
3393,
18416,
45,
12020,
33389,
1763,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
197,
322,
4230,
26656,
14887,
624,
2405,
1848,
28051,
573,
6141,
198,
1444,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPipeCollection_GetPipe(t *testing.T) {
c := &PipeCollection{}
p1 := c.GetPipe()
if p1 == nil {
t.Error("pipe not initialized")
}
p2 := c.GetPipe()
if p1 != p2 {
t.Error("not the same pipe")
}
client := &Client{}
p1.Register(client)
p1.Unregister(client)
for {
if c.pipe == nil {
break
}
}
} | explode_data.jsonl/27042 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
34077,
6482,
13614,
34077,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
34077,
6482,
16094,
3223,
16,
1669,
272,
2234,
34077,
2822,
743,
281,
16,
621,
2092,
341,
197,
3244,
6141,
445,
13768,
537,
17271,
1138,
197,
630,
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... | 5 |
func TestValues(t *testing.T) {
t.Parallel()
maps := datatype.DefaultMapper()
v, _ := jason.NewValueFromBytes([]byte("666"))
results := maps.Values("", map[string]*jason.Value{"devil": v})
if len(results) != 1 {
t.Errorf("len(results) = (%d); want (1)", len(results))
}
results = maps.Values("", map[string]*jason.Value{})
if len(results) != 0 {
t.Errorf("len(results) = (%d); want (0)", len(results))
}
v, _ = jason.NewValueFromBytes(nil)
results = maps.Values("", map[string]*jason.Value{"nil": v})
if len(results) != 0 {
t.Errorf("len(results) = (%d); want (0)", len(results))
}
} | explode_data.jsonl/57180 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
6227,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2109,
2625,
1669,
46634,
13275,
10989,
741,
5195,
11,
716,
1669,
502,
1497,
7121,
1130,
3830,
7078,
10556,
3782,
445,
21,
21,
21,
5455,
55497,
1669,
14043,
35145,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEntity_WriteTo_multipart(t *testing.T) {
e := testMakeMultipart()
var b bytes.Buffer
if err := e.WriteTo(&b); err != nil {
t.Fatal("Expected no error while writing entity, got", err)
}
if s := b.String(); s != testMultipartText {
t.Errorf("Expected written entity to be:\n%s\nbut got:\n%s", testMultipartText, s)
}
} | explode_data.jsonl/30554 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
3030,
31825,
1249,
717,
18204,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
1273,
8078,
44,
18204,
2822,
2405,
293,
5820,
22622,
198,
743,
1848,
1669,
384,
4073,
1249,
2099,
65,
1215,
1848,
961,
2092,
341,
197,
3244,
26133,
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... | 3 |
func TestStatements(t *testing.T) {
if testing.Short() {
t.Skip()
}
execStatements(t, []string{
"create table stream1(id int, val varbinary(128), primary key(id))",
"create table stream2(id int, val varbinary(128), primary key(id))",
})
defer execStatements(t, []string{
"drop table stream1",
"drop table stream2",
})
engine.se.Reload(context.Background())
testcases := []testcase{{
input: []string{
"begin",
"insert into stream1 values (1, 'aaa')",
"update stream1 set val='bbb' where id = 1",
"commit",
},
output: [][]string{{
`begin`,
`type:FIELD field_event:{table_name:"stream1" fields:{name:"id" type:INT32 table:"stream1" org_table:"stream1" database:"vttest" org_name:"id" column_length:11 charset:63 column_type:"int(11)"} fields:{name:"val" type:VARBINARY table:"stream1" org_table:"stream1" database:"vttest" org_name:"val" column_length:128 charset:63 column_type:"varbinary(128)"}}`,
`type:ROW row_event:{table_name:"stream1" row_changes:{after:{lengths:1 lengths:3 values:"1aaa"}}}`,
`type:ROW row_event:{table_name:"stream1" row_changes:{before:{lengths:1 lengths:3 values:"1aaa"} after:{lengths:1 lengths:3 values:"1bbb"}}}`,
`gtid`,
`commit`,
}},
}, {
// Normal DDL.
input: "alter table stream1 change column val val varbinary(128)",
output: [][]string{{
`gtid`,
`type:DDL statement:"alter table stream1 change column val val varbinary(128)"`,
}},
}, {
// DDL padded with comments.
input: " /* prefix */ alter table stream1 change column val val varbinary(256) /* suffix */ ",
output: [][]string{{
`gtid`,
`type:DDL statement:"/* prefix */ alter table stream1 change column val val varbinary(256) /* suffix */"`,
}},
}, {
// Multiple tables, and multiple rows changed per statement.
input: []string{
"begin",
"insert into stream1 values (2, 'bbb')",
"insert into stream2 values (1, 'aaa')",
"update stream1 set val='ccc'",
"delete from stream1",
"commit",
},
output: [][]string{{
`begin`,
`type:FIELD field_event:{table_name:"stream1" fields:{name:"id" type:INT32 table:"stream1" org_table:"stream1" database:"vttest" org_name:"id" column_length:11 charset:63 column_type:"int(11)"} fields:{name:"val" type:VARBINARY table:"stream1" org_table:"stream1" database:"vttest" org_name:"val" column_length:256 charset:63 column_type:"varbinary(256)"}}`,
`type:ROW row_event:{table_name:"stream1" row_changes:{after:{lengths:1 lengths:3 values:"2bbb"}}}`,
`type:FIELD field_event:{table_name:"stream2" fields:{name:"id" type:INT32 table:"stream2" org_table:"stream2" database:"vttest" org_name:"id" column_length:11 charset:63 column_type:"int(11)"} fields:{name:"val" type:VARBINARY table:"stream2" org_table:"stream2" database:"vttest" org_name:"val" column_length:128 charset:63 column_type:"varbinary(128)"}}`,
`type:ROW row_event:{table_name:"stream2" row_changes:{after:{lengths:1 lengths:3 values:"1aaa"}}}`,
`type:ROW row_event:{table_name:"stream1" ` +
`row_changes:{before:{lengths:1 lengths:3 values:"1bbb"} after:{lengths:1 lengths:3 values:"1ccc"}} ` +
`row_changes:{before:{lengths:1 lengths:3 values:"2bbb"} after:{lengths:1 lengths:3 values:"2ccc"}}}`,
`type:ROW row_event:{table_name:"stream1" ` +
`row_changes:{before:{lengths:1 lengths:3 values:"1ccc"}} ` +
`row_changes:{before:{lengths:1 lengths:3 values:"2ccc"}}}`,
`gtid`,
`commit`,
}},
}, {
// truncate is a DDL
input: "truncate table stream2",
output: [][]string{{
`gtid`,
`type:DDL statement:"truncate table stream2"`,
}},
}, {
// Reverse alter table, else FilePos tests fail
input: " /* prefix */ alter table stream1 change column val val varbinary(128) /* suffix */ ",
output: [][]string{{
`gtid`,
`type:DDL statement:"/* prefix */ alter table stream1 change column val val varbinary(128) /* suffix */"`,
}},
}}
runCases(t, nil, testcases, "current", nil)
// Test FilePos flavor
savedEngine := engine
defer func() { engine = savedEngine }()
engine = customEngine(t, func(in mysql.ConnParams) mysql.ConnParams {
in.Flavor = "FilePos"
return in
})
defer engine.Close()
runCases(t, nil, testcases, "current", nil)
} | explode_data.jsonl/10408 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1590
} | [
2830,
3393,
93122,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
741,
197,
630,
67328,
93122,
1155,
11,
3056,
917,
515,
197,
197,
1,
3182,
1965,
4269,
16,
3724,
526,
11,
1044,
762,
25891,
7,
16,
17,
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... | 1 |
func TestInjectOverrideCommandsMultipleImages(t *testing.T) {
f := newIBDFixture(t, k8s.EnvGKE)
defer f.TearDown()
cmd1 := model.ToUnixCmd("./command1.sh foo")
cmd2 := model.ToUnixCmd("./command2.sh bar baz")
iTarget1 := NewSanchoDockerBuildImageTarget(f).WithOverrideCommand(cmd1)
iTarget2 := NewSanchoSidecarDockerBuildImageTarget(f).WithOverrideCommand(cmd2)
kTarget := k8s.MustTarget("sancho", testyaml.SanchoSidecarYAML).
WithDependencyIDs([]model.TargetID{iTarget1.ID(), iTarget2.ID()})
targets := []model.TargetSpec{iTarget1, iTarget2, kTarget}
_, err := f.ibd.BuildAndDeploy(f.ctx, f.st, targets, store.BuildStateSet{})
if err != nil {
t.Fatal(err)
}
entities, err := k8s.ParseYAMLFromString(f.k8s.Yaml)
if err != nil {
t.Fatal(err)
}
if !assert.Equal(t, 1, len(entities)) {
return
}
d := entities[0].Obj.(*v1.Deployment)
if !assert.Equal(t, 2, len(d.Spec.Template.Spec.Containers)) {
return
}
sanchoContainer := d.Spec.Template.Spec.Containers[0]
sidecarContainer := d.Spec.Template.Spec.Containers[1]
// Make sure container ref injection worked as expected
assert.Equal(t, "gcr.io/some-project-162817/sancho:tilt-11cd0b38bc3ceb95", sanchoContainer.Image)
assert.Equal(t, "gcr.io/some-project-162817/sancho-sidecar:tilt-11cd0b38bc3ceb95", sidecarContainer.Image)
assert.Equal(t, cmd1.Argv, sanchoContainer.Command)
assert.Equal(t, cmd2.Argv, sidecarContainer.Command)
} | explode_data.jsonl/38276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 590
} | [
2830,
3393,
13738,
2177,
30479,
32089,
14228,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
3256,
5262,
12735,
1155,
11,
595,
23,
82,
81214,
38,
3390,
340,
16867,
282,
836,
682,
4454,
2822,
25920,
16,
1669,
1614,
3274,
55832,
15613,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBigBin(t *testing.T) {
for _, appName := range testData {
output, err := Run(appName)
if err != nil {
t.Fatalf("BigBin failed to start app %s with error: %s", appName, err)
}
if strings.Trim(string(output), " \n") != appName {
t.Fatalf("BigBin failed to execute app %s correctly expected output was '%s' but got: '%s'",
appName, appName, output)
}
}
} | explode_data.jsonl/28616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
15636,
28794,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
67819,
1669,
2088,
67348,
341,
197,
21170,
11,
1848,
1669,
6452,
11462,
675,
340,
197,
743,
1848,
961,
2092,
341,
298,
3244,
30762,
445,
15636,
28794,
4641,
311,
1191,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUIDWIthNoCookie(t *testing.T) {
req := httptest.NewRequest("GET", "/getuids", nil)
endpoint := NewGetUIDsEndpoint(config.HostCookie{})
res := httptest.NewRecorder()
endpoint(res, req, nil)
assert.Equal(t, http.StatusOK, res.Code)
assert.JSONEq(t, `{}`, res.Body.String(), "GetUIDs endpoint shouldn't return anything if there doesn't exist a PBS cookie")
} | explode_data.jsonl/55873 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
1949,
6463,
60195,
339,
2753,
20616,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
54320,
70334,
75274,
445,
3806,
497,
3521,
455,
91216,
497,
2092,
340,
6246,
2768,
1669,
1532,
1949,
6463,
82,
27380,
8754,
29840,
20616,
37790,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGlobBody(t *testing.T) {
hreq := &definition.Request{}
hreq.Body = "Hello World From Test"
mreq := &definition.Request{}
mreq.Body = "*World*"
m := MockMatch{}
if m, err := m.Match(hreq, mreq); !m {
t.Error(err)
}
} | explode_data.jsonl/1095 | {
"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,
38,
1684,
5444,
1155,
353,
8840,
836,
8,
341,
9598,
2958,
1669,
609,
18375,
9659,
16094,
9598,
2958,
20934,
284,
330,
9707,
4337,
5542,
3393,
698,
2109,
2958,
1669,
609,
18375,
9659,
16094,
2109,
2958,
20934,
284,
15630,
101... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetadata(t *testing.T) {
t.Run("gRPC headers", func(t *testing.T) {
req := NewInvokeMethodRequest("test_method")
md := map[string][]string{
"test1": {"val1", "val2"},
"test2": {"val3", "val4"},
}
req.WithMetadata(md)
mdata := req.Metadata()
assert.Equal(t, "val1", mdata["test1"].GetValues()[0])
assert.Equal(t, "val2", mdata["test1"].GetValues()[1])
assert.Equal(t, "val3", mdata["test2"].GetValues()[0])
assert.Equal(t, "val4", mdata["test2"].GetValues()[1])
})
t.Run("HTTP headers", func(t *testing.T) {
var req = fasthttp.AcquireRequest()
req.Header.Set("Header1", "Value1")
req.Header.Set("Header2", "Value2")
req.Header.Set("Header3", "Value3")
re := NewInvokeMethodRequest("test_method")
re.WithFastHTTPHeaders(&req.Header)
mheader := re.Metadata()
assert.Equal(t, "Value1", mheader["Header1"].GetValues()[0])
assert.Equal(t, "Value2", mheader["Header2"].GetValues()[0])
assert.Equal(t, "Value3", mheader["Header3"].GetValues()[0])
})
} | explode_data.jsonl/46240 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
14610,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
70,
29528,
7102,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
24395,
1669,
1532,
17604,
3523,
1900,
445,
1944,
9032,
1138,
197,
84374,
1669,
2415,
14032,
45725,
917,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHybiClientReadWithMasking(t *testing.T) {
wireData := []byte{0x81, 0x85, 0xcc, 0x55, 0x80, 0x20,
0xa4, 0x30, 0xec, 0x4c, 0xa3, // hello
}
br := bufio.NewReader(bytes.NewBuffer(wireData))
bw := bufio.NewWriter(bytes.NewBuffer([]byte{}))
conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil)
// client MUST close the connection upon receiving a masked frame.
msg := make([]byte, 512)
_, err := conn.Read(msg)
if err != io.EOF {
t.Errorf("read 1st frame, expect %q, but got %q", io.EOF, err)
}
} | explode_data.jsonl/53449 | {
"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,
30816,
8221,
2959,
4418,
2354,
12686,
287,
1155,
353,
8840,
836,
8,
341,
6692,
554,
1043,
1669,
3056,
3782,
90,
15,
87,
23,
16,
11,
220,
15,
87,
23,
20,
11,
220,
15,
47380,
11,
220,
15,
87,
20,
20,
11,
220,
15,
87,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPathWithSlashes(t *testing.T) {
assert.Equal(t, pathPrefix+"%2Ftest%2Fpath%2Fwith%2Fslashes", pathFromName("/test/path/with/slashes"), "should escape illegal url characters and add prefix")
} | explode_data.jsonl/78239 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
1820,
2354,
7442,
14051,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
1815,
14335,
5172,
4,
17,
37,
1944,
4,
17,
37,
2343,
4,
17,
37,
4197,
4,
17,
37,
47629,
497,
1815,
3830,
675,
4283,
1944,
50976,
14,
4197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMakeString(t *testing.T) {
for _, literal := range []string{"test", ""} {
if ok, got, err := fixture.MakeString(literal); err != nil {
t.Errorf("unexpected error: %s", err)
} else if !ok {
t.Errorf("expected string %q to be made", literal)
} else if got != literal {
t.Errorf("expected %q got %q", literal, got)
}
}
} | explode_data.jsonl/31894 | {
"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,
8078,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
23141,
1669,
2088,
3056,
917,
4913,
1944,
497,
1591,
92,
341,
197,
743,
5394,
11,
2684,
11,
1848,
1669,
12507,
50133,
703,
2333,
9953,
1215,
1848,
961,
2092,
341,
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... | 5 |
func TestElideTombstone(t *testing.T) {
opts := &Options{}
opts.EnsureDefaults()
type want struct {
key string
expected bool
}
testCases := []struct {
desc string
level int
version *version
wants []want
}{
{
desc: "empty",
level: 1,
version: newVersion(opts, [numLevels][]*fileMetadata{}),
wants: []want{
{"x", true},
},
},
{
desc: "non-empty",
level: 1,
version: newVersion(opts, [numLevels][]*fileMetadata{
1: {
{
Smallest: base.ParseInternalKey("c.SET.801"),
Largest: base.ParseInternalKey("g.SET.800"),
},
{
Smallest: base.ParseInternalKey("x.SET.701"),
Largest: base.ParseInternalKey("y.SET.700"),
},
},
2: {
{
Smallest: base.ParseInternalKey("d.SET.601"),
Largest: base.ParseInternalKey("h.SET.600"),
},
{
Smallest: base.ParseInternalKey("r.SET.501"),
Largest: base.ParseInternalKey("t.SET.500"),
},
},
3: {
{
Smallest: base.ParseInternalKey("f.SET.401"),
Largest: base.ParseInternalKey("g.SET.400"),
},
{
Smallest: base.ParseInternalKey("w.SET.301"),
Largest: base.ParseInternalKey("x.SET.300"),
},
},
4: {
{
Smallest: base.ParseInternalKey("f.SET.201"),
Largest: base.ParseInternalKey("m.SET.200"),
},
{
Smallest: base.ParseInternalKey("t.SET.101"),
Largest: base.ParseInternalKey("t.SET.100"),
},
},
}),
wants: []want{
{"b", true},
{"c", true},
{"d", true},
{"e", true},
{"f", false},
{"g", false},
{"h", false},
{"l", false},
{"m", false},
{"n", true},
{"q", true},
{"r", true},
{"s", true},
{"t", false},
{"u", true},
{"v", true},
{"w", false},
{"x", false},
{"y", true},
{"z", true},
},
},
{
desc: "repeated ukey",
level: 1,
version: newVersion(opts, [numLevels][]*fileMetadata{
6: {
{
Smallest: base.ParseInternalKey("i.SET.401"),
Largest: base.ParseInternalKey("i.SET.400"),
},
{
Smallest: base.ParseInternalKey("i.SET.301"),
Largest: base.ParseInternalKey("k.SET.300"),
},
{
Smallest: base.ParseInternalKey("k.SET.201"),
Largest: base.ParseInternalKey("m.SET.200"),
},
{
Smallest: base.ParseInternalKey("m.SET.101"),
Largest: base.ParseInternalKey("m.SET.100"),
},
},
}),
wants: []want{
{"h", true},
{"i", false},
{"j", false},
{"k", false},
{"l", false},
{"m", false},
{"n", true},
},
},
}
for _, tc := range testCases {
c := compaction{
cmp: DefaultComparer.Compare,
version: tc.version,
inputs: []compactionLevel{{level: tc.level}, {level: tc.level + 1}},
smallest: base.ParseInternalKey("a.SET.0"),
largest: base.ParseInternalKey("z.SET.0"),
}
c.startLevel, c.outputLevel = &c.inputs[0], &c.inputs[1]
c.setupInuseKeyRanges()
for _, w := range tc.wants {
if got := c.elideTombstone([]byte(w.key)); got != w.expected {
t.Errorf("%s: ukey=%q: got %v, want %v", tc.desc, w.key, got, w.expected)
}
}
}
} | explode_data.jsonl/51398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1672
} | [
2830,
3393,
6582,
577,
51,
2855,
10812,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
609,
3798,
16094,
64734,
22834,
19098,
16273,
2822,
13158,
1366,
2036,
341,
197,
23634,
414,
914,
198,
197,
42400,
1807,
198,
197,
630,
18185,
37302,
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... | 4 |
func TestSessionStoreExists(t *testing.T) {
cs := NewCookieStore([]byte(""), []byte(""), []byte("testtesttesttest"))
// Fail when attempting to Store with bad context
err := cs.Store(nil, "", "", time.Hour)
assert.Equal(t, err, ErrNoResponseWriter)
// Fail when attempting to Verify without valid cookie
req, err := http.NewRequest("", "", nil)
v, tm, err := cs.Exists(SetContext(nil, nil, req, ""), "uid")
assert.Error(t, err)
assert.False(t, v)
assert.Equal(t, time.Time{}, tm)
// Write token to cookie
rec := NewResponseRecorder()
ctx := SetContext(nil, rec, nil, "")
err = cs.Store(ctx, "token", "uid", time.Hour)
assert.NoError(t, err)
assert.NotNil(t, rec.Header().Get("Set-Cookie"))
// Read response
resp := rec.Response()
req, err = http.NewRequest("", "", nil)
assert.NoError(t, err)
for _, c := range resp.Cookies() {
req.AddCookie(c)
}
// Check Exists
v, tm, err = cs.Exists(SetContext(nil, nil, req, ""), "uid")
assert.NoError(t, err)
assert.True(t, v)
assert.NotEqual(t, time.Time{}, tm)
// Check Exists fails for wrong uid
v, tm, err = cs.Exists(SetContext(nil, nil, req, ""), "anotheruid")
assert.Equal(t, err, ErrWrongTokenUID)
assert.False(t, v)
assert.Equal(t, time.Time{}, tm)
// Test bad cookie fails verification
req, err = http.NewRequest("", "", nil)
req.AddCookie(&http.Cookie{Name: "passwordless", Value: "invalid!"})
v, tm, err = cs.Exists(SetContext(nil, nil, req, ""), "uid")
assert.Error(t, err)
assert.False(t, v)
assert.Equal(t, time.Time{}, tm)
} | explode_data.jsonl/27426 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 601
} | [
2830,
3393,
5283,
6093,
15575,
1155,
353,
8840,
836,
8,
341,
71899,
1669,
1532,
20616,
6093,
10556,
3782,
86076,
3056,
3782,
86076,
3056,
3782,
445,
1944,
1944,
1944,
1944,
28075,
197,
322,
39645,
979,
19405,
311,
9129,
448,
3873,
2266,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEqualApprox(t *testing.T) {
t.Parallel()
s1 := []float64{1, 2, 3, 4}
s2 := []float64{1, 2, 3, 4 + 1e-10}
if EqualApprox(s1, s2, 1e-13) {
t.Errorf("Unequal slices returned as equal for absolute")
}
if !EqualApprox(s1, s2, 1e-5) {
t.Errorf("Equal slices returned as unequal for absolute")
}
s1 = []float64{1, 2, 3, 1000}
s2 = []float64{1, 2, 3, 1000 * (1 + 1e-7)}
if EqualApprox(s1, s2, 1e-8) {
t.Errorf("Unequal slices returned as equal for relative")
}
if !EqualApprox(s1, s2, 1e-5) {
t.Errorf("Equal slices returned as unequal for relative")
}
if EqualApprox(s1, []float64{}, 1e-5) {
t.Errorf("Unequal slice lengths returned as equal")
}
} | explode_data.jsonl/1220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
2993,
69520,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
16,
1669,
3056,
3649,
21,
19,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
532,
1903,
17,
1669,
3056,
3649,
21,
19,
90,
16,
11,
220,
17,
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... | 6 |
func TestOwnedOutputState(t *testing.T) {
intf := interface{}(&OwnedOutput{})
if _, ok := intf.(verify.State); !ok {
t.Fatalf("should be marked as state")
}
} | explode_data.jsonl/22033 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
57641,
5097,
1397,
1155,
353,
8840,
836,
8,
341,
2084,
69,
1669,
3749,
6257,
2099,
57641,
5097,
37790,
743,
8358,
5394,
1669,
93706,
12832,
12446,
18942,
1215,
753,
562,
341,
197,
3244,
30762,
445,
5445,
387,
12864,
438,
158... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDirectoryEntryToBytes(t *testing.T) {
fs := &FileSystem{
blocksize: int64(2048),
}
validDe, validBytes, _, _, err := getRockRidgeDirectoryEntries(fs, true)
if err != nil {
t.Fatal(err)
}
for i, de := range validDe[0:1] {
b, err := de.toBytes(false, []uint32{19})
switch {
case err != nil:
t.Errorf("Error converting directory entry to bytes: %v", err)
t.Logf("%v", de)
case int(b[0][0]) != len(b[0]):
t.Errorf("Reported size as %d but had %d bytes", b[0], len(b))
default:
// compare the actual dir entry
if bytes.Compare(directoryEntryBytesNullDate(b[0]), directoryEntryBytesNullDate(validBytes[i][0])) != 0 {
t.Errorf("%d: Mismatched entry bytes %s, actual vs expected", i, de.filename)
t.Log(b[0])
t.Log(validBytes[i])
}
// compare the continuation entries
if len(validBytes[i]) != len(b) {
t.Errorf("%d: Mismatched number of continuation entries actual %d expected %d", i, len(b)-1, len(validBytes[i])-1)
}
for j, e := range validBytes[i][1:] {
if bytes.Compare(e, b[j+1]) != 0 {
t.Errorf("%d: mismatched continuation entry bytes, actual then expected", i)
t.Log(b[j+1])
t.Log(e)
}
}
}
}
} | explode_data.jsonl/71549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 520
} | [
2830,
3393,
9310,
5874,
1249,
7078,
1155,
353,
8840,
836,
8,
341,
53584,
1669,
609,
50720,
515,
197,
47996,
2141,
25,
526,
21,
19,
7,
17,
15,
19,
23,
1326,
197,
532,
56322,
1912,
11,
2697,
7078,
11,
8358,
8358,
1848,
1669,
633,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResolveTCPAddr(t *testing.T) {
origTestHookLookupIP := testHookLookupIP
defer func() { testHookLookupIP = origTestHookLookupIP }()
testHookLookupIP = lookupLocalhost
for _, tt := range resolveTCPAddrTests {
addr, err := ResolveTCPAddr(tt.network, tt.litAddrOrName)
if !reflect.DeepEqual(addr, tt.addr) || !reflect.DeepEqual(err, tt.err) {
t.Errorf("ResolveTCPAddr(%q, %q) = %#v, %v, want %#v, %v", tt.network, tt.litAddrOrName, addr, err, tt.addr, tt.err)
continue
}
if err == nil {
addr2, err := ResolveTCPAddr(addr.Network(), addr.String())
if !reflect.DeepEqual(addr2, tt.addr) || err != tt.err {
t.Errorf("(%q, %q): ResolveTCPAddr(%q, %q) = %#v, %v, want %#v, %v", tt.network, tt.litAddrOrName, addr.Network(), addr.String(), addr2, err, tt.addr, tt.err)
}
}
}
} | explode_data.jsonl/18971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
56808,
49896,
13986,
1155,
353,
8840,
836,
8,
341,
197,
4670,
2271,
31679,
34247,
3298,
1669,
1273,
31679,
34247,
3298,
198,
16867,
2915,
368,
314,
1273,
31679,
34247,
3298,
284,
2713,
2271,
31679,
34247,
3298,
50746,
18185,
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 TestWebhookInvalid(t *testing.T) {
f, _ := ioutil.ReadFile("testdata/webhooks/push.json")
r, _ := http.NewRequest("GET", "/", bytes.NewBuffer(f))
r.Header.Set("X-GitHub-Event", "push")
r.Header.Set("X-GitHub-Delivery", "ee8d97b4-1479-43f1-9cac-fbbd1b80da55")
r.Header.Set("X-Hub-Signature", "sha1=380f462cd2e160b84765144beabdad2e930a7ec5")
s := new(webhookService)
_, err := s.Parse(r, secretFunc)
if err != scm.ErrSignatureInvalid {
t.Errorf("Expect invalid signature error, got %v", err)
}
} | explode_data.jsonl/81321 | {
"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,
5981,
20873,
7928,
1155,
353,
8840,
836,
8,
341,
1166,
11,
716,
1669,
43144,
78976,
445,
92425,
21808,
38560,
4322,
1116,
4323,
1138,
7000,
11,
716,
1669,
1758,
75274,
445,
3806,
497,
64657,
5820,
7121,
4095,
955,
1171,
7000... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadOrGenerate(t *testing.T) {
dataDir, err := ioutil.TempDir("", "oasis-identity-test_")
require.NoError(t, err, "create data dir")
defer os.RemoveAll(dataDir)
factory := fileSigner.NewFactory(dataDir, signature.SignerNode, signature.SignerP2P, signature.SignerConsensus)
// Generate a new identity.
identity, err := LoadOrGenerate(dataDir, factory)
require.NoError(t, err, "LoadOrGenerate")
// Load an existing identity.
identity2, err := LoadOrGenerate(dataDir, factory)
require.NoError(t, err, "LoadOrGenerate (2)")
require.EqualValues(t, identity.NodeSigner, identity2.NodeSigner)
require.EqualValues(t, identity.P2PSigner, identity2.P2PSigner)
require.EqualValues(t, identity.ConsensusSigner, identity2.ConsensusSigner)
require.EqualValues(t, identity.TLSSigner, identity2.TLSSigner)
// TODO: Check that it always generates a fresh certificate once oasis-core#1541 is done.
require.EqualValues(t, identity.TLSCertificate, identity2.TLSCertificate)
} | explode_data.jsonl/52520 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
5879,
2195,
31115,
1155,
353,
8840,
836,
8,
341,
8924,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
78,
10718,
12,
16912,
16839,
62,
1138,
17957,
35699,
1155,
11,
1848,
11,
330,
3182,
821,
5419,
1138,
16867,
2643,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCAConfigDBStringer(t *testing.T) {
dbconfig := CAConfigDB{
Type: "postgres",
Datasource: "dbname=mypostgres host=127.0.0.1 port=8888 user=admin password=admin sslmode=disable",
}
str := fmt.Sprintf("%+v", dbconfig) // String method of CAConfigDB is called here
t.Logf("Stringified postgres CAConfigDB: %s", str)
assert.Contains(t, str, "user=****", "Username is not masked in the datasource URL")
assert.Contains(t, str, "password=****", "Password is not masked in the datasource URL")
dbconfig.Datasource = "dbname=mypostgres host=127.0.0.1 port=8888 password=admin sslmode=disable user=admin"
str = fmt.Sprintf("%+v", dbconfig) // String method of CAConfigDB is called here
t.Logf("Stringified postgres CAConfigDB: %s", str)
assert.Contains(t, str, "user=****", "Username is not masked in the datasource URL")
assert.Contains(t, str, "password=****", "Password is not masked in the datasource URL")
dbconfig.Datasource = "dbname=cadb password=adminpwd host=127.0.0.1 port=8888 user=cadb sslmode=disable"
str = fmt.Sprintf("%+v", dbconfig) // String method of CAConfigDB is called here
t.Logf("Stringified postgres CAConfigDB: %s", str)
assert.Contains(t, str, "user=****", "Username is not masked in the datasource URL")
assert.Contains(t, str, "password=****", "Password is not masked in the datasource URL")
dbconfig = CAConfigDB{
Type: "mysql",
Datasource: "root:rootpw@tcp(localhost:8888)/mysqldb?parseTime=true",
}
str = fmt.Sprintf("%+v", dbconfig)
t.Logf("Stringified mysql CAConfigDB: %s", str)
assert.NotContains(t, str, "root", "Username is not masked in the datasource URL")
assert.NotContains(t, str, "rootpw", "Password is not masked in the datasource URL")
} | explode_data.jsonl/82694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 641
} | [
2830,
3393,
5049,
2648,
3506,
703,
261,
1155,
353,
8840,
836,
8,
341,
20939,
1676,
1669,
9183,
2648,
3506,
515,
197,
27725,
25,
981,
330,
43070,
756,
197,
10957,
19346,
919,
25,
330,
35265,
27221,
1082,
535,
17818,
3468,
28,
16,
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 TestShimInCgroup(t *testing.T) {
t.Parallel()
client, err := newClient(t, address)
if err != nil {
t.Fatal(err)
}
defer client.Close()
if client.runtime == "io.containerd.runc.v1" {
t.Skip()
}
var (
ctx, cancel = testContext()
id = t.Name()
)
defer cancel()
image, err := client.GetImage(ctx, testImage)
if err != nil {
t.Fatal(err)
}
container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), oci.WithProcessArgs("sleep", "30")))
if err != nil {
t.Fatal(err)
}
defer container.Delete(ctx, WithSnapshotCleanup)
// create a cgroup for the shim to use
path := "/containerd/shim"
cg, err := cgroups.New(cgroups.V1, cgroups.StaticPath(path), &specs.LinuxResources{})
if err != nil {
t.Fatal(err)
}
defer cg.Delete()
task, err := container.NewTask(ctx, empty(), func(_ context.Context, client *Client, r *TaskInfo) error {
r.Options = &runctypes.CreateOptions{
ShimCgroup: path,
}
return nil
})
if err != nil {
t.Fatal(err)
}
defer task.Delete(ctx)
statusC, err := task.Wait(ctx)
if err != nil {
t.Fatal(err)
}
// check to see if the shim is inside the cgroup
processes, err := cg.Processes(cgroups.Devices, false)
if err != nil {
t.Fatal(err)
}
if len(processes) == 0 {
t.Errorf("created cgroup should have atleast one process inside: %d", len(processes))
}
if err := task.Kill(ctx, unix.SIGKILL); err != nil {
t.Fatal(err)
}
<-statusC
} | explode_data.jsonl/39631 | {
"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,
2016,
318,
641,
34,
4074,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
25291,
11,
1848,
1669,
501,
2959,
1155,
11,
2621,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
2943,
10421,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStdTest(t *testing.T) {
testenv.MustHaveGoBuild(t)
if testing.Short() && testenv.Builder() == "" {
t.Skip("skipping in short mode")
}
testTestDir(t, filepath.Join(runtime.GOROOT(), "test"),
"cmplxdivide.go", // also needs file cmplxdivide1.go - ignore
)
} | explode_data.jsonl/53276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
22748,
2271,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
50463,
12116,
10850,
11066,
1155,
692,
743,
7497,
55958,
368,
1009,
1273,
3160,
15641,
368,
621,
1591,
341,
197,
3244,
57776,
445,
4886,
5654,
304,
2805,
3856,
1138,
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... | 3 |
func TestLogObjMethods(t *testing.T) {
var expected = ":\n{\n\t\"Value1\": 42,\n\t\"Value2\": true,\n\t\"Value3\": \"Moin\"\n}"
var log = Init(TRACE_LEVEL, false, true)
var exampleObj = Example{
Value1: 42,
Value2: true,
Value3: "Moin",
}
log.TraceObj(exampleObj)
var lastTrace = log.GetLastLog()
log.DebugObj(exampleObj)
var lastDebug = log.GetLastLog()
log.InfoObj(exampleObj)
var lastInfo = log.GetLastLog()
log.WarnObj(exampleObj)
var lastWarn = log.GetLastLog()
log.ErrorObj(exampleObj)
var lastError = log.GetLastLog()
if !strings.Contains(lastTrace, expected) {
t.Errorf("Got: %s expected: %s", lastTrace, expected)
}
if !strings.Contains(lastDebug, expected) {
t.Errorf("Got: %s expected: %s", lastTrace, expected)
}
if !strings.Contains(lastInfo, expected) {
t.Errorf("Got: %s expected: %s", lastInfo, expected)
}
if !strings.Contains(lastWarn, expected) {
t.Errorf("Got: %s expected: %s", lastWarn, expected)
}
if !strings.Contains(lastError, expected) {
t.Errorf("Got: %s expected: %s", lastError, expected)
}
} | explode_data.jsonl/3662 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 432
} | [
2830,
3393,
2201,
5261,
17856,
1155,
353,
8840,
836,
8,
341,
2405,
3601,
284,
330,
7190,
77,
35702,
77,
4955,
2105,
1130,
16,
11693,
220,
19,
17,
26266,
77,
4955,
2105,
1130,
17,
11693,
830,
26266,
77,
4955,
2105,
1130,
18,
11693,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetDefaultProviderName(t *testing.T) {
testCases := []getDefaultProviderNameTestCase{
getDefaultProviderNameTestCase{
name: "Get set default",
config: &latest.Config{
Default: "myDefault",
},
expectedDefault: "myDefault",
},
}
for _, testCase := range testCases {
loader := &loader{
loadedConfig: testCase.config,
}
defaultProvider, _ := loader.GetDefaultProviderName()
assert.Equal(t, defaultProvider, testCase.expectedDefault, "Unexpected provider name in testCase %s", testCase.name)
}
} | explode_data.jsonl/54494 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
1949,
3675,
5179,
675,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
75987,
5179,
675,
16458,
515,
197,
10366,
3675,
5179,
675,
16458,
515,
298,
11609,
25,
330,
1949,
738,
1638,
756,
298,
25873,
25,
609,
19350,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnhappyHealthCheck(t *testing.T) {
draftContentRW := mockHealthyExternalService()
cAPI := new(ExternalServiceMock)
cAPI.On("GTG").Return(errors.New("computer says no"))
cAPI.On("Endpoint").Return("http://cool.api.ft.com/content")
liveBlogPost := mockHealthyExternalService()
h, err := NewHealthService("", "", "", draftContentRW, cAPI, &mockConfig, []ExternalService{liveBlogPost})
assert.NoError(t, err)
req := httptest.NewRequest("GET", "/__health", nil)
w := httptest.NewRecorder()
h.HealthCheckHandleFunc()(w, req)
resp := w.Result()
assert.Equal(t, http.StatusOK, resp.StatusCode)
hcBody := make(map[string]interface{})
err = json.NewDecoder(resp.Body).Decode(&hcBody)
assert.NoError(t, err)
assert.Len(t, hcBody["checks"], 3)
assert.False(t, hcBody["ok"].(bool))
checks := hcBody["checks"].([]interface{})
for _, c := range checks {
check := c.(map[string]interface{})
if check["id"] == "check-content-api-health" {
assert.False(t, check["ok"].(bool))
assert.Equal(t, "computer says no", check["checkOutput"])
assert.Equal(t, "Content API is not available at http://cool.api.ft.com/content", check["technicalSummary"])
break
}
}
cAPI.AssertExpectations(t)
} | explode_data.jsonl/2302 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 456
} | [
2830,
3393,
1806,
56521,
14542,
3973,
1155,
353,
8840,
836,
8,
341,
2698,
2944,
2762,
56368,
1669,
7860,
96113,
25913,
1860,
2822,
1444,
7082,
1669,
501,
7,
25913,
1860,
11571,
340,
1444,
7082,
8071,
445,
25388,
38,
1827,
5598,
38881,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContextRenderRedirectAll(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "http://example.com", nil)
assert.Panics(t, func() { c.Redirect(http.StatusOK, "/resource") })
assert.Panics(t, func() { c.Redirect(http.StatusAccepted, "/resource") })
assert.Panics(t, func() { c.Redirect(299, "/resource") })
assert.Panics(t, func() { c.Redirect(309, "/resource") })
assert.NotPanics(t, func() { c.Redirect(http.StatusMultipleChoices, "/resource") })
assert.NotPanics(t, func() { c.Redirect(http.StatusPermanentRedirect, "/resource") })
} | explode_data.jsonl/26801 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
1972,
6750,
17725,
2403,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
4230,
2271,
1972,
73392,
83,
70334,
7121,
47023,
2398,
1444,
9659,
11,
716,
284,
1758,
75274,
445,
2946,
497,
330,
1254,
1110,
8687,
905,
497,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDelete(t *testing.T) {
d, done := newDS(t, nil)
defer done()
addTestCases(t, d, testcases)
has, err := d.Has(bg, ds.NewKey("/a/b/c"))
if err != nil {
t.Error(err)
}
if !has {
t.Error("Key should be found")
}
err = d.Delete(bg, ds.NewKey("/a/b/c"))
if err != nil {
t.Error(err)
}
has, err = d.Has(bg, ds.NewKey("/a/b/c"))
if err != nil {
t.Error(err)
}
if has {
t.Error("Key should not be found")
}
} | explode_data.jsonl/923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
6435,
1155,
353,
8840,
836,
8,
341,
2698,
11,
2814,
1669,
501,
5936,
1155,
11,
2092,
340,
16867,
2814,
741,
12718,
2271,
37302,
1155,
11,
294,
11,
1273,
23910,
692,
63255,
11,
1848,
1669,
294,
16152,
59360,
11,
11472,
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... | 6 |
func TestClose(t *testing.T) {
gaia.Cfg = &gaia.Config{}
tmp, _ := ioutil.TempDir("", "TestInit")
gaia.Cfg.Logger = hclog.New(&hclog.LoggerOptions{
Level: hclog.Trace,
Output: hclog.DefaultOutput,
Name: "Gaia",
})
emptyPlugin := &Plugin{}
p := emptyPlugin.NewPlugin(new(fakeCAAPI))
logpath := filepath.Join(tmp, "test")
p.Init(exec.Command("echo", "world"), &logpath)
p.Close()
} | explode_data.jsonl/25830 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
7925,
1155,
353,
8840,
836,
8,
341,
3174,
64,
685,
727,
4817,
284,
609,
6743,
685,
10753,
16094,
20082,
11,
716,
1669,
43144,
65009,
6184,
19814,
330,
2271,
3803,
1138,
3174,
64,
685,
727,
4817,
12750,
284,
50394,
839,
712... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadErrorBadTar(t *testing.T) {
var buf bytes.Buffer
gw := gzip.NewWriter(&buf)
_, _ = gw.Write([]byte("bad tar bytes"))
_ = gw.Close()
_, err := NewReader(&buf).Read()
if err == nil {
t.Fatal("expected error")
}
} | explode_data.jsonl/55378 | {
"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,
4418,
1454,
17082,
62733,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
5820,
22622,
198,
3174,
86,
1669,
57795,
7121,
6492,
2099,
5909,
340,
197,
6878,
716,
284,
56572,
4073,
10556,
3782,
445,
13855,
12183,
5820,
5455,
197,
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... | 2 |
func TestSortByRevision(t *testing.T) {
SortByRevision(releases)
check(t, "ByRevision", func(i, j int) bool {
vi := releases[i].Version
vj := releases[j].Version
return vi < vj
})
} | explode_data.jsonl/4971 | {
"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,
10231,
1359,
33602,
1155,
353,
8840,
836,
8,
341,
7568,
371,
1359,
33602,
5801,
28299,
692,
25157,
1155,
11,
330,
1359,
33602,
497,
2915,
1956,
11,
502,
526,
8,
1807,
341,
197,
5195,
72,
1669,
19232,
989,
936,
5637,
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 |
func Test_solve(t *testing.T) {
tests := []struct {
name string
input string
expected int
}{
{
name: "example1",
input: `
7
`,
expected: 2,
},
{
name: "example1",
input: `
127
`,
expected: 4,
},
{
name: "example1",
input: `
3
`,
expected: 3,
},
{
name: "example1",
input: `
44852
`,
expected: 16,
},
}
for _, tt := range tests {
reader := bufio.NewReader(strings.NewReader(lib_TrimSpaceAndNewLineCodeAndTab(tt.input)))
input, err := lib_NewInputFromReader(reader)
if err != nil {
t.Errorf("unexpected error occurred in test %s: %v", tt.name, err)
}
actual := solve(input)
if actual != tt.expected {
t.Errorf("%s is expected to return %v when input %q is given, but actually return %v",
tt.name, tt.expected, input.lines, actual)
}
}
} | explode_data.jsonl/52715 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
86246,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
914,
198,
197,
42400,
526,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
8687,
16,
756,
298,
22427,
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... | 4 |
func TestNew(t *testing.T) {
ln, _ := node.GenerateTestNode(t)
cfg := config.DefaultConfig()
sim := service.NewSimulator()
n1 := sim.NewNodeFrom(ln.Node)
d := New(ln, cfg.SwarmConfig, n1)
assert.NotNil(t, d, "D is not nil")
} | explode_data.jsonl/37073 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
197,
2261,
11,
716,
1669,
2436,
57582,
2271,
1955,
1155,
692,
50286,
1669,
2193,
13275,
2648,
741,
1903,
318,
1669,
2473,
7121,
14027,
10511,
2822,
9038,
16,
1669,
1643,
7121,
1955,
3830,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSelectForUpdateNoWait(t *testing.T) {
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk3 := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk2.MustExec("use test")
tk3.MustExec("use test")
tk.MustExec("drop table if exists tk")
tk.MustExec("create table tk (c1 int primary key, c2 int)")
tk.MustExec("insert into tk values(1,1),(2,2),(3,3),(4,4),(5,5)")
tk.MustExec("set @@autocommit = 0")
tk2.MustExec("set @@autocommit = 0")
tk3.MustExec("set @@autocommit = 0")
// point get with no autocommit
tk.MustExec("begin pessimistic")
tk.MustExec("select * from tk where c1 = 2 for update") // lock succ
tk2.MustExec("begin pessimistic")
_, err := tk2.Exec("select * from tk where c1 = 2 for update nowait")
require.Error(t, err)
tk.MustExec("commit")
tk2.MustExec("select * from tk where c1 = 2 for update nowait") // lock succ
tk3.MustExec("begin pessimistic")
_, err = tk3.Exec("select * from tk where c1 = 2 for update nowait")
require.Error(t, err)
tk2.MustExec("commit")
tk3.MustExec("select * from tk where c1 = 2 for update")
tk3.MustExec("commit")
tk.MustExec("commit")
tk3.MustExec("begin pessimistic")
tk3.MustExec("update tk set c2 = c2 + 1 where c1 = 3")
tk2.MustExec("begin pessimistic")
_, err = tk2.Exec("select * from tk where c1 = 3 for update nowait")
require.Error(t, err)
tk3.MustExec("commit")
tk2.MustExec("select * from tk where c1 = 3 for update nowait")
tk2.MustExec("commit")
tk.MustExec("commit")
tk2.MustExec("commit")
tk3.MustExec("commit")
// scan with no autocommit
tk.MustExec("begin pessimistic")
tk.MustExec("select * from tk where c1 >= 2 for update")
tk2.MustExec("begin pessimistic")
_, err = tk2.Exec("select * from tk where c1 = 2 for update nowait")
require.Error(t, err)
_, err = tk2.Exec("select * from tk where c1 > 3 for update nowait")
require.Error(t, err)
tk2.MustExec("select * from tk where c1 = 1 for update nowait")
tk2.MustExec("commit")
tk.MustQuery("select * from tk where c1 >= 2 for update").Check(testkit.Rows("2 2", "3 4", "4 4", "5 5"))
tk.MustExec("commit")
tk.MustExec("begin pessimistic")
tk.MustExec("update tk set c2 = c2 + 10 where c1 > 3")
tk3.MustExec("begin pessimistic")
_, err = tk3.Exec("select * from tk where c1 = 5 for update nowait")
require.Error(t, err)
tk3.MustExec("select * from tk where c1 = 1 for update nowait")
tk.MustExec("commit")
tk3.MustQuery("select * from tk where c1 > 3 for update nowait").Check(testkit.Rows("4 14", "5 15"))
tk3.MustExec("commit")
// delete
tk3.MustExec("begin pessimistic")
tk3.MustExec("delete from tk where c1 <= 2")
tk.MustExec("begin pessimistic")
_, err = tk.Exec("select * from tk where c1 = 1 for update nowait")
require.Error(t, err)
tk3.MustExec("commit")
tk.MustQuery("select * from tk where c1 > 1 for update nowait").Check(testkit.Rows("3 4", "4 14", "5 15"))
tk.MustExec("update tk set c2 = c2 + 1 where c1 = 5")
tk2.MustExec("begin pessimistic")
_, err = tk2.Exec("select * from tk where c1 = 5 for update nowait")
require.Error(t, err)
tk.MustExec("commit")
tk2.MustQuery("select * from tk where c1 = 5 for update nowait").Check(testkit.Rows("5 16"))
tk2.MustExec("update tk set c2 = c2 + 1 where c1 = 5")
tk2.MustQuery("select * from tk where c1 = 5 for update nowait").Check(testkit.Rows("5 17"))
tk2.MustExec("commit")
} | explode_data.jsonl/12462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1309
} | [
2830,
3393,
3379,
2461,
4289,
2753,
14190,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1855,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodeStack_Peek(t *testing.T) {
stack := new(gost.NodeStack)
value := stack.Peek()
if value != nil {
t.Error("Peek() did not return nil on empty stack")
}
elem := newVector(0)
stack.Push(elem)
value = stack.Peek()
if value == nil {
t.Error("Peek() failed")
}
if *(value.(*vector)) != *elem {
t.Errorf("Peek() error: expected %v, got %v", elem, value)
}
} | explode_data.jsonl/40065 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
1955,
4336,
1088,
68,
1225,
1155,
353,
8840,
836,
8,
341,
48227,
1669,
501,
3268,
535,
21714,
4336,
340,
16309,
1669,
5611,
94279,
741,
743,
897,
961,
2092,
341,
197,
3244,
6141,
445,
10197,
1225,
368,
1521,
537,
470,
2092... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShardTimeRangesIsEmpty(t *testing.T) {
assert.True(t, shardTimeRanges{}.IsEmpty())
assert.True(t, shardTimeRanges{0: xtime.NewRanges(), 1: xtime.NewRanges()}.IsEmpty())
assert.True(t, shardTimeRanges{0: xtime.NewRanges(xtime.Range{})}.IsEmpty())
assert.False(t, shardTimeRanges{0: xtime.NewRanges(xtime.Range{
Start: time.Now(),
End: time.Now().Add(time.Second),
})}.IsEmpty())
} | explode_data.jsonl/4674 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
2016,
567,
1462,
74902,
91307,
1155,
353,
8840,
836,
8,
341,
6948,
32443,
1155,
11,
52069,
1462,
74902,
46391,
91307,
2398,
6948,
32443,
1155,
11,
52069,
1462,
74902,
90,
15,
25,
856,
1678,
7121,
74902,
1507,
220,
16,
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... | 1 |
func TestAllocsInterfaceSmall(t *testing.T) {
if testing.Short() {
t.Skip("skipping malloc count in short mode")
}
v := ValueOf(int64(0))
if allocs := testing.AllocsPerRun(100, func() { v.Interface() }); allocs > 0 {
t.Error("allocs:", allocs)
}
} | explode_data.jsonl/29618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
25154,
82,
5051,
25307,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
15731,
1760,
304,
2805,
3856,
1138,
197,
532,
5195,
1669,
5162,
2124,
1548,
21,
19,
7,
15,
1171,
743,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetField(t *testing.T) {
m := &MyType{
Foo: "hello",
Bar: 42,
}
tests := []struct {
Field string
Exp interface{}
}{
{
Field: "Foo",
Exp: "hello",
},
{
Field: "Bar",
Exp: int(42),
},
}
for _, test := range tests {
t.Run(test.Field, func(t *testing.T) {
field, err := GetField(m, test.Field)
require.NoError(t, err)
assert.Equal(t, test.Exp, field)
})
}
} | explode_data.jsonl/68916 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
1949,
1877,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
609,
5050,
929,
515,
197,
12727,
2624,
25,
330,
14990,
756,
197,
197,
3428,
25,
220,
19,
17,
345,
197,
630,
78216,
1669,
3056,
1235,
341,
197,
94478,
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... | 1 |
func TestTooManyRecords(t *testing.T) {
const recs = int(^uint16(0)) + 1
tests := []struct {
name string
msg Message
want error
}{
{
"Questions",
Message{
Questions: make([]Question, recs),
},
errTooManyQuestions,
},
{
"Answers",
Message{
Answers: make([]Resource, recs),
},
errTooManyAnswers,
},
{
"Authorities",
Message{
Authorities: make([]Resource, recs),
},
errTooManyAuthorities,
},
{
"Additionals",
Message{
Additionals: make([]Resource, recs),
},
errTooManyAdditionals,
},
}
for _, test := range tests {
if _, got := test.msg.Pack(); got != test.want {
t.Errorf("Packing %d %s: got = %v, want = %v", recs, test.name, got, test.want)
}
}
} | explode_data.jsonl/60557 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 346
} | [
2830,
3393,
31246,
8441,
25876,
1155,
353,
8840,
836,
8,
341,
4777,
1395,
82,
284,
526,
33810,
2496,
16,
21,
7,
15,
593,
488,
220,
16,
198,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
21169,
220,
4856,
198,
197,
50780,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileWithTimeoutAndRetry(t *testing.T) {
for _, tc := range []struct {
name string
retries int
conditionSucceeded corev1.ConditionStatus
wantEvents []string
}{{
name: "One try has to be done",
retries: 1,
conditionSucceeded: corev1.ConditionFalse,
wantEvents: []string{
"Warning Failed PipelineRun \"test-pipeline-retry-run-with-timeout\" failed to finish within",
},
}, {
name: "No more retries are needed",
retries: 2,
conditionSucceeded: corev1.ConditionUnknown,
wantEvents: []string{
"Warning Failed PipelineRun \"test-pipeline-retry-run-with-timeout\" failed to finish within",
},
}} {
t.Run(tc.name, func(t *testing.T) {
ps := []*v1beta1.Pipeline{parse.MustParsePipeline(t, fmt.Sprintf(`
metadata:
name: test-pipeline-retry
namespace: foo
spec:
tasks:
- name: hello-world-1
retries: %d
taskRef:
name: hello-world
`, tc.retries))}
prs := []*v1beta1.PipelineRun{parse.MustParsePipelineRun(t, `
metadata:
name: test-pipeline-retry-run-with-timeout
namespace: foo
spec:
pipelineRef:
name: test-pipeline-retry
serviceAccountName: test-sa
timeout: 12h0m0s
status:
startTime: "2021-12-31T00:00:00Z"
`)}
ts := []*v1beta1.Task{
simpleHelloWorldTask,
}
trs := []*v1beta1.TaskRun{parse.MustParseTaskRun(t, `
metadata:
name: hello-world-1
namespace: foo
status:
conditions:
- status: "False"
type: Succeeded
podName: my-pod-name
retriesStatus:
- conditions:
- status: "False"
type: Succeeded
`)}
prtrs := &v1beta1.PipelineRunTaskRunStatus{
PipelineTaskName: "hello-world-1",
Status: &trs[0].Status,
}
prs[0].Status.TaskRuns = make(map[string]*v1beta1.PipelineRunTaskRunStatus)
prs[0].Status.TaskRuns["hello-world-1"] = prtrs
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
TaskRuns: trs,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-retry-run-with-timeout", []string{}, false)
if len(reconciledRun.Status.TaskRuns["hello-world-1"].Status.RetriesStatus) != tc.retries {
t.Fatalf(" %d retry expected but %d ", tc.retries, len(reconciledRun.Status.TaskRuns["hello-world-1"].Status.RetriesStatus))
}
if status := reconciledRun.Status.TaskRuns["hello-world-1"].Status.GetCondition(apis.ConditionSucceeded).Status; status != tc.conditionSucceeded {
t.Fatalf("Succeeded expected to be %s but is %s", tc.conditionSucceeded, status)
}
})
}
} | explode_data.jsonl/27304 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1185
} | [
2830,
3393,
693,
40446,
457,
2354,
7636,
3036,
51560,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
11609,
2290,
914,
198,
197,
17200,
4543,
310,
526,
198,
197,
197,
9056,
50,
43805,
6200,
85,
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... | 3 |
func TestTeamMembersMinusGroupMembers(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
user1 := th.BasicUser
user2 := th.BasicUser2
team := th.CreateTeam()
team.GroupConstrained = model.NewBool(true)
team, err := th.App.UpdateTeam(team)
require.Nil(t, err)
_, err = th.App.AddTeamMember(team.Id, user1.Id)
require.Nil(t, err)
_, err = th.App.AddTeamMember(team.Id, user2.Id)
require.Nil(t, err)
group1 := th.CreateGroup()
group2 := th.CreateGroup()
_, err = th.App.UpsertGroupMember(group1.Id, user1.Id)
require.Nil(t, err)
_, err = th.App.UpsertGroupMember(group2.Id, user2.Id)
require.Nil(t, err)
// No permissions
_, _, res := th.Client.TeamMembersMinusGroupMembers(team.Id, []string{group1.Id, group2.Id}, 0, 100, "")
require.Equal(t, "api.context.permissions.app_error", res.Error.Id)
testCases := map[string]struct {
groupIDs []string
page int
perPage int
length int
count int
otherAssertions func([]*model.UserWithGroups)
}{
"All groups, expect no users removed": {
groupIDs: []string{group1.Id, group2.Id},
page: 0,
perPage: 100,
length: 0,
count: 0,
},
"Some nonexistent group, page 0": {
groupIDs: []string{model.NewId()},
page: 0,
perPage: 1,
length: 1,
count: 2,
},
"Some nonexistent group, page 1": {
groupIDs: []string{model.NewId()},
page: 1,
perPage: 1,
length: 1,
count: 2,
},
"One group, expect one user removed": {
groupIDs: []string{group1.Id},
page: 0,
perPage: 100,
length: 1,
count: 1,
otherAssertions: func(uwg []*model.UserWithGroups) {
require.Equal(t, uwg[0].Id, user2.Id)
},
},
"Other group, expect other user removed": {
groupIDs: []string{group2.Id},
page: 0,
perPage: 100,
length: 1,
count: 1,
otherAssertions: func(uwg []*model.UserWithGroups) {
require.Equal(t, uwg[0].Id, user1.Id)
},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
uwg, count, res := th.SystemAdminClient.TeamMembersMinusGroupMembers(team.Id, tc.groupIDs, tc.page, tc.perPage, "")
require.Nil(t, res.Error)
require.Len(t, uwg, tc.length)
require.Equal(t, tc.count, int(count))
if tc.otherAssertions != nil {
tc.otherAssertions(uwg)
}
})
}
} | explode_data.jsonl/70745 | {
"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,
14597,
24371,
74458,
2808,
24371,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
19060,
16,
1669,
270,
48868,
1474,
198,
19060,
17,
1669,
270,
48868,
1474,
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 TestRequestUnmarshal(t *testing.T) {
s := []string{`{"TableName":"Reply","ReturnConsumedCapacity":"TOTAL"}`, `{"TableName":"Reply","ScanFilter":{"PostedBy":{"AttributeValueList":[{"S":"joe@example.com"}],"ComparisonOperator":"EQ"}},"ReturnConsumedCapacity":"TOTAL"}`}
for _, v := range s {
var q Scan
um_err := json.Unmarshal([]byte(v), &q)
if um_err != nil {
e := fmt.Sprintf("unmarshal Query: %v", um_err)
t.Errorf(e)
}
_, jerr := json.Marshal(q)
if jerr != nil {
t.Errorf("cannot marshal %v\n", jerr)
}
}
} | explode_data.jsonl/46874 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
1900,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
3056,
917,
90,
63,
4913,
33227,
3252,
20841,
2198,
5598,
41966,
291,
29392,
3252,
48929,
1,
28350,
1565,
4913,
33227,
3252,
20841,
2198,
26570,
5632,
22317,
17372,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerGameServerPod(t *testing.T) {
t.Parallel()
c, mocks := newFakeController()
fakeWatch := watch.NewFake()
mocks.KubeClient.AddWatchReactor("pods", k8stesting.DefaultWatchReactor(fakeWatch, nil))
gs := &v1alpha1.GameServer{ObjectMeta: metav1.ObjectMeta{Name: "gameserver", UID: "1234"}, Spec: newSingleContainerSpec()}
gs.ApplyDefaults()
pod := &corev1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod1", Labels: map[string]string{v1alpha1.GameServerPodLabel: gs.ObjectMeta.Name}}}
stop, cancel := agtesting.StartInformers(mocks, c.gameServerSynced)
defer cancel()
_, err := c.gameServerPod(gs)
assert.Equal(t, errPodNotFound, err)
// not owned
fakeWatch.Add(pod.DeepCopy())
cache.WaitForCacheSync(stop, c.gameServerSynced)
_, err = c.gameServerPod(gs)
assert.Equal(t, errPodNotFound, err)
// owned
ownedPod, err := gs.Pod()
assert.Nil(t, err)
ownedPod.ObjectMeta.Name = "owned1"
fakeWatch.Add(ownedPod)
cache.WaitForCacheSync(stop, c.gameServerSynced)
// should be fine
pod2, err := c.gameServerPod(gs)
assert.Nil(t, err)
assert.Equal(t, ownedPod, pod2)
// add another non-owned pod
p2 := pod.DeepCopy()
p2.ObjectMeta.Name = "pod2"
fakeWatch.Add(p2)
cache.WaitForCacheSync(stop, c.gameServerSynced)
// should still be fine
pod2, err = c.gameServerPod(gs)
assert.Nil(t, err)
assert.Equal(t, ownedPod, pod2)
// now add another owned pod
p3 := ownedPod.DeepCopy()
p3.ObjectMeta.Name = "pod3"
fakeWatch.Add(p3)
cache.WaitForCacheSync(stop, c.gameServerSynced)
// should error out
_, err = c.gameServerPod(gs)
assert.NotNil(t, err)
} | explode_data.jsonl/25435 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 624
} | [
2830,
3393,
2051,
4868,
5475,
23527,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1444,
11,
68909,
1669,
501,
52317,
2051,
741,
1166,
726,
14247,
1669,
3736,
7121,
52317,
741,
2109,
25183,
11352,
3760,
2959,
1904,
14247,
693,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWatchCancelOnServer(t *testing.T) {
integration2.BeforeTest(t)
cluster := integration2.NewClusterV3(t, &integration2.ClusterConfig{Size: 1})
defer cluster.Terminate(t)
client := cluster.RandClient()
numWatches := 10
// The grpc proxy starts watches to detect leadership after the proxy server
// returns as started; to avoid racing on the proxy's internal watches, wait
// until require leader watches get create responses to ensure the leadership
// watches have started.
for {
ctx, cancel := context.WithCancel(clientv3.WithRequireLeader(context.TODO()))
ww := client.Watch(ctx, "a", clientv3.WithCreatedNotify())
wresp := <-ww
cancel()
if wresp.Err() == nil {
break
}
}
cancels := make([]context.CancelFunc, numWatches)
for i := 0; i < numWatches; i++ {
// force separate streams in client
md := metadata.Pairs("some-key", fmt.Sprintf("%d", i))
mctx := metadata.NewOutgoingContext(context.Background(), md)
ctx, cancel := context.WithCancel(mctx)
cancels[i] = cancel
w := client.Watch(ctx, fmt.Sprintf("%d", i), clientv3.WithCreatedNotify())
<-w
}
// get max watches; proxy tests have leadership watches, so total may be >numWatches
maxWatches, _ := cluster.Members[0].Metric("etcd_debugging_mvcc_watcher_total")
// cancel all and wait for cancels to propagate to etcd server
for i := 0; i < numWatches; i++ {
cancels[i]()
}
time.Sleep(time.Second)
minWatches, err := cluster.Members[0].Metric("etcd_debugging_mvcc_watcher_total")
if err != nil {
t.Fatal(err)
}
maxWatchV, minWatchV := 0, 0
n, serr := fmt.Sscanf(maxWatches+" "+minWatches, "%d %d", &maxWatchV, &minWatchV)
if n != 2 || serr != nil {
t.Fatalf("expected n=2 and err=nil, got n=%d and err=%v", n, serr)
}
if maxWatchV-minWatchV < numWatches {
t.Fatalf("expected %d canceled watchers, got %d", numWatches, maxWatchV-minWatchV)
}
} | explode_data.jsonl/28942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 696
} | [
2830,
3393,
14247,
9269,
1925,
5475,
1155,
353,
8840,
836,
8,
341,
2084,
17376,
17,
31153,
2271,
1155,
692,
197,
18855,
1669,
17590,
17,
7121,
28678,
53,
18,
1155,
11,
609,
60168,
17,
72883,
2648,
90,
1695,
25,
220,
16,
3518,
16867,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTrades(t *testing.T) {
t.Parallel()
_, err := h.GetTrades("hptusdt")
if err != nil {
t.Errorf("Test failed - Huobi TestGetTrades: %s", err)
}
} | explode_data.jsonl/24328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
1949,
1282,
3452,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
305,
2234,
1282,
3452,
445,
71,
417,
355,
8047,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
2271,
4641,
481,
21793,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoteParse(t *testing.T) {
r := "https://github.com/hummerd/client_golang.git"
p, err := projectFromRemote(r)
if err != nil {
t.Fatalf("failed to parse remote %s: %v", r, err)
}
if p != "hummerd/client_golang" {
t.Fatalf("wrong project: %s", p)
}
r = "git@bitbucket.org:hummerd/client_golang.git"
p, err = projectFromRemote(r)
if err != nil {
t.Fatalf("failed to parse remote %s: %v", r, err)
}
if p != "hummerd/client_golang" {
t.Fatalf("wrong project: %s", p)
}
r = "git@bitbucket.org:hummerd/client_golang"
p, err = projectFromRemote(r)
if err != nil {
t.Fatalf("failed to parse remote %s: %v", r, err)
}
if p != "hummerd/client_golang" {
t.Fatalf("wrong project: %s", p)
}
} | explode_data.jsonl/12247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 326
} | [
2830,
3393,
24703,
14463,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
330,
2428,
1110,
5204,
905,
7530,
62273,
67,
25085,
1889,
37287,
32799,
698,
3223,
11,
1848,
1669,
2390,
3830,
24703,
2601,
340,
743,
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... | 7 |
func TestWindow_TappedAndDoubleTapped(t *testing.T) {
tapped := 0
but := newDoubleTappableButton()
but.OnTapped = func() {
tapped = 1
}
but.onDoubleTap = func() {
tapped = 2
}
c := NewCanvas().(*mobileCanvas)
c.SetContent(fyne.NewContainerWithLayout(layout.NewMaxLayout(), but))
c.resize(fyne.NewSize(36, 24))
simulateTap(c)
time.Sleep(700 * time.Millisecond)
assert.Equal(t, 1, tapped)
simulateTap(c)
simulateTap(c)
time.Sleep(700 * time.Millisecond)
assert.Equal(t, 2, tapped)
} | explode_data.jsonl/43165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
4267,
1139,
5677,
3036,
7378,
51,
5677,
1155,
353,
8840,
836,
8,
341,
3244,
5677,
1669,
220,
15,
198,
2233,
332,
1669,
501,
7378,
51,
86384,
1567,
741,
2233,
332,
8071,
51,
5677,
284,
2915,
368,
341,
197,
3244,
5677,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReloadIstiodCert(t *testing.T) {
dir, err := ioutil.TempDir("", "istiod_certs")
stop := make(chan struct{})
s := &Server{
fileWatcher: filewatcher.NewWatcher(),
}
defer func() {
close(stop)
_ = s.fileWatcher.Close()
_ = os.RemoveAll(dir)
}()
if err != nil {
t.Fatalf("TempDir() failed: %v", err)
}
certFile := filepath.Join(dir, "cert-file.yaml")
keyFile := filepath.Join(dir, "key-file.yaml")
// load key and cert files.
if err := ioutil.WriteFile(certFile, testcerts.ServerCert, 0644); err != nil { // nolint: vetshadow
t.Fatalf("WriteFile(%v) failed: %v", certFile, err)
}
if err := ioutil.WriteFile(keyFile, testcerts.ServerKey, 0644); err != nil { // nolint: vetshadow
t.Fatalf("WriteFile(%v) failed: %v", keyFile, err)
}
tlsOptions := TLSOptions{
CertFile: certFile,
KeyFile: keyFile,
}
// setup cert watches.
err = s.initCertificateWatches(tlsOptions)
for _, fn := range s.startFuncs {
if err := fn(stop); err != nil {
t.Fatalf("Could not invoke startFuncs: %v", err)
}
}
if err != nil {
t.Fatalf("initCertificateWatches failed: %v", err)
}
// Validate that the certs are loaded.
checkCert(t, s, testcerts.ServerCert, testcerts.ServerKey)
// Update cert/key files.
if err := ioutil.WriteFile(tlsOptions.CertFile, testcerts.RotatedCert, 0644); err != nil { // nolint: vetshadow
t.Fatalf("WriteFile(%v) failed: %v", tlsOptions.CertFile, err)
}
if err := ioutil.WriteFile(tlsOptions.KeyFile, testcerts.RotatedKey, 0644); err != nil { // nolint: vetshadow
t.Fatalf("WriteFile(%v) failed: %v", tlsOptions.KeyFile, err)
}
g := NewGomegaWithT(t)
// Validate that istiod cert is updated.
g.Eventually(func() bool {
return checkCert(t, s, testcerts.RotatedCert, testcerts.RotatedKey)
}, "10s", "100ms").Should(BeTrue())
} | explode_data.jsonl/9020 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 730
} | [
2830,
3393,
50035,
40,
267,
3127,
36934,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
380,
3127,
666,
15546,
1138,
62644,
1669,
1281,
35190,
2036,
37790,
1903,
1669,
609,
5475,
515,
197,
17661,
47... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContainsRefGlobs(t *testing.T) {
tests := []struct {
query string
want bool
globbing bool
}{
{
query: "repo:foo",
want: false,
},
{
query: "repo:foo@bar",
want: false,
},
{
query: "repo:foo@*ref/tags",
want: true,
},
{
query: "repo:foo@*!refs/tags",
want: true,
},
{
query: "repo:foo@bar:*refs/heads",
want: true,
},
{
query: "repo:foo@refs/tags/v3.14.3",
want: false,
},
{
query: "repo:foo@*refs/tags/v3.14.?",
want: true,
},
{
query: "repo:*foo*@v3.14.3",
globbing: true,
want: false,
},
{
query: "repo:foo@v3.14.3 repo:foo@*refs/tags/v3.14.* bar",
want: true,
},
}
for _, tt := range tests {
t.Run(tt.query, func(t *testing.T) {
qInfo, err := query.ProcessAndOr(tt.query, query.ParserOptions{SearchType: query.SearchTypeLiteral, Globbing: tt.globbing})
if err != nil {
t.Error(err)
}
got := containsRefGlobs(qInfo)
if got != tt.want {
t.Errorf("got %t, expected %t", got, tt.want)
}
})
}
} | explode_data.jsonl/52668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 573
} | [
2830,
3393,
23805,
3945,
38,
68164,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
27274,
262,
914,
198,
197,
50780,
257,
1807,
198,
197,
3174,
1684,
7132,
1807,
198,
197,
59403,
197,
197,
515,
298,
27274,
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... | 3 |
func TestType_BigInteger(t *testing.T) {
var v interface{}
var err error
assert := assert.New(t)
assert.True(BigInteger.Check(int64(1)))
assert.False(BigInteger.Check(1))
assert.False(BigInteger.Check(int32(1)))
assert.False(BigInteger.Check(""))
v, err = BigInteger.Convert(int64(1))
assert.Nil(err)
assert.Equal(int64(1), v)
v, err = BigInteger.Convert(1)
assert.Nil(err)
assert.Equal(int64(1), v)
v, err = BigInteger.Convert(int32(1))
assert.Nil(err)
assert.Equal(int64(1), v)
v, err = BigInteger.Convert(int64(9223372036854775807))
assert.Nil(err)
assert.Equal(int64(9223372036854775807), v)
v, err = BigInteger.Convert(uint32(4294967295))
assert.Nil(err)
assert.Equal(int64(4294967295), v)
v, err = BigInteger.Convert(uint64(18446744073709551615))
assert.NotNil(err)
assert.Nil(v)
v, err = BigInteger.Convert("")
assert.NotNil(err)
assert.Nil(v)
assert.Equal(-1, BigInteger.Compare(int64(1), int64(2)))
assert.Equal(0, BigInteger.Compare(int64(1), int64(1)))
assert.Equal(1, BigInteger.Compare(int64(2), int64(1)))
} | explode_data.jsonl/67154 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 462
} | [
2830,
3393,
929,
1668,
47950,
1155,
353,
8840,
836,
8,
341,
2405,
348,
3749,
16094,
2405,
1848,
1465,
198,
6948,
1669,
2060,
7121,
1155,
340,
6948,
32443,
91756,
10600,
1548,
21,
19,
7,
16,
5929,
6948,
50757,
91756,
10600,
7,
16,
1171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGocloak_CreateDeleteClientProtocolMapper(t *testing.T) {
t.Parallel()
cfg := GetConfig(t)
client := NewClientWithDebug(t)
testClient := GetClientByClientID(t, client, cfg.GoCloak.ClientID)
token := GetAdminToken(t, client)
id := GetRandomName("protocol-mapper-id-")
err := client.CreateClientProtocolMapper(
token.AccessToken,
cfg.GoCloak.Realm,
testClient.ID,
ProtocolMapperRepresentation{
ID: id,
Name: "test",
Protocol: "openid-connect",
ProtocolMapper: "oidc-usermodel-attribute-mapper",
Config: map[string]string{
"access.token.claim": "true",
"aggregate.attrs": "",
"claim.name": "test",
"id.token.claim": "true",
"jsonType.label": "String",
"multivalued": "",
"user.attribute": "test",
"userinfo.token.claim": "true",
},
},
)
FailIfErr(t, err, "CreateClientProtocolMapper failed")
testClientAfter := GetClientByClientID(t, client, cfg.GoCloak.ClientID)
FailIf(t, len(testClient.ProtocolMappers) >= len(testClientAfter.ProtocolMappers), "protocol mapper has not been created")
err = client.DeleteClientProtocolMapper(
token.AccessToken,
cfg.GoCloak.Realm,
testClient.ID,
id,
)
FailIfErr(t, err, "DeleteClientProtocolMapper failed")
testClientAgain := GetClientByClientID(t, client, cfg.GoCloak.ClientID)
FailIf(t, len(testClient.ProtocolMappers) != len(testClientAgain.ProtocolMappers), "protocol mapper has not been deleted")
} | explode_data.jsonl/79567 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 634
} | [
2830,
3393,
38,
509,
385,
585,
34325,
6435,
2959,
20689,
10989,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
1669,
2126,
2648,
1155,
340,
25291,
1669,
1532,
2959,
2354,
7939,
1155,
340,
18185,
2959,
1669,
2126,
2959,
135... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeviceTokenReturnsErrorIfCodeExpired(t *testing.T) {
sender := mocks.NewSender()
body := mocks.NewBody(errorDeviceTokenResponse("code_expired"))
sender.AppendResponse(mocks.NewResponseWithBodyAndStatus(body, http.StatusBadRequest, "Bad Request"))
_, err := WaitForUserCompletion(sender, deviceCode())
if err != ErrDeviceCodeExpired {
t.Fatalf("adal: got wrong error expected(%s) actual(%s)", ErrDeviceCodeExpired.Error(), err.Error())
}
if body.IsOpen() {
t.Fatalf("response body was left open!")
}
} | explode_data.jsonl/27510 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
6985,
3323,
16446,
1454,
2679,
2078,
54349,
1155,
353,
8840,
836,
8,
341,
1903,
1659,
1669,
68909,
7121,
20381,
741,
35402,
1669,
68909,
7121,
5444,
6390,
6985,
3323,
2582,
445,
1851,
80221,
5455,
1903,
1659,
8982,
2582,
1255,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStateOutputVoteStats(t *testing.T) {
config := configSetup(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cs, vss := makeState(ctx, t, makeStateArgs{config: config, validators: 2})
// create dummy peer
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
require.NoError(t, err)
randBytes := tmrand.Bytes(crypto.HashSize)
blockID := types.BlockID{
Hash: randBytes,
}
vote := signVote(ctx, t, vss[1], tmproto.PrecommitType, config.ChainID(), blockID)
voteMessage := &VoteMessage{vote}
cs.handleMsg(ctx, msgInfo{voteMessage, peerID, tmtime.Now()})
statsMessage := <-cs.statsMsgQueue
require.Equal(t, voteMessage, statsMessage.Msg, "")
require.Equal(t, peerID, statsMessage.PeerID, "")
// sending the same part from different peer
cs.handleMsg(ctx, msgInfo{&VoteMessage{vote}, "peer2", tmtime.Now()})
// sending the vote for the bigger height
incrementHeight(vss[1])
vote = signVote(ctx, t, vss[1], tmproto.PrecommitType, config.ChainID(), blockID)
cs.handleMsg(ctx, msgInfo{&VoteMessage{vote}, peerID, tmtime.Now()})
select {
case <-cs.statsMsgQueue:
t.Errorf("should not output stats message after receiving the known vote or vote from bigger height")
case <-time.After(50 * time.Millisecond):
}
} | explode_data.jsonl/54294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 447
} | [
2830,
3393,
1397,
5097,
41412,
16635,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2193,
21821,
1155,
340,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
71899,
11,
348,
778,
1669,
1281,
1397,
7502,
11,
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... | 3 |
func TestRedisBlpop(t *testing.T) {
runOnRedis(t, func(client *Redis) {
client.Ping()
var node mockedNode
_, err := client.Blpop(nil, "foo")
assert.NotNil(t, err)
_, err = client.Blpop(node, "foo")
assert.NotNil(t, err)
})
} | explode_data.jsonl/39193 | {
"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,
48137,
4923,
8374,
1155,
353,
8840,
836,
8,
341,
56742,
1925,
48137,
1155,
11,
2915,
12805,
353,
48137,
8,
341,
197,
25291,
1069,
287,
741,
197,
2405,
2436,
46149,
1955,
198,
197,
197,
6878,
1848,
1669,
2943,
21569,
8374,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResourceConfigMode_nestedSet(t *testing.T) {
resource.UnitTest(t, resource.TestCase{
Providers: testAccProviders,
CheckDestroy: testAccCheckResourceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: strings.TrimSpace(`
resource "test_resource_config_mode" "foo" {
resource_as_attr = []
nested_set {
value = "a"
}
nested_set {
value = "b"
set = []
}
}
`),
Check: resource.ComposeTestCheckFunc(),
},
},
})
} | explode_data.jsonl/8383 | {
"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,
4783,
2648,
3636,
66279,
1649,
1155,
353,
8840,
836,
8,
341,
50346,
25159,
2271,
1155,
11,
5101,
31363,
515,
197,
197,
37351,
25,
262,
1273,
14603,
37351,
345,
197,
69472,
14245,
25,
1273,
14603,
3973,
4783,
14245,
345,
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 TestRPCGetProcessesMsgEquals(t *testing.T) {
msg := CreateGetProcessesMsg(core.GenerateRandomID(), 1, 2)
assert.True(t, msg.Equals(msg))
assert.False(t, msg.Equals(nil))
} | explode_data.jsonl/36212 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
29528,
1949,
92727,
6611,
4315,
1155,
353,
8840,
836,
8,
341,
21169,
1669,
4230,
1949,
92727,
6611,
47867,
57582,
13999,
915,
1507,
220,
16,
11,
220,
17,
340,
6948,
32443,
1155,
11,
3750,
16207,
8119,
1171,
6948,
50757,
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 |
func TestMonitor_Reporter(t *testing.T) {
reporter := ReporterFunc(func(tags map[string]string) []models.Statistic {
return []models.Statistic{
{
Name: "foo",
Tags: tags,
Values: map[string]interface{}{
"value": "bar",
},
},
}
})
done := make(chan struct{})
defer close(done)
ch := make(chan models.Points)
var mc MetaClient
mc.CreateDatabaseWithRetentionPolicyFn = func(name string, spec *meta.RetentionPolicySpec) (*meta.DatabaseInfo, error) {
return &meta.DatabaseInfo{Name: name}, nil
}
var pw PointsWriter
pw.WritePointsFn = func(database, policy string, points models.Points) error {
// Attempt to write the points to the main goroutine.
select {
case <-done:
case ch <- points:
}
return nil
}
config := monitor.NewConfig()
config.StoreInterval = toml.Duration(10 * time.Millisecond)
s := monitor.New(reporter, config)
s.MetaClient = &mc
s.PointsWriter = &pw
if err := s.Open(); err != nil {
t.Fatalf("unexpected error: %s", err)
}
defer s.Close()
timer := time.NewTimer(100 * time.Millisecond)
select {
case points := <-ch:
timer.Stop()
// Look for the statistic.
found := false
for _, pt := range points {
if !bytes.Equal(pt.Name(), []byte("foo")) {
continue
}
found = true
break
}
if !found {
t.Error("unable to find foo statistic")
}
case <-timer.C:
t.Errorf("timeout while waiting for statistics to be written")
}
} | explode_data.jsonl/7525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 552
} | [
2830,
3393,
30098,
62,
52766,
1155,
353,
8840,
836,
8,
341,
69931,
261,
1669,
46981,
9626,
18552,
57213,
2415,
14032,
30953,
8,
3056,
6507,
53419,
4532,
341,
197,
853,
3056,
6507,
53419,
4532,
515,
298,
197,
515,
571,
21297,
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... | 1 |
func TestDeviceTokenReturnsErrorIfAuthorizationPending(t *testing.T) {
sender := mocks.NewSender()
body := mocks.NewBody(errorDeviceTokenResponse("authorization_pending"))
sender.AppendResponse(mocks.NewResponseWithBodyAndStatus(body, http.StatusBadRequest, "Bad Request"))
_, err := CheckForUserCompletion(sender, deviceCode())
if err != ErrDeviceAuthorizationPending {
t.Fatalf("!!!")
}
if body.IsOpen() {
t.Fatalf("response body was left open!")
}
} | explode_data.jsonl/27505 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
6985,
3323,
16446,
1454,
2679,
18124,
32027,
1155,
353,
8840,
836,
8,
341,
1903,
1659,
1669,
68909,
7121,
20381,
741,
35402,
1669,
68909,
7121,
5444,
6390,
6985,
3323,
2582,
445,
39554,
37861,
5455,
1903,
1659,
8982,
2582,
125... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChatSrvNewConversationLocal(t *testing.T) {
runWithMemberTypes(t, func(mt chat1.ConversationMembersType) {
ctc := makeChatTestContext(t, "NewConversationLocal", 2)
defer ctc.cleanup()
users := ctc.users()
created := mustCreateConversationForTest(t, ctc, users[0], chat1.TopicType_CHAT, mt,
ctc.as(t, users[1]).user())
tc := ctc.world.Tcs[users[0].Username]
ctx := ctc.as(t, users[0]).startCtx
uid := users[0].User.GetUID().ToBytes()
conv, err := utils.GetUnverifiedConv(ctx, tc.Context(), uid, created.Id,
types.InboxSourceDataSourceRemoteOnly)
require.NoError(t, err)
require.NotZero(t, len(conv.Conv.MaxMsgSummaries))
switch mt {
case chat1.ConversationMembersType_KBFS, chat1.ConversationMembersType_IMPTEAMNATIVE:
refName := string(kbtest.CanonicalTlfNameForTest(
ctc.as(t, users[0]).user().Username + "," + ctc.as(t, users[1]).user().Username),
)
require.Equal(t, refName, conv.Conv.MaxMsgSummaries[0].TlfName)
case chat1.ConversationMembersType_TEAM:
teamName := ctc.teamCache[teamKey(ctc.users())]
require.Equal(t, strings.ToLower(teamName), conv.Conv.MaxMsgSummaries[0].TlfName)
}
})
} | explode_data.jsonl/63669 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 485
} | [
2830,
3393,
15672,
50,
10553,
3564,
60313,
7319,
1155,
353,
8840,
836,
8,
341,
56742,
2354,
9366,
4173,
1155,
11,
2915,
81618,
6236,
16,
4801,
22323,
24371,
929,
8,
341,
197,
89216,
66,
1669,
1281,
15672,
2271,
1972,
1155,
11,
330,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventPage_GetAllEventResults_EventPage(t *testing.T) {
s := graphql.NewMockSubServer(t,
graphql.AddVarNamesToQuery(eventPageSubscription, PageID), map[string]interface{}{PageID: "page"},
&eventPageResult{EventQueryResults: testEventQueryResultsOne},
&eventPageResult{EventQueryResults: testEventQueryResultsTwo},
&eventPageResult{EventQueryResults: testEventQueryResultsThree}, //Result with RUNNING status
&eventPageResult{EventQueryResults: testClosureEventQueryResult}, //testClosureEventQueryResult is the signal that all events have been returned. (what the sdk will return in a live situation)
)
defer s.Close()
svc := New(s.URL, client.WithHTTPTimeout(5*time.Second))
sub, err := svc.EventPage(context.Background(), "page")
require.NoError(t, err)
defer sub.Close()
c, next, err := sub.GetAllEventResults(context.Background())
require.NoError(t, err)
expectedData, err := json.Marshal(Results{testEventQueryResultsOne, testEventQueryResultsTwo})
require.NoError(t, err)
actualData, err := json.Marshal(c)
require.JSONEq(t, string(expectedData), string(actualData))
require.Equal(t, &testNextPage, next)
} | explode_data.jsonl/36560 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
1556,
2665,
13614,
2403,
1556,
9801,
39354,
2665,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
48865,
7121,
11571,
3136,
5475,
1155,
345,
197,
197,
38294,
1904,
3962,
7980,
1249,
2859,
6235,
2665,
33402,
11,
5755,
915,
701,
241... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateCommentReaction(t *testing.T) {
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
t.Errorf("Bad method: %s", r.Method)
}
if r.URL.Path != "/repos/k8s/kuber/issues/comments/5/reactions" {
t.Errorf("Bad request path: %s", r.URL.Path)
}
if r.Header.Get("Accept") != "application/vnd.github.squirrel-girl-preview" {
t.Errorf("Bad Accept header: %s", r.Header.Get("Accept"))
}
http.Error(w, "201 Created", http.StatusCreated)
}))
defer ts.Close()
c := getClient(ts.URL)
if err := c.CreateCommentReaction("k8s", "kuber", 5, "+1"); err != nil {
t.Errorf("Didn't expect error: %v", err)
}
} | explode_data.jsonl/6251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
4021,
10677,
87236,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
1758,
20798,
4133,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGreaterEqualDates(t *testing.T) {
t.Parallel()
d1, err := civil.ParseDate("2006-01-01")
require.Nil(t, err)
d2, err := civil.ParseDate("2006-01-03")
require.Nil(t, err)
match, err := path.GreaterEqual(&testType1{
Dates: []civil.Date{d1, d2},
}, "dates", "2006-01-02")
require.Nil(t, err)
require.True(t, match)
match, err = path.GreaterEqual(&testType1{
Dates: []civil.Date{d1, d2},
}, "dates", "2006-01-03")
require.Nil(t, err)
require.True(t, match)
match, err = path.GreaterEqual(&testType1{
Dates: []civil.Date{d1, d2},
}, "dates", "2006-01-04")
require.Nil(t, err)
require.False(t, match)
} | explode_data.jsonl/78483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
41366,
2993,
55238,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2698,
16,
11,
1848,
1669,
8267,
8937,
1916,
445,
17,
15,
15,
21,
12,
15,
16,
12,
15,
16,
1138,
17957,
59678,
1155,
11,
1848,
692,
2698,
17,
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 Test_DatabaseAccountsSqlDatabasesContainersTriggers_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip from DatabaseAccountsSqlDatabasesContainersTriggers_Spec to DatabaseAccountsSqlDatabasesContainersTriggers_Spec via AssignPropertiesToDatabaseAccountsSqlDatabasesContainersTriggersSpec & AssignPropertiesFromDatabaseAccountsSqlDatabasesContainersTriggersSpec returns original",
prop.ForAll(RunPropertyAssignmentTestForDatabaseAccountsSqlDatabasesContainersTriggersSpec, DatabaseAccountsSqlDatabasesContainersTriggersSpecGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
} | explode_data.jsonl/18743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
1557,
2211,
41369,
8269,
35,
23822,
74632,
1282,
21385,
1098,
992,
62,
4498,
7903,
61941,
2568,
795,
21884,
1690,
26040,
39838,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnknownConfig(t *testing.T) {
desc := model.ConfigDescriptor{model.ProtoSchema{
Type: "unknown-config",
Plural: "unknown-configs",
Group: "test",
Version: "v1",
MessageName: "test.MockConfig",
Validate: nil,
}}
_, err := makeClient(t, desc)
if err == nil {
t.Fatalf("expect client to fail with unknown types")
}
} | explode_data.jsonl/35315 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
13790,
2648,
1155,
353,
8840,
836,
8,
341,
41653,
1669,
1614,
10753,
11709,
90,
2528,
7763,
983,
8632,
515,
197,
27725,
25,
286,
330,
16088,
25130,
756,
197,
197,
2120,
4176,
25,
414,
330,
16088,
25130,
82,
756,
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... | 2 |
func Test0006KCP(t *testing.T) {
c, err := NewConn("kcp")
if err != nil {
fmt.Println(err)
return
}
cc, err := c.Listen("127.0.0.1:58780")
if err != nil {
fmt.Println(err)
return
}
go func() {
cc, err := cc.Accept()
if err != nil {
fmt.Println(err)
return
}
defer cc.Close()
fmt.Println("accept done")
buf := make([]byte, 10)
_, err = cc.Read(buf)
if err != nil {
fmt.Println("Read " + err.Error())
return
}
fmt.Println("Read done")
}()
ccc, err := c.Dial("127.0.0.1:58780")
if err != nil {
fmt.Println(err)
return
}
go func() {
time.Sleep(time.Second)
ccc.Close()
fmt.Println("client close")
}()
time.Sleep(time.Second * 3)
cc.Close()
ccc.Close()
time.Sleep(time.Second)
} | explode_data.jsonl/19983 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
15,
15,
15,
21,
42,
7123,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
9701,
445,
74,
4672,
1138,
743,
1848,
961,
2092,
341,
197,
11009,
12419,
3964,
340,
197,
853,
198,
197,
630,
63517,
11,
1848,
1669,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRWSetTooBig(t *testing.T) {
state := make(map[string]map[string][]byte)
state["lscc"] = make(map[string][]byte)
v := newValidationInstance(state)
ccname := "mycc"
ccver := "1"
cd := &ccprovider.ChaincodeData{
Name: ccname,
Version: ccver,
InstantiationPolicy: nil,
}
cdbytes := protoutil.MarshalOrPanic(cd)
rwsetBuilder := rwsetutil.NewRWSetBuilder()
rwsetBuilder.AddToWriteSet("lscc", ccname, cdbytes)
rwsetBuilder.AddToWriteSet("lscc", "spurious", []byte("spurious"))
sr, err := rwsetBuilder.GetTxSimulationResults()
assert.NoError(t, err)
srBytes, err := sr.GetPubSimulationBytes()
assert.NoError(t, err)
tx, err := createLSCCTx(ccname, ccver, lscc.DEPLOY, srBytes)
if err != nil {
t.Fatalf("createTx returned err %s", err)
}
envBytes, err := protoutil.GetBytesEnvelope(tx)
if err != nil {
t.Fatalf("GetBytesEnvelope returned err %s", err)
}
// good path: signed by the right MSP
policy, err := getSignedByMSPMemberPolicy(mspid)
if err != nil {
t.Fatalf("failed getting policy, err %s", err)
}
b := &common.Block{Data: &common.BlockData{Data: [][]byte{envBytes}}}
err = v.Validate(b, "lscc", 0, 0, policy)
assert.EqualError(t, err, "LSCC can only issue a single putState upon deploy")
t.Logf("error: %s", err)
} | explode_data.jsonl/42497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 525
} | [
2830,
3393,
56368,
1649,
31246,
15636,
1155,
353,
8840,
836,
8,
341,
24291,
1669,
1281,
9147,
14032,
60,
2186,
14032,
45725,
3782,
340,
24291,
1183,
4730,
638,
1341,
284,
1281,
9147,
14032,
45725,
3782,
692,
5195,
1669,
501,
13799,
2523,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test_RegistrySynchronizer_UpkeepPerformedLog(t *testing.T) {
g := gomega.NewWithT(t)
db, synchronizer, ethMock, lb, job := setupRegistrySync(t)
contractAddress := job.KeeperSpec.ContractAddress.Address()
fromAddress := job.KeeperSpec.FromAddress.Address()
registryMock := cltest.NewContractMockReceiver(t, ethMock, keeper.RegistryABI, contractAddress)
registryMock.MockResponse("getConfig", registryConfig).Once()
registryMock.MockResponse("getKeeperList", []common.Address{fromAddress}).Once()
registryMock.MockResponse("getCanceledUpkeepList", []*big.Int{}).Once()
registryMock.MockResponse("getUpkeepCount", big.NewInt(1)).Once()
registryMock.MockResponse("getUpkeep", upkeepConfig).Once()
require.NoError(t, synchronizer.Start())
defer synchronizer.Close()
cltest.WaitForCount(t, db, "keeper_registries", 1)
cltest.WaitForCount(t, db, "upkeep_registrations", 1)
pgtest.MustExec(t, db, `UPDATE upkeep_registrations SET last_run_block_height = 100`)
cfg := cltest.NewTestGeneralConfig(t)
head := cltest.MustInsertHead(t, db, cfg, 1)
rawLog := types.Log{BlockHash: head.Hash}
log := keeper_registry_wrapper.KeeperRegistryUpkeepPerformed{Id: big.NewInt(0)}
logBroadcast := new(logmocks.Broadcast)
logBroadcast.On("DecodedLog").Return(&log)
logBroadcast.On("RawLog").Return(rawLog)
logBroadcast.On("String").Maybe().Return("")
lb.On("MarkConsumed", mock.Anything, mock.Anything).Return(nil)
lb.On("WasAlreadyConsumed", mock.Anything, mock.Anything).Return(false, nil)
// Do the thing
synchronizer.HandleLog(logBroadcast)
g.Eventually(func() int64 {
var upkeep keeper.UpkeepRegistration
err := db.Get(&upkeep, `SELECT * FROM upkeep_registrations`)
require.NoError(t, err)
return upkeep.LastRunBlockHeight
}, cltest.WaitTimeout(t), cltest.DBPollingInterval).Should(gomega.Equal(int64(0)))
ethMock.AssertExpectations(t)
logBroadcast.AssertExpectations(t)
} | explode_data.jsonl/35263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 678
} | [
2830,
3393,
62,
15603,
50,
14113,
3135,
88425,
13096,
14855,
2201,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
2354,
51,
1155,
692,
20939,
11,
14121,
3135,
11,
8372,
11571,
11,
18866,
11,
2618,
1669,
6505,
15603,
12154,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCorruptDB_SequenceNumberRecovery(t *testing.T) {
h := newDbCorruptHarness(t)
defer h.close()
h.put("foo", "v1")
h.put("foo", "v2")
h.put("foo", "v3")
h.put("foo", "v4")
h.put("foo", "v5")
h.closeDB()
h.recover()
h.getVal("foo", "v5")
h.put("foo", "v6")
h.getVal("foo", "v6")
h.reopenDB()
h.getVal("foo", "v6")
} | explode_data.jsonl/45794 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
10580,
6585,
3506,
26920,
4375,
2833,
693,
7449,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
7994,
10580,
6585,
74248,
1155,
340,
16867,
305,
4653,
2822,
9598,
3597,
445,
7975,
497,
330,
85,
16,
1138,
9598,
3597,
445,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDesmosCLIProfileDelete(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// Start Desmosd server
proc := f.GDStart()
defer proc.Stop(false)
// Save key addresses for later use
fooAddr := f.KeyAddress(keyFoo)
// Later usage variables
fooAcc := f.QueryAccount(fooAddr)
startTokens := sdk.TokensFromConsensusPower(140)
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
// Create a profile
success, _, sterr := f.TxProfileSave("mrBrown", fooAddr, "-y")
require.True(t, success)
require.Empty(t, sterr)
tests.WaitForNextNBlocksTM(1, f.Port)
// Make sure the profile is saved
storedProfiles := f.QueryProfiles()
require.NotEmpty(t, storedProfiles)
profile := storedProfiles[0]
require.Equal(t, profile.DTag, "mrBrown")
// Delete the profile
success, _, sterr = f.TxProfileDelete(fooAddr, "-y")
require.True(t, success)
require.Empty(t, sterr)
tests.WaitForNextNBlocksTM(1, f.Port)
// Make sure the profile is deleted
storedProfiles = f.QueryProfiles()
require.Empty(t, storedProfiles)
// Test --dry-run
success, _, _ = f.TxProfileDelete(fooAddr, "--dry-run")
require.True(t, success)
// Test --generate-only
success, stdout, stderr := f.TxProfileDelete(fooAddr, "--generate-only=true")
require.Empty(t, stderr)
require.True(t, success)
msg := unmarshalStdTx(f.T, stdout)
require.NotZero(t, msg.Fee.Gas)
require.Len(t, msg.Msgs, 1)
require.Len(t, msg.GetSignatures(), 0)
// Check state didn't change
storedProfiles = f.QueryProfiles()
require.Len(t, storedProfiles, 0)
f.Cleanup()
} | explode_data.jsonl/29802 | {
"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,
4896,
8631,
63959,
8526,
6435,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1166,
1669,
15690,
25958,
18513,
1155,
692,
197,
322,
5145,
3874,
8631,
67,
3538,
198,
197,
15782,
1669,
282,
1224,
35,
3479,
741,
16867,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileBadFile(t *testing.T) {
type config struct {
SecretKey string `env:"SECRET_KEY,file"`
}
file, err := ioutil.TempFile("", "sec_key_*")
assert.NoError(t, err)
err = ioutil.WriteFile(file.Name(), []byte("secret"), 0660)
assert.NoError(t, err)
filename := file.Name()
defer os.Clearenv()
os.Setenv("SECRET_KEY", filename)
err = os.Remove(filename)
assert.NoError(t, err)
cfg := config{}
err = Parse(&cfg)
assert.Error(t, err)
assert.EqualError(t, err, fmt.Sprintf(`env: could not load content of file "%s" from variable SECRET_KEY: open %s: no such file or directory`, filename, filename))
} | explode_data.jsonl/78805 | {
"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,
1703,
17082,
1703,
1155,
353,
8840,
836,
8,
341,
13158,
2193,
2036,
341,
197,
7568,
50856,
1592,
914,
1565,
3160,
2974,
65310,
6600,
57476,
8805,
197,
630,
17661,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
5024,
3097,
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 TestTrainWithOptimizer(t *testing.T) {
a := assert.New(t)
tir := ir.MockTrainStmt(false)
a.NotContains(tir.Attributes, "model.optimizer")
_, err := Train(tir, mockSession())
a.NoError(err)
a.NotContains(tir.Attributes, "model.optimizer")
tir.Attributes["model.optimizer"] = "RMSprop"
a.NoError(InitializeAttributes(tir))
_, err = Train(tir, mockSession())
a.NoError(err)
a.Equal(tir.Attributes["model.optimizer"], "RMSprop()")
tir.Attributes["not_optimizer.learning_rate"] = 123
tir.Attributes["model.optimizer"] = "RMSprop"
a.Error(InitializeAttributes(tir))
tir = ir.MockTrainStmt(false)
tir.Attributes["optimizer.learning_rate"] = 0.002
a.NoError(InitializeAttributes(tir))
_, err = Train(tir, mockSession())
a.NoError(err)
a.Equal(tir.Attributes["model.optimizer"], "Adagrad(learning_rate=0.002, )")
a.NotContains(tir.Attributes, "optimizer.learning_rate")
tir.Attributes["model.optimizer"] = "RMSprop"
tir.Attributes["optimizer.learning_rate"] = 0.002
a.NoError(InitializeAttributes(tir))
_, err = Train(tir, mockSession())
a.NoError(err)
a.Equal(tir.Attributes["model.optimizer"], "RMSprop(learning_rate=0.002, )")
} | explode_data.jsonl/81398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 458
} | [
2830,
3393,
34613,
2354,
80637,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
340,
3244,
404,
1669,
6216,
24664,
34613,
31063,
3576,
340,
11323,
15000,
23805,
1155,
404,
31384,
11,
330,
2528,
70295,
1138,
197,
6878,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTextFormatter(t *testing.T) {
tests := []struct {
comment string
formatConfig []string
assertErr require.ErrorAssertionFunc
}{
{
comment: "invalid key (does not exist)",
formatConfig: []string{"level", "invalid key"},
assertErr: require.Error,
},
{
comment: "valid keys and formatting",
formatConfig: []string{"level", "component", "timestamp"},
assertErr: require.NoError,
},
}
for _, tt := range tests {
t.Run(tt.comment, func(t *testing.T) {
formatter := &utils.TextFormatter{
ExtraFields: tt.formatConfig,
}
tt.assertErr(t, formatter.CheckAndSetDefaults())
})
}
} | explode_data.jsonl/47181 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
1178,
14183,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
96268,
414,
914,
198,
197,
59416,
2648,
3056,
917,
198,
197,
6948,
7747,
262,
1373,
6141,
68639,
9626,
198,
197,
59403,
197,
197,
515,
298,
9626... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRouter_Prefix_CreateTreeWhenStillNotCreated(t *testing.T) {
mainRouter := Router{}
secondRouter := Router{}
assertNil(t, mainRouter.trees)
_ = mainRouter.Prefix("/path", &secondRouter)
assertNotNil(t, mainRouter.trees)
} | explode_data.jsonl/31729 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
9523,
1088,
5060,
34325,
6533,
4498,
23322,
2623,
11694,
1155,
353,
8840,
836,
8,
341,
36641,
9523,
1669,
10554,
16094,
197,
5569,
9523,
1669,
10554,
16094,
6948,
19064,
1155,
11,
1887,
9523,
734,
7858,
692,
197,
62,
284,
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 |
func TestPruneInitContainers(t *testing.T) {
dm, fake := newTestDockerManager()
pod := makePod("", &api.PodSpec{
InitContainers: []api.Container{
{Name: "init1"},
{Name: "init2"},
},
})
status := &kubecontainer.PodStatus{
ContainerStatuses: []*kubecontainer.ContainerStatus{
{Name: "init2", ID: kubecontainer.ContainerID{ID: "init2-new-1"}, State: kubecontainer.ContainerStateExited},
{Name: "init1", ID: kubecontainer.ContainerID{ID: "init1-new-1"}, State: kubecontainer.ContainerStateExited},
{Name: "init1", ID: kubecontainer.ContainerID{ID: "init1-new-2"}, State: kubecontainer.ContainerStateExited},
{Name: "init1", ID: kubecontainer.ContainerID{ID: "init1-old-1"}, State: kubecontainer.ContainerStateExited},
{Name: "init2", ID: kubecontainer.ContainerID{ID: "init2-old-1"}, State: kubecontainer.ContainerStateExited},
},
}
fake.ExitedContainerList = []dockertypes.Container{
{ID: "init1-new-1"},
{ID: "init1-new-2"},
{ID: "init1-old-1"},
{ID: "init2-new-1"},
{ID: "init2-old-1"},
}
keep := map[kubecontainer.DockerID]int{}
dm.pruneInitContainersBeforeStart(pod, status, keep)
sort.Sort(sort.StringSlice(fake.Removed))
if !reflect.DeepEqual([]string{"init1-new-2", "init1-old-1", "init2-old-1"}, fake.Removed) {
t.Fatal(fake.Removed)
}
} | explode_data.jsonl/31199 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 545
} | [
2830,
3393,
3533,
2886,
3803,
74632,
1155,
353,
8840,
836,
8,
341,
2698,
76,
11,
12418,
1669,
501,
2271,
35,
13659,
2043,
741,
3223,
347,
1669,
1281,
23527,
19814,
609,
2068,
88823,
8327,
515,
197,
98762,
74632,
25,
3056,
2068,
33672,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMemBackend(t *testing.T) {
// Create a memBackend
b := New()
// Try to verify a missing blob
if ok, _ := b.Verify("foo", nil); ok {
t.Fatalf("returned true on non-existent blob")
}
// Try to get a missing blob
if _, err := b.Get("foo", nil); err == nil {
t.Fatalf("expected error from Get(), but got none")
}
// Set a value in the store
if err := b.Put("foo", []byte("bar"), nil); err != nil {
t.Fatalf("err in Put(): %v", err)
}
// Retrieve that value
data, err := b.Get("foo", nil)
if err != nil {
t.Fatalf("err in Get(): %v", err)
}
// Check for corruption
if string(data) != "bar" {
t.Fatalf("bad data returned from Get()")
}
} | explode_data.jsonl/78217 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
18816,
29699,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
264,
1833,
29699,
198,
2233,
1669,
1532,
2822,
197,
322,
9735,
311,
10146,
264,
7402,
23404,
198,
743,
5394,
11,
716,
1669,
293,
54853,
445,
7975,
497,
2092,
1215... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodesWherePreemptionMightHelp(t *testing.T) {
// Prepare 4 nodes names.
nodeNames := []string{"node1", "node2", "node3", "node4"}
tests := []struct {
name string
nodesStatuses framework.NodeToStatusMap
expected map[string]bool // set of expected node names. Value is ignored.
}{
{
name: "No node should be attempted",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodeaffinity.ErrReason),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodename.ErrReason),
"node3": framework.NewStatus(framework.UnschedulableAndUnresolvable, tainttoleration.ErrReasonNotMatch),
"node4": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodelabel.ErrReasonPresenceViolated),
},
expected: map[string]bool{},
},
{
name: "ErrReasonAffinityNotMatch should be tried as it indicates that the pod is unschedulable due to inter-pod affinity or anti-affinity",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.Unschedulable, interpodaffinity.ErrReasonAffinityNotMatch),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodename.ErrReason),
"node3": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodeunschedulable.ErrReasonUnschedulable),
},
expected: map[string]bool{"node1": true, "node4": true},
},
{
name: "pod with both pod affinity and anti-affinity should be tried",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.Unschedulable, interpodaffinity.ErrReasonAffinityNotMatch),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodename.ErrReason),
},
expected: map[string]bool{"node1": true, "node3": true, "node4": true},
},
{
name: "ErrReasonAffinityRulesNotMatch should not be tried as it indicates that the pod is unschedulable due to inter-pod affinity, but ErrReasonAffinityNotMatch should be tried as it indicates that the pod is unschedulable due to inter-pod affinity or anti-affinity",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, interpodaffinity.ErrReasonAffinityRulesNotMatch),
"node2": framework.NewStatus(framework.Unschedulable, interpodaffinity.ErrReasonAffinityNotMatch),
},
expected: map[string]bool{"node2": true, "node3": true, "node4": true},
},
{
name: "Mix of failed predicates works fine",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, volumerestrictions.ErrReasonDiskConflict),
"node2": framework.NewStatus(framework.Unschedulable, fmt.Sprintf("Insufficient %v", v1.ResourceMemory)),
},
expected: map[string]bool{"node2": true, "node3": true, "node4": true},
},
{
name: "Node condition errors should be considered unresolvable",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodeunschedulable.ErrReasonUnknownCondition),
},
expected: map[string]bool{"node2": true, "node3": true, "node4": true},
},
{
name: "ErrVolume... errors should not be tried as it indicates that the pod is unschedulable due to no matching volumes for pod on node",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.UnschedulableAndUnresolvable, volumezone.ErrReasonConflict),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, string(volumescheduling.ErrReasonNodeConflict)),
"node3": framework.NewStatus(framework.UnschedulableAndUnresolvable, string(volumescheduling.ErrReasonBindConflict)),
},
expected: map[string]bool{"node4": true},
},
{
name: "ErrReasonConstraintsNotMatch should be tried as it indicates that the pod is unschedulable due to topology spread constraints",
nodesStatuses: framework.NodeToStatusMap{
"node1": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, nodename.ErrReason),
"node3": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
},
expected: map[string]bool{"node1": true, "node3": true, "node4": true},
},
{
name: "UnschedulableAndUnresolvable status should be skipped but Unschedulable should be tried",
nodesStatuses: framework.NodeToStatusMap{
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, ""),
"node3": framework.NewStatus(framework.Unschedulable, ""),
"node4": framework.NewStatus(framework.UnschedulableAndUnresolvable, ""),
},
expected: map[string]bool{"node1": true, "node3": true},
},
{
name: "ErrReasonNodeLabelNotMatch should not be tried as it indicates that the pod is unschedulable due to node doesn't have the required label",
nodesStatuses: framework.NodeToStatusMap{
"node2": framework.NewStatus(framework.UnschedulableAndUnresolvable, podtopologyspread.ErrReasonNodeLabelNotMatch),
"node3": framework.NewStatus(framework.Unschedulable, ""),
"node4": framework.NewStatus(framework.UnschedulableAndUnresolvable, ""),
},
expected: map[string]bool{"node1": true, "node3": true},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var nodeInfos []*framework.NodeInfo
for _, name := range nodeNames {
ni := framework.NewNodeInfo()
ni.SetNode(st.MakeNode().Name(name).Obj())
nodeInfos = append(nodeInfos, ni)
}
nodes := nodesWherePreemptionMightHelp(nodeInfos, tt.nodesStatuses)
if len(tt.expected) != len(nodes) {
t.Errorf("number of nodes is not the same as expected. exptectd: %d, got: %d. Nodes: %v", len(tt.expected), len(nodes), nodes)
}
for _, node := range nodes {
name := node.Node().Name
if _, found := tt.expected[name]; !found {
t.Errorf("node %v is not expected.", name)
}
}
})
}
} | explode_data.jsonl/14214 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2191
} | [
2830,
3393,
12288,
9064,
4703,
33106,
44,
491,
12689,
1155,
353,
8840,
836,
8,
341,
197,
322,
31166,
220,
19,
7798,
5036,
624,
20831,
7980,
1669,
3056,
917,
4913,
3509,
16,
497,
330,
3509,
17,
497,
330,
3509,
18,
497,
330,
3509,
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... | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.