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 TestJsonSerializerSingle(t *testing.T) {
item := NewTraceTelemetry("testing", Verbose)
now := time.Now()
item.timestamp = now
want := fmt.Sprintf(`{"name":"Microsoft.ApplicationInsights.Message","time":"%s","iKey":"","tags":{},"data":{"baseType":"MessageData","baseData":{"ver":2,"properties":null,"message":"testing","severityLevel":0}}}`, now.Format(time.RFC3339))
result := serialize(item)
if result != want {
t.Errorf("serialize() returned '%s', want '%s'", result, want)
}
} | explode_data.jsonl/58230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
5014,
13909,
10888,
1155,
353,
8840,
836,
8,
1476,
22339,
1669,
1532,
6550,
6639,
35958,
445,
8840,
497,
6250,
8297,
340,
80922,
1669,
882,
13244,
741,
22339,
22511,
284,
1431,
271,
50780,
1669,
8879,
17305,
5809,
4913,
606,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestU128_Encode(t *testing.T) {
a := big.NewInt(0).SetBytes([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 52})
b := big.NewInt(0).SetBytes([]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})
c := big.NewInt(0).SetBytes([]byte{255, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})
assertEncode(t, []encodingAssert{
{NewU128(*big.NewInt(0)), MustHexDecodeString("0x00000000000000000000000000000000")},
{NewU128(*big.NewInt(29)), MustHexDecodeString("0x1d000000000000000000000000000000")},
{NewU128(*a), MustHexDecodeString("0x34120000000000000000000000000000")},
{NewU128(*b), MustHexDecodeString("0x100f0e0d0c0b0a090807060504030201")},
{NewU128(*c), MustHexDecodeString("0x100f0e0d0c0b0a0908070605040302ff")},
})
} | explode_data.jsonl/18417 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
52,
16,
17,
23,
93529,
534,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2409,
7121,
1072,
7,
15,
568,
1649,
7078,
10556,
3782,
90,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHasOutputResultRef(t *testing.T) {
wf := unmarshalWF(resultVarRefWf)
assert.True(t, hasOutputResultRef("generate-random", &wf.Spec.Templates[0]))
assert.True(t, hasOutputResultRef("generate-random-1", &wf.Spec.Templates[0]))
} | explode_data.jsonl/71040 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
10281,
5097,
2077,
3945,
1155,
353,
8840,
836,
8,
341,
6692,
69,
1669,
650,
27121,
32131,
4456,
3962,
3945,
54,
69,
340,
6948,
32443,
1155,
11,
702,
5097,
2077,
3945,
445,
19366,
91675,
497,
609,
43083,
36473,
836,
76793,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOKExSpot_GetDepth(t *testing.T) {
dep, err := okex.OKExSpot.GetDepth(2, goex.EOS_BTC)
assert.Nil(t, err)
t.Log(dep.AskList)
t.Log(dep.BidList)
} | explode_data.jsonl/3924 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
3925,
840,
47049,
13614,
19776,
1155,
353,
8840,
836,
8,
341,
197,
14891,
11,
1848,
1669,
5394,
327,
15480,
840,
47049,
2234,
19776,
7,
17,
11,
728,
327,
5142,
3126,
1668,
7749,
340,
6948,
59678,
1155,
11,
1848,
340,
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 |
func TestParsePEMCert(t *testing.T) {
for _, testCase := range []struct {
name string
input []byte
expectValid bool
}{
{"invalid certificate data", []byte{0}, false},
{"certificate with junk appended", []byte(testCertPEM + "\nABC"), false},
{"multiple certificates", []byte(testCertPEM + "\n" + testCertPEM), false},
{"valid", []byte(testCertPEM), true},
} {
cert, err := parsePEMCert(testCase.input)
if testCase.expectValid {
if err != nil {
t.Errorf("failed TestParsePEMCert(%s): unexpected error %v", testCase.name, err)
}
if cert == nil {
t.Errorf("failed TestParsePEMCert(%s): returned nil", testCase.name)
}
} else {
if err == nil {
t.Errorf("failed TestParsePEMCert(%s): expected an error", testCase.name)
}
if cert != nil {
t.Errorf("failed TestParsePEMCert(%s): expected not to get a certificate back, but got one", testCase.name)
}
}
}
} | explode_data.jsonl/52401 | {
"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,
14463,
1740,
11604,
529,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
54452,
1669,
2088,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
22427,
981,
3056,
3782,
198,
197,
24952,
4088,
1807,
198,
197,
59403,
197,
197,
4913,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue28739(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec(`USE test`)
tk.MustExec("SET time_zone = 'Europe/Vilnius'")
tk.MustQuery("SELECT UNIX_TIMESTAMP('2020-03-29 03:45:00')").Check(testkit.Rows("1585443600"))
tk.MustQuery("SELECT FROM_UNIXTIME(UNIX_TIMESTAMP('2020-03-29 03:45:00'))").Check(testkit.Rows("2020-03-29 04:00:00"))
tk.MustExec(`DROP TABLE IF EXISTS t`)
tk.MustExec(`CREATE TABLE t (dt DATETIME NULL)`)
defer tk.MustExec(`DROP TABLE t`)
// Test the vector implememtation
tk.MustExec(`INSERT INTO t VALUES ('2021-10-31 02:30:00'), ('2021-03-28 02:30:00'), ('2020-10-04 02:15:00'), ('2020-03-29 03:45:00'), (NULL)`)
tk.MustQuery(`SELECT dt, UNIX_TIMESTAMP(dt) FROM t`).Sort().Check(testkit.Rows(
"2020-03-29 03:45:00 1585443600",
"2020-10-04 02:15:00 1601766900",
"2021-03-28 02:30:00 1616891400",
"2021-10-31 02:30:00 1635636600",
"<nil> <nil>"))
} | explode_data.jsonl/65620 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 445
} | [
2830,
3393,
42006,
17,
23,
22,
18,
24,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintTemplate(t *testing.T) {
tests := []struct {
template templateapi.Template
want string
}{
{
templateapi.Template{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Annotations: map[string]string{
"description": "description",
},
},
Parameters: []templateapi.Parameter{{}},
Objects: []runtime.Object{&kapi.Pod{}},
},
"name\tdescription\t1 (1 blank)\t1\n",
},
{
templateapi.Template{
ObjectMeta: metav1.ObjectMeta{
Name: "long",
Annotations: map[string]string{
"description": "the long description of this template is way way way way way way way way way way way way way too long",
},
},
Parameters: []templateapi.Parameter{},
Objects: []runtime.Object{},
},
"long\tthe long description of this template is way way way way way way way way way...\t0 (all set)\t0\n",
},
{
templateapi.Template{
ObjectMeta: metav1.ObjectMeta{
Name: "multiline",
Annotations: map[string]string{
"description": "Once upon a time\nthere was a template\nwith multiple\nlines\n",
},
},
Parameters: []templateapi.Parameter{},
Objects: []runtime.Object{},
},
"multiline\tOnce upon a time...\t0 (all set)\t0\n",
},
{
templateapi.Template{
ObjectMeta: metav1.ObjectMeta{
Name: "trailingnewline",
Annotations: map[string]string{
"description": "Next line please\n",
},
},
Parameters: []templateapi.Parameter{},
Objects: []runtime.Object{},
},
"trailingnewline\tNext line please...\t0 (all set)\t0\n",
},
{
templateapi.Template{
ObjectMeta: metav1.ObjectMeta{
Name: "longmultiline",
Annotations: map[string]string{
"description": "12345678901234567890123456789012345678901234567890123456789012345678901234567890123\n0",
},
},
Parameters: []templateapi.Parameter{},
Objects: []runtime.Object{},
},
"longmultiline\t12345678901234567890123456789012345678901234567890123456789012345678901234567...\t0 (all set)\t0\n",
},
}
for i, test := range tests {
buf := bytes.NewBuffer([]byte{})
err := printTemplate(&test.template, buf, kprinters.PrintOptions{})
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
got := buf.String()
if got != test.want {
t.Errorf("[%d] expected %q, got %q", i, test.want, got)
continue
}
}
} | explode_data.jsonl/61178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1066
} | [
2830,
3393,
8994,
7275,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22832,
3811,
2068,
52530,
198,
197,
50780,
257,
914,
198,
197,
59403,
197,
197,
515,
298,
22832,
2068,
52530,
515,
571,
23816,
12175,
25,
77520,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTodos(t *testing.T) {
r := new(MemoryRepository)
s := NewService(r)
defaultPriorityID := defaultPriority().id
s.AddTodo("do stuff", nil, 1, &defaultPriorityID)
s.AddTodo("do stuff", nil, 1, &defaultPriorityID)
s.AddTodo("do stuff", nil, 1, &defaultPriorityID)
s.AddTodo("gud todo", nil, 2, &defaultPriorityID)
tests := map[string]struct {
userID int
wantTodoLength int
}{
"gets": {
1,
3,
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
got, _ := s.GetTodos(tc.userID)
if len(got) != tc.wantTodoLength {
t.Fatalf("expected %#v, got: %#v", tc.wantTodoLength, len(got))
}
})
}
} | explode_data.jsonl/21372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 303
} | [
2830,
3393,
1949,
42147,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
501,
3189,
4731,
4624,
340,
1903,
1669,
1532,
1860,
2601,
692,
11940,
20555,
915,
1669,
1638,
20555,
1005,
307,
198,
1903,
1904,
24176,
445,
2982,
6259,
497,
2092,
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... | 2 |
func TestLittleEndianByteAt(t *testing.T) {
tests := []struct {
x string
y int
exp byte
}{
{"00", 0, 0x00},
{"01", 1, 0x00},
{"00", 1, 0x00},
{"01", 0, 0x00},
{"0000000000000000000000000000000000000000000000000000000000102030", 0, 0x00},
{"0000000000000000000000000000000000000000000000000000000000102030", 1, 0x00},
{"ABCDEF0908070605040302010000000000000000000000000000000000000000", 31, 0x00},
{"ABCDEF0908070605040302010000000000000000000000000000000000000000", 32, 0x00},
{"ABCDEF0908070605040302010000000000000000000000000000000000000000", 0, 0xAB},
{"ABCDEF0908070605040302010000000000000000000000000000000000000000", 1, 0xCD},
{"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 0, 0x00},
{"00CDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff", 1, 0xCD},
{"0000000000000000000000000000000000000000000000000000000000102030", 31, 0x30},
{"0000000000000000000000000000000000000000000000000000000000102030", 30, 0x20},
{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 32, 0x0},
{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 31, 0xFF},
{"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0xFFFF, 0x0},
}
for _, test := range tests {
v := new(big.Int).SetBytes(common.Hex2Bytes(test.x))
actual := Byte(v, 32, test.y)
if actual != test.exp {
t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
}
}
} | explode_data.jsonl/35398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 523
} | [
2830,
3393,
38103,
43231,
7153,
1655,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
10225,
256,
914,
198,
197,
14522,
256,
526,
198,
197,
48558,
4922,
198,
197,
59403,
197,
197,
4913,
15,
15,
497,
220,
15,
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... | 3 |
func TestBlkioSetWeightDevice(t *testing.T) {
const (
weightDeviceBefore = "8:0 400"
)
for _, legacyIOScheduler := range []bool{false, true} {
// Populate cgroup
helper := NewCgroupTestUtil("blkio", t)
defer helper.cleanup()
weightFilename := "blkio.bfq.weight"
weightDeviceFilename := "blkio.bfq.weight_device"
if legacyIOScheduler {
weightFilename = "blkio.weight"
weightDeviceFilename = "blkio.weight_device"
}
helper.writeFileContents(map[string]string{
weightFilename: "",
weightDeviceFilename: weightDeviceBefore,
})
// Apply new configuration
wd := configs.NewWeightDevice(8, 0, 500, 0)
weightDeviceAfter := wd.WeightString()
helper.CgroupData.config.Resources.BlkioWeightDevice = []*configs.WeightDevice{wd}
blkio := &BlkioGroup{}
if err := blkio.Set(helper.CgroupPath, helper.CgroupData.config.Resources); err != nil {
t.Fatal(err)
}
// Verify results
if weightDeviceFilename != blkio.weightDeviceFilename {
t.Fatalf("weight_device filename detection failed: expected %q, detected %q", weightDeviceFilename, blkio.weightDeviceFilename)
}
value, err := fscommon.GetCgroupParamString(helper.CgroupPath, weightDeviceFilename)
if err != nil {
t.Fatal(err)
}
if value != weightDeviceAfter {
t.Fatalf("Got the wrong value, set %s failed.", weightDeviceFilename)
}
}
} | explode_data.jsonl/45834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 506
} | [
2830,
3393,
4923,
74,
815,
1649,
8295,
6985,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
197,
4765,
6985,
10227,
284,
330,
23,
25,
15,
220,
19,
15,
15,
698,
197,
692,
2023,
8358,
19588,
28136,
15222,
1669,
2088,
3056,
2641,
90,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSetSecp256k1(t *testing.T) {
var r Record
if err := r.Sign(privkey); err != nil {
t.Fatal(err)
}
var pk Secp256k1
require.NoError(t, r.Load(&pk))
assert.EqualValues(t, pubkey, &pk)
} | explode_data.jsonl/39488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
1949,
1649,
8430,
79,
17,
20,
21,
74,
16,
1155,
353,
8840,
836,
8,
341,
2405,
435,
13583,
198,
743,
1848,
1669,
435,
41152,
51750,
792,
1215,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
2405,
22458,
4520... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientRedirectHostClientChangingSchemaHttp2Https(t *testing.T) {
t.Parallel()
listenHTTPS := testClientRedirectListener(t, true)
defer listenHTTPS.Close()
listenHTTP := testClientRedirectListener(t, false)
defer listenHTTP.Close()
sHTTPS := testClientRedirectChangingSchemaServer(t, listenHTTPS, listenHTTP, true)
defer sHTTPS.Stop()
sHTTP := testClientRedirectChangingSchemaServer(t, listenHTTPS, listenHTTP, false)
defer sHTTP.Stop()
destURL := fmt.Sprintf("http://%s/baz", listenHTTP.Addr().String())
urlParsed, err := url.Parse(destURL)
if err != nil {
t.Fatal(err)
return
}
reqClient := &HostClient{
Addr: urlParsed.Host,
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
_, _, err = reqClient.GetTimeout(nil, destURL, 4000*time.Millisecond)
if err != ErrHostClientRedirectToDifferentScheme {
t.Fatal("expected HostClient error")
}
} | explode_data.jsonl/79341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
2959,
17725,
9296,
2959,
59046,
8632,
2905,
17,
92869,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
14440,
268,
82354,
1669,
1273,
2959,
17725,
2743,
1155,
11,
830,
340,
16867,
8844,
82354,
10421,
2822,
14440,
268,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObjectLinks(t *testing.T) {
s := RunBasicJetStreamServer()
defer shutdown(s)
nc, js := jsClient(t, s)
defer nc.Close()
root, err := js.CreateObjectStore(&nats.ObjectStoreConfig{Bucket: "ROOT"})
expectOk(t, err)
_, err = root.PutString("A", "AAA")
expectOk(t, err)
_, err = root.PutString("B", "BBB")
expectOk(t, err)
info, err := root.GetInfo("A")
expectOk(t, err)
// Self link to individual object.
_, err = root.AddLink("LA", info)
expectOk(t, err)
dir, err := js.CreateObjectStore(&nats.ObjectStoreConfig{Bucket: "DIR"})
expectOk(t, err)
_, err = dir.PutString("DIR/A", "DIR-AAA")
expectOk(t, err)
_, err = dir.PutString("DIR/B", "DIR-BBB")
expectOk(t, err)
info, err = dir.GetInfo("DIR/B")
expectOk(t, err)
binfo, err := root.AddLink("DBL", info)
expectOk(t, err)
if binfo.Name != "DBL" || binfo.NUID == "" || binfo.ModTime.IsZero() {
t.Fatalf("Link info not what was expected: %+v", binfo)
}
// Now add whole other store as a link, like a directory.
_, err = root.AddBucketLink("dir", dir)
expectOk(t, err)
// Now try to get a linked object.
dbl, err := root.GetString("DBL")
expectOk(t, err)
if dbl != "DIR-BBB" {
t.Fatalf("Expected %q but got %q", "DIR-BBB", dbl)
}
} | explode_data.jsonl/75497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 527
} | [
2830,
3393,
1190,
24089,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
6452,
15944,
35641,
3027,
5475,
741,
16867,
23766,
1141,
692,
197,
1016,
11,
6994,
1669,
6994,
2959,
1155,
11,
274,
340,
16867,
25126,
10421,
2822,
33698,
11,
1848,
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... | 5 |
func TestScanTypeHashingIgnoresNonScbAnnotations(t *testing.T) {
originalScanType := scanType.DeepCopy()
originalScanType.ObjectMeta.Annotations = map[string]string{
"foo.example.com/bar": "54165165135",
}
modifiedScantype := scanType.DeepCopy()
modifiedScantype.ObjectMeta.Annotations = map[string]string{
"foo.example.com/bar": "719839183223",
}
assert.Equal(
t,
HashScanType(*originalScanType),
HashScanType(*modifiedScantype),
"Should ignore non scb annotation on the scantypes",
)
} | explode_data.jsonl/24497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
26570,
929,
6370,
287,
40,
70,
2152,
416,
8121,
3326,
65,
21418,
1155,
353,
8840,
836,
8,
341,
197,
9889,
26570,
929,
1669,
8569,
929,
55602,
12106,
741,
197,
9889,
26570,
929,
80222,
91172,
284,
2415,
14032,
30953,
515,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStorageCreate(t *testing.T) {
// initialize storage
storage := Init(driver.NewMemory())
// create fake release
rls := ReleaseTestData{
Name: "angry-beaver",
Version: 1,
}.ToRelease()
assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease")
// fetch the release
res, err := storage.Get(rls.Name, rls.Version)
assertErrNil(t.Fatal, err, "QueryRelease")
// verify the fetched and created release are the same
if !reflect.DeepEqual(rls, res) {
t.Fatalf("Expected %q, got %q", rls, res)
}
} | explode_data.jsonl/35123 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
5793,
4021,
1155,
353,
8840,
836,
8,
341,
197,
322,
9468,
5819,
198,
197,
16172,
1669,
15690,
24032,
7121,
10642,
12367,
197,
322,
1855,
12418,
4879,
198,
197,
2381,
82,
1669,
17381,
83920,
515,
197,
21297,
25,
262,
330,
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... | 2 |
func TestSimpleSign(t *testing.T) {
signer, cl := newBootstrapSigner()
cm := newConfigMap("", "")
signer.configMaps.Add(cm)
secret := newTokenSecret(testTokenID, "tokenSecret")
addSecretSigningUsage(secret, "true")
signer.secrets.Add(secret)
signer.signConfigMap()
expected := []core.Action{
core.NewUpdateAction(schema.GroupVersionResource{Version: "v1", Resource: "configmaps"},
api.NamespacePublic,
newConfigMap(testTokenID, "eyJhbGciOiJIUzI1NiIsImtpZCI6ImFiYzEyMyJ9..QSxpUG7Q542CirTI2ECPSZjvBOJURUW5a7XqFpNI958")),
}
verifyActions(t, expected, cl.Actions())
} | explode_data.jsonl/68881 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
16374,
7264,
1155,
353,
8840,
836,
8,
341,
69054,
261,
11,
1185,
1669,
501,
45511,
7264,
261,
2822,
98316,
1669,
501,
2648,
2227,
19814,
14676,
69054,
261,
5423,
36562,
1904,
51126,
692,
197,
20474,
1669,
501,
3323,
19773,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnsureDir(t *testing.T) {
h := test.NewHelper(t)
defer h.Cleanup()
h.TempDir(".")
h.TempFile("file", "")
tmpPath := h.Path(".")
var dn string
cleanup := setupInaccessibleDir(t, func(dir string) error {
dn = filepath.Join(dir, "dir")
return os.Mkdir(dn, 0777)
})
defer cleanup()
tests := map[string]bool{
// [success] A dir already exists for the given path.
tmpPath: true,
// [success] Dir does not exist but parent dir exists, so should get created.
filepath.Join(tmpPath, "testdir"): true,
// [failure] Dir and parent dir do not exist, should return an error.
filepath.Join(tmpPath, "notexist", "testdir"): false,
// [failure] Regular file present at given path.
h.Path("file"): false,
// [failure] Path inaccessible.
dn: false,
}
if runtime.GOOS == "windows" {
// This test doesn't work on Microsoft Windows because
// of the differences in how file permissions are
// implemented. For this to work, the directory where
// the directory exists should be inaccessible.
delete(tests, dn)
}
for path, shouldEnsure := range tests {
err := EnsureDir(path, 0777)
if shouldEnsure {
if err != nil {
t.Fatalf("unexpected error %q for %q", err, path)
} else if ok, err := IsDir(path); !ok {
t.Fatalf("expected directory to be preset at %q", path)
t.Fatal(err)
}
} else if err == nil {
t.Fatalf("expected error for path %q, got none", path)
}
}
} | explode_data.jsonl/72215 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 581
} | [
2830,
3393,
64439,
6184,
1155,
353,
8840,
836,
8,
972,
9598,
1669,
1273,
7121,
5511,
1155,
1218,
16867,
305,
727,
60639,
3568,
9598,
65009,
6184,
5680,
6060,
9598,
65009,
1703,
445,
1192,
497,
11700,
871,
20082,
1820,
1669,
305,
17474,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldKeepSessionWhenInactivityTimeoutHasNotBeenExceeded(t *testing.T) {
mock := mocks.NewMockAutheliaCtx(t)
defer mock.Close()
mock.Clock.Set(time.Now())
mock.Ctx.Configuration.Session.Inactivity = testInactivity
past := mock.Clock.Now().Add(-1 * time.Hour)
userSession := mock.Ctx.GetSession()
userSession.Username = testUsername
userSession.Emails = []string{"john.doe@example.com"}
userSession.AuthenticationLevel = authentication.TwoFactor
userSession.LastActivity = past.Unix()
userSession.RefreshTTL = mock.Clock.Now().Add(5 * time.Minute)
err := mock.Ctx.SaveSession(userSession)
require.NoError(t, err)
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
VerifyGet(verifyGetCfg)(mock.Ctx)
// The session has been destroyed.
newUserSession := mock.Ctx.GetSession()
assert.Equal(t, "john", newUserSession.Username)
assert.Equal(t, authentication.TwoFactor, newUserSession.AuthenticationLevel)
// Check the inactivity timestamp has been updated to current time in the new session.
assert.Equal(t, mock.Clock.Now().Unix(), newUserSession.LastActivity)
} | explode_data.jsonl/20194 | {
"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,
14996,
19434,
5283,
4498,
641,
7175,
7636,
10281,
2623,
25102,
840,
94206,
1155,
353,
8840,
836,
8,
341,
77333,
1669,
68909,
7121,
11571,
5087,
35929,
23684,
1155,
340,
16867,
7860,
10421,
2822,
77333,
79248,
4202,
9730,
13244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSafeEntry(t *testing.T) {
var s safeRead
s.lf = &logFile{}
e := NewEntry([]byte("foo"), []byte("bar"))
buf := bytes.NewBuffer(nil)
_, err := s.lf.encodeEntry(e, buf, 0)
require.NoError(t, err)
ne, err := s.Entry(buf)
require.NoError(t, err)
require.Equal(t, e.Key, ne.Key, "key mismatch")
require.Equal(t, e.Value, ne.Value, "value mismatch")
require.Equal(t, e.meta, ne.meta, "meta mismatch")
require.Equal(t, e.UserMeta, ne.UserMeta, "usermeta mismatch")
require.Equal(t, e.ExpiresAt, ne.ExpiresAt, "expiresAt mismatch")
} | explode_data.jsonl/39103 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
25663,
5874,
1155,
353,
8840,
836,
8,
341,
2405,
274,
6092,
4418,
198,
1903,
918,
69,
284,
609,
839,
1703,
16094,
7727,
1669,
1532,
5874,
10556,
3782,
445,
7975,
3975,
3056,
3782,
445,
2257,
5455,
26398,
1669,
5820,
7121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateServiceVersion(t *testing.T) {
validatePayloadMetadata(t, func(tracer *apm.Tracer) {
tracer.Service.Version = strings.Repeat("x", 1025)
})
} | explode_data.jsonl/781 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 61
} | [
2830,
3393,
17926,
1860,
5637,
1155,
353,
8840,
836,
8,
341,
197,
7067,
29683,
14610,
1155,
11,
2915,
7624,
9584,
353,
391,
76,
8240,
9584,
8,
341,
197,
25583,
9584,
13860,
35842,
284,
9069,
2817,
10979,
445,
87,
497,
220,
16,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestIgnorePackages_whenIgnorePackages(t *testing.T) {
assert := testifyassert.New(t)
arbitraryPackages := []string{"abc", "xyz/abc/opq"}
assert.NoError(os.Setenv("QUORUM_IGNORE_TEST_PACKAGES", "abc, xyz/abc"))
actual := IgnorePackages(arbitraryPackages)
assert.Len(actual, 0)
} | explode_data.jsonl/73326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
12497,
69513,
47636,
12497,
69513,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
48162,
2207,
7121,
1155,
692,
69340,
87851,
69513,
1669,
3056,
917,
4913,
13683,
497,
330,
28854,
14,
13683,
52000,
80,
16707,
6948,
35699,
9638,
420... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFrontendPlugin(t *testing.T) {
t.Run("When setting paths based on App on Windows", func(t *testing.T) {
cfg := setting.NewCfg()
cfg.StaticRootPath = "c:\\grafana\\public"
fp := &FrontendPluginBase{
PluginBase: PluginBase{
PluginDir: "c:\\grafana\\public\\app\\plugins\\app\\testdata\\datasources\\datasource",
BaseUrl: "fpbase",
},
}
app := &AppPlugin{
FrontendPluginBase: FrontendPluginBase{
PluginBase: PluginBase{
PluginDir: "c:\\grafana\\public\\app\\plugins\\app\\testdata",
Id: "testdata",
BaseUrl: "public/app/plugins/app/testdata",
},
},
}
fp.setPathsBasedOnApp(app, cfg)
require.Equal(t, "app/plugins/app/testdata/datasources/datasource/module", fp.Module)
})
} | explode_data.jsonl/73827 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 322
} | [
2830,
3393,
23395,
408,
11546,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4498,
6243,
12716,
3118,
389,
1845,
389,
5515,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
50286,
1669,
6243,
7121,
42467,
741,
197,
50286,
58826,
8439,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContainsChar(t *testing.T) {
if !containsChar('#', "#.") {
t.Errorf("containsChar should be true, but %t: %s", containsChar('#', "#."), "#")
}
if containsChar('a', "#.") {
t.Errorf("containsChar should be false, but %t: %s", containsChar('a', "#."), "a")
}
} | explode_data.jsonl/34985 | {
"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,
23805,
4768,
1155,
353,
8840,
836,
8,
341,
743,
753,
13372,
4768,
3515,
516,
5869,
38739,
341,
197,
3244,
13080,
445,
13372,
4768,
1265,
387,
830,
11,
714,
1018,
83,
25,
1018,
82,
497,
5610,
4768,
3515,
516,
5869,
82815,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadPlainDOUBLE(t *testing.T) {
testData := [][]interface{}{
{float64(0), float64(1), float64(2)},
{float64(0), float64(0), float64(0)},
}
for _, data := range testData {
res, _ := ReadPlainDOUBLE(bytes.NewReader(WritePlainDOUBLE(data)), uint64(len(data)))
if fmt.Sprintf("%v", data) != fmt.Sprintf("%v", res) {
t.Errorf("ReadPlainDOUBLE err, %v", data)
}
}
} | explode_data.jsonl/23898 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
4418,
26982,
77647,
1155,
353,
8840,
836,
8,
341,
18185,
1043,
1669,
52931,
4970,
67066,
197,
197,
90,
3649,
21,
19,
7,
15,
701,
2224,
21,
19,
7,
16,
701,
2224,
21,
19,
7,
17,
39781,
197,
197,
90,
3649,
21,
19,
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 TestBernoulliProcess(t *testing.T) {
Convey("Test BernoulliProcess interfaces", t, func() {
process := NewBernoulliProcess(0.5)
So(process, ShouldImplement, (*StochasticProcess)(nil))
})
Convey("Test BernoulliProcess.Sample", t, func() {
const n = 100
process := NewBernoulliProcess(0.7)
mean := 0.0
for i := 0; i < n; i++ {
rv := process.Sample()
So(rv, ShouldHaveSameTypeAs, (*variable.DiscreteRV)(nil))
mean += rv.Val()
}
mean /= n
So(mean, ShouldBeBetween, 0.65, 0.75)
})
Convey("Test BernoulliProcess.SetBias", t, func() {
const n = 100
process := NewBernoulliProcess(0.7)
process.SetBias(0.5)
mean := 0.0
for i := 0; i < n; i++ {
rv := process.Sample()
So(rv, ShouldHaveSameTypeAs, (*variable.DiscreteRV)(nil))
mean += rv.Val()
}
mean /= n
So(mean, ShouldBeBetween, 0.45, 0.55)
})
Convey("Test BernoulliProcess.SampleN", t, func() {
const n = 100
process := NewBernoulliProcess(0.7)
mean := 0.0
for _, rv := range process.SampleN(n) {
So(rv, ShouldHaveSameTypeAs, (*variable.DiscreteRV)(nil))
mean += rv.Val()
}
mean /= n
So(mean, ShouldBeBetween, 0.65, 0.75)
})
Convey("Test BernoulliProcess.Factor", t, func() {
process := NewBernoulliProcess(0.7)
bias := process.Params[0]
rvs := process.SampleN(10)
factors := process.Factors(rvs)
for i, factor := range factors {
So(factor.Adjacent(), ShouldResemble, []variable.RandomVariable{rvs[i], bias})
if rvs[i].Val() == 0 {
So(factor.Score(), ShouldAlmostEqual, 0.3)
} else {
So(factor.Score(), ShouldAlmostEqual, 0.7)
}
}
process.SetBias(0.3)
So(bias.Val(), ShouldEqual, 0.3)
for i, factor := range factors {
if rvs[i].Val() == 0 {
So(factor.Score(), ShouldAlmostEqual, 0.7)
} else {
So(factor.Score(), ShouldAlmostEqual, 0.3)
}
}
bias.Set(0.7)
for i, factor := range factors {
if rvs[i].Val() == 0 {
So(factor.Score(), ShouldAlmostEqual, 0.3)
} else {
So(factor.Score(), ShouldAlmostEqual, 0.7)
}
}
})
} | explode_data.jsonl/61363 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 902
} | [
2830,
3393,
59926,
283,
39976,
7423,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2271,
14168,
283,
39976,
7423,
24099,
497,
259,
11,
2915,
368,
341,
197,
53314,
1669,
1532,
59926,
283,
39976,
7423,
7,
15,
13,
20,
340,
197,
76912,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHealthtoi(t *testing.T) {
t.Parallel()
require.Equal(t, 0, healthtoi("ONLINE"))
require.Equal(t, 1, healthtoi("DEGRADED"))
require.Equal(t, 2, healthtoi("SUSPENDED"))
require.Equal(t, 3, healthtoi("UNAVAIL"))
require.Equal(t, 99, healthtoi("what the heck is this nonsense"))
} | explode_data.jsonl/18987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
14542,
52609,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
17957,
12808,
1155,
11,
220,
15,
11,
2820,
52609,
445,
711,
8265,
5455,
17957,
12808,
1155,
11,
220,
16,
11,
2820,
52609,
445,
1150,
46975,
11490,
5455,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestActivityService_MarkNotificationsRead(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testFormValues(t, r, values{
"last_read_at": "2006-01-02T15:04:05Z",
})
w.WriteHeader(http.StatusResetContent)
})
_, err := client.Activity.MarkNotificationsRead(time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))
if err != nil {
t.Errorf("Activity.MarkNotificationsRead returned error: %v", err)
}
} | explode_data.jsonl/6717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
4052,
1860,
1245,
838,
34736,
4418,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
38188,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
18185,
3523,
1155,
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 TestRegionCanonicalize(t *testing.T) {
for i, tt := range []struct{ in, out string }{
{"UK", "GB"},
{"TP", "TL"},
{"QU", "EU"},
{"SU", "SU"},
{"VD", "VN"},
{"DD", "DE"},
} {
r := MustParseRegion(tt.in)
want := MustParseRegion(tt.out)
if got := r.Canonicalize(); got != want {
t.Errorf("%d: got %v; want %v", i, got, want)
}
}
} | explode_data.jsonl/15842 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
14091,
70914,
551,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
17853,
1669,
2088,
3056,
1235,
90,
304,
11,
700,
914,
335,
515,
197,
197,
4913,
24537,
497,
330,
5381,
7115,
197,
197,
4913,
4239,
497,
330,
13470,
7115,
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 TestGenericEndpoint_loadBase64Secrets(t *testing.T) {
tests := []struct {
name string
creds genericEndpointCredentials
wantRawUsername string
wantRawPassword string
wantRawToken string
wantErr bool
}{
// Bogus credential type
{
"credential type bogus",
genericEndpointCredentials{Type: "X"},
"", "", "",
true,
},
// No type set
{
"no credential fields set",
genericEndpointCredentials{},
"", "", "",
false,
},
// Type 'none'
{
"credential type none, no other fields set",
genericEndpointCredentials{},
"", "", "",
false,
},
// Type 'basic'
{
"credential type basic, nothing set",
genericEndpointCredentials{Type: "basic"},
"", "", "",
true,
},
{
"credential type basic, username set, passowrd not set",
genericEndpointCredentials{Type: "basic", Username: fooString},
"", "", "",
true,
},
{
"credential type basic, username set, passowrd not set",
genericEndpointCredentials{Type: "basic", Password: barString},
"", "", "",
true,
},
{
"credential type basic, username set, password set",
genericEndpointCredentials{Type: "basic", Username: fooString, Password: barString},
"foo", "bar", "",
false,
},
{
"credential type basic, username junk, password set",
genericEndpointCredentials{Type: "basic", Username: "X", Password: barString},
"", "", "",
true,
},
{
"credential type basic, username set, password junk",
genericEndpointCredentials{Type: "basic", Username: fooString, Password: "X"},
"", "", "",
true,
},
// Type 'bearer'
{
"credential type bearer, nothing set",
genericEndpointCredentials{Type: "bearer"},
"", "", "",
true,
},
{
"credential type bearer, token set",
genericEndpointCredentials{Type: "bearer", Token: bazString},
"", "", "baz",
false,
},
{
"credential type bearer, token bogus",
genericEndpointCredentials{Type: "bearer", Token: "X"},
"", "", "",
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ep := &GenericEndpoint{
endpointType: "jenkins",
endpointName: "epname",
config: genericEndpointConfig{
URL: "http://example.com",
Credentials: tt.creds,
},
}
if err := ep.loadBase64Secrets(); (err != nil) != tt.wantErr {
t.Errorf("GenericEndpoint.loadBase64Secrets() error = %v, wantErr %v", err, tt.wantErr)
}
compareBytes(t, tt.wantRawUsername, ep.config.Credentials.rawUsername, "rawUsername")
compareBytes(t, tt.wantRawPassword, ep.config.Credentials.rawPassword, "rawPassword")
compareBytes(t, tt.wantRawToken, ep.config.Credentials.rawToken, "rawToken")
})
}
} | explode_data.jsonl/67227 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1176
} | [
2830,
3393,
19964,
27380,
12411,
3978,
21,
19,
19773,
82,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
197,
85734,
1843,
13954,
27380,
27025,
198,
197,
50780,
20015,
11115,
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... | 2 |
func TestSecretUpdated(t *testing.T) {
datacenter := "0.0.0.0"
secretName := "vccreds"
secretNamespace := "kube-system"
username := "test-username"
password := "test-password"
basicSecret := fakeSecret(secretName, secretNamespace, datacenter, username, password)
cfg, cleanup := configFromSim()
defer cleanup()
cfg.Global.User = username
cfg.Global.Password = password
cfg.Global.Datacenter = datacenter
cfg.Global.SecretName = secretName
cfg.Global.SecretNamespace = secretNamespace
vsphere, err := buildVSphereFromConfig(cfg)
if err != nil {
t.Fatalf("Should succeed when a valid config is provided: %s", err)
}
klog.Flush()
klog.InitFlags(nil)
flag.Set("logtostderr", "false")
flag.Set("alsologtostderr", "false")
flag.Set("v", "9")
flag.Parse()
testcases := []struct {
name string
oldSecret *v1.Secret
secret *v1.Secret
expectOutput bool
expectErrOutput bool
}{
{
name: "Secrets are equal",
oldSecret: basicSecret.DeepCopy(),
secret: basicSecret.DeepCopy(),
expectOutput: false,
},
{
name: "Secret with a different name",
oldSecret: basicSecret.DeepCopy(),
secret: fakeSecret("different", secretNamespace, datacenter, username, password),
expectOutput: false,
},
{
name: "Secret with a different data",
oldSecret: basicSecret.DeepCopy(),
secret: fakeSecret(secretName, secretNamespace, datacenter, "...", "..."),
expectOutput: true,
},
{
name: "Secret being nil",
oldSecret: basicSecret.DeepCopy(),
secret: nil,
expectOutput: true,
expectErrOutput: true,
},
}
for _, testcase := range testcases {
t.Run(testcase.name, func(t *testing.T) {
buf := new(bytes.Buffer)
errBuf := new(bytes.Buffer)
klog.SetOutputBySeverity("INFO", buf)
klog.SetOutputBySeverity("WARNING", errBuf)
vsphere.SecretUpdated(testcase.oldSecret, testcase.secret)
klog.Flush()
if testcase.expectOutput && len(buf.String()) == 0 {
t.Fatalf("Expected log secret update for secrets:\nOld:\n\t%+v\nNew\n\t%+v", testcase.oldSecret, testcase.secret)
} else if !testcase.expectOutput && len(buf.String()) > 0 {
t.Fatalf("Unexpected log messages for secrets:\nOld:\n\t%+v\n\nNew:\n\t%+v\nMessage:%s", testcase.oldSecret, testcase.secret, buf.String())
}
if testcase.expectErrOutput && len(errBuf.String()) == 0 {
t.Fatalf("Expected log error output on secret update for secrets:\nOld:\n\t%+v\nNew\n\t%+v", testcase.oldSecret, testcase.secret)
} else if !testcase.expectErrOutput && len(errBuf.String()) > 0 {
t.Fatalf("Unexpected log error messages for secrets:\nOld:\n\t%+v\n\nNew:\n\t%+v\nMessage:%s", testcase.oldSecret, testcase.secret, errBuf.String())
}
})
}
} | explode_data.jsonl/65376 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1164
} | [
2830,
3393,
19773,
16196,
1155,
353,
8840,
836,
8,
341,
8924,
3057,
1669,
330,
15,
13,
15,
13,
15,
13,
15,
698,
197,
20474,
675,
1669,
330,
85,
638,
53369,
698,
197,
20474,
22699,
1669,
330,
97717,
36648,
698,
72358,
1669,
330,
1944... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnreadFlowControlReturned_Server(t *testing.T) {
unblock := make(chan bool, 1)
defer close(unblock)
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
// Don't read the 16KB request body. Wait until the client's
// done sending it and then return. This should cause the Server
// to then return those 16KB of flow control to the client.
<-unblock
}, optOnlyServer)
defer st.Close()
tr := &Transport{TLSClientConfig: tlsConfigInsecure}
defer tr.CloseIdleConnections()
// This previously hung on the 4th iteration.
for i := 0; i < 6; i++ {
body := io.MultiReader(
io.LimitReader(neverEnding('A'), 16<<10),
funcReader(func([]byte) (n int, err error) {
unblock <- true
return 0, io.EOF
}),
)
req, _ := http.NewRequest("POST", st.ts.URL, body)
res, err := tr.RoundTrip(req)
if err != nil {
t.Fatal(err)
}
res.Body.Close()
}
} | explode_data.jsonl/71701 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 350
} | [
2830,
3393,
1806,
878,
18878,
3273,
84804,
62320,
1155,
353,
8840,
836,
8,
341,
20479,
4574,
1669,
1281,
35190,
1807,
11,
220,
16,
340,
16867,
3265,
18364,
4574,
692,
18388,
1669,
501,
5475,
58699,
1155,
11,
2915,
3622,
1758,
37508,
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 TestMuxPlain(t *testing.T) {
r := NewRouter()
r.Get("/hi", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("bye"))
})
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
w.Write([]byte("nothing here"))
})
ts := httptest.NewServer(r)
defer ts.Close()
if _, body := testRequest(t, ts, "GET", "/hi", nil); body != "bye" {
t.Fatalf(body)
}
if _, body := testRequest(t, ts, "GET", "/nothing-here", nil); body != "nothing here" {
t.Fatalf(body)
}
} | explode_data.jsonl/42865 | {
"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,
44,
2200,
26982,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
9523,
741,
7000,
2234,
4283,
6023,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
4073,
10556,
3782,
445,
28374,
5455,
197,
3518,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientReconnect(t *testing.T) {
t.Parallel()
ctx, cancel := testContext()
defer cancel()
client, err := newClient(t, address)
if err != nil {
t.Fatal(err)
}
if client == nil {
t.Fatal("New() returned nil client")
}
ok, err := client.IsServing(ctx)
if err != nil {
t.Fatal(err)
}
if !ok {
t.Fatal("containerd is not serving")
}
if err := client.Reconnect(); err != nil {
t.Fatal(err)
}
if ok, err = client.IsServing(ctx); err != nil {
t.Fatal(err)
}
if !ok {
t.Fatal("containerd is not serving")
}
if err := client.Close(); err != nil {
t.Errorf("client closed returned errror %v", err)
}
} | explode_data.jsonl/37736 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
2959,
693,
6459,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
1273,
1972,
741,
16867,
9121,
2822,
25291,
11,
1848,
1669,
501,
2959,
1155,
11,
2621,
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... | 9 |
func TestFunction2(t *testing.T) {
const SCRIPT = `
var trace = "";
function f(count) {
trace += "f("+count+")";
if (count == 0) {
return;
}
return f(count-1);
}
function f1() {
trace += "f1";
}
var f2 = f;
f = f1;
f2(1);
trace;
`
testScript1(SCRIPT, asciiString("f(1)f1"), t)
} | explode_data.jsonl/75283 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
5152,
17,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
11655,
284,
5438,
7527,
282,
11512,
8,
341,
7782,
65058,
1421,
330,
69,
34973,
1830,
57224,
876,
7782,
743,
320,
1830,
621,
220,
15,
8,
341,
17362,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNonBlockingOwnerRefDoesNotBlock(t *testing.T) {
ctx := setup(t, 5)
defer ctx.tearDown()
clientSet := ctx.clientSet
ns := createNamespaceOrDie("gc-foreground2", clientSet, t)
defer deleteNamespaceOrDie(ns.Name, clientSet, t)
podClient := clientSet.CoreV1().Pods(ns.Name)
rcClient := clientSet.CoreV1().ReplicationControllers(ns.Name)
// create the RC with the orphan finalizer set
toBeDeletedRC, err := rcClient.Create(newOwnerRC(toBeDeletedRCName, ns.Name))
if err != nil {
t.Fatalf("Failed to create replication controller: %v", err)
}
// BlockingOwnerDeletion is not set
pod1 := newPod("pod1", ns.Name, []metav1.OwnerReference{
{UID: toBeDeletedRC.ObjectMeta.UID, Name: toBeDeletedRC.Name},
})
// adding finalizer that no controller handles, so that the pod won't be deleted
pod1.ObjectMeta.Finalizers = []string{"x/y"}
// BlockingOwnerDeletion is false
falseVar := false
pod2 := newPod("pod2", ns.Name, []metav1.OwnerReference{
{UID: toBeDeletedRC.ObjectMeta.UID, Name: toBeDeletedRC.Name, BlockOwnerDeletion: &falseVar},
})
// adding finalizer that no controller handles, so that the pod won't be deleted
pod2.ObjectMeta.Finalizers = []string{"x/y"}
_, err = podClient.Create(pod1)
if err != nil {
t.Fatalf("Failed to create Pod: %v", err)
}
_, err = podClient.Create(pod2)
if err != nil {
t.Fatalf("Failed to create Pod: %v", err)
}
err = rcClient.Delete(toBeDeletedRCName, getForegroundOptions())
if err != nil {
t.Fatalf("Failed to delete the rc: %v", err)
}
// verify the toBeDeleteRC is deleted
if err := wait.PollImmediate(1*time.Second, 30*time.Second, func() (bool, error) {
_, err := rcClient.Get(toBeDeletedRC.Name, metav1.GetOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
return true, nil
}
return false, err
}
return false, nil
}); err != nil {
t.Errorf("unexpected error: %v", err)
}
// verify pods are still there
pods, err := podClient.List(metav1.ListOptions{})
if err != nil {
t.Fatalf("Failed to list pods: %v", err)
}
if len(pods.Items) != 2 {
t.Errorf("expect there to be 2 pods, got %#v", pods.Items)
}
} | explode_data.jsonl/18180 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 811
} | [
2830,
3393,
8121,
48266,
13801,
3945,
21468,
2623,
4713,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6505,
1155,
11,
220,
20,
340,
16867,
5635,
31853,
59342,
2822,
25291,
1649,
1669,
5635,
6581,
1649,
271,
84041,
1669,
1855,
22699,
2195,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandlers_PostMessage(t *testing.T) {
t.Parallel()
path := "/api/v3/channels/{channelId}/messages"
env := Setup(t, common1)
user := env.CreateUser(t, rand)
ch := env.CreateChannel(t, rand)
archived := env.CreateChannel(t, rand)
require.NoError(t, env.CM.ArchiveChannel(archived.ID, user.GetID()))
s := env.S(t, user.GetID())
req := &PostMessageRequest{
Content: "Hello, traP",
Embed: true,
}
t.Run("not logged in", func(t *testing.T) {
t.Parallel()
e := env.R(t)
e.POST(path, ch.ID).
WithJSON(req).
Expect().
Status(http.StatusUnauthorized)
})
t.Run("not found", func(t *testing.T) {
t.Parallel()
e := env.R(t)
e.POST(path, uuid.Must(uuid.NewV4())).
WithCookie(session.CookieName, s).
WithJSON(req).
Expect().
Status(http.StatusNotFound)
})
t.Run("archived", func(t *testing.T) {
t.Parallel()
e := env.R(t)
e.POST(path, archived.ID).
WithCookie(session.CookieName, s).
WithJSON(req).
Expect().
Status(http.StatusBadRequest)
})
t.Run("bad request", func(t *testing.T) {
t.Parallel()
e := env.R(t)
e.POST(path, ch.ID).
WithCookie(session.CookieName, s).
WithJSON(&PostMessageRequest{Content: ""}).
Expect().
Status(http.StatusBadRequest)
})
t.Run("success", func(t *testing.T) {
t.Parallel()
e := env.R(t)
obj := e.POST(path, ch.ID).
WithCookie(session.CookieName, s).
WithJSON(req).
Expect().
Status(http.StatusCreated).
JSON().
Object()
obj.Value("id").String().NotEmpty()
obj.Value("userId").String().Equal(user.GetID().String())
obj.Value("channelId").String().Equal(ch.ID.String())
obj.Value("content").String().Equal("Hello, traP")
obj.Value("createdAt").String().NotEmpty()
obj.Value("updatedAt").String().NotEmpty()
obj.Value("pinned").Boolean().False()
obj.Value("stamps").Array().Length().Equal(0)
id, err := uuid.FromString(obj.Value("id").String().Raw())
if assert.NoError(t, err) {
m, err := env.MM.Get(id)
require.NoError(t, err)
messageEquals(t, m, obj)
}
})
} | explode_data.jsonl/40161 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 896
} | [
2830,
3393,
39949,
66726,
2052,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
26781,
1669,
3521,
2068,
5457,
18,
21284,
6680,
9388,
10119,
764,
4472,
16325,
698,
57538,
1669,
18626,
1155,
11,
4185,
16,
340,
19060,
1669,
6105,
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 TestPostLog(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
Client := th.Client
enableDev := *th.App.Config().ServiceSettings.EnableDeveloper
defer func() {
*th.App.Config().ServiceSettings.EnableDeveloper = enableDev
}()
*th.App.Config().ServiceSettings.EnableDeveloper = true
message := make(map[string]string)
message["level"] = "ERROR"
message["message"] = "this is a test"
_, resp := Client.PostLog(message)
CheckNoError(t, resp)
Client.Logout()
_, resp = Client.PostLog(message)
CheckNoError(t, resp)
*th.App.Config().ServiceSettings.EnableDeveloper = false
_, resp = Client.PostLog(message)
CheckForbiddenStatus(t, resp)
logMessage, resp := th.SystemAdminClient.PostLog(message)
CheckNoError(t, resp)
if len(logMessage) == 0 {
t.Fatal("should return the log message")
}
} | explode_data.jsonl/10688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
4133,
2201,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
197,
12552,
14592,
1669,
353,
339,
5105,
10753,
100... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBackupCreatedStats(t *testing.T) {
defer leaktest.AfterTest(t)()
const numAccounts = 1
_, _, sqlDB, _, cleanupFn := BackupRestoreTestSetup(t, singleNode, numAccounts, InitNone)
defer cleanupFn()
sqlDB.Exec(t, `SET CLUSTER SETTING sql.stats.automatic_collection.enabled=false`)
sqlDB.Exec(t, `CREATE TABLE data.foo (a INT PRIMARY KEY)`)
sqlDB.Exec(t, `CREATE STATISTICS foo_stats FROM data.foo`)
sqlDB.Exec(t, `CREATE STATISTICS bank_stats FROM data.bank`)
sqlDB.Exec(t, `BACKUP data.bank, data.foo TO $1 WITH revision_history`, LocalFoo)
sqlDB.Exec(t, `CREATE DATABASE "data 2"`)
sqlDB.Exec(t, `RESTORE data.bank, data.foo FROM $1 WITH skip_missing_foreign_keys, into_db = $2`,
LocalFoo, "data 2")
sqlDB.CheckQueryResults(t,
`SELECT statistics_name, column_names, row_count, distinct_count, null_count
FROM [SHOW STATISTICS FOR TABLE "data 2".bank] WHERE statistics_name='bank_stats'`,
[][]string{
{"bank_stats", "{id}", "1", "1", "0"},
{"bank_stats", "{balance}", "1", "1", "0"},
{"bank_stats", "{payload}", "1", "1", "0"},
})
sqlDB.CheckQueryResults(t,
`SELECT statistics_name, column_names, row_count, distinct_count, null_count
FROM [SHOW STATISTICS FOR TABLE "data 2".foo] WHERE statistics_name='foo_stats'`,
[][]string{
{"foo_stats", "{a}", "0", "0", "0"},
})
} | explode_data.jsonl/57618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 523
} | [
2830,
3393,
56245,
11694,
16635,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
4777,
1629,
41369,
284,
220,
16,
198,
197,
6878,
8358,
5704,
3506,
11,
8358,
21290,
24911,
1669,
43438,
56284,
2271,
21821,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterInsertUpdateNone(t *testing.T) {
f := bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateNone)
// Add the generation pubkey
inputStr := "04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c" +
"876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a" +
"2252247d97a46a91"
inputBytes, err := hex.DecodeString(inputStr)
if err != nil {
t.Errorf("TestFilterInsertUpdateNone DecodeString failed: %v", err)
return
}
f.Add(inputBytes)
// Add the output address for the 4th transaction
inputStr = "b6efd80d99179f4f4ff6f4dd0a007d018c385d21"
inputBytes, err = hex.DecodeString(inputStr)
if err != nil {
t.Errorf("TestFilterInsertUpdateNone DecodeString failed: %v", err)
return
}
f.Add(inputBytes)
inputStr = "147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"
sha, err := wire.NewShaHashFromStr(inputStr)
if err != nil {
t.Errorf("TestFilterInsertUpdateNone NewShaHashFromStr failed: %v", err)
return
}
outpoint := wire.NewOutPoint(sha, 0)
if f.MatchesOutPoint(outpoint) {
t.Errorf("TestFilterInsertUpdateNone matched outpoint %s", inputStr)
return
}
inputStr = "02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041"
sha, err = wire.NewShaHashFromStr(inputStr)
if err != nil {
t.Errorf("TestFilterInsertUpdateNone NewShaHashFromStr failed: %v", err)
return
}
outpoint = wire.NewOutPoint(sha, 0)
if f.MatchesOutPoint(outpoint) {
t.Errorf("TestFilterInsertUpdateNone matched outpoint %s", inputStr)
return
}
} | explode_data.jsonl/24704 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 633
} | [
2830,
3393,
5632,
13780,
4289,
4064,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
51454,
7121,
5632,
7,
16,
15,
11,
220,
15,
11,
220,
15,
13,
15,
15,
15,
15,
15,
16,
11,
9067,
1785,
18474,
4289,
4064,
692,
197,
322,
2691,
279,
9471... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStartAndShutdownWithWork(t *testing.T) {
r := &CountingReconciler{}
reporter := &FakeStatsReporter{}
impl := NewImplWithStats(r, TestLogger(t), "Testing", reporter)
ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{})
go func() {
defer close(doneCh)
StartAll(ctx, impl)
}()
t.Cleanup(func() {
cancel()
<-doneCh
})
impl.EnqueueKey(types.NamespacedName{Namespace: "foo", Name: "bar"})
select {
case <-time.After(10 * time.Millisecond):
// We don't expect completion before the context is cancelled.
case <-doneCh:
t.Error("StartAll finished early.")
}
cancel()
select {
case <-time.After(time.Second):
t.Error("Timed out waiting for controller to finish.")
case <-doneCh:
// We expect the work to complete.
}
if got, want := r.count.Load(), int32(1); got != want {
t.Errorf("reconcile count = %v, wanted %v", got, want)
}
if got, want := impl.WorkQueue().NumRequeues(types.NamespacedName{Namespace: "foo", Name: "bar"}), 0; got != want {
t.Errorf("requeues = %v, wanted %v", got, want)
}
checkStats(t, reporter, 1, 0, 1, trueString)
} | explode_data.jsonl/45288 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
3479,
3036,
62004,
2354,
6776,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
609,
2507,
287,
693,
40446,
5769,
16094,
69931,
261,
1669,
609,
52317,
16635,
52766,
16094,
197,
6383,
1669,
1532,
9673,
2354,
16635,
2601,
11,
3393,
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 TestTypeSystem_ScalarTypesMustBeSerializable_RejectsAScalarTypeDefiningParseValueButNotParseLiteral(t *testing.T) {
_, err := schemaWithFieldType(graphql.NewScalar(graphql.ScalarConfig{
Name: "SomeScalar",
Serialize: func(value interface{}) interface{} {
return nil
},
ParseValue: func(value interface{}) interface{} {
return nil
},
}))
expectedError := `SomeScalar must provide both "parseValue" and "parseLiteral" functions.`
if err == nil || err.Error() != expectedError {
t.Fatalf("Expected error: %v, got %v", expectedError, err)
}
} | explode_data.jsonl/79170 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
929,
2320,
1098,
59153,
4173,
31776,
3430,
29268,
50693,
583,
82,
1911,
59153,
45102,
5740,
14463,
1130,
3983,
2623,
14463,
17350,
1155,
353,
8840,
836,
8,
1476,
197,
6878,
1848,
1669,
10802,
2354,
63733,
24312,
1470,
7121,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPatchCurrentDC(t *testing.T) {
type args struct {
name string
dcBefore appsv1.DeploymentConfig
dcPatch appsv1.DeploymentConfig
}
tests := []struct {
name string
args args
wantErr bool
actions int
}{
{
name: "Case 1: Test patching",
args: args{
name: "foo",
dcBefore: *fakeDeploymentConfig("foo", "foo", []corev1.EnvVar{{Name: "key1", Value: "value1"}, {Name: "key2", Value: "value2"}}),
dcPatch: generateGitDeploymentConfig(metav1.ObjectMeta{Name: "foo"}, "bar",
[]corev1.ContainerPort{{Name: "foo", HostPort: 80, ContainerPort: 80}},
[]corev1.EnvVar{{Name: "key1", Value: "value1"}, {Name: "key2", Value: "value2"}}),
},
wantErr: false,
actions: 2,
},
{
name: "Case 2: Test patching with the wrong name",
args: args{
name: "foo",
dcBefore: *fakeDeploymentConfig("foo", "foo", []corev1.EnvVar{{Name: "key1", Value: "value1"}, {Name: "key2", Value: "value2"}}),
dcPatch: generateGitDeploymentConfig(metav1.ObjectMeta{Name: "foo2"}, "bar",
[]corev1.ContainerPort{corev1.ContainerPort{Name: "foo", HostPort: 80, ContainerPort: 80}},
[]corev1.EnvVar{{Name: "key1", Value: "value1"}, {Name: "key2", Value: "value2"}}),
},
wantErr: true,
actions: 2,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fakeClient, fakeClientSet := FakeNew()
// Fake getting DC
fakeClientSet.AppsClientset.PrependReactor("get", "deploymentconfigs", func(action ktesting.Action) (bool, runtime.Object, error) {
return true, &tt.args.dcBefore, nil
})
// Fake the "update"
fakeClientSet.AppsClientset.PrependReactor("update", "deploymentconfigs", func(action ktesting.Action) (bool, runtime.Object, error) {
dc := action.(ktesting.UpdateAction).GetObject().(*appsv1.DeploymentConfig)
if dc.Name != tt.args.dcPatch.Name {
return true, nil, fmt.Errorf("got different dc")
}
return true, nil, nil
})
// Run function PatchCurrentDC
err := fakeClient.PatchCurrentDC(tt.args.name, tt.args.dcPatch)
// Error checking PatchCurrentDC
if !tt.wantErr == (err != nil) {
t.Errorf(" client.PatchCurrentDC() unexpected error %v, wantErr %v", err, tt.wantErr)
}
if err == nil && !tt.wantErr {
// Check to see how many actions are being ran
if (len(fakeClientSet.AppsClientset.Actions()) != tt.actions) && !tt.wantErr {
t.Errorf("expected %v action(s) in PatchCurrentDC got: %v", tt.actions, fakeClientSet.Kubernetes.Actions())
}
} else if err == nil && tt.wantErr {
t.Error("test failed, expected: false, got true")
} else if err != nil && !tt.wantErr {
t.Errorf("test failed, expected: no error, got error: %s", err.Error())
}
})
}
} | explode_data.jsonl/65172 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1140
} | [
2830,
3393,
43622,
5405,
5626,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
11609,
257,
914,
198,
197,
87249,
10227,
906,
3492,
16,
34848,
39130,
2648,
198,
197,
87249,
43622,
220,
906,
3492,
16,
34848,
39130,
2648,
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 TestIfdBuilder_AddStandardWithName(t *testing.T) {
im := NewIfdMapping()
err := LoadStandardIfds(im)
log.PanicIf(err)
ti := NewTagIndex()
ib := NewIfdBuilder(im, ti, exifcommon.IfdStandardIfdIdentity, exifcommon.TestDefaultByteOrder)
err = ib.AddStandardWithName("ProcessingSoftware", "some software")
log.PanicIf(err)
if len(ib.tags) != 1 {
t.Fatalf("Exactly one tag was not found: (%d)", len(ib.tags))
}
bt := ib.tags[0]
if bt.ifdPath != exifcommon.IfdStandardIfdIdentity.UnindexedString() {
t.Fatalf("II not correct: %s", bt.ifdPath)
} else if bt.tagId != 0x000b {
t.Fatalf("Tag-ID not correct: (0x%04x)", bt.tagId)
}
s := string(bt.value.Bytes())
if s != "some software\000" {
t.Fatalf("Value not correct: (%d) [%s]", len(s), s)
}
} | explode_data.jsonl/36647 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
2679,
67,
3297,
21346,
19781,
54523,
1155,
353,
8840,
836,
8,
341,
54892,
1669,
1532,
2679,
67,
6807,
2822,
9859,
1669,
8893,
19781,
2679,
5356,
25107,
340,
6725,
1069,
31270,
2679,
3964,
692,
72859,
1669,
1532,
5668,
1552,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAllocateWithStopper(t *testing.T) {
defer leaktest.AfterTest(t)
store, _, stopper := createTestStore(t)
idAlloc, err := newIDAllocator(keys.RaftIDGenerator, store.ctx.DB, 2, 10, stopper)
if err != nil {
log.Fatal(err)
}
stopper.Stop()
if _, err := idAlloc.Allocate(); err == nil {
t.Errorf("unexpected success")
} else if !strings.Contains(err.Error(), "system is draining") {
t.Errorf("unexpected error: %s", err)
}
} | explode_data.jsonl/45461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
75380,
2354,
10674,
712,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
340,
57279,
11,
8358,
2936,
712,
1669,
1855,
2271,
6093,
1155,
340,
15710,
25154,
11,
1848,
1669,
501,
915,
42730,
36131,
2013,
64... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKeylevelValidationPvtData(t *testing.T) {
t.Parallel()
// Scenario: we validate a transaction that writes
// to a pvt key that contains key-level validation params.
// We simulate policy check success and failure
vpMetadataKey := pb.MetaDataKeys_VALIDATION_PARAMETER.String()
mr := &mockState{GetStateMetadataRv: map[string][]byte{vpMetadataKey: []byte("EP")}, GetPrivateDataMetadataByHashRv: map[string][]byte{vpMetadataKey: []byte("EP")}}
ms := &mockStateFetcher{FetchStateRv: mr}
pm := &KeyLevelValidationParameterManagerImpl{PolicyTranslator: &mockTranslator{}, StateFetcher: ms}
pe := &mockPolicyEvaluator{}
validator := NewKeyLevelValidator(NewV13Evaluator(pe, pm), pm)
rwsbu := rwsetutil.NewRWSetBuilder()
rwsbu.AddToPvtAndHashedWriteSet("cc", "coll", "key", []byte("value"))
rws := rwsbu.GetTxReadWriteSet()
rwsb, err := rws.ToProtoBytes()
assert.NoError(t, err)
prp := []byte("barf")
block := buildBlockWithTxs(buildTXWithRwset(rwsetUpdatingMetadataFor("cc", "key")), buildTXWithRwset(rwsetUpdatingMetadataFor("cc", "key")))
validator.PreValidate(1, block)
go func() {
validator.PostValidate("cc", 1, 0, fmt.Errorf(""))
}()
err = validator.Validate("cc", 1, 1, rwsb, prp, []byte("CCEP"), []*pb.Endorsement{})
assert.NoError(t, err)
pe.EvaluateRV = fmt.Errorf("policy evaluation error")
err = validator.Validate("cc", 1, 1, rwsb, prp, []byte("CCEP"), []*pb.Endorsement{})
assert.Error(t, err)
assert.IsType(t, &errors.VSCCEndorsementPolicyError{}, err)
} | explode_data.jsonl/80486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 577
} | [
2830,
3393,
6608,
967,
889,
13799,
47,
9708,
1043,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
58663,
25,
582,
9593,
264,
7745,
429,
13914,
198,
197,
322,
311,
264,
281,
9708,
1376,
429,
5610,
1376,
11591,
10519,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPubmaticInvalidCall(t *testing.T) {
an := NewPubmaticLegacyAdapter(adapters.DefaultHTTPAdapterConfig, "blah")
ctx := context.Background()
pbReq := pbs.PBSRequest{}
pbBidder := pbs.PBSBidder{}
_, err := an.Call(ctx, &pbReq, &pbBidder)
if err == nil {
t.Fatalf("No error received for invalid request")
}
} | explode_data.jsonl/77911 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
29162,
37244,
7928,
7220,
1155,
353,
8840,
836,
8,
1476,
79457,
1669,
1532,
29162,
37244,
77415,
5940,
43779,
17425,
13275,
9230,
5940,
2648,
11,
330,
70614,
5130,
20985,
1669,
2266,
19047,
741,
3223,
65,
27234,
1669,
281,
127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_Problem0219(t *testing.T) {
ast := assert.New(t)
qs := []question{
question{
para{
[]int{1, 2, 1, 3, 4, 5},
2,
},
ans{
true,
},
},
question{
para{
[]int{1, 2, 3, 4, 5},
0,
},
ans{
false,
},
},
question{
para{
[]int{1, 2, 3, 4, 5},
2,
},
ans{
false,
},
},
// 如需多个测试,可以复制上方元素。
}
for _, q := range qs {
a, p := q.ans, q.para
fmt.Printf("~~%v~~\n", p)
ast.Equal(a.one, containsNearbyDuplicate(p.nums, p.k), "输入:%v", p)
}
} | explode_data.jsonl/9330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
16670,
10121,
15,
17,
16,
24,
1155,
353,
8840,
836,
8,
341,
88836,
1669,
2060,
7121,
1155,
692,
18534,
82,
1669,
3056,
7841,
4257,
197,
197,
7841,
515,
298,
197,
14794,
515,
571,
197,
1294,
396,
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... | 2 |
func TestApiTest_GraphQLRequest(t *testing.T) {
apitest.New().
HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
bodyBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
var req apitest.GraphQLRequestBody
if err := json.Unmarshal(bodyBytes, &req); err != nil {
t.Fatal(err)
}
expected := apitest.GraphQLRequestBody{
Query: `query { todos { text } }`,
OperationName: "myOperation",
Variables: map[string]interface{}{
"a": float64(1),
"b": "2",
},
}
assert.Equal(t, expected, req)
w.WriteHeader(http.StatusOK)
}).
Post("/query").
GraphQLRequest(apitest.GraphQLRequestBody{
Query: "query { todos { text } }",
Variables: map[string]interface{}{
"a": 1,
"b": "2",
},
OperationName: "myOperation",
}).
Expect(t).
Status(http.StatusOK).
End()
} | explode_data.jsonl/54796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 407
} | [
2830,
3393,
6563,
2271,
2646,
1935,
3588,
1900,
1155,
353,
8840,
836,
8,
341,
69898,
97105,
7121,
25829,
197,
197,
3050,
9626,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
298,
35402,
7078,
11,
1848,
1669,
43144,
41851,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkflowRepos(t *testing.T) {
ctl := gomock.NewController(t)
defer ctl.Finish()
middle := mock.NewMockMiddleClient(ctl)
gomock.InOrder(
middle.EXPECT().
GetAvailableApp(gomock.Any(), gomock.Any()).
Return(&pb.AppReply{Token: ""}, nil),
)
ctx := rulebot.NewContext(nil, nil, nil, nil,
middle, nil, nil, nil,
nil, nil, nil)
in := result.Result{
Kind: result.Repos,
Content: map[string]string{
"test": "test",
},
}
Workflow(ctx, in)
} | explode_data.jsonl/55331 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
62768,
693,
966,
1155,
353,
8840,
836,
8,
341,
197,
12373,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
64935,
991,
18176,
2822,
2109,
3310,
1669,
7860,
7121,
11571,
43935,
2959,
7,
12373,
340,
3174,
316,
1176,
5337,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCleanPeers(t *testing.T) {
// peers
peer1 := NewForTests("node1", NewMemStore(), nil).AsPeer()
peer2 := NewForTests("node2", NewMemStore(), nil).AsPeer()
// node
store := NewMemStore()
node := NewForTests("node", store, nil)
node.StartService()
defer node.Stop()
peers := []*Peer{peer1, peer2}
store.BootstrapPeers(peers...)
node.initPeers()
t.Run("leave hosts as is", func(t *testing.T) {
assertar := assert.New(t)
node.PeerReadyForReq(peer1.Host)
node.PeerReadyForReq(peer2.Host)
node.trimHosts(2, 2)
assertar.Equal(len(node.peers.hosts), len(peers))
})
t.Run("clean expired hosts", func(t *testing.T) {
assertar := assert.New(t)
// We already have info about 2 hosts but limit is 1
// Clean all expired hosts
node.trimHosts(1, 1)
assertar.Equal(len(node.peers.hosts), 1)
})
t.Run("clean extra hosts", func(t *testing.T) {
assertar := assert.New(t)
node.PeerReadyForReq(peer1.Host)
node.PeerReadyForReq(peer2.Host)
node.ConnectOK(peer1)
node.ConnectOK(peer2)
// Clean extra
node.trimHosts(1, 1)
assertar.Equal(len(node.peers.hosts), 1)
})
} | explode_data.jsonl/54069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 473
} | [
2830,
3393,
27529,
10197,
388,
1155,
353,
8840,
836,
8,
341,
197,
322,
25029,
198,
197,
16537,
16,
1669,
1532,
2461,
18200,
445,
3509,
16,
497,
1532,
18816,
6093,
1507,
2092,
568,
2121,
30888,
741,
197,
16537,
17,
1669,
1532,
2461,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestItoa(t *testing.T) {
for _, tt := range []struct {
in int
out []byte
}{
{-1, []byte{}},
{0, []byte{'0'}},
{1, []byte{'1'}},
{12, []byte{'1', '2'}},
{123, []byte{'1', '2', '3'}},
{1234, []byte{'1', '2', '3', '4'}},
{12345, []byte{'1', '2', '3', '4', '5'}},
} {
out := itoa(tt.in)
if !bytes.Equal(out, tt.out) {
t.Errorf("%d: got %v, want %v", tt.in, out, tt.out)
}
}
} | explode_data.jsonl/25851 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
40,
49095,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
17430,
220,
526,
198,
197,
13967,
3056,
3782,
198,
197,
59403,
197,
197,
19999,
16,
11,
3056,
3782,
6257,
1583,
197,
197,
90,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreatePipelineVersion_GetParametersError(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
// Create a pipeline.
_, err := manager.CreatePipeline("pipeline", "", []byte(testWorkflow.ToStringForStore()))
assert.Nil(t, err)
// Create a version under the above pipeline.
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
_, err = manager.CreatePipelineVersion(
&api.PipelineVersion{
Name: "pipeline_version",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
Id: DefaultFakeUUID,
Type: api.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
},
},
},
[]byte("I am invalid yaml"), true)
assert.Equal(t, codes.InvalidArgument, err.(*util.UserError).ExternalStatusCode())
assert.Contains(t, err.Error(), "Failed to parse the parameter")
} | explode_data.jsonl/77073 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 400
} | [
2830,
3393,
4021,
34656,
5637,
13614,
9706,
1454,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
1532,
52317,
2959,
2043,
2195,
62396,
67811,
7121,
52317,
1462,
2461,
44338,
2398,
16867,
3553,
10421,
741,
92272,
1669,
1532,
32498,
31200,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeploy(t *testing.T) {
contract := neoutils.SmartContractInfo{
AVMHEX: "",
Name: "Test Contract",
Version: "1.0",
Author: "Apisit",
Email: "apisit@o3.network",
Description: "https://o3.network",
InputTypes: []smartcontract.ParameterType{smartcontract.String, smartcontract.Array},
ReturnType: smartcontract.ByteArray,
Properties: smartcontract.HasStorage + smartcontract.Payable,
}
log.Printf("sc hash %v", contract.GetScriptHash())
asset := smartcontract.GAS
amount := float64(490)
encryptedKey := ""
passphrase := ""
wif, _ := neoutils.NEP2Decrypt(encryptedKey, passphrase)
privateNetwallet, err := neoutils.GenerateFromWIF(wif)
if err != nil {
log.Printf("%v", err)
t.Fail()
return
}
log.Printf("wallet address %v", privateNetwallet.Address)
unspent, err := utxo("main", privateNetwallet.Address)
log.Printf("unspent %+v", unspent)
if err != nil {
log.Printf("error %v", err)
t.Fail()
return
}
attributes := map[smartcontract.TransactionAttribute][]byte{}
tx, err := neoutils.DeploySmartContractScript(contract, *privateNetwallet, asset, amount, unspent, attributes)
if err != nil {
log.Printf("error %v", err)
return
}
log.Printf("tx %x", tx)
} | explode_data.jsonl/15632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
69464,
1155,
353,
8840,
836,
8,
1476,
197,
20257,
1669,
834,
411,
8669,
808,
33472,
14067,
1731,
515,
197,
197,
8093,
44,
1799,
55,
25,
414,
8324,
197,
21297,
25,
286,
330,
2271,
19185,
756,
197,
77847,
25,
257,
330,
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... | 4 |
func TestBroadcastDatatypeNSGetFail(t *testing.T) {
bm, cancel := newTestBroadcast(t)
defer cancel()
mdm := bm.data.(*datamocks.Manager)
mdm.On("VerifyNamespaceExists", mock.Anything, "ns1").Return(fmt.Errorf("pop"))
_, err := bm.BroadcastDatatype(context.Background(), "ns1", &fftypes.Datatype{
Name: "name1",
Namespace: "ns1",
Version: "0.0.1",
Value: fftypes.Byteable(`{}`),
}, false)
assert.EqualError(t, err, "pop")
} | explode_data.jsonl/78965 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
43362,
45696,
20157,
2448,
1949,
19524,
1155,
353,
8840,
836,
8,
341,
2233,
76,
11,
9121,
1669,
501,
2271,
43362,
1155,
340,
16867,
9121,
741,
2109,
13849,
1669,
34868,
2196,
41399,
5911,
309,
25183,
58298,
340,
2109,
13849,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCso_Pack(t *testing.T) {
testCases := []struct {
desc string
path string
value interface{}
expected *csov1.Secret
wantErr bool
}{
{
desc: "Empty path",
path: "",
wantErr: true,
},
{
desc: "Invalid path",
path: "/toto",
wantErr: true,
},
{
desc: "Meta path",
path: "meta/cso/revision",
value: map[string]interface{}{
"rev": "6",
},
wantErr: false,
expected: &csov1.Secret{
RingLevel: csov1.RingLevel_RING_LEVEL_META,
Path: &csov1.Secret_Meta{
Meta: &csov1.Meta{
Key: "cso/revision",
},
},
},
},
{
desc: "Infra path",
path: "infra/aws/security/us-east-1/rds/adminconsole/root_creds",
value: map[string]interface{}{
"user": "foo",
"password": "bar",
},
wantErr: false,
expected: &csov1.Secret{
RingLevel: csov1.RingLevel_RING_LEVEL_INFRASTRUCTURE,
Path: &csov1.Secret_Infrastructure{
Infrastructure: &csov1.Infrastructure{
CloudProvider: "aws",
AccountId: "security",
Region: "us-east-1",
ServiceName: "rds",
Key: "adminconsole/root_creds",
},
},
},
},
{
desc: "Platform path",
path: "platform/dev/customer-1/us-east-1/adminconsole/database/creds",
value: map[string]interface{}{
"user": "foo",
"password": "bar",
},
wantErr: false,
expected: &csov1.Secret{
RingLevel: csov1.RingLevel_RING_LEVEL_PLATFORM,
Path: &csov1.Secret_Platform{
Platform: &csov1.Platform{
Stage: csov1.QualityLevel_QUALITY_LEVEL_DEV,
Name: "customer-1",
Region: "us-east-1",
ServiceName: "adminconsole",
Key: "database/creds",
},
},
},
},
{
desc: "Product path",
path: "product/ece/v1.0.0/server/http/jwt_hmac",
value: map[string]interface{}{
"user": "foo",
"password": "bar",
},
wantErr: false,
expected: &csov1.Secret{
RingLevel: csov1.RingLevel_RING_LEVEL_PRODUCT,
Path: &csov1.Secret_Product{
Product: &csov1.Product{
Name: "ece",
Version: "v1.0.0",
ComponentName: "server",
Key: "http/jwt_hmac",
},
},
},
},
{
desc: "Application path",
path: "app/dev/customer-1/ece/v1.0.0/server/http/jwt_hmac",
value: map[string]interface{}{
"user": "foo",
"password": "bar",
},
wantErr: false,
expected: &csov1.Secret{
RingLevel: csov1.RingLevel_RING_LEVEL_APPLICATION,
Path: &csov1.Secret_Application{
Application: &csov1.Application{
Stage: csov1.QualityLevel_QUALITY_LEVEL_DEV,
PlatformName: "customer-1",
ProductName: "ece",
ProductVersion: "v1.0.0",
ComponentName: "server",
Key: "http/jwt_hmac",
},
},
},
},
{
desc: "Artifact path",
path: "artifact/docker/sha256:fab2dded59dd0c2894dd9dbae71418f565be5bd0d8fd82365c16aec41c7e367f/attestations/snyk_report",
value: map[string]interface{}{
"user": "foo",
"password": "bar",
},
wantErr: false,
expected: &csov1.Secret{
RingLevel: csov1.RingLevel_RING_LEVEL_ARTIFACT,
Path: &csov1.Secret_Artifact{
Artifact: &csov1.Artifact{
Type: "docker",
Id: "sha256:fab2dded59dd0c2894dd9dbae71418f565be5bd0d8fd82365c16aec41c7e367f",
Key: "attestations/snyk_report",
},
},
},
},
}
for _, tC := range testCases {
t.Run(tC.desc, func(t *testing.T) {
got, err := Pack(tC.path, tC.value)
if (err != nil) != tC.wantErr {
t.Errorf("error: got %v, but not error expected", err)
}
if tC.wantErr {
return
}
if diff := cmp.Diff(got, tC.expected, cmpOpts...); diff != "" {
t.Errorf("%q. Pack():\n-got/+want\ndiff %s", tC.desc, diff)
}
})
}
} | explode_data.jsonl/990 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2045
} | [
2830,
3393,
34,
704,
1088,
473,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
26781,
257,
914,
198,
197,
16309,
262,
3749,
16094,
197,
42400,
353,
66,
84293,
16,
74779,
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 TestCommitFromPreviousRound(t *testing.T) {
cs1, vss := randState(4)
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
height, round := cs1.Height, 1
partSize := types.BlockPartSizeBytes
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock)
proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round)
propBlockHash := propBlock.Hash()
propBlockParts := propBlock.MakePartSet(partSize)
// start round in which PO is not proposer
startTestRound(cs1, height, round)
ensureNewRound(newRoundCh, height, round)
// vs2, vs3 and vs4 send precommit for propBlock for the previous round
signAddVotes(cs1, types.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4)
ensureNewValidBlock(validBlockCh, height, round)
rs := cs1.GetRoundState()
assert.True(t, rs.Step == cstypes.RoundStepCommit)
assert.True(t, rs.CommitRound == vs2.Round)
assert.True(t, rs.ProposalBlock == nil)
assert.True(t, rs.ProposalBlockParts.Header().Equals(propBlockParts.Header()))
if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil {
t.Fatal(err)
}
ensureNewProposal(proposalCh, height, round)
ensureNewRound(newRoundCh, height+1, 0)
} | explode_data.jsonl/81661 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 480
} | [
2830,
3393,
33441,
3830,
21291,
27497,
1155,
353,
8840,
836,
8,
341,
71899,
16,
11,
348,
778,
1669,
10382,
1397,
7,
19,
340,
5195,
82,
17,
11,
6165,
18,
11,
6165,
19,
1669,
348,
778,
58,
16,
1125,
348,
778,
58,
17,
1125,
348,
77... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddVersionToSchema(t *testing.T) {
testDir, err := ioutil.TempDir("", "version-schema-test-")
require.NoError(t, err)
copyDir(t, "fixtures/render_version_test", testDir)
wd, err := os.Getwd()
require.NoError(t, err)
require.NoError(t, os.Chdir(testDir))
addVersionToSchema(nil, []string{"hydra", "v1.0.0", ".schema/config.schema.json"})
require.NoError(t, os.Chdir(wd))
expected, err := ioutil.ReadFile("expected/render_version_test/.schema/version.schema.json")
require.NoError(t, err)
actual, err := ioutil.ReadFile(path.Join(testDir, ".schema/version.schema.json"))
require.NoError(t, err)
// converting to string to have nice output in case they are not equal
assert.Equal(t, string(expected), string(actual), "To accept the new render output run:\ncp %s %s", path.Join(testDir, ".schema/version.schema.json"), path.Join(wd, "expected/render_version_test/.schema/version.schema.json"))
} | explode_data.jsonl/76220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 339
} | [
2830,
3393,
2212,
5637,
1249,
8632,
1155,
353,
8840,
836,
8,
341,
18185,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
4366,
79684,
16839,
12,
1138,
17957,
35699,
1155,
11,
1848,
692,
49124,
6184,
1155,
11,
330,
45247,
83201,
94... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenSeedInvalidEntropy(t *testing.T) {
t.Parallel()
// First, we'll create a new test directory and unlocker service for
// that directory.
testDir, err := ioutil.TempDir("", "testcreate")
if err != nil {
t.Fatalf("unable to create temp directory: %v", err)
}
defer func() {
os.RemoveAll(testDir)
}()
service := walletunlocker.New(testDir, testNetParams, true, nil)
// Now that the service has been created, we'll ask it to generate a
// new seed for us given a test passphrase. However, we'll be using an
// invalid set of entropy that's 55 bytes, instead of 15 bytes.
aezeedPass := []byte("kek")
genSeedReq := &lnrpc.GenSeedRequest{
AezeedPassphrase: aezeedPass,
SeedEntropy: bytes.Repeat([]byte("a"), 55),
}
// We should get an error now since the entropy source was invalid.
ctx := context.Background()
_, err = service.GenSeed(ctx, genSeedReq)
if err == nil {
t.Fatalf("seed creation should've failed")
}
if !strings.Contains(err.Error(), "incorrect entropy length") {
t.Fatalf("wrong error, expected incorrect entropy length")
}
} | explode_data.jsonl/24037 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 375
} | [
2830,
3393,
9967,
41471,
7928,
97582,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
5512,
11,
582,
3278,
1855,
264,
501,
1273,
6220,
323,
15055,
261,
2473,
369,
198,
197,
322,
429,
6220,
624,
18185,
6184,
11,
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 TestMetrics(t *testing.T) {
fixture := newTestFixture(t, metrics.New())
fixture.server.ch = make(chan UpdateRequestV1)
defer fixture.server.stop()
ctx := context.Background()
fixture.plugin.Start(ctx)
defer fixture.plugin.Stop(ctx)
// Ignore the plugin updating its status (tested elsewhere)
<-fixture.server.ch
status := testStatus()
fixture.plugin.BulkUpdateBundleStatus(map[string]*bundle.Status{"bundle": status})
result := <-fixture.server.ch
exp := map[string]interface{}{"<built-in>": map[string]interface{}{}}
if !reflect.DeepEqual(result.Metrics, exp) {
t.Fatalf("Expected %v but got %v", exp, result.Metrics)
}
} | explode_data.jsonl/27529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
27328,
1155,
353,
8840,
836,
8,
341,
1166,
12735,
1669,
501,
69356,
1155,
11,
16734,
7121,
2398,
1166,
12735,
12638,
5329,
284,
1281,
35190,
5549,
1900,
53,
16,
340,
16867,
12507,
12638,
13227,
2822,
20985,
1669,
2266,
19047,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEtcdGrafanaDashboardFiltered(t *testing.T) {
enabled := false
c := NewDefaultConfig()
c.EtcdConfig.Enabled = &enabled
f := NewFactory("openshift-monitoring", c)
cms, err := f.GrafanaDashboardDefinitions()
if err != nil {
t.Fatal(err)
}
for _, cm := range cms.Items {
if cm.Name == "grafana-dashboard-etcd" {
t.Fatal("etcd dashboard found, even if etcd is disabled")
}
}
} | explode_data.jsonl/68665 | {
"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,
31860,
4385,
38,
15453,
3362,
26947,
67310,
1155,
353,
8840,
836,
8,
341,
197,
15868,
1669,
895,
198,
1444,
1669,
1532,
3675,
2648,
741,
1444,
5142,
83,
4385,
2648,
13690,
284,
609,
15868,
198,
1166,
1669,
1532,
4153,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindUnqualifiedSearchRegistries(t *testing.T) {
sys := &types.SystemContext{
SystemRegistriesConfPath: "testdata/unqualified-search.conf",
SystemRegistriesConfDirPath: "testdata/this-does-not-exist",
}
registries, err := GetRegistries(sys)
assert.Nil(t, err)
assert.Equal(t, 4, len(registries))
unqRegs, origin, err := UnqualifiedSearchRegistriesWithOrigin(sys)
assert.Nil(t, err)
assert.Equal(t, []string{"registry-a.com", "registry-c.com", "registry-d.com"}, unqRegs)
assert.Equal(t, "testdata/unqualified-search.conf", origin)
_, err = UnqualifiedSearchRegistries(&types.SystemContext{
SystemRegistriesConfPath: "testdata/invalid-search.conf",
SystemRegistriesConfDirPath: "testdata/this-does-not-exist",
})
assert.Error(t, err)
} | explode_data.jsonl/62229 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
9885,
1806,
36335,
5890,
3477,
380,
4019,
1155,
353,
8840,
836,
8,
341,
41709,
1669,
609,
9242,
16620,
1972,
515,
197,
5816,
3477,
380,
4019,
15578,
1820,
25,
262,
330,
92425,
35217,
36335,
19428,
13937,
756,
197,
5816,
3477... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunningSum(t *testing.T) {
tt := []struct {
input []int
output []int
}{
// #1
{
input: []int{1, 2, 3, 4},
output: []int{1, 3, 6, 10},
},
// #2
{
input: []int{1, 1, 1, 1, 1},
output: []int{1, 2, 3, 4, 5},
},
// #2
{
input: []int{3, 1, 2, 10, 1},
output: []int{3, 4, 6, 16, 17},
},
}
for _, tc := range tt {
assert.Equal(t, tc.output, runningSum(tc.input))
}
} | explode_data.jsonl/6737 | {
"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,
18990,
9190,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
22427,
220,
3056,
396,
198,
197,
21170,
3056,
396,
198,
197,
59403,
197,
197,
322,
671,
16,
198,
197,
197,
515,
298,
22427,
25,
220,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLabelSelector(t *testing.T) {
g := NewGomegaWithT(t)
l := New()
l.PD()
l.Instance("demo")
l.Namespace("ns-1")
s, err := l.Selector()
st := labels.Set(map[string]string{
NameLabelKey: "tidb-cluster",
ManagedByLabelKey: "tidb-operator",
ComponentLabelKey: "pd",
InstanceLabelKey: "demo",
NamespaceLabelKey: "ns-1",
})
g.Expect(err).NotTo(HaveOccurred())
g.Expect(s.Matches(st)).To(BeTrue())
} | explode_data.jsonl/22131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
2476,
5877,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
692,
8810,
1669,
1532,
741,
8810,
1069,
35,
741,
8810,
12688,
445,
25762,
1138,
8810,
46011,
445,
4412,
12,
16,
1138,
1903,
11,
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 TestBoolArrayScanUnsupported(t *testing.T) {
var arr BoolArray
err := arr.Scan(1)
if err == nil {
t.Fatal("Expected error when scanning from int")
}
if !strings.Contains(err.Error(), "int to BoolArray") {
t.Errorf("Expected type to be mentioned when scanning, got %q", err)
}
} | explode_data.jsonl/5304 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
11233,
1857,
26570,
41884,
1155,
353,
8840,
836,
8,
341,
2405,
2890,
12608,
1857,
198,
9859,
1669,
2890,
54874,
7,
16,
692,
743,
1848,
621,
2092,
341,
197,
3244,
26133,
445,
18896,
1465,
979,
35101,
504,
526,
1138,
197,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChangeMilestoneStatus(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
milestone := AssertExistsAndLoadBean(t, &Milestone{ID: 1}).(*Milestone)
assert.NoError(t, ChangeMilestoneStatus(milestone, true))
AssertExistsAndLoadBean(t, &Milestone{ID: 1}, "is_closed=1")
CheckConsistencyFor(t, &Repository{ID: milestone.RepoID}, &Milestone{})
assert.NoError(t, ChangeMilestoneStatus(milestone, false))
AssertExistsAndLoadBean(t, &Milestone{ID: 1}, "is_closed=0")
CheckConsistencyFor(t, &Repository{ID: milestone.RepoID}, &Milestone{})
} | explode_data.jsonl/21828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
4072,
44,
93028,
2522,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
2271,
5988,
2398,
2109,
93028,
1669,
5319,
15575,
3036,
5879,
10437,
1155,
11,
609,
44,
93028,
90,
915,
25,
220,
16,
16630,
4071,
44,
93028... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLines(t *testing.T) {
const jsonStr = `{"name": "Gilbert", "age": 61}
{"name": "Alexa", "age": 34}
{"name": "May", "age": 57}
{"name": "Deloise", "age": 44}`
// 遍历每一行jsonStr
ForEachLine(jsonStr, func(line Result) bool {
println(line.String())
return true
})
} | explode_data.jsonl/43408 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 136
} | [
2830,
3393,
16794,
1155,
353,
8840,
836,
8,
341,
4777,
2951,
2580,
284,
1565,
4913,
606,
788,
330,
97037,
9160,
497,
330,
424,
788,
220,
21,
16,
532,
16693,
5212,
606,
788,
330,
27387,
64,
497,
330,
424,
788,
220,
18,
19,
532,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPodSchedulableMap(t *testing.T) {
rc1 := apiv1.ReplicationController{
ObjectMeta: metav1.ObjectMeta{
Name: "rc1",
Namespace: "default",
SelfLink: testapi.Default.SelfLink("replicationcontrollers", "rc"),
UID: "12345678-1234-1234-1234-123456789012",
},
}
rc2 := apiv1.ReplicationController{
ObjectMeta: metav1.ObjectMeta{
Name: "rc2",
Namespace: "default",
SelfLink: testapi.Default.SelfLink("replicationcontrollers", "rc"),
UID: "12345678-1234-1234-1234-12345678901a",
},
}
pMap := make(podSchedulableMap)
podInRc1_1 := BuildTestPod("podInRc1_1", 500, 1000)
podInRc1_1.Annotations = map[string]string{apiv1.CreatedByAnnotation: RefJSON(&rc1)}
podInRc2 := BuildTestPod("podInRc2", 500, 1000)
podInRc2.Annotations = map[string]string{apiv1.CreatedByAnnotation: RefJSON(&rc2)}
// Basic sanity checks
_, found := pMap.get(podInRc1_1)
assert.False(t, found)
pMap.set(podInRc1_1, true)
sched, found := pMap.get(podInRc1_1)
assert.True(t, found)
assert.True(t, sched)
// Pod in different RC
_, found = pMap.get(podInRc2)
assert.False(t, found)
pMap.set(podInRc2, false)
sched, found = pMap.get(podInRc2)
assert.True(t, found)
assert.False(t, sched)
// Another replica in rc1
podInRc1_2 := BuildTestPod("podInRc1_1", 500, 1000)
podInRc1_2.Annotations = map[string]string{apiv1.CreatedByAnnotation: RefJSON(&rc1)}
sched, found = pMap.get(podInRc1_2)
assert.True(t, found)
assert.True(t, sched)
// A pod in rc1, but with different requests
differentPodInRc1 := BuildTestPod("differentPodInRc1", 1000, 1000)
differentPodInRc1.Annotations = map[string]string{apiv1.CreatedByAnnotation: RefJSON(&rc1)}
_, found = pMap.get(differentPodInRc1)
assert.False(t, found)
pMap.set(differentPodInRc1, false)
sched, found = pMap.get(differentPodInRc1)
assert.True(t, found)
assert.False(t, sched)
// A non-repliated pod
nonReplicatedPod := BuildTestPod("nonReplicatedPod", 1000, 1000)
_, found = pMap.get(nonReplicatedPod)
assert.False(t, found)
pMap.set(nonReplicatedPod, false)
_, found = pMap.get(nonReplicatedPod)
assert.False(t, found)
// Verify information about first pod has not been overwritten by adding
// other pods
sched, found = pMap.get(podInRc1_1)
assert.True(t, found)
assert.True(t, sched)
} | explode_data.jsonl/44987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 970
} | [
2830,
3393,
23527,
50,
2397,
360,
480,
2227,
1155,
353,
8840,
836,
8,
341,
30295,
16,
1669,
1443,
344,
16,
2817,
79,
1693,
2051,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
1287,
16,
756,
298,
90823,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_tryReadFromRoaring32_File(t *testing.T) {
tempDir, err := ioutil.TempDir("./", "testdata")
if err != nil {
t.Fail()
}
defer os.RemoveAll(tempDir)
r32 := roaring.BitmapOf(1, 2, 65535, math.MaxUint32-1)
bs, err := r32.ToBytes()
if err != nil {
t.Fatal(err)
}
name := filepath.Join(tempDir, "r32")
if err := ioutil.WriteFile(name, bs, 0600); err != nil {
t.Fatal(err)
}
file, err := os.Open(name)
if err != nil {
t.Fatal(err)
}
defer file.Close()
r64 := NewBitmap()
r64.ReadFrom(file)
assert.True(t, r64.Contains(1))
assert.True(t, r64.Contains(2))
assert.True(t, r64.Contains(65535))
assert.True(t, r64.Contains(math.MaxUint32-1))
} | explode_data.jsonl/20357 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 314
} | [
2830,
3393,
53283,
4418,
3830,
38872,
3249,
18,
17,
34061,
1155,
353,
8840,
836,
8,
341,
16280,
6184,
11,
1848,
1669,
43144,
65009,
6184,
13988,
497,
330,
92425,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
57243,
741,
197,
532,
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... | 5 |
func TestSend(t *testing.T) {
log.Printf("start\n")
sender := keengo.NewSender(projectId, writeKey)
log.Printf("Have a sender\n")
sender.Queue("testing", map[string]interface{}{
"hat": 1,
"cheese": "wensleydale",
})
log.Printf("Queued\n")
sender.Close()
} | explode_data.jsonl/9579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
11505,
1155,
353,
8840,
836,
8,
341,
6725,
19367,
445,
2468,
1699,
1138,
1903,
1659,
1669,
1962,
64653,
7121,
20381,
21168,
764,
11,
3270,
1592,
340,
6725,
19367,
445,
12116,
264,
4646,
1699,
5130,
1903,
1659,
50251,
445,
88... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestYesFilter_MatchesCall(t *testing.T) {
type args struct {
in0 *http.Request
in1 *http.Response
}
tests := []struct {
name string
args args
}{
{"both nil", args{nil, nil}},
{"only request", args{&http.Request{}, nil}},
{"only response", args{nil, &http.Response{}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
nf := &YesFilter{}
e := (&events.EventBase{}).SetRequest(tt.args.in0).SetResponse(tt.args.in1)
if gotTrue := nf.MatchesCall(e); !gotTrue {
t.Errorf("MatchesCall() = %v, want true", gotTrue)
}
})
}
} | explode_data.jsonl/25900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
9454,
5632,
1245,
9118,
7220,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
17430,
15,
353,
1254,
9659,
198,
197,
17430,
16,
353,
1254,
12574,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRadixSort(t *testing.T) {
test_cases := []struct {
input []int
expected []int
}{
{[]int{100, 3, 8}, []int{3, 8, 100}},
{[]int{100, 3, 8, -9}, []int{-9, 3, 8, 100}},
{[]int{100, 3, 0, 8, -9}, []int{-9, 0, 3, 8, 100}},
{[]int{-9999, 0, -999, 999, 999, 998, 100, 1000, 10000}, []int{-9999, -999, 0, 100, 998, 999, 999, 1000, 10000}},
{[]int{}, []int{}},
{[]int{1000}, []int{1000}},
{[]int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586}, []int{-5467984, -784, 0, 0, 42, 59, 74, 238, 905, 959, 7586, 7586, 9845}},
}
for _, tc := range test_cases {
Ints(tc.input)
verifySlice(tc.input, tc.expected, t)
}
} | explode_data.jsonl/78367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 337
} | [
2830,
3393,
41931,
941,
10231,
1155,
353,
8840,
836,
8,
341,
18185,
41427,
1669,
3056,
1235,
341,
197,
22427,
262,
3056,
396,
198,
197,
42400,
3056,
396,
198,
197,
59403,
197,
197,
90,
1294,
396,
90,
16,
15,
15,
11,
220,
18,
11,
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... | 2 |
func TestParserFetchAndPublishBlock_NormalCase(t *testing.T) {
setup.CleanupPgContainer(database.Gorm)
stopChan := make(chan struct{}, 1)
params := setupParser(stopChan)
params.Database = database
ctx, cancel := context.WithCancel(context.Background())
params.Ctx = ctx
params.Queue = []mq.Queue{mq.RawTransactions}
go parser.RunParser(params)
time.Sleep(time.Microsecond)
ConsumerToTestAmountOfBlocks(rawTransactionsChannel.GetMessage(), t, cancel)
<-stopChan
} | explode_data.jsonl/49809 | {
"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,
6570,
20714,
3036,
50145,
4713,
74900,
4207,
1155,
353,
8840,
836,
8,
341,
84571,
727,
60639,
82540,
4502,
41649,
1224,
493,
340,
62644,
46019,
1669,
1281,
35190,
2036,
22655,
220,
16,
692,
25856,
1669,
6505,
6570,
60170,
4601... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNameFormat(t *testing.T) {
name := GetRandomName(0)
if !strings.Contains(name, "_") {
t.Fatalf("Generated name does not contain an underscore")
}
if strings.ContainsAny(name, "0123456789") {
t.Fatalf("Generated name contains numbers!")
}
} | explode_data.jsonl/31452 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
675,
4061,
1155,
353,
8840,
836,
8,
341,
11609,
1669,
2126,
13999,
675,
7,
15,
340,
743,
753,
18594,
11545,
3153,
11,
9000,
899,
341,
197,
3244,
30762,
445,
15741,
829,
1558,
537,
6644,
458,
52109,
1138,
197,
532,
743,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNodeMounter_GetDeviceName(t *testing.T) {
fakeMounter := &mount.FakeMounter{
MountPoints: []mount.MountPoint{
{
Device: "/dev/disk/by-path/testdisk",
Path: "/mnt/test",
},
},
}
type args struct {
mountPath string
}
tests := []struct {
name string
args args
wantDevice string
wantRefCount int
wantErr bool
}{
{
name: "return device successfully",
args: args{
mountPath: "/mnt/test",
},
wantDevice: "/dev/disk/by-path/testdisk",
wantRefCount: 1,
},
{
name: "return no device if no device was mounted on path",
args: args{
mountPath: "/mnt/notmounted",
},
wantDevice: "",
wantRefCount: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &NodeMounter{
mount.SafeFormatAndMount{
Interface: fakeMounter,
Exec: exec.New(),
},
exec.New(),
}
got, got1, err := m.GetDeviceName(tt.args.mountPath)
if (err != nil) != tt.wantErr {
t.Errorf("NodeMounter.GetDeviceName() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.wantDevice {
t.Errorf("NodeMounter.GetDeviceName() got = %v, want %v", got, tt.wantDevice)
}
if got1 != tt.wantRefCount {
t.Errorf("NodeMounter.GetDeviceName() got1 = %v, want %v", got1, tt.wantRefCount)
}
})
}
} | explode_data.jsonl/75640 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 640
} | [
2830,
3393,
1955,
16284,
261,
13614,
6985,
675,
1155,
353,
8840,
836,
8,
341,
1166,
726,
16284,
261,
1669,
609,
16557,
991,
726,
16284,
261,
515,
197,
9209,
629,
11411,
25,
3056,
16557,
1321,
629,
2609,
515,
298,
197,
515,
571,
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 Test_FileStore_write(t *testing.T) {
storedir := "/tmp/TestStore/_write"
f := NewFileStore(storedir)
f.Open()
pm := newPublishMsg(QOS_ONE, "/a/b/c", []byte{0xBE, 0xEF, 0xED})
pm.setMsgId(91)
key := ibound_mid2key(pm.MsgId())
f.Put(key, pm)
if !exists(storedir + "/i.91.msg") {
t.Fatalf("message not in store")
}
} | explode_data.jsonl/37286 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
34061,
6093,
9165,
1155,
353,
8840,
836,
8,
341,
18388,
3018,
404,
1669,
3521,
5173,
80527,
6093,
19632,
4934,
698,
1166,
1669,
1532,
1703,
6093,
5895,
3018,
404,
340,
1166,
12953,
2822,
86511,
1669,
501,
50145,
6611,
6253,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpendableCoinsDelVestingAcc(t *testing.T) {
now := osttime.Now()
endTime := now.Add(24 * time.Hour)
_, _, addr := testdata.KeyTestPubAddr()
origCoins := sdk.Coins{sdk.NewInt64Coin(feeDenom, 1000), sdk.NewInt64Coin(stakeDenom, 100)}
bacc := authtypes.NewBaseAccountWithAddress(addr)
// require that all coins are locked in the beginning of the vesting
// schedule
dva := types.NewDelayedVestingAccount(bacc, origCoins, endTime.Unix())
lockedCoins := dva.LockedCoins(now)
require.True(t, lockedCoins.IsEqual(origCoins))
// require that all coins are spendable after the maturation of the vesting
// schedule
lockedCoins = dva.LockedCoins(endTime)
require.Equal(t, sdk.NewCoins(), lockedCoins)
// require that all coins are still vesting after some time
lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour))
require.True(t, lockedCoins.IsEqual(origCoins))
// receive some coins
// require that only received coins are spendable since the account is still
// vesting
lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour))
require.True(t, lockedCoins.IsEqual(origCoins))
// delegate some locked coins
// require that locked is reduced
delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50))
dva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount)
lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour))
require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount)))
} | explode_data.jsonl/31288 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 511
} | [
2830,
3393,
50,
3740,
480,
69602,
16532,
53,
59855,
14603,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
36896,
1678,
13244,
741,
6246,
1462,
1669,
1431,
1904,
7,
17,
19,
353,
882,
73550,
692,
197,
6878,
8358,
10789,
1669,
1273,
691,
961... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncapsulateMFA(t *testing.T) {
devicepk, devicesk, _ := Wallet.GenerateRandomKeyPair()
computer := Ephemeral.NewEphemeral()
smartphone := Ephemeral.NewEphemeral()
seedfy, err := NewSeedFY()
if err != nil {
t.Error(err)
}
token, err := NewToken(seedfy.String(), []byte("123456789"))
if err != nil {
t.Error(err)
}
envelope := NewEnvelope(devicepk, smartphone.PublicKey(), computer.PublicKey(), token)
envelope.Sign(&devicesk)
envelope.Encrypt(&smartphone)
smartphoneEnvelope, _ := envelope.MarshalBinary()
rEnvelope := new(Envelope)
rEnvelope.UnmarshalBinary(smartphoneEnvelope)
rEnvelope.Decrypt(&computer)
if !bytes.Equal(rEnvelope.Capsule.Token[:], token[:]) || bytes.Equal(envelope.Capsule.Token[:], token[:]) {
t.Error("encryption wrong")
}
if !rEnvelope.IsValidSignature(nil) {
t.Error("invalid signature")
}
} | explode_data.jsonl/53631 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
7408,
2625,
6334,
44,
3627,
1155,
353,
8840,
836,
8,
341,
54719,
20819,
11,
7611,
74,
11,
716,
1669,
36483,
57582,
13999,
1592,
12443,
2822,
32810,
11281,
1669,
468,
59941,
3253,
7121,
36,
59941,
3253,
741,
1903,
33472,
4844... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTrie_SetGet(t *testing.T) {
trie := NewTrie()
data := []testData{
{"Pepan", "Pepan Zdepan", success},
{"Pepin", "Pepin Omacka", success},
{"Honza", "Honza Novak", success},
{"Jenik", "Jenik Poustevnicek", success},
{"Pepan", "Pepan Dupan", failure},
{"Karel", "Karel Pekar", success},
{"Jenik", "Jenik Poustevnicek", failure},
{"Pepanek", "Pepanek Zemlicka", success},
}
for _, v := range data {
t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
}
}
for _, v := range data {
t.Logf("SET %q to 10", v.key)
trie.Set(Prefix(v.key), 10)
}
for _, v := range data {
value := trie.Get(Prefix(v.key))
t.Logf("GET %q => %v", v.key, value)
if value.(int) != 10 {
t.Errorf("Unexpected return value, %v != 10", value)
}
}
if value := trie.Get(Prefix("random crap")); value != nil {
t.Errorf("Unexpected return value, %v != <nil>", value)
}
} | explode_data.jsonl/2359 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 474
} | [
2830,
3393,
51,
7231,
14812,
1949,
1155,
353,
8840,
836,
8,
341,
197,
8927,
1669,
1532,
51,
7231,
2822,
8924,
1669,
3056,
1944,
1043,
515,
197,
197,
4913,
47,
747,
276,
497,
330,
47,
747,
276,
1863,
450,
848,
497,
2393,
1583,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestInterfaces1(t *testing.T) {
out1 := `
1. \Device\NPF_{BAC1CFBD-DE27-4023-B478-0C490B99DC5E} (Local Area Connection 2)
2. \Device\NPF_{78032B7E-4968-42D3-9F37-287EA86C0AAA} (Local Area Connection* 10)
3. \Device\NPF_{84E7CAE6-E96F-4F31-96FD-170B0F514AB2} (Npcap Loopback Adapter)
4. \Device\NPF_NdisWanIpv6 (NdisWan Adapter)
5. \Device\NPF_{503E1F71-C57C-438D-B004-EA5563723C16} (Local Area Connection 5)
6. \Device\NPF_{15DDE443-C208-4328-8919-9666682EE804} (Local Area Connection* 11)
`[1:]
interfaces, err := interfacesFrom(bytes.NewReader([]byte(out1)))
assert.NoError(t, err)
assert.Equal(t, 6, len(interfaces))
v := interfaces[2]
assert.Equal(t, `\Device\NPF_{78032B7E-4968-42D3-9F37-287EA86C0AAA}`, v[1])
assert.Equal(t, `Local Area Connection* 10`, v[0])
} | explode_data.jsonl/80384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
41066,
16,
1155,
353,
8840,
836,
8,
341,
13967,
16,
1669,
22074,
16,
13,
1124,
6985,
59,
45,
19701,
15159,
33,
1706,
16,
9650,
9548,
12,
1150,
17,
22,
12,
19,
15,
17,
18,
7671,
19,
22,
23,
12,
15,
34,
19,
24,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPickDomainFromUrl(t *testing.T) {
type args struct {
url string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "Test-Http",
args: args{
url: "http://192.168.0.1:81/abc/123",
},
want: "192.168.0.1:81",
wantErr: false,
},
{
name: "Test-Https",
args: args{
url: "https://192.168.0.1:81/abc/123",
},
want: "192.168.0.1:81",
wantErr: false,
},
{
name: "Test-Error",
args: args{
url: "http:/",
},
want: "",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := PickDomainFromUrl(tt.args.url)
if (err != nil) != tt.wantErr {
t.Errorf("PickDomainFromUrl() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("PickDomainFromUrl() got = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/74442 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
36953,
13636,
3830,
2864,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
19320,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
198,
197,
50780,
262,
914,
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... | 3 |
func TestStatefulPodControlNoOpUpdate(t *testing.T) {
recorder := record.NewFakeRecorder(10)
set := newStatefulSet(3)
pod := newStatefulSetPod(set, 0)
fakeClient := &fake.Clientset{}
control := NewRealStatefulPodControl(fakeClient, nil, nil, nil, recorder)
fakeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {
t.Error("no-op update should not make any client invocation")
return true, nil, apierrors.NewInternalError(errors.New("if we are here we have a problem"))
})
if err := control.UpdateStatefulPod(set, pod); err != nil {
t.Errorf("Error returned on no-op update error: %s", err)
}
events := collectEvents(recorder.Events)
if eventCount := len(events); eventCount != 0 {
t.Errorf("no-op update: got %d events, but want 0", eventCount)
}
} | explode_data.jsonl/17902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
1397,
1262,
23527,
3273,
2753,
7125,
4289,
1155,
353,
8840,
836,
8,
341,
67904,
1358,
1669,
3255,
7121,
52317,
47023,
7,
16,
15,
340,
8196,
1669,
36848,
1262,
1649,
7,
18,
340,
3223,
347,
1669,
36848,
1262,
1649,
23527,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRgPyexecute(t *testing.T) {
t.Parallel()
/**
* Success with OK
*/
t.Run("should process command with OK result", func(t *testing.T) {
t.Parallel()
// Client
client := testClient{
rcv: "OK",
err: nil,
}
// Response
resp := queryRgPyexecute(queryModel{Command: models.GearsPyExecute, Key: "GB().run()"}, &client)
require.Len(t, resp.Frames, 2)
require.Len(t, resp.Frames[0].Fields, 1)
require.Equal(t, "results", resp.Frames[0].Name)
require.Equal(t, "results", resp.Frames[0].Fields[0].Name)
require.Equal(t, 0, resp.Frames[0].Fields[0].Len())
require.Len(t, resp.Frames[1].Fields, 1)
require.Equal(t, "errors", resp.Frames[1].Name)
require.Equal(t, "errors", resp.Frames[1].Fields[0].Name)
require.Equal(t, 0, resp.Frames[1].Fields[0].Len())
require.NoError(t, resp.Error)
})
/**
* Success with Unblocking
*/
t.Run("should process command with Unblocking and requirements", func(t *testing.T) {
t.Parallel()
// Client
client := testClient{
rcv: []byte("0000000000000000000000000000000000000000-11"),
err: nil,
}
// Response
resp := queryRgPyexecute(queryModel{Command: models.GearsPyExecute, Key: "GB().run()", Unblocking: true, Requirements: "numpy"}, &client)
require.Len(t, resp.Frames, 1)
require.Len(t, resp.Frames[0].Fields, 1)
require.Equal(t, "operationId", resp.Frames[0].Name)
require.Equal(t, "operationId", resp.Frames[0].Fields[0].Name)
require.Greater(t, resp.Frames[0].Fields[0].Len(), 0)
require.Equal(t, "0000000000000000000000000000000000000000-11", resp.Frames[0].Fields[0].At(0))
require.NoError(t, resp.Error)
})
/**
* Success with 2 arrays in result
*/
t.Run("should process command with 2 arrays in result", func(t *testing.T) {
t.Parallel()
// Client
client := testClient{
rcv: []interface{}{
[]interface{}{
[]byte("success info"),
},
[]interface{}{
[]byte("error info"),
},
},
err: nil,
}
// Response
resp := queryRgPyexecute(queryModel{Command: models.GearsPyExecute, Key: "GB().run()"}, &client)
require.Len(t, resp.Frames, 2)
require.Len(t, resp.Frames[0].Fields, 1)
require.Equal(t, "results", resp.Frames[0].Name)
require.Equal(t, "results", resp.Frames[0].Fields[0].Name)
require.IsType(t, "", resp.Frames[0].Fields[0].At(0))
require.Len(t, resp.Frames[1].Fields, 1)
require.Equal(t, "errors", resp.Frames[1].Name)
require.Equal(t, "errors", resp.Frames[1].Fields[0].Name)
require.Equal(t, 1, resp.Frames[0].Fields[0].Len())
require.Equal(t, "success info", resp.Frames[0].Fields[0].At(0))
require.Equal(t, 1, resp.Frames[1].Fields[0].Len())
require.Equal(t, "error info", resp.Frames[1].Fields[0].At(0))
require.NoError(t, resp.Error)
})
/**
* Unexpected Type Error
*/
t.Run("should handle unexpected type error", func(t *testing.T) {
t.Parallel()
// Client
client := testClient{
rcv: 0,
batchRcv: nil,
err: nil,
}
// Response
resp := queryRgPyexecute(queryModel{Command: models.GearsPyExecute, Key: "GB().run()"}, &client)
require.Len(t, resp.Frames, 2)
require.Len(t, resp.Frames[0].Fields, 1)
require.Equal(t, 0, resp.Frames[0].Fields[0].Len())
require.Equal(t, 0, resp.Frames[1].Fields[0].Len())
})
/**
* Error
*/
t.Run("should handle error", func(t *testing.T) {
t.Parallel()
// Client
client := testClient{
rcv: nil,
batchRcv: nil,
err: errors.New("error occurred")}
// Response
resp := queryRgPyexecute(queryModel{Command: models.GearsPyExecute, Key: "GB().run()"}, &client)
require.EqualError(t, resp.Error, "error occurred")
})
} | explode_data.jsonl/66883 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1513
} | [
2830,
3393,
49,
70,
13828,
10257,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
1747,
197,
353,
13047,
448,
10402,
198,
197,
735,
3244,
16708,
445,
5445,
1882,
3210,
448,
10402,
1102,
497,
2915,
1155,
353,
8840,
836,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergeUlimitsConfig(t *testing.T) {
specials := &specials{
m: map[reflect.Type]func(dst, src reflect.Value) error{
reflect.TypeOf(&types.UlimitsConfig{}): mergeUlimitsConfig,
},
}
base := map[string]*types.UlimitsConfig{
"override-single": {Single: 100},
"override-single-with-soft-hard": {Single: 200},
"override-soft-hard": {Soft: 300, Hard: 301},
"override-soft-hard-with-single": {Soft: 400, Hard: 401},
"dont-override": {Single: 500},
}
override := map[string]*types.UlimitsConfig{
"override-single": {Single: 110},
"override-single-with-soft-hard": {Soft: 210, Hard: 211},
"override-soft-hard": {Soft: 310, Hard: 311},
"override-soft-hard-with-single": {Single: 410},
"add": {Single: 610},
}
err := mergo.Merge(&base, &override, mergo.WithOverride, mergo.WithTransformers(specials))
assert.NilError(t, err)
assert.DeepEqual(
t,
base,
map[string]*types.UlimitsConfig{
"override-single": {Single: 110},
"override-single-with-soft-hard": {Soft: 210, Hard: 211},
"override-soft-hard": {Soft: 310, Hard: 311},
"override-soft-hard-with-single": {Single: 410},
"dont-override": {Single: 500},
"add": {Single: 610},
},
)
} | explode_data.jsonl/59637 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 659
} | [
2830,
3393,
52096,
52,
41078,
2648,
1155,
353,
8840,
836,
8,
341,
1903,
2964,
82,
1669,
609,
15144,
82,
515,
197,
2109,
25,
2415,
58,
34913,
10184,
60,
2830,
30260,
11,
2286,
8708,
6167,
8,
1465,
515,
298,
197,
34913,
73921,
2099,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_prefixReplace_Replace(t *testing.T) {
tests := []struct {
name string
oldPrefix string
changeTo string
old string
want Variant
}{
{
name: "mismatch",
oldPrefix: "gen/",
changeTo: "gitlab.stageoffice.ru/UCS-COMMON/schema/",
old: "github.com/sirkon/message",
want: Nothing{},
},
{
name: "match",
oldPrefix: "gen/",
changeTo: "gitlab.stageoffice.ru/UCS-COMMON/schema/",
old: "gen/marker",
want: Replacement("gitlab.stageoffice.ru/UCS-COMMON/schema/marker"),
},
{
name: "full-match",
oldPrefix: "github.com/sirkon/goproxy/",
changeTo: "github.com/sirkon/goproxy/v2/",
old: "github.com/sirkon/goproxy",
want: Replacement("github.com/sirkon/goproxy/v2"),
},
{
name: "mismatch-2",
oldPrefix: "gen/",
changeTo: "gitlab.stageoffice.ru/UCS-COMMON/schema/",
old: "gene/marker",
want: Nothing{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := Prefix(tt.oldPrefix, tt.changeTo)
if got := p.Replace(tt.old); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Replace() = %#v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/57228 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 635
} | [
2830,
3393,
13974,
23107,
62,
23107,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
61828,
14335,
914,
198,
197,
68380,
1249,
220,
914,
198,
197,
61828,
981,
914,
198,
197,
50780,
414,
3929... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckSuite_String(t *testing.T) {
v := CheckSuite{
ID: Int64(0),
NodeID: String(""),
HeadBranch: String(""),
HeadSHA: String(""),
URL: String(""),
BeforeSHA: String(""),
AfterSHA: String(""),
Status: String(""),
Conclusion: String(""),
App: &App{},
Repository: &Repository{},
HeadCommit: &Commit{},
}
want := `github.CheckSuite{ID:0, NodeID:"", HeadBranch:"", HeadSHA:"", URL:"", BeforeSHA:"", AfterSHA:"", Status:"", Conclusion:"", App:github.App{}, Repository:github.Repository{}, HeadCommit:github.Commit{}}`
if got := v.String(); got != want {
t.Errorf("CheckSuite.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33222 | {
"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,
3973,
28000,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
4248,
28000,
515,
197,
29580,
25,
260,
1333,
21,
19,
7,
15,
1326,
197,
30217,
915,
25,
257,
923,
445,
4461,
197,
197,
12346,
18197,
25,
923,
445,
4461,
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 TestInter(t *testing.T) {
val := interface{}("something")
m := map[string]interface{}{"value": val, "nothing": nil}
assert.Equal(t, val, New(m).Get("value").Inter())
assert.Equal(t, val, New(m).Get("value").MustInter())
assert.Equal(t, interface{}(nil), New(m).Get("nothing").Inter())
assert.Equal(t, val, New(m).Get("nothing").Inter("something"))
assert.Panics(t, func() {
New(m).Get("age").MustInter()
})
} | explode_data.jsonl/23376 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
3306,
1155,
353,
8840,
836,
8,
1476,
19302,
1669,
3749,
6257,
445,
33331,
1138,
2109,
1669,
2415,
14032,
31344,
6257,
4913,
957,
788,
1044,
11,
330,
41212,
788,
2092,
532,
6948,
12808,
1155,
11,
1044,
11,
1532,
1255,
568,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFrameClauseRestore(t *testing.T) {
testCases := []NodeRestoreTestCase{
{"ROWS CURRENT ROW", "ROWS BETWEEN CURRENT ROW AND CURRENT ROW"},
{"ROWS UNBOUNDED PRECEDING", "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW"},
{"ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING", "ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING"},
{"RANGE BETWEEN ? PRECEDING AND ? FOLLOWING", "RANGE BETWEEN ? PRECEDING AND ? FOLLOWING"},
{"RANGE BETWEEN INTERVAL 5 DAY PRECEDING AND INTERVAL '2:30' MINUTE_SECOND FOLLOWING", "RANGE BETWEEN INTERVAL 5 DAY PRECEDING AND INTERVAL _UTF8MB4'2:30' MINUTE_SECOND FOLLOWING"},
}
extractNodeFunc := func(node Node) Node {
return node.(*SelectStmt).Fields.Fields[0].Expr.(*WindowFuncExpr).Spec.Frame
}
runNodeRestoreTest(t, testCases, "select avg(val) over (%s) from t", extractNodeFunc)
} | explode_data.jsonl/27584 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 321
} | [
2830,
3393,
4369,
28482,
56284,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1955,
56284,
16458,
515,
197,
197,
4913,
37142,
43107,
45715,
497,
330,
37142,
56639,
43107,
45715,
3567,
43107,
45715,
7115,
197,
197,
4913,
37142,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_snipMsg(t *testing.T) {
msgs, err := snippetCreateCmd.Flags().GetStringArray("message")
if err != nil {
t.Fatal(err)
}
title, desc := snipMsg(msgs)
assert.Equal(t, "-", title)
assert.Equal(t, "", desc)
} | explode_data.jsonl/35612 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
28022,
573,
6611,
1155,
353,
8840,
836,
8,
341,
21169,
82,
11,
1848,
1669,
43065,
4021,
15613,
51887,
1005,
48905,
1857,
445,
1994,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
24751,
11,
6560,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLogEvent_eventPayloadBytes(t *testing.T) {
testMessage := "test message"
logEvent := NewLogEvent(0, testMessage)
assert.Equal(t, len(testMessage)+PerEventHeaderBytes, logEvent.eventPayloadBytes())
} | explode_data.jsonl/61458 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
2201,
1556,
6748,
29683,
7078,
1155,
353,
8840,
836,
8,
341,
18185,
2052,
1669,
330,
1944,
1943,
698,
6725,
1556,
1669,
1532,
2201,
1556,
7,
15,
11,
1273,
2052,
340,
6948,
12808,
1155,
11,
2422,
8623,
2052,
7257,
3889,
155... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAggregateTypes(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.Nil(t, err)
defer conn.Close()
exec(t, conn, "insert into aggr_test(id, val1, val2) values(1,'a',1), (2,'A',1), (3,'b',1), (4,'c',3), (5,'c',4)")
exec(t, conn, "insert into aggr_test(id, val1, val2) values(6,'d',null), (7,'e',null), (8,'E',1)")
qr := exec(t, conn, "select val1, count(distinct val2), count(*) from aggr_test group by val1")
if got, want := fmt.Sprintf("%v", qr.Rows), `[[VARCHAR("a") INT64(1) INT64(2)] [VARCHAR("b") INT64(1) INT64(1)] [VARCHAR("c") INT64(2) INT64(2)] [VARCHAR("d") INT64(0) INT64(1)] [VARCHAR("e") INT64(1) INT64(2)]]`; got != want {
t.Errorf("select:\n%v want\n%v", got, want)
}
qr = exec(t, conn, "select val1, sum(distinct val2), sum(val2) from aggr_test group by val1")
if got, want := fmt.Sprintf("%v", qr.Rows), `[[VARCHAR("a") DECIMAL(1) DECIMAL(2)] [VARCHAR("b") DECIMAL(1) DECIMAL(1)] [VARCHAR("c") DECIMAL(7) DECIMAL(7)] [VARCHAR("d") NULL NULL] [VARCHAR("e") DECIMAL(1) DECIMAL(1)]]`; got != want {
t.Errorf("select:\n%v want\n%v", got, want)
}
qr = exec(t, conn, "select val1, count(distinct val2) k, count(*) from aggr_test group by val1 order by k desc, val1")
if got, want := fmt.Sprintf("%v", qr.Rows), `[[VARCHAR("c") INT64(2) INT64(2)] [VARCHAR("a") INT64(1) INT64(2)] [VARCHAR("b") INT64(1) INT64(1)] [VARCHAR("e") INT64(1) INT64(2)] [VARCHAR("d") INT64(0) INT64(1)]]`; got != want {
t.Errorf("select:\n%v want\n%v", got, want)
}
qr = exec(t, conn, "select val1, count(distinct val2) k, count(*) from aggr_test group by val1 order by k desc, val1 limit 4")
if got, want := fmt.Sprintf("%v", qr.Rows), `[[VARCHAR("c") INT64(2) INT64(2)] [VARCHAR("a") INT64(1) INT64(2)] [VARCHAR("b") INT64(1) INT64(1)] [VARCHAR("e") INT64(1) INT64(2)]]`; got != want {
t.Errorf("select:\n%v want\n%v", got, want)
}
} | explode_data.jsonl/497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 889
} | [
2830,
3393,
64580,
4173,
1155,
353,
8840,
836,
8,
341,
16867,
10652,
1069,
31270,
3050,
1155,
340,
20985,
1669,
2266,
19047,
741,
32917,
11,
1848,
1669,
10564,
43851,
7502,
11,
609,
9708,
4870,
340,
17957,
59678,
1155,
11,
1848,
340,
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... | 5 |
func TestOrderListFulfillments(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/orders/1/fulfillments.json", client.pathPrefix),
httpmock.NewStringResponder(200, `{"fulfillments": [{"id":1},{"id":2}]}`))
fulfillments, err := client.Order.ListFulfillments(1, nil)
if err != nil {
t.Errorf("Order.ListFulfillments() returned error: %v", err)
}
expected := []Fulfillment{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(fulfillments, expected) {
t.Errorf("Order.ListFulfillments() returned %+v, expected %+v", fulfillments, expected)
}
} | explode_data.jsonl/17998 | {
"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,
4431,
852,
37,
86516,
1368,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
28080,
16712,
19983,
30884,
445,
3806,
497,
8879,
17305,
445,
2428,
1110,
824,
9267,
453,
12618,
8675,
1437,
905,
12627,
82,
82818,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCT_ColorReplaceEffectConstructor(t *testing.T) {
v := dml.NewCT_ColorReplaceEffect()
if v == nil {
t.Errorf("dml.NewCT_ColorReplaceEffect must return a non-nil value")
}
if err := v.Validate(); err != nil {
t.Errorf("newly constructed dml.CT_ColorReplaceEffect should validate: %s", err)
}
} | explode_data.jsonl/64423 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
1162,
43387,
23107,
7738,
13288,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
294,
1014,
7121,
1162,
43387,
23107,
7738,
741,
743,
348,
621,
2092,
341,
197,
3244,
13080,
445,
67,
1014,
7121,
1162,
43387,
23107,
7738,
1969,
470,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalAmino(t *testing.T) {
aminoCdc := codec.NewLegacyAmino()
privKey := secp256k1.GenPrivKey()
pubKey := privKey.PubKey().(*secp256k1.PubKey)
testCases := []struct {
desc string
msg codec.AminoMarshaler
typ interface{}
expBinary []byte
expJSON string
}{
{
"secp256k1 private key",
privKey,
&secp256k1.PrivKey{},
append([]byte{32}, privKey.Bytes()...), // Length-prefixed.
"\"" + base64.StdEncoding.EncodeToString(privKey.Bytes()) + "\"",
},
{
"secp256k1 public key",
pubKey,
&secp256k1.PubKey{},
append([]byte{33}, pubKey.Bytes()...), // Length-prefixed.
"\"" + base64.StdEncoding.EncodeToString(pubKey.Bytes()) + "\"",
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
// Do a round trip of encoding/decoding binary.
bz, err := aminoCdc.Marshal(tc.msg)
require.NoError(t, err)
require.Equal(t, tc.expBinary, bz)
err = aminoCdc.Unmarshal(bz, tc.typ)
require.NoError(t, err)
require.Equal(t, tc.msg, tc.typ)
// Do a round trip of encoding/decoding JSON.
bz, err = aminoCdc.MarshalJSON(tc.msg)
require.NoError(t, err)
require.Equal(t, tc.expJSON, string(bz))
err = aminoCdc.UnmarshalJSON(bz, tc.typ)
require.NoError(t, err)
require.Equal(t, tc.msg, tc.typ)
})
}
} | explode_data.jsonl/66575 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 622
} | [
2830,
3393,
55438,
32,
31824,
1155,
353,
8840,
836,
8,
341,
197,
309,
3313,
34,
7628,
1669,
34647,
7121,
77415,
32,
31824,
741,
71170,
1592,
1669,
511,
4672,
17,
20,
21,
74,
16,
65384,
32124,
1592,
741,
62529,
1592,
1669,
6095,
1592,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContextFingerprint(t *testing.T) {
assert := assert.New(t)
assert.Nil(GetFingerprint(nil))
assert.Nil(GetFingerprint(context.Background()))
assert.Nil(GetFingerprint(context.WithValue(context.Background(), contextFingerprintKey{}, 1234)))
assert.Equal([]string{"foo", "bar"}, GetFingerprint(WithFingerprint(context.Background(), "foo", "bar")))
} | explode_data.jsonl/39127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
1972,
37,
47918,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
6948,
59678,
24460,
37,
47918,
27907,
1171,
6948,
59678,
24460,
37,
47918,
5378,
19047,
12145,
6948,
59678,
24460,
37,
47918,
5378,
26124,
1130,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnonymousScanner(t *testing.T) {
user := User{Name: "anonymous_scanner", Role: Role{Name: "admin"}}
DB.Save(&user)
var user2 User
DB.First(&user2, "name = ?", "anonymous_scanner")
if user2.Role.Name != "admin" {
t.Errorf("Should be able to get anonymous scanner")
}
if !user2.IsAdmin() {
t.Errorf("Should be able to get anonymous scanner")
}
} | explode_data.jsonl/6069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
32684,
31002,
1155,
353,
8840,
836,
8,
341,
19060,
1669,
2657,
63121,
25,
330,
25280,
13171,
4887,
497,
15404,
25,
15404,
63121,
25,
330,
2882,
95642,
45409,
13599,
2099,
872,
692,
2405,
1196,
17,
2657,
198,
45409,
15926,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindAndRemoveNonattachableVolumes(t *testing.T) {
// create dswp
mode := v1.PersistentVolumeFilesystem
pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: "dswp-test-volume-name",
},
Spec: v1.PersistentVolumeSpec{
ClaimRef: &v1.ObjectReference{Namespace: "ns", Name: "file-bound"},
VolumeMode: &mode,
},
}
pvc := &v1.PersistentVolumeClaim{
Spec: v1.PersistentVolumeClaimSpec{
VolumeName: "dswp-test-volume-name",
},
Status: v1.PersistentVolumeClaimStatus{
Phase: v1.ClaimBound,
},
}
fakeVolumePluginMgr, fakeVolumePlugin := volumetesting.GetTestKubeletVolumePluginMgr(t)
dswp, fakePodManager, fakesDSW, _, _ := createDswpWithVolumeWithCustomPluginMgr(t, pv, pvc, fakeVolumePluginMgr)
// create pod
containers := []v1.Container{
{
VolumeMounts: []v1.VolumeMount{
{
Name: "dswp-test-volume-name",
MountPath: "/mnt",
},
},
},
}
pod := createPodWithVolume("dswp-test-pod", "dswp-test-volume-name", "file-bound", containers)
fakePodManager.AddPod(pod)
podName := util.GetUniquePodName(pod)
generatedVolumeName := "fake-plugin/" + pod.Spec.Volumes[0].Name
dswp.findAndAddNewPods()
if !dswp.pods.processedPods[podName] {
t.Fatalf("Failed to record that the volumes for the specified pod: %s have been processed by the populator", podName)
}
expectedVolumeName := v1.UniqueVolumeName(generatedVolumeName)
volumeExists := fakesDSW.VolumeExists(expectedVolumeName)
if !volumeExists {
t.Fatalf(
"VolumeExists(%q) failed. Expected: <true> Actual: <%v>",
expectedVolumeName,
volumeExists)
}
// change the volume plugin from attachable to non-attachable
fakeVolumePlugin.NonAttachable = true
// The volume should still exist
verifyVolumeExistsInVolumesToMount(
t, v1.UniqueVolumeName(generatedVolumeName), false /* expectReportedInUse */, fakesDSW)
dswp.findAndRemoveDeletedPods()
// After the volume plugin changes to nonattachable, the corresponding volume attachable field should change.
volumesToMount := fakesDSW.GetVolumesToMount()
for _, volume := range volumesToMount {
if volume.VolumeName == expectedVolumeName {
if volume.PluginIsAttachable {
t.Fatalf(
"Volume %v in the list of desired state of world volumes to mount is still attachable. Expected not",
expectedVolumeName)
}
}
}
} | explode_data.jsonl/45750 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 877
} | [
2830,
3393,
9885,
3036,
13021,
8121,
16330,
480,
96325,
1155,
353,
8840,
836,
8,
341,
197,
322,
1855,
294,
2280,
79,
198,
60247,
1669,
348,
16,
61655,
18902,
1703,
8948,
198,
3223,
85,
1669,
609,
85,
16,
61655,
18902,
515,
197,
23816,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormattingOneLineRmImports36824(t *testing.T) {
const onelineProgramB = `
-- a.go --
package x; import "os"; func f() {}
-- a.go.imported --
package x
func f() {}
`
runner.Run(t, onelineProgramB, func(t *testing.T, env *Env) {
env.OpenFile("a.go")
env.OrganizeImports("a.go")
got := env.Editor.BufferText("a.go")
want := env.ReadWorkspaceFile("a.go.imported")
if got != want {
t.Errorf("unexpected formatting result:\n%s", tests.Diff(want, got))
}
})
} | explode_data.jsonl/42820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
82135,
3966,
2460,
49,
76,
31250,
18,
21,
23,
17,
19,
1155,
353,
8840,
836,
8,
341,
4777,
389,
4834,
10690,
33,
284,
22074,
313,
264,
18002,
39514,
1722,
856,
26,
1159,
330,
436,
5123,
2915,
282,
368,
10086,
313,
264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_addOutput(t *testing.T) {
type args struct {
infrastructure *commons.Infrastructure
outputName string
output *commons.Output
}
tests := []struct {
name string
args args
jsonResult string
}{
{"OneOutput", args{&commons.Infrastructure{}, "O1", &commons.Output{Value: "V1"}}, `{"output":{"O1":{"value":"V1"}}}`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
commons.AddOutput(tt.args.infrastructure, tt.args.outputName, tt.args.output)
res, err := json.Marshal(tt.args.infrastructure)
require.Nil(t, err)
require.Equal(t, tt.jsonResult, string(res))
})
}
} | explode_data.jsonl/35266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
2891,
5097,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
197,
13573,
10314,
353,
52361,
40435,
198,
197,
21170,
675,
257,
914,
198,
197,
21170,
260,
353,
52361,
34246,
198,
197,
532,
78216,
1669,
3056,
1235,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSortPostsubmitRepoOrder(t *testing.T) {
tests := []struct {
name string
postsubmits map[string][]prowConfig.Postsubmit
expectedRepos []string
}{
{
name: "empty list of postsubmits",
postsubmits: map[string][]prowConfig.Postsubmit{},
expectedRepos: []string{},
},
{
name: "unordered list of postsubmits",
postsubmits: map[string][]prowConfig.Postsubmit{
"GoogleCloudPlatform/oss-test-infra": {
prowConfig.Postsubmit{
JobBase: prowConfig.JobBase{
Name: "pull-test-infra-go-test",
},
},
},
"kubernetes/kubernetes": {
prowConfig.Postsubmit{
JobBase: prowConfig.JobBase{
Name: "ci-kubernetes-e2e",
},
},
prowConfig.Postsubmit{
JobBase: prowConfig.JobBase{
Name: "ci-kubernetes-unit",
},
},
},
"containerd/cri": {
prowConfig.Postsubmit{
JobBase: prowConfig.JobBase{
Name: "pull-cri-containerd-build",
},
},
},
},
expectedRepos: []string{"GoogleCloudPlatform/oss-test-infra", "containerd/cri", "kubernetes/kubernetes"},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actualRepos := sortPostsubmits(test.postsubmits)
if !reflect.DeepEqual(test.expectedRepos, actualRepos) {
t.Fatalf("Postsubmit repos do not match; actual: %v\n expected %v\n", test.expectedRepos, actualRepos)
}
})
}
} | explode_data.jsonl/22113 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 677
} | [
2830,
3393,
10231,
4133,
5955,
25243,
4431,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
51172,
1966,
44703,
256,
2415,
14032,
45725,
79,
651,
2648,
23442,
5955,
198,
197,
42400,
693,
966,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTCF1Consent(t *testing.T) {
bidderAllowedByConsent := openrtb_ext.BidderAppnexus
tcf1Consent := "BOS2bx5OS2bx5ABABBAAABoAAAABBwAA"
perms := permissionsImpl{
vendorIDs: map[openrtb_ext.BidderName]uint16{
openrtb_ext.BidderAppnexus: 2,
},
}
bidReq, passGeo, passID, err := perms.AuctionActivitiesAllowed(context.Background(), bidderAllowedByConsent, "", SignalYes, tcf1Consent, false)
assert.Nil(t, err, "TCF1 consent - no error returned")
assert.Equal(t, false, bidReq, "TCF1 consent - bid request not allowed")
assert.Equal(t, false, passGeo, "TCF1 consent - passing geo not allowed")
assert.Equal(t, false, passID, "TCF1 consent - passing id not allowed")
} | explode_data.jsonl/31102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
7749,
37,
16,
15220,
306,
1155,
353,
8840,
836,
8,
341,
2233,
307,
1107,
35382,
1359,
15220,
306,
1669,
1787,
3342,
65,
9927,
1785,
307,
1107,
2164,
77,
23666,
198,
3244,
9792,
16,
15220,
306,
1669,
330,
33,
3126,
17,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.