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 TestRowLock(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk1 := testkit.NewTestKit(t, store)
tk1.MustExec("use test")
tk2 := testkit.NewTestKit(t, store)
tk2.MustExec("use test")
tk.MustExec("drop table if exists t")
txn, err := tk.Session().Txn(true)
require.True(t, kv.ErrInvalidTxn.Equal(err))
require.False(t, txn.Valid())
tk.MustExec("create table t (c1 int, c2 int, c3 int)")
tk.MustExec("insert t values (11, 2, 3)")
tk.MustExec("insert t values (12, 2, 3)")
tk.MustExec("insert t values (13, 2, 3)")
tk1.MustExec("set @@tidb_disable_txn_auto_retry = 0")
tk1.MustExec("begin")
tk1.MustExec("update t set c2=21 where c1=11")
tk2.MustExec("begin")
tk2.MustExec("update t set c2=211 where c1=11")
tk2.MustExec("commit")
// tk1 will retry and the final value is 21
tk1.MustExec("commit")
// Check the result is correct
tk.MustQuery("select c2 from t where c1=11").Check(testkit.Rows("21"))
tk1.MustExec("begin")
tk1.MustExec("update t set c2=21 where c1=11")
tk2.MustExec("begin")
tk2.MustExec("update t set c2=22 where c1=12")
tk2.MustExec("commit")
tk1.MustExec("commit")
} | explode_data.jsonl/5801 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 504
} | [
2830,
3393,
3102,
11989,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetBlobChannel(t *testing.T) {
img := NewMatWithSize(100, 100, 5+16)
defer img.Close()
blob := BlobFromImage(img, 1.0, image.Pt(0, 0), NewScalar(0, 0, 0, 0), true, false)
defer blob.Close()
ch2 := GetBlobChannel(blob, 0, 1)
defer ch2.Close()
if ch2.Empty() {
t.Errorf("GetBlobChannel failed to retrieve 2nd chan of a 3channel blob")
}
if ch2.Rows() != img.Rows() || ch2.Cols() != img.Cols() {
t.Errorf("GetBlobChannel: retrieved image size does not match original")
}
} | explode_data.jsonl/31269 | {
"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,
1949,
37985,
9629,
1155,
353,
8840,
836,
8,
341,
39162,
1669,
1532,
11575,
2354,
1695,
7,
16,
15,
15,
11,
220,
16,
15,
15,
11,
220,
20,
10,
16,
21,
340,
16867,
4964,
10421,
2822,
2233,
1684,
1669,
49439,
3830,
1906,
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... | 4 |
func TestCanSupport(t *testing.T) {
pluginMgr := volume.VolumePluginMgr{}
tempDir, host := newTestHost(t, nil)
defer os.RemoveAll(tempDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(secretPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
}
if plugin.GetPluginName() != secretPluginName {
t.Errorf("Wrong name: %s", plugin.GetPluginName())
}
if !plugin.CanSupport(&volume.Spec{Volume: &api.Volume{VolumeSource: api.VolumeSource{Secret: &api.SecretVolumeSource{SecretName: ""}}}}) {
t.Errorf("Expected true")
}
if plugin.CanSupport(&volume.Spec{}) {
t.Errorf("Expected false")
}
} | explode_data.jsonl/15324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
6713,
7916,
1155,
353,
8840,
836,
8,
341,
197,
9138,
25567,
1669,
8123,
79106,
11546,
25567,
16094,
16280,
6184,
11,
3468,
1669,
501,
2271,
9296,
1155,
11,
2092,
340,
16867,
2643,
84427,
9758,
6184,
340,
197,
9138,
25567,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExample1(t *testing.T) {
assert := assert.New(t)
rancher := NewRancherMockClient()
rancher.AddEnvironment(client.Project{Name: "prod", Resource: client.Resource{Id: "1a5"}})
rancher.AddEnvironment(client.Project{Name: "dev", Resource: client.Resource{Id: "1a6"}})
prod1 := client.Host{Hostname: "prod01.mysite.com", AccountId: "1a5"}
prod2 := client.Host{Hostname: "prod02.mysite.com", AccountId: "1a5"}
dev1 := client.Host{Hostname: "dev01.mysite.com", AccountId: "1a6"}
dev2 := client.Host{Hostname: "dev02.mysite.com", AccountId: "1a6"}
system_p := client.Stack{Name: "systemstack", AccountId: "1a5", Resource: client.Resource{Id: "2a1"}, ServiceIds: []string{"3a1"}, System: true}
system_d := client.Stack{Name: "systemstack", AccountId: "1a6", Resource: client.Resource{Id: "2b1"}, ServiceIds: []string{"3b1"}, System: true}
app_p1 := client.Stack{Name: "myapp", AccountId: "1a5", Resource: client.Resource{Id: "2a2"}, ServiceIds: []string{"3a2"}}
app_d1 := client.Stack{Name: "myapp", AccountId: "1a6", Resource: client.Resource{Id: "2b2"}, ServiceIds: []string{"3b2"}}
sys_serv_p := client.Service{Name: "system-service", AccountId: "1a5", Resource: client.Resource{Id: "3a1"}, StackId: "2a1", System: true}
sys_serv_d := client.Service{Name: "system-service", AccountId: "1a6", Resource: client.Resource{Id: "3b1"}, StackId: "2b1", System: true}
app_serv_p := client.Service{Name: "myapp-service", AccountId: "1a5", Resource: client.Resource{Id: "3a1"}, StackId: "2a2"}
app_serv_d := client.Service{Name: "myapp-service", AccountId: "1a6", Resource: client.Resource{Id: "3b2"}, StackId: "2b2"}
rancher.AddStack(system_p)
rancher.AddStack(system_d)
rancher.AddStack(app_p1)
rancher.AddStack(app_d1)
filterHosts := "*"
filterStacks := "*,-%ENV=dev,%SYSTEM"
filterStacksV2 := "*,%SYSTEM!L,-%ENV=dev"
filterServices := "*,-%ENV=dev,%SYSTEM"
assert.True(filterHost(rancher, prod1, filterHosts))
assert.True(filterHost(rancher, prod2, filterHosts))
assert.True(filterHost(rancher, dev1, filterHosts))
assert.True(filterHost(rancher, dev2, filterHosts))
assert.True(filterStack(rancher, system_p, filterStacks))
assert.True(filterStack(rancher, system_d, filterStacks))
assert.True(filterStack(rancher, app_p1, filterStacks))
assert.False(filterStack(rancher, app_d1, filterStacks))
assert.True(filterStack(rancher, system_p, filterStacksV2))
assert.True(filterStack(rancher, system_d, filterStacksV2))
assert.True(filterStack(rancher, app_p1, filterStacksV2))
assert.False(filterStack(rancher, app_d1, filterStacksV2))
assert.True(filterService(rancher, sys_serv_p, filterServices))
assert.True(filterService(rancher, sys_serv_d, filterServices))
assert.True(filterService(rancher, app_serv_p, filterServices))
assert.False(filterService(rancher, app_serv_d, filterServices))
} | explode_data.jsonl/48867 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1101
} | [
2830,
3393,
13314,
16,
1155,
353,
8840,
836,
8,
1476,
6948,
1669,
2060,
7121,
1155,
340,
7000,
3497,
261,
1669,
1532,
49,
3497,
261,
11571,
2959,
2822,
7000,
3497,
261,
1904,
12723,
12805,
30944,
63121,
25,
330,
19748,
497,
11765,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSigstruct(t *testing.T) {
require := require.New(t)
var mrEnclave sgx.MrEnclave
err := mrEnclave.UnmarshalHex("c50673624a6cb17c1c6c2a4e6906f47a170c4629b8723781d1017ef376f1a75d")
require.NoError(err, "MrEnclave.UnmarshalHex")
privateKey, err := loadTestPrivateKey()
require.NoError(err, "x509.ParsePKCS1PrivateKey")
// Generate a SIGSTRUCT.
builder := New(
WithBuildDate(time.Date(2016, 1, 9, 0, 0, 0, 0, time.UTC)),
WithAttributes(sgx.Attributes{
Flags: 0x04,
Xfrm: 0x03,
}),
WithMiscSelectMask(^uint32(0)),
WithAttributesMask([2]uint64{^uint64(0x2), ^uint64(0xe4)}),
WithEnclaveHash(mrEnclave),
)
sigstruct, err := builder.Sign(privateKey)
require.NoError(err, "Sigstruct.New")
expected, err := ioutil.ReadFile("../testdata/sig1.sigstruct.bin")
require.NoError(err, "ioutil.ReadFile(sig1.sigstruct.bin)")
require.Equal(expected, sigstruct, "SIGSTRUCT should match Fortanix's")
extractedPublicKey, derivedBuilder, err := Verify(sigstruct)
require.NoError(err, "SIGSTRUCT should validate")
require.EqualValues(builder, derivedBuilder, "Parsed SIGSTRUCT should match builder")
require.EqualValues(privateKey.Public(), extractedPublicKey, "SIGSTRUCT public key extraction")
} | explode_data.jsonl/75797 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 484
} | [
2830,
3393,
47246,
1235,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
2405,
17317,
1702,
40533,
30673,
87,
1321,
81,
1702,
40533,
198,
9859,
1669,
17317,
1702,
40533,
38097,
20335,
445,
66,
20,
15,
21,
22,
18,
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 |
func TestStatefulSetControllerAddPod(t *testing.T) {
ssc, spc, _ := newFakeStatefulSetController()
set1 := newStatefulSet(3)
set2 := newStatefulSet(3)
pod1 := newStatefulSetPod(set1, 0)
pod2 := newStatefulSetPod(set2, 0)
spc.setsIndexer.Add(set1)
spc.setsIndexer.Add(set2)
ssc.addPod(pod1)
key, done := ssc.queue.Get()
if key == nil || done {
t.Error("failed to enqueue StatefulSet")
} else if key, ok := key.(string); !ok {
t.Error("key is not a string")
} else if expectedKey, _ := controller.KeyFunc(set1); expectedKey != key {
t.Errorf("expected StatefulSet key %s found %s", expectedKey, key)
}
ssc.queue.Done(key)
ssc.addPod(pod2)
key, done = ssc.queue.Get()
if key == nil || done {
t.Error("failed to enqueue StatefulSet")
} else if key, ok := key.(string); !ok {
t.Error("key is not a string")
} else if expectedKey, _ := controller.KeyFunc(set2); expectedKey != key {
t.Errorf("expected StatefulSet key %s found %s", expectedKey, key)
}
ssc.queue.Done(key)
} | explode_data.jsonl/18611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
1397,
1262,
1649,
2051,
2212,
23527,
1155,
353,
8840,
836,
8,
341,
34472,
66,
11,
978,
66,
11,
716,
1669,
501,
52317,
1397,
1262,
1649,
2051,
741,
8196,
16,
1669,
36848,
1262,
1649,
7,
18,
340,
8196,
17,
1669,
36848,
126... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommentBodyMatches(t *testing.T) {
var testcases = []struct {
repo string
body string
expectedJobs []string
}{
{
"org/repo",
"this is a random comment",
[]string{},
},
{
"org/repo",
"/ok-to-test",
[]string{"gce", "unit"},
},
{
"org/repo",
"/test all",
[]string{"gce", "unit", "gke"},
},
{
"org/repo",
"/test unit",
[]string{"unit"},
},
{
"org/repo",
"/test federation",
[]string{"federation"},
},
{
"org/repo2",
"/test all",
[]string{"cadveapster", "after-cadveapster", "after-after-cadveapster"},
},
{
"org/repo2",
"/test really",
[]string{"after-cadveapster"},
},
{
"org/repo2",
"/test again really",
[]string{"after-after-cadveapster"},
},
{
"org/repo3",
"/test all",
[]string{},
},
}
c := &Config{
JobConfig: JobConfig{
Presubmits: map[string][]Presubmit{
"org/repo": {
{
Name: "gce",
re: regexp.MustCompile(`/test (gce|all)`),
AlwaysRun: true,
},
{
Name: "unit",
re: regexp.MustCompile(`/test (unit|all)`),
AlwaysRun: true,
},
{
Name: "gke",
re: regexp.MustCompile(`/test (gke|all)`),
AlwaysRun: false,
},
{
Name: "federation",
re: regexp.MustCompile(`/test federation`),
AlwaysRun: false,
},
},
"org/repo2": {
{
Name: "cadveapster",
re: regexp.MustCompile(`/test all`),
AlwaysRun: true,
RunAfterSuccess: []Presubmit{
{
Name: "after-cadveapster",
re: regexp.MustCompile(`/test (really|all)`),
AlwaysRun: true,
RunAfterSuccess: []Presubmit{
{
Name: "after-after-cadveapster",
re: regexp.MustCompile(`/test (again really|all)`),
AlwaysRun: true,
},
},
},
{
Name: "another-after-cadveapster",
re: regexp.MustCompile(`@k8s-bot dont test this`),
AlwaysRun: true,
},
},
},
},
},
},
}
for _, tc := range testcases {
actualJobs := c.MatchingPresubmits(tc.repo, tc.body, regexp.MustCompile(`/ok-to-test`).MatchString(tc.body))
match := true
if len(actualJobs) != len(tc.expectedJobs) {
match = false
} else {
for _, actualJob := range actualJobs {
found := false
for _, expectedJob := range tc.expectedJobs {
if expectedJob == actualJob.Name {
found = true
break
}
}
if !found {
match = false
break
}
}
}
if !match {
t.Errorf("Wrong jobs for body %s. Got %v, expected %v.", tc.body, actualJobs, tc.expectedJobs)
}
}
} | explode_data.jsonl/36536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1534
} | [
2830,
3393,
10677,
5444,
42470,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
23910,
284,
3056,
1235,
341,
197,
17200,
5368,
260,
914,
198,
197,
35402,
260,
914,
198,
197,
42400,
40667,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func Test_InjectEnvoyContainerVG(t *testing.T) {
type args struct {
ms *appmesh.Mesh
vg *appmesh.VirtualGateway
pod *corev1.Pod
}
type expected struct {
containers int
xray bool
}
tests := []struct {
name string
conf Config
args args
want expected
wantErr error
}{
{
name: "Inject Envoy container with xray",
conf: getConfig(func(cnf Config) Config {
cnf.EnableXrayTracing = true
cnf.XrayDaemonPort = 2000
cnf.XRayImage = "amazon/aws-xray-daemon"
return cnf
}),
args: args{
ms: getMesh(),
vg: getVg(nil),
pod: getPod(nil),
},
want: expected{
containers: 2,
xray: true,
},
wantErr: nil,
},
{
name: "Inject Envoy container with xray - missing xray daemon port",
conf: getConfig(func(cnf Config) Config {
cnf.EnableXrayTracing = true
cnf.XRayImage = "amazon/aws-xray-daemon"
return cnf
}),
args: args{
ms: getMesh(),
vg: getVg(nil),
pod: getPod(nil),
},
want: expected{
containers: 1,
xray: true,
},
wantErr: errors.New("Missing configuration parameters: xRayDaemonPort"),
},
{
name: "Inject Envoy container with xray - missing xray image",
conf: getConfig(func(cnf Config) Config {
cnf.EnableXrayTracing = true
cnf.XrayDaemonPort = 2000
return cnf
}),
args: args{
ms: getMesh(),
vg: getVg(nil),
pod: getPod(nil),
},
want: expected{
containers: 1,
xray: true,
},
wantErr: errors.New("Missing configuration parameters: xRayImage"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
inj := NewSidecarInjector(tt.conf, "000000000000", "us-west-2", nil, nil, nil, nil)
pod := tt.args.pod
err := inj.injectAppMeshPatches(tt.args.ms, nil, tt.args.vg, pod)
if tt.wantErr != nil {
assert.EqualError(t, err, tt.wantErr.Error())
} else {
assert.Equal(t, tt.want.containers, len(pod.Spec.Containers), "Numbers of containers mismatch")
if tt.want.xray {
found := false
for _, v := range pod.Spec.Containers {
if v.Name == "xray-daemon" {
found = true
}
}
assert.True(t, found, "X-ray container not found")
}
}
})
}
} | explode_data.jsonl/80315 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1080
} | [
2830,
3393,
62,
13738,
14359,
2253,
4502,
46641,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
47691,
220,
353,
676,
23506,
50155,
198,
197,
5195,
70,
220,
353,
676,
23506,
95979,
40709,
198,
197,
3223,
347,
353,
98645,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMotorDriverToggle(t *testing.T) {
d := initTestMotorDriver()
d.Off()
d.Toggle()
gobottest.Assert(t, d.IsOn(), true)
d.Toggle()
gobottest.Assert(t, d.IsOn(), false)
} | explode_data.jsonl/23133 | {
"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,
33577,
11349,
18897,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
2930,
2271,
33577,
11349,
741,
2698,
13,
4596,
741,
2698,
80700,
741,
3174,
674,
1716,
477,
11711,
1155,
11,
294,
4506,
1925,
1507,
830,
340,
2698,
80700,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestTimeStamp(t *testing.T) {
var event events.Generic
ts := time.Date(2018, 8, 10, 17, 35, 16, 538978048, time.UTC)
event.SetTimestamp(ts)
ensure.DeepEqual(t, event.GetTimestamp(), ts)
event.Timestamp = 1546899001.019501
ensure.DeepEqual(t, event.GetTimestamp(),
time.Date(2019, 1, 7, 22, 10, 01, 19501056, time.UTC))
} | explode_data.jsonl/69101 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 141
} | [
2830,
3393,
66146,
1155,
353,
8840,
836,
8,
341,
2405,
1538,
4357,
4341,
198,
57441,
1669,
882,
8518,
7,
17,
15,
16,
23,
11,
220,
23,
11,
220,
16,
15,
11,
220,
16,
22,
11,
220,
18,
20,
11,
220,
16,
21,
11,
220,
20,
18,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWithHeader(t *testing.T) {
const headerKey = "X-Foo"
const headerVal = "Bar"
req := NewRequest("/").WithHeader(headerKey, headerVal)
header := req.Header.Get(headerKey)
if header != headerVal {
t.Errorf("bad Header, got: %v, want: %v", header, headerVal)
}
} | explode_data.jsonl/55923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
2354,
4047,
1155,
353,
8840,
836,
8,
341,
220,
733,
4247,
1592,
284,
330,
55,
7276,
2624,
698,
220,
733,
4247,
2208,
284,
330,
3428,
1837,
220,
4232,
1669,
1532,
1900,
4283,
1827,
2354,
4047,
25534,
1592,
11,
4247,
2208,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientSuccessAndErrorResponses(t *testing.T) {
// Service that succeeds only if requested size is 1, otherwise errors
h := PickyHatmaker(1)
s := httptest.NewServer(NewHaberdasherServer(h, nil))
defer s.Close()
// Clients
protoCli := NewHaberdasherProtobufClient(s.URL, &http.Client{})
jsonCli := NewHaberdasherJSONClient(s.URL, &http.Client{})
ctx := context.Background()
var resp *Hat
var err error
// Test proto success
resp, err = protoCli.MakeHat(ctx, &Size{Inches: 1})
if err != nil {
t.Fatalf("Proto client method returned unexpected error: %s", err)
}
if resp == nil {
t.Fatalf("Proto client method expected to return non-nil response, but it is nil")
}
// Test proto failure
resp, err = protoCli.MakeHat(ctx, &Size{Inches: 666})
if err == nil {
t.Fatalf("Proto client method expected to fail, but error is nil")
}
if resp != nil {
t.Fatalf("Proto client method expected to return nil response on error, but returned non-nil")
}
// Test json success
resp, err = jsonCli.MakeHat(ctx, &Size{Inches: 1})
if err != nil {
t.Fatalf("JSON client method returned unexpected error: %s", err)
}
if resp == nil {
t.Fatalf("JSON client method expected to return non-nil response, but it is nil")
}
// Test json failure
resp, err = jsonCli.MakeHat(ctx, &Size{Inches: 666})
if err == nil {
t.Fatalf("JSON client method expected to fail, but error is nil")
}
if resp != nil {
t.Fatalf("JSON client method expected to return nil response on error, but returned non-nil")
}
} | explode_data.jsonl/613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 528
} | [
2830,
3393,
2959,
7188,
3036,
1454,
70743,
1155,
353,
8840,
836,
8,
341,
197,
322,
5362,
429,
50081,
1172,
421,
11223,
1379,
374,
220,
16,
11,
5937,
5975,
198,
9598,
1669,
393,
18964,
72287,
25766,
7,
16,
340,
1903,
1669,
54320,
70334... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDomains_AllRecordsForDomainName(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/domains/example.com/records", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"domain_records":[{"id":1},{"id":2}]}`)
})
records, _, err := client.Domains.Records(ctx, "example.com", nil)
if err != nil {
t.Errorf("Domains.List returned error: %v", err)
}
expected := []DomainRecord{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(records, expected) {
t.Errorf("Domains.List returned %+v, expected %+v", records, expected)
}
} | explode_data.jsonl/22674 | {
"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,
74713,
53629,
25876,
2461,
13636,
675,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
85,
17,
71344,
1735,
65182,
905,
14,
26203,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDominatorsDeadCode(t *testing.T) {
c := testConfig(t)
fun := Fun(c, "entry",
Bloc("entry",
Valu("mem", OpInitMem, TypeMem, 0, nil),
Valu("p", OpConstBool, TypeBool, 0, nil),
If("p", "b3", "b5")),
Bloc("b2", Exit("mem")),
Bloc("b3", Goto("b2")),
Bloc("b4", Goto("b2")),
Bloc("b5", Goto("b2")))
doms := map[string]string{
"b2": "entry",
"b3": "entry",
"b5": "entry",
}
CheckFunc(fun.f)
verifyDominators(t, fun, dominators, doms)
verifyDominators(t, fun, dominatorsSimple, doms)
} | explode_data.jsonl/77584 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
71541,
2973,
28320,
2078,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1273,
2648,
1155,
340,
90126,
1669,
16071,
1337,
11,
330,
4085,
756,
197,
12791,
1074,
445,
4085,
756,
298,
197,
2208,
84,
445,
10536,
497,
10672,
3803,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewInMemory_Purge(t *testing.T) {
t.Parallel()
m := containable.NewInMemory()
for i := 0; i < 6; i++ {
id := []byte(`eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9`)
id = strconv.AppendInt(id, int64(i), 10)
assert.NoError(t, m.Set(id, time.Second))
time.Sleep(time.Second) // bit lame this test but so far ok, can be refactored one day.
}
assert.Exactly(t, 3, m.Len())
} | explode_data.jsonl/42546 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 176
} | [
2830,
3393,
3564,
641,
10642,
1088,
39823,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2109,
1669,
6644,
480,
7121,
641,
10642,
741,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
21,
26,
600,
1027,
341,
197,
15710,
1669,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestWorkflowTemplateServer_UpdateClusterWorkflowTemplate(t *testing.T) {
server, ctx := getClusterWorkflowTemplateServer()
t.Run("Labelled", func(t *testing.T) {
req := &clusterwftmplpkg.ClusterWorkflowTemplateUpdateRequest{
Template: cwftObj2.DeepCopy(),
}
req.Template.Spec.Templates[0].Container.Image = "alpine:latest"
cwftRsp, err := server.UpdateClusterWorkflowTemplate(ctx, req)
if assert.NoError(t, err) {
assert.Equal(t, "alpine:latest", cwftRsp.Spec.Templates[0].Container.Image)
}
})
t.Run("Unlabelled", func(t *testing.T) {
_, err := server.UpdateClusterWorkflowTemplate(ctx, &clusterwftmplpkg.ClusterWorkflowTemplateUpdateRequest{
Template: &unlabelled,
})
assert.Error(t, err)
})
} | explode_data.jsonl/48141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 283
} | [
2830,
3393,
62768,
7275,
5475,
47393,
28678,
62768,
7275,
1155,
353,
8840,
836,
8,
341,
41057,
11,
5635,
1669,
633,
28678,
62768,
7275,
5475,
741,
3244,
16708,
445,
2476,
832,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
24395,
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... | 2 |
func TestPrintReplicationController(t *testing.T) {
tests := []struct {
rc api.ReplicationController
options printers.GenerateOptions
expected []metav1.TableRow
}{
// Basic print replication controller without replicas or status.
{
rc: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{
Name: "rc1",
Namespace: "test-namespace",
},
Spec: api.ReplicationControllerSpec{
Selector: map[string]string{"a": "b"},
Template: &api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"a": "b"},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "test",
Image: "test_image",
ImagePullPolicy: api.PullIfNotPresent,
TerminationMessagePolicy: api.TerminationMessageReadFile,
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
},
options: printers.GenerateOptions{},
// Columns: Name, Desired, Current, Ready, Age
expected: []metav1.TableRow{{Cells: []interface{}{"rc1", int64(0), int64(0), int64(0), "<unknown>"}}},
},
// Basic print replication controller with replicas; does not print containers or labels
{
rc: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{
Name: "rc1",
Namespace: "test-namespace",
},
Spec: api.ReplicationControllerSpec{
Replicas: 5,
Selector: map[string]string{"a": "b"},
Template: &api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"a": "b"},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "test",
Image: "test_image",
ImagePullPolicy: api.PullIfNotPresent,
TerminationMessagePolicy: api.TerminationMessageReadFile,
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
Status: api.ReplicationControllerStatus{
Replicas: 3,
ReadyReplicas: 1,
},
},
options: printers.GenerateOptions{},
// Columns: Name, Desired, Current, Ready, Age
expected: []metav1.TableRow{{Cells: []interface{}{"rc1", int64(5), int64(3), int64(1), "<unknown>"}}},
},
// Generate options: Wide; print containers and labels.
{
rc: api.ReplicationController{
ObjectMeta: metav1.ObjectMeta{
Name: "rc1",
},
Spec: api.ReplicationControllerSpec{
Replicas: 5,
Selector: map[string]string{"a": "b"},
Template: &api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"a": "b"},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "test",
Image: "test_image",
ImagePullPolicy: api.PullIfNotPresent,
TerminationMessagePolicy: api.TerminationMessageReadFile,
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
Status: api.ReplicationControllerStatus{
Replicas: 3,
ReadyReplicas: 1,
},
},
options: printers.GenerateOptions{Wide: true},
// Columns: Name, Desired, Current, Ready, Age, Containers, Images, Selector
expected: []metav1.TableRow{{Cells: []interface{}{"rc1", int64(5), int64(3), int64(1), "<unknown>", "test", "test_image", "a=b"}}},
},
}
for i, test := range tests {
rows, err := printReplicationController(&test.rc, test.options)
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1861
} | [
2830,
3393,
8994,
18327,
1693,
2051,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
30295,
981,
6330,
2817,
79,
1693,
2051,
198,
197,
35500,
220,
55953,
57582,
3798,
198,
197,
42400,
3056,
4059,
402,
16,
18257,
3102,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFacadeError(t *testing.T) {
st, ok := status.FromError(facade.Error(codes.Internal, "ohno"))
require.True(t, ok, "error is not a gRPC status")
assert.Equal(t, codes.Internal, st.Code())
assert.Equal(t, "type(name): ohno", st.Message())
} | explode_data.jsonl/30820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
55331,
1454,
1155,
353,
8840,
836,
8,
341,
18388,
11,
5394,
1669,
2639,
11439,
1454,
955,
580,
1021,
6141,
1337,
2539,
32579,
11,
330,
2267,
2152,
5455,
17957,
32443,
1155,
11,
5394,
11,
330,
841,
374,
537,
264,
342,
29528... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReturnsErrorWithNoPod(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
defer leaktest.Check(t)()
r, _ := http.NewRequest("GET", "/latest/meta-data/iam/security-credentials/role", nil)
rr := httptest.NewRecorder()
client := st.NewStubClient().WithCredentials(st.GetCredentialsResult{nil, server.ErrPodNotFound})
handler := newCredentialsHandler(client, getBlankClientIP)
router := mux.NewRouter()
handler.Install(router)
router.ServeHTTP(rr, r.WithContext(ctx))
if rr.Code != http.StatusInternalServerError {
t.Error("unexpected status", rr.Code)
}
if !strings.Contains(rr.Body.String(), "error fetching credentials: no pod found") {
t.Error("unexpected error", rr.Body.String())
}
} | explode_data.jsonl/19348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 271
} | [
2830,
3393,
16446,
1454,
2354,
2753,
23527,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
882,
32435,
9,
20,
340,
16867,
9121,
741,
16867,
23352,
1944,
10600,
1155,
8,
2822,
7000,
11,
716,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSlimTrie_String_empty(t *testing.T) {
ta := require.New(t)
keys := []string{}
values := makeI32s(len(keys))
st, err := NewSlimTrie(encode.I32{}, keys, values)
ta.NoError(err)
want := trim(`
`)
dd(st)
ta.Equal(want, st.String())
testUnknownKeysGRS(t, st, randVStrings(100, 0, 10))
testPresentKeysGet(t, st, keys, values)
} | explode_data.jsonl/62315 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
87208,
51,
7231,
31777,
15124,
1155,
353,
8840,
836,
8,
1476,
197,
2565,
1669,
1373,
7121,
1155,
692,
80112,
1669,
3056,
917,
16094,
45939,
1669,
1281,
40,
18,
17,
82,
6901,
36131,
1171,
18388,
11,
1848,
1669,
1532,
87208,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCard_Layout(t *testing.T) {
test.NewApp()
test.ApplyTheme(t, theme.LightTheme())
for name, tt := range map[string]struct {
title, subtitle string
icon *canvas.Image
content fyne.CanvasObject
}{
"title": {
title: "Title",
subtitle: "",
icon: nil,
content: nil,
},
"subtitle": {
title: "",
subtitle: "Subtitle",
icon: nil,
content: nil,
},
"titles": {
title: "Title",
subtitle: "Subtitle",
icon: nil,
content: nil,
},
"titles_image": {
title: "Title",
subtitle: "Subtitle",
icon: canvas.NewImageFromResource(theme.FyneLogo()),
content: nil,
},
"just_image": {
title: "",
subtitle: "",
icon: canvas.NewImageFromResource(theme.FyneLogo()),
content: nil,
},
"just_content": {
title: "",
subtitle: "",
icon: nil,
content: newContentRect(),
},
"title_content": {
title: "Hello",
subtitle: "",
icon: nil,
content: newContentRect(),
},
"image_content": {
title: "",
subtitle: "",
icon: canvas.NewImageFromResource(theme.FyneLogo()),
content: newContentRect(),
},
"all_items": {
title: "Longer title",
subtitle: "subtitle with length",
icon: canvas.NewImageFromResource(theme.FyneLogo()),
content: newContentRect(),
},
} {
t.Run(name, func(t *testing.T) {
card := &widget.Card{
Title: tt.title,
Subtitle: tt.subtitle,
Image: tt.icon,
Content: tt.content,
}
window := test.NewWindow(card)
size := card.MinSize().Max(fyne.NewSize(80, 0)) // give a little width for image only tests
window.Resize(size.Add(fyne.NewSize(theme.Padding()*2, theme.Padding()*2)))
if tt.content != nil {
assert.Equal(t, 10, tt.content.Size().Height)
}
test.AssertImageMatches(t, "card/layout_"+name+".png", window.Canvas().Capture())
window.Close()
})
}
} | explode_data.jsonl/77607 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 922
} | [
2830,
3393,
5770,
62,
2175,
1155,
353,
8840,
836,
8,
341,
18185,
7121,
2164,
741,
18185,
36051,
12594,
1155,
11,
6912,
50791,
12594,
12367,
2023,
829,
11,
17853,
1669,
2088,
2415,
14032,
60,
1235,
341,
197,
24751,
11,
31735,
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 TestError(t *testing.T) {
errorMessage := "sentinel error"
input := errors.New(errorMessage)
inputGRPCCode := codes.Unauthenticated
inputGRPC := status.Error(inputGRPCCode, errorMessage)
for _, tc := range []struct {
desc string
errorf func(err error) error
code codes.Code
}{
{
desc: "Internal",
errorf: ErrInternal,
code: codes.Internal,
},
{
desc: "InvalidArgument",
errorf: ErrInvalidArgument,
code: codes.InvalidArgument,
},
{
desc: "PreconditionFailed",
errorf: ErrPreconditionFailed,
code: codes.FailedPrecondition,
},
{
desc: "NotFound",
errorf: ErrNotFound,
code: codes.NotFound,
},
} {
t.Run(tc.desc, func(t *testing.T) {
// tc.code and our canary test code must not
// clash!
require.NotEqual(t, tc.code, inputGRPCCode)
// When not re-throwing an error we get the
// GRPC error code corresponding to the
// function's name.
err := tc.errorf(input)
require.EqualError(t, err, errorMessage)
require.False(t, errors.Is(err, inputGRPC))
require.Equal(t, tc.code, status.Code(err))
// When re-throwing an error an existing GRPC
// error code will get preserved, instead of
// the one corresponding to the function's
// name.
err = tc.errorf(inputGRPC)
require.True(t, errors.Is(err, inputGRPC))
require.False(t, errors.Is(err, input))
require.Equal(t, inputGRPCCode, status.Code(err))
require.NotEqual(t, tc.code, status.Code(inputGRPC))
})
}
} | explode_data.jsonl/42907 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 621
} | [
2830,
3393,
1454,
1155,
353,
8840,
836,
8,
341,
18290,
2052,
1669,
330,
24512,
29708,
1465,
698,
22427,
1669,
5975,
7121,
70130,
340,
22427,
8626,
4872,
2078,
1669,
13912,
10616,
57707,
198,
22427,
8626,
4872,
1669,
2639,
6141,
5384,
8626... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCharsetRemoveAll(t *testing.T) {
c := NewCharset()
c.MakeFromBytes([]byte("\\x01-\\x05a-c\\k-m"))
c.RemoveAll()
str := c.StringAsInt()
test.EXPECT_EQ(t, str, "", "")
test.EXPECT_EQ(t, c.Size(), uint32(0), "")
} | explode_data.jsonl/51963 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
78172,
13021,
2403,
1155,
353,
8840,
836,
8,
972,
1444,
1669,
1532,
78172,
3568,
1444,
50133,
3830,
7078,
10556,
3782,
29710,
87,
15,
16,
12,
3422,
87,
15,
20,
64,
1786,
3422,
74,
1448,
26043,
1444,
84427,
3568,
11355,
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 TestKubeadmConfigReconciler_ClusterToKubeadmConfigs(t *testing.T) {
_ = feature.MutableGates.Set("MachinePool=true")
g := NewWithT(t)
cluster := newCluster("my-cluster")
objs := []client.Object{cluster}
expectedNames := []string{}
for i := 0; i < 3; i++ {
m := newMachine(cluster, fmt.Sprintf("my-machine-%d", i))
configName := fmt.Sprintf("my-config-%d", i)
c := newKubeadmConfig(m, configName)
expectedNames = append(expectedNames, configName)
objs = append(objs, m, c)
}
for i := 3; i < 6; i++ {
mp := newMachinePool(cluster, fmt.Sprintf("my-machinepool-%d", i))
configName := fmt.Sprintf("my-config-%d", i)
c := newMachinePoolKubeadmConfig(mp, configName)
expectedNames = append(expectedNames, configName)
objs = append(objs, mp, c)
}
fakeClient := helpers.NewFakeClientWithScheme(setupScheme(), objs...)
reconciler := &KubeadmConfigReconciler{
Client: fakeClient,
}
configs := reconciler.ClusterToKubeadmConfigs(cluster)
names := make([]string, 6)
for i := range configs {
names[i] = configs[i].Name
}
for _, name := range expectedNames {
found := false
for _, foundName := range names {
if foundName == name {
found = true
}
}
g.Expect(found).To(BeTrue())
}
} | explode_data.jsonl/44329 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 497
} | [
2830,
3393,
42,
392,
3149,
76,
2648,
693,
40446,
5769,
85110,
4993,
1249,
42,
392,
3149,
76,
84905,
1155,
353,
8840,
836,
8,
341,
197,
62,
284,
4565,
74028,
38,
973,
4202,
445,
21605,
10551,
11265,
1138,
3174,
1669,
1532,
2354,
51,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMeanStdDev(t *testing.T) {
src := NewMatWithSize(101, 102, MatTypeCV8U)
dst := NewMat()
dstStdDev := NewMat()
MeanStdDev(src, &dst, &dstStdDev)
if dst.Empty() {
t.Error("TestMeanStdDev dst should not be empty.")
}
if dstStdDev.Empty() {
t.Error("TestMeanStdDev dstStdDev should not be empty.")
}
} | explode_data.jsonl/81713 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
18783,
22748,
14592,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
1532,
11575,
2354,
1695,
7,
16,
15,
16,
11,
220,
16,
15,
17,
11,
6867,
929,
19589,
23,
52,
340,
52051,
1669,
1532,
11575,
741,
52051,
22748,
14592,
1669,
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... | 3 |
func TestLocalDockerComposeWithMultipleComposeFiles(t *testing.T) {
composeFiles := []string{
"testresources/docker-compose-simple.yml",
"testresources/docker-compose-postgres.yml",
"testresources/docker-compose-override.yml",
}
identifier := strings.ToLower(uuid.New().String())
compose := NewLocalDockerCompose(composeFiles, identifier, WithLogger(TestLogger(t)))
destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()
err := compose.
WithCommand([]string{"up", "-d"}).
WithEnv(map[string]string{
"bar": "BAR",
"foo": "FOO",
}).
Invoke()
checkIfError(t, err)
assert.Equal(t, 3, len(compose.Services))
assert.Contains(t, compose.Services, "nginx")
assert.Contains(t, compose.Services, "mysql")
assert.Contains(t, compose.Services, "postgres")
containerNameNginx := compose.Identifier + "_nginx_1"
present := map[string]string{
"bar": "BAR",
"foo": "FOO",
}
absent := map[string]string{}
assertContainerEnvironmentVariables(t, containerNameNginx, present, absent)
} | explode_data.jsonl/43636 | {
"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,
7319,
35,
13659,
70492,
2354,
32089,
70492,
10809,
1155,
353,
8840,
836,
8,
341,
32810,
2900,
10809,
1669,
3056,
917,
515,
197,
197,
1,
1944,
12745,
61764,
65070,
65957,
33936,
756,
197,
197,
1,
1944,
12745,
61764,
65070,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHeartbeatsGoToAllStreams(t *testing.T) {
heartbeatInterval := time.Millisecond * 20
sp := &mockStreamProvider{credentialOfDesiredType: config.SDKKey("")}
store := makeMockStore(nil, nil)
es := NewEnvStreams([]StreamProvider{sp}, store, heartbeatInterval, ldlog.NewDisabledLoggers())
defer es.Close()
sdkKey1, sdkKey2 := config.SDKKey("sdk-key1"), config.SDKKey("sdk-key2")
es.AddCredential(sdkKey1)
es.AddCredential(sdkKey2)
require.Len(t, sp.createdStreams, 2)
esp1, esp2 := sp.createdStreams[0], sp.createdStreams[1]
<-time.After(heartbeatInterval * 4)
assert.GreaterOrEqual(t, esp1.getNumHeartbeats(), 2)
assert.GreaterOrEqual(t, esp2.getNumHeartbeats(), 2)
} | explode_data.jsonl/69851 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
45384,
1371,
1862,
10850,
1249,
2403,
73576,
1155,
353,
8840,
836,
8,
341,
197,
72471,
10256,
1669,
882,
71482,
353,
220,
17,
15,
271,
41378,
1669,
609,
16712,
3027,
5179,
90,
66799,
2124,
4896,
2690,
929,
25,
2193,
46822,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNormalizeExpr(t *testing.T) {
tables := []struct {
key string
op metav1.LabelSelectorOperator
values []string
expName string
}{
{
"role",
metav1.LabelSelectorOpIn,
[]string{"db", "app"},
fmt.Sprintf("%s %s %s", "role", metav1.LabelSelectorOpIn, []string{"db", "app"}),
},
{
"role",
metav1.LabelSelectorOpExists,
[]string{},
fmt.Sprintf("%s %s", "role", metav1.LabelSelectorOpExists),
},
}
for _, table := range tables {
name := normalizeExpr(table.key, table.op, table.values)
if name != table.expName {
t.Errorf("Name not normalized correctly. Expected %s, got %s", table.expName, name)
}
}
} | explode_data.jsonl/82437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
87824,
16041,
1155,
353,
8840,
836,
8,
341,
26481,
82,
1669,
3056,
1235,
341,
197,
23634,
257,
914,
198,
197,
39703,
414,
77520,
16,
4679,
5877,
18461,
198,
197,
45939,
220,
3056,
917,
198,
197,
48558,
675,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRangeLookupUseReverse(t *testing.T) {
defer leaktest.AfterTest(t)
store, stopper := createTestStore(t)
defer stopper.Stop()
// Init test ranges:
// ["","a"), ["a","c"), ["c","e"), ["e","g") and ["g","\xff\xff").
splits := []roachpb.AdminSplitRequest{
adminSplitArgs(roachpb.Key("g"), roachpb.Key("g")),
adminSplitArgs(roachpb.Key("e"), roachpb.Key("e")),
adminSplitArgs(roachpb.Key("c"), roachpb.Key("c")),
adminSplitArgs(roachpb.Key("a"), roachpb.Key("a")),
}
for _, split := range splits {
_, err := client.SendWrapped(rg1(store), nil, &split)
if err != nil {
t.Fatalf("%q: split unexpected error: %s", split.SplitKey, err)
}
}
// Resolve the intents.
scanArgs := roachpb.ScanRequest{
Span: roachpb.Span{
Key: keys.RangeMetaKey(roachpb.RKeyMin.Next()),
EndKey: keys.RangeMetaKey(roachpb.RKeyMax),
},
}
util.SucceedsWithin(t, time.Second, func() error {
_, err := client.SendWrapped(rg1(store), nil, &scanArgs)
return err
})
revScanArgs := func(key []byte, maxResults int32) *roachpb.RangeLookupRequest {
return &roachpb.RangeLookupRequest{
Span: roachpb.Span{
Key: key,
},
MaxRanges: maxResults,
Reverse: true,
}
}
// Test cases.
testCases := []struct {
request *roachpb.RangeLookupRequest
expected []roachpb.RangeDescriptor
}{
// Test key in the middle of the range.
{
request: revScanArgs(keys.RangeMetaKey(roachpb.RKey("f")), 2),
// ["e","g") and ["c","e").
expected: []roachpb.RangeDescriptor{
{StartKey: roachpb.RKey("e"), EndKey: roachpb.RKey("g")},
{StartKey: roachpb.RKey("c"), EndKey: roachpb.RKey("e")},
},
},
// Test key in the end key of the range.
{
request: revScanArgs(keys.RangeMetaKey(roachpb.RKey("g")), 3),
// ["e","g"), ["c","e") and ["a","c").
expected: []roachpb.RangeDescriptor{
{StartKey: roachpb.RKey("e"), EndKey: roachpb.RKey("g")},
{StartKey: roachpb.RKey("c"), EndKey: roachpb.RKey("e")},
{StartKey: roachpb.RKey("a"), EndKey: roachpb.RKey("c")},
},
},
{
request: revScanArgs(keys.RangeMetaKey(roachpb.RKey("e")), 2),
// ["c","e") and ["a","c").
expected: []roachpb.RangeDescriptor{
{StartKey: roachpb.RKey("c"), EndKey: roachpb.RKey("e")},
{StartKey: roachpb.RKey("a"), EndKey: roachpb.RKey("c")},
},
},
// Test Meta2KeyMax.
{
request: revScanArgs(keys.Meta2KeyMax, 2),
// ["e","g") and ["g","\xff\xff")
expected: []roachpb.RangeDescriptor{
{StartKey: roachpb.RKey("g"), EndKey: roachpb.RKey("\xff\xff")},
{StartKey: roachpb.RKey("e"), EndKey: roachpb.RKey("g")},
},
},
// Test Meta1KeyMax.
{
request: revScanArgs(keys.Meta1KeyMax, 1),
// ["","a")
expected: []roachpb.RangeDescriptor{
{StartKey: roachpb.RKeyMin, EndKey: roachpb.RKey("a")},
},
},
}
for _, test := range testCases {
resp, err := client.SendWrappedWith(rg1(store), nil, roachpb.Header{
ReadConsistency: roachpb.INCONSISTENT,
}, test.request)
if err != nil {
t.Fatalf("RangeLookup error: %s", err)
}
rlReply := resp.(*roachpb.RangeLookupResponse)
// Checks the results count.
if int32(len(rlReply.Ranges)) != test.request.MaxRanges {
t.Fatalf("returned results count, expected %d,but got %d", test.request.MaxRanges, len(rlReply.Ranges))
}
// Checks the range descriptors.
for i, rng := range test.expected {
if !(rng.StartKey.Equal(rlReply.Ranges[i].StartKey) && rng.EndKey.Equal(rlReply.Ranges[i].EndKey)) {
t.Fatalf("returned range is not correct, expected %v ,but got %v", rng, rlReply.Ranges[i])
}
}
}
} | explode_data.jsonl/8002 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1566
} | [
2830,
3393,
6046,
34247,
10253,
45695,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
340,
57279,
11,
2936,
712,
1669,
1855,
2271,
6093,
1155,
340,
16867,
2936,
712,
30213,
2822,
197,
322,
15690,
1273,
21283,
510,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGocloak_AddRealmRoleToUser_DeleteRealmRoleFromUser(t *testing.T) {
t.Parallel()
cfg := GetConfig(t)
client := NewClientWithDebug(t)
token := GetAdminToken(t, client)
tearDownUser, userID := CreateUser(t, client)
defer tearDownUser()
tearDownRole, roleName := CreateRealmRole(t, client)
defer tearDownRole()
role, err := client.GetRealmRole(
token.AccessToken,
cfg.GoCloak.Realm,
roleName)
assert.NoError(t, err, "GetRealmRole failed")
roles := []Role{*role}
err = client.AddRealmRoleToUser(
token.AccessToken,
cfg.GoCloak.Realm,
userID,
roles,
)
assert.NoError(t, err, "AddRealmRoleToUser failed")
err = client.DeleteRealmRoleFromUser(
token.AccessToken,
cfg.GoCloak.Realm,
userID,
roles,
)
assert.NoError(t, err, "DeleteRealmRoleFromUser failed")
} | explode_data.jsonl/79548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
38,
509,
385,
585,
21346,
64290,
9030,
1249,
1474,
57418,
64290,
9030,
3830,
1474,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
1669,
2126,
2648,
1155,
340,
25291,
1669,
1532,
2959,
2354,
7939,
1155,
340,
439... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCharsetDecoderError(t *testing.T) {
dec := &WordDecoder{
CharsetReader: func(charset string, input io.Reader) (io.Reader, error) {
return nil, errors.New("Test error")
},
}
if _, err := dec.DecodeHeader("=?charset?Q?foo?="); err == nil {
t.Error("DecodeHeader should return an error")
}
} | explode_data.jsonl/36207 | {
"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,
78172,
20732,
1454,
1155,
353,
8840,
836,
8,
341,
197,
8169,
1669,
609,
10879,
20732,
515,
197,
197,
78172,
5062,
25,
2915,
6933,
746,
914,
11,
1946,
6399,
47431,
8,
320,
815,
47431,
11,
1465,
8,
341,
298,
853,
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... | 1 |
func TestParseConnectedSlaveString(t *testing.T) {
tsts := []slaveData{
{k: "slave0", v: "ip=10.254.11.1,port=6379,state=online,offset=1751844676,lag=0", offset: 1751844676, ip: "10.254.11.1", port: "6379", state: "online", ok: true, lag: 0},
{k: "slave0", v: "ip=2a00:1450:400e:808::200e,port=6379,state=online,offset=1751844676,lag=0", offset: 1751844676, ip: "2a00:1450:400e:808::200e", port: "6379", state: "online", ok: true, lag: 0},
{k: "slave1", v: "offset=1,lag=0", offset: 1, ok: true},
{k: "slave1", v: "offset=1", offset: 1, ok: true, lag: -1},
{k: "slave2", v: "ip=1.2.3.4,state=online,offset=123,lag=42", offset: 123, ip: "1.2.3.4", state: "online", ok: true, lag: 42},
{k: "slave", v: "offset=1751844676,lag=0", ok: false},
{k: "slaveA", v: "offset=1751844676,lag=0", ok: false},
{k: "slave0", v: "offset=abc,lag=0", ok: false},
{k: "slave0", v: "offset=0,lag=abc", ok: false},
}
for _, tst := range tsts {
name := fmt.Sprintf("%s---%s", tst.k, tst.v)
t.Run(name, func(t *testing.T) {
if offset, ip, port, state, lag, ok := parseConnectedSlaveString(tst.k, tst.v); true {
if ok != tst.ok {
t.Errorf("failed for: db:%s stats:%s", tst.k, tst.v)
return
}
if offset != tst.offset || ip != tst.ip || port != tst.port || state != tst.state || lag != tst.lag {
t.Errorf("values not matching, string:%s %f %s %s %s %f", tst.v, offset, ip, port, state, lag)
}
}
})
}
} | explode_data.jsonl/46985 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 687
} | [
2830,
3393,
14463,
21146,
95960,
703,
1155,
353,
8840,
836,
8,
341,
3244,
36279,
1669,
3056,
52505,
1043,
515,
197,
197,
69094,
25,
330,
52505,
15,
497,
348,
25,
330,
573,
28,
16,
15,
13,
17,
20,
19,
13,
16,
16,
13,
16,
96898,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestFormatParDoError(t *testing.T) {
got := formatParDoError(testFunction, 2, 1)
want := "beam.testFunction has 2 outputs, but ParDo requires 1 outputs, use ParDo2 instead."
if !strings.Contains(got, want) {
t.Errorf("formatParDoError(testFunction,2,1) = %v, want = %v", got, want)
}
} | explode_data.jsonl/29427 | {
"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,
4061,
4272,
5404,
1454,
1155,
353,
8840,
836,
8,
341,
3174,
354,
1669,
3561,
4272,
5404,
1454,
8623,
5152,
11,
220,
17,
11,
220,
16,
340,
50780,
1669,
330,
53871,
5958,
5152,
702,
220,
17,
16275,
11,
714,
4270,
5404,
746... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProductDb_Save(t *testing.T){
setUp()
defer Db.Close()
productDb := db.NewProductDb(Db)
product := application.NewProduct()
product.Name = "Product Test"
product.Price = 25
productResult, err := productDb.Save(product)
require.Nil(t, err)
require.Equal(t, product.Name, productResult.GetName())
require.Equal(t, product.Price, product.GetPrice())
require.Equal(t, product.Status, product.GetStatus())
product.Status = "enabled"
productResult, err = productDb.Save(product)
require.Nil(t, err)
require.Equal(t, product.Name, productResult.GetName())
require.Equal(t, product.Price, product.GetPrice())
require.Equal(t, product.Status, product.GetStatus())
} | explode_data.jsonl/58346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
4816,
7994,
78746,
1155,
353,
8840,
836,
1264,
8196,
2324,
741,
16867,
11988,
10421,
741,
69288,
7994,
1669,
2927,
7121,
4816,
7994,
52169,
692,
69288,
1669,
3766,
7121,
4816,
741,
1572,
69288,
2967,
284,
330,
4816,
3393,
698,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestText(t *testing.T) {
t.Parallel()
ctx, cancel := testAllocate(t, "form.html")
defer cancel()
tests := []struct {
sel string
by QueryOption
exp string
}{
{"#foo", ByID, "insert"},
{"body > form > span", ByQueryAll, "insert"},
{"body > form > span:nth-child(2)", ByQuery, "keyword"},
{"/html/body/form/span[2]", BySearch, "keyword"},
{`document.querySelector("#form > span:nth-child(2)")`, ByJSPath, "keyword"},
{"#inner-hidden", ByID, "this is"},
{"#hidden", ByID, ""},
}
for i, test := range tests {
var text string
if err := Run(ctx, Text(test.sel, &text, test.by)); err != nil {
t.Fatalf("test %d got error: %v", i, err)
}
if text != test.exp {
t.Errorf("test %d expected %q, got: %s", i, test.exp, text)
}
}
} | explode_data.jsonl/59468 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
1178,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
1273,
75380,
1155,
11,
330,
627,
2564,
1138,
16867,
9121,
2822,
78216,
1669,
3056,
1235,
341,
197,
1903,
301,
914,
198,
197,
197,
1694,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSliceList(t *testing.T) {
l := SliceList[int]([]int{1, 2, 3, 4, 5})
testutil.Equal(t, 5, l.Len())
l.Append(6)
testutil.Equal(t, 6, l.Len())
v, _ := l.Pop()
testutil.Equal(t, 5, l.Len())
testutil.Equal(t, 6, v)
v, _ = l.PopFront()
testutil.Equal(t, 4, l.Len())
testutil.Equal(t, 1, v)
v = l.Remove(1)
testutil.Equal(t, 3, l.Len())
testutil.Equal(t, 3, v)
l.Prepend(1)
testutil.Equal(t, 4, l.Len())
r := make([]int, l.Len())
l.Iterate(func(p alg.Pair[int, int]) bool {
r[p.L] = p.R
return true
})
testutil.EqualFn(t, []int{1, 2, 4, 5}, r, slices.Equal[int])
} | explode_data.jsonl/3737 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 313
} | [
2830,
3393,
33236,
852,
1155,
353,
8840,
836,
8,
341,
8810,
1669,
56476,
852,
18640,
9533,
1294,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
3518,
18185,
1314,
12808,
1155,
11,
220,
20,
11,
326,
65819,
12367,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClosestPoint(t *testing.T) {
b0, b1 := newBody(NewBox(0.5, 0.5, 0.5)), newBody(NewBox(1, 1, 1))
b0.World().Loc.SetS(0, 0, 1.49)
con := newContactPair(b0, b1)
_, _, pocs := collideBoxBox(b0, b1, con.pocs[0:4])
con.pocs = pocs
for _, cp := range pocs {
cp.prepForSolver(con)
}
cp0, cp2 := pocs[0], pocs[2]
if con.closestPoint(cp0) != 0 || con.closestPoint(cp2) != 2 {
t.Errorf("Should have found the matching points %d %d", con.closestPoint(cp0), con.closestPoint(cp2))
}
} | explode_data.jsonl/4954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
7925,
267,
2609,
1155,
353,
8840,
836,
8,
341,
2233,
15,
11,
293,
16,
1669,
501,
5444,
35063,
1611,
7,
15,
13,
20,
11,
220,
15,
13,
20,
11,
220,
15,
13,
20,
5731,
501,
5444,
35063,
1611,
7,
16,
11,
220,
16,
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... | 4 |
func TestOverrideAndroidTest(t *testing.T) {
ctx, _ := testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
package_name: "com.android.foo",
sdk_version: "current",
}
override_android_app {
name: "bar",
base: "foo",
package_name: "com.android.bar",
}
android_test {
name: "foo_test",
srcs: ["b.java"],
instrumentation_for: "foo",
}
override_android_test {
name: "bar_test",
base: "foo_test",
package_name: "com.android.bar.test",
instrumentation_for: "bar",
instrumentation_target_package: "com.android.bar",
}
`)
expectedVariants := []struct {
moduleName string
variantName string
apkPath string
overrides []string
targetVariant string
packageFlag string
targetPackageFlag string
}{
{
variantName: "android_common",
apkPath: "/target/product/test_device/testcases/foo_test/arm64/foo_test.apk",
overrides: nil,
targetVariant: "android_common",
packageFlag: "",
targetPackageFlag: "",
},
{
variantName: "android_common_bar_test",
apkPath: "/target/product/test_device/testcases/bar_test/arm64/bar_test.apk",
overrides: []string{"foo_test"},
targetVariant: "android_common_bar",
packageFlag: "com.android.bar.test",
targetPackageFlag: "com.android.bar",
},
}
for _, expected := range expectedVariants {
variant := ctx.ModuleForTests("foo_test", expected.variantName)
// Check the final apk name
variant.Output("out/soong" + expected.apkPath)
// Check if the overrides field values are correctly aggregated.
mod := variant.Module().(*AndroidTest)
if !reflect.DeepEqual(expected.overrides, mod.appProperties.Overrides) {
t.Errorf("Incorrect overrides property value, expected: %q, got: %q",
expected.overrides, mod.appProperties.Overrides)
}
// Check if javac classpath has the correct jar file path. This checks instrumentation_for overrides.
javac := variant.Rule("javac")
turbine := filepath.Join("out", "soong", ".intermediates", "foo", expected.targetVariant, "turbine-combined", "foo.jar")
if !strings.Contains(javac.Args["classpath"], turbine) {
t.Errorf("classpath %q does not contain %q", javac.Args["classpath"], turbine)
}
// Check aapt2 flags.
res := variant.Output("package-res.apk")
aapt2Flags := res.Args["flags"]
checkAapt2LinkFlag(t, aapt2Flags, "rename-manifest-package", expected.packageFlag)
checkAapt2LinkFlag(t, aapt2Flags, "rename-resources-package", expected.packageFlag)
checkAapt2LinkFlag(t, aapt2Flags, "rename-instrumentation-target-package", expected.targetPackageFlag)
}
} | explode_data.jsonl/58499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1115
} | [
2830,
3393,
2177,
21831,
2271,
1155,
353,
8840,
836,
8,
341,
20985,
11,
716,
1669,
1273,
15041,
1155,
11,
22074,
197,
197,
5954,
8191,
341,
298,
11609,
25,
330,
7975,
756,
298,
41144,
82,
25,
4383,
64,
10848,
8097,
298,
197,
1722,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInsertNode(t *testing.T) {
root := new(dag.ProtoNode)
e := NewDagEditor(root, nil)
testInsert(t, e, "a", "anodefortesting", false, "")
testInsert(t, e, "a/b", "data", false, "")
testInsert(t, e, "a/b/c/d/e", "blah", false, "no link by that name")
testInsert(t, e, "a/b/c/d/e", "foo", true, "")
testInsert(t, e, "a/b/c/d/f", "baz", true, "")
testInsert(t, e, "a/b/c/d/f", "bar", true, "")
testInsert(t, e, "", "bar", true, "cannot create link with no name")
testInsert(t, e, "////", "slashes", true, "cannot create link with no name")
c := e.GetNode().Cid()
if c.String() != "QmZ8yeT9uD6ouJPNAYt62XffYuXBT6b4mP4obRSE9cJrSt" {
t.Fatal("output was different than expected: ", c)
}
} | explode_data.jsonl/51622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
13780,
1955,
1155,
353,
8840,
836,
8,
341,
33698,
1669,
501,
1500,
351,
7763,
983,
1955,
340,
7727,
1669,
1532,
35,
351,
9410,
9206,
11,
2092,
692,
18185,
13780,
1155,
11,
384,
11,
330,
64,
497,
330,
276,
534,
3969,
5985... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenesisAccountValidate(t *testing.T) {
addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
tests := []struct {
name string
acc GenesisAccount
expErr error
}{
{
"valid account",
NewGenesisAccountRaw(addr, sdk.NewCoins(), sdk.NewCoins(), 0, 0, "", ""),
nil,
},
{
"valid module account",
NewGenesisAccountRaw(addr, sdk.NewCoins(), sdk.NewCoins(), 0, 0, "mint", supply.Minter),
nil,
},
{
"invalid vesting amount",
NewGenesisAccountRaw(addr, sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), 0, 0, "", ""),
errors.New("vesting amount cannot be greater than total amount"),
},
{
"invalid vesting amount with multi coins",
NewGenesisAccountRaw(addr,
sdk.NewCoins(sdk.NewInt64Coin("uatom", 50), sdk.NewInt64Coin("eth", 50)),
sdk.NewCoins(sdk.NewInt64Coin("uatom", 100), sdk.NewInt64Coin("eth", 20)),
0, 0, "", ""),
errors.New("vesting amount cannot be greater than total amount"),
},
{
"invalid vesting times",
NewGenesisAccountRaw(addr, sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)), 1654668078, 1554668078, "", ""),
errors.New("vesting start-time cannot be before end-time"),
},
{
"invalid module account name",
NewGenesisAccountRaw(addr, sdk.NewCoins(), sdk.NewCoins(), 0, 0, " ", ""),
errors.New("module account name cannot be blank"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.acc.Validate()
require.Equal(t, tt.expErr, err)
})
}
} | explode_data.jsonl/48813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 688
} | [
2830,
3393,
84652,
7365,
17926,
1155,
353,
8840,
836,
8,
341,
53183,
1669,
45402,
77538,
4286,
10478,
4672,
17,
20,
21,
74,
16,
65384,
32124,
1592,
1005,
29162,
1592,
1005,
4286,
2398,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateBuilder(t *testing.T) {
test.CmdValidator(
t,
UpdateBuilder(),
0,
[]string{flag.Output, flag.ProjectID, flag.Username, flag.Password, flag.Status, flag.SSL, flag.Encryption, flag.ExcludedNamespace,
flag.IncludedNamespace, flag.Provisioned, flag.AuthMechanism, flag.StorageEngine, flag.SyncSource},
)
} | explode_data.jsonl/36620 | {
"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,
4289,
3297,
1155,
353,
8840,
836,
8,
341,
18185,
64512,
14256,
1006,
197,
3244,
345,
197,
70064,
3297,
3148,
197,
197,
15,
345,
197,
197,
1294,
917,
90,
9903,
34246,
11,
5181,
30944,
915,
11,
5181,
42777,
11,
5181,
25690,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJolokia2_MetricMbeanMatching(t *testing.T) {
config := `
[jolokia2_agent]
urls = ["%s"]
[[jolokia2_agent.metric]]
name = "mbean_name_and_object_keys"
mbean = "test1:foo=bar,fizz=buzz"
[[jolokia2_agent.metric]]
name = "mbean_name_and_unordered_object_keys"
mbean = "test2:fizz=buzz,foo=bar"
[[jolokia2_agent.metric]]
name = "mbean_name_and_attributes"
mbean = "test3"
paths = ["foo", "bar"]
[[jolokia2_agent.metric]]
name = "mbean_name_and_attribute_with_paths"
mbean = "test4"
paths = ["flavor/chocolate", "flavor/strawberry"]
`
response := `[{
"request": {
"mbean": "test1:foo=bar,fizz=buzz",
"type": "read"
},
"value": 123,
"status": 200
}, {
"request": {
"mbean": "test2:foo=bar,fizz=buzz",
"type": "read"
},
"value": 123,
"status": 200
}, {
"request": {
"mbean": "test3",
"attribute": "foo",
"type": "read"
},
"value": 123,
"status": 200
}, {
"request": {
"mbean": "test3",
"attribute": "bar",
"type": "read"
},
"value": 456,
"status": 200
}, {
"request": {
"mbean": "test4",
"attribute": "flavor",
"path": "chocolate",
"type": "read"
},
"value": 123,
"status": 200
}, {
"request": {
"mbean": "test4",
"attribute": "flavor",
"path": "strawberry",
"type": "read"
},
"value": 456,
"status": 200
}]`
server := setupServer(http.StatusOK, response)
defer server.Close()
plugin := setupPlugin(t, fmt.Sprintf(config, server.URL))
var acc testutil.Accumulator
assert.NoError(t, plugin.Gather(&acc))
acc.AssertContainsTaggedFields(t, "mbean_name_and_object_keys", map[string]interface{}{
"value": 123.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "mbean_name_and_unordered_object_keys", map[string]interface{}{
"value": 123.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "mbean_name_and_attributes", map[string]interface{}{
"foo": 123.0,
"bar": 456.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "mbean_name_and_attribute_with_paths", map[string]interface{}{
"flavor.chocolate": 123.0,
"flavor.strawberry": 456.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
} | explode_data.jsonl/5358 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1069
} | [
2830,
3393,
41,
337,
27552,
17,
1245,
16340,
44,
17479,
64430,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
22074,
197,
3809,
337,
27552,
17,
25730,
921,
197,
19320,
82,
284,
4383,
4,
82,
25912,
197,
15505,
73,
337,
27552,
17,
25730,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmphasisMix(t *testing.T) {
var tests = []string{
"***triple emphasis***\n",
"<p><strong><em>triple emphasis</em></strong></p>\n",
"***triple\nemphasis***\n",
"<p><strong><em>triple\nemphasis</em></strong></p>\n",
"___triple emphasis___\n",
"<p><strong><em>triple emphasis</em></strong></p>\n",
"***triple emphasis___\n",
"<p>***triple emphasis___</p>\n",
"*__triple emphasis__*\n",
"<p><em><strong>triple emphasis</strong></em></p>\n",
"__*triple emphasis*__\n",
"<p><strong><em>triple emphasis</em></strong></p>\n",
"**improper *nesting** is* bad\n",
"<p><strong>improper *nesting</strong> is* bad</p>\n",
"*improper **nesting* is** bad\n",
"<p><em>improper **nesting</em> is** bad</p>\n",
}
doTestsInline(t, tests)
} | explode_data.jsonl/57349 | {
"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,
2269,
54149,
58083,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
917,
515,
197,
197,
1,
12210,
376,
3778,
24654,
12210,
59,
77,
756,
197,
197,
22476,
79,
1784,
4519,
1784,
336,
29,
376,
3778,
24654,
522,
336,
147... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepareWithWindowFunction(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@tidb_enable_window_function = 1")
defer tk.MustExec("set @@tidb_enable_window_function = 0")
tk.MustExec("use test")
tk.MustExec("create table window_prepare(a int, b double)")
tk.MustExec("insert into window_prepare values(1, 1.1), (2, 1.9)")
tk.MustExec("prepare stmt1 from 'select row_number() over() from window_prepare';")
// Test the unnamed window can be executed successfully.
tk.MustQuery("execute stmt1").Check(testkit.Rows("1", "2"))
// Test the stmt can be prepared successfully.
tk.MustExec("prepare stmt2 from 'select count(a) over (order by a rows between ? preceding and ? preceding) from window_prepare'")
tk.MustExec("set @a=0, @b=1;")
tk.MustQuery("execute stmt2 using @a, @b").Check(testkit.Rows("0", "0"))
} | explode_data.jsonl/5506 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
50590,
2354,
4267,
5152,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50463,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidCertInIngress(t *testing.T) {
rh, cc, done := setup(t)
defer done()
// Create an invalid TLS secret
secret := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-tls",
Namespace: "default",
},
Type: "kubernetes.io/tls",
Data: secretdata("wrong", RSA_PRIVATE_KEY),
}
rh.OnAdd(secret)
// Create a service
rh.OnAdd(&v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "kuard",
Namespace: "default",
},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{
Protocol: "TCP",
Port: 80,
TargetPort: intstr.FromInt(8080),
}},
},
})
// Create an ingress that uses the invalid secret
rh.OnAdd(&v1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{Name: "kuard-ing", Namespace: "default"},
Spec: v1beta1.IngressSpec{
TLS: []v1beta1.IngressTLS{{
Hosts: []string{"kuard.io"},
SecretName: "example-tls",
}},
Rules: []v1beta1.IngressRule{{
Host: "kuard.io",
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{{
Backend: v1beta1.IngressBackend{
ServiceName: "kuard",
ServicePort: intstr.FromInt(80),
},
}},
},
},
}},
},
})
assertRDS(t, cc, "1", virtualhosts(
envoy.VirtualHost("kuard.io",
&envoy_api_v2_route.Route{
Match: routePrefix("/"),
Action: routecluster("default/kuard/80/da39a3ee5e"),
},
),
), nil)
// Correct the secret
rh.OnUpdate(secret, &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-tls",
Namespace: "default",
},
Type: "kubernetes.io/tls",
Data: secretdata(CERTIFICATE, RSA_PRIVATE_KEY),
})
assertRDS(t, cc, "2", virtualhosts(
envoy.VirtualHost("kuard.io",
&envoy_api_v2_route.Route{
Match: routePrefix("/"),
Action: routecluster("default/kuard/80/da39a3ee5e"),
},
),
), virtualhosts(
envoy.VirtualHost("kuard.io",
&envoy_api_v2_route.Route{
Match: routePrefix("/"),
Action: routecluster("default/kuard/80/da39a3ee5e"),
},
),
))
} | explode_data.jsonl/70754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 999
} | [
2830,
3393,
7928,
36934,
641,
641,
2483,
1155,
353,
8840,
836,
8,
341,
7000,
71,
11,
12527,
11,
2814,
1669,
6505,
1155,
340,
16867,
2814,
2822,
197,
322,
4230,
458,
8318,
41654,
6234,
198,
197,
20474,
1669,
609,
85,
16,
74779,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateAPITracesExporter(t *testing.T) {
server := testutils.DatadogServerMock()
defer server.Close()
logger := zap.NewNop()
factories, err := componenttest.ExampleComponents()
require.NoError(t, err)
factory := NewFactory()
factories.Exporters[configmodels.Type(typeStr)] = factory
cfg, err := configtest.LoadConfigFile(t, path.Join(".", "testdata", "config.yaml"), factories)
require.NoError(t, err)
require.NotNil(t, cfg)
// Use the mock server for API key validation
c := (cfg.Exporters["datadog/api"]).(*config.Config)
c.Metrics.TCPAddr.Endpoint = server.URL
c.SendMetadata = false
ctx := context.Background()
exp, err := factory.CreateTracesExporter(
ctx,
component.ExporterCreateParams{Logger: logger},
cfg.Exporters["datadog/api"],
)
assert.NoError(t, err)
assert.NotNil(t, exp)
} | explode_data.jsonl/73029 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 306
} | [
2830,
3393,
4021,
2537,
952,
81,
2434,
88025,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
1273,
6031,
909,
266,
329,
538,
5475,
11571,
741,
16867,
3538,
10421,
2822,
17060,
1669,
32978,
7121,
45,
453,
2822,
1166,
52893,
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... | 1 |
func TestWhereFloat32(t *testing.T) {
v := &Value{data: []float32{float32(1), float32(1), float32(1), float32(1), float32(1), float32(1)}}
selected := v.WhereFloat32(func(i int, val float32) bool {
return i%2 == 0
}).MustFloat32Slice()
assert.Equal(t, 3, len(selected))
} | explode_data.jsonl/23508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
9064,
5442,
18,
17,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
3056,
3649,
18,
17,
90,
3649,
18,
17,
7,
16,
701,
2224,
18,
17,
7,
16,
701,
2224,
18,
17,
7,
16,
701,
2224,
18,
17,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInitializeContainerOrderingWithError(t *testing.T) {
containerWithVolumeError := &apicontainer.Container{
Name: "myName",
Image: "image:tag",
VolumesFrom: []apicontainer.VolumeFrom{{SourceContainer: "dummyContainer"}},
}
containerWithLinkError1 := &apicontainer.Container{
Name: "myName1",
Image: "image:tag",
Links: []string{"dummyContainer"},
}
containerWithLinkError2 := &apicontainer.Container{
Name: "myName2",
Image: "image:tag",
Links: []string{"myName:link1:link2"},
}
task1 := &Task{
Arn: "test",
ResourcesMapUnsafe: make(map[string][]taskresource.TaskResource),
Containers: []*apicontainer.Container{containerWithVolumeError, containerWithLinkError1},
}
task2 := &Task{
Arn: "test",
ResourcesMapUnsafe: make(map[string][]taskresource.TaskResource),
Containers: []*apicontainer.Container{containerWithVolumeError, containerWithLinkError2},
}
errVolume1 := task1.initializeContainerOrderingForVolumes()
assert.Error(t, errVolume1)
errLink1 := task1.initializeContainerOrderingForLinks()
assert.Error(t, errLink1)
errVolume2 := task2.initializeContainerOrderingForVolumes()
assert.Error(t, errVolume2)
errLink2 := task2.initializeContainerOrderingForLinks()
assert.Error(t, errLink2)
} | explode_data.jsonl/37263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 501
} | [
2830,
3393,
9928,
4502,
4431,
287,
66102,
1155,
353,
8840,
836,
8,
341,
53290,
2354,
18902,
1454,
1669,
609,
391,
51160,
1743,
33672,
515,
197,
21297,
25,
286,
330,
2408,
675,
756,
197,
53397,
25,
981,
330,
1805,
25,
4578,
756,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTransferInputNotState(t *testing.T) {
intf := interface{}(&TransferInput{})
if _, ok := intf.(verify.State); ok {
t.Fatalf("shouldn't be marked as state")
}
} | explode_data.jsonl/31626 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
21970,
2505,
2623,
1397,
1155,
353,
8840,
836,
8,
341,
2084,
69,
1669,
3749,
6257,
2099,
21970,
2505,
37790,
743,
8358,
5394,
1669,
93706,
12832,
12446,
18942,
1215,
5394,
341,
197,
3244,
30762,
445,
5445,
77,
944,
387,
1286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBadRefresh(t *testing.T) {
s2 := zktest.New()
z, ch, _ := s2.Connect()
badForce := errors.New("nope")
c := 0
z.SetErrorCheck(func(s string) error {
if s == "childrenw" {
c++
}
if c > 2 && s == "childrenw" {
return badForce
}
return nil
})
zkConnFunc := ZkConnCreatorFunc(func() (ZkConn, <-chan zk.Event, error) {
zkp, err := zkplus.NewBuilder().PathPrefix("/test").Connector(&zkplus.StaticConnector{C: z, Ch: ch}).Build()
return zkp, zkp.EventChan(), err
})
d1, _ := New(zkConnFunc, "TestAdvertise1", nil)
require.NoError(t, d1.Advertise("TestAdvertiseService", "", (uint16)(1234)))
s, err := d1.Services("TestAdvertiseService")
require.NoError(t, err)
d1.manualEvents <- zk.Event{
Path: "/TestAdvertiseService",
}
for {
runtime.Gosched()
err := errors.Tail(s.refresh(z))
if err == badForce {
break
}
}
z.SetErrorCheck(nil)
s2.SetErrorCheck(func(s string) error {
return zk.ErrNoNode
})
d1.manualEvents <- zk.Event{
Path: "/TestAdvertiseService",
}
require.NoError(t, s.refresh(z))
require.Equal(t, 0, len(s.ServiceInstances()))
z.SetErrorCheck(nil)
s2.SetErrorCheck(func(s string) error {
return badForce
})
// Verifying that .Services() doesn't cache a bad result
delete(d1.watchedServices, "TestAdvertiseService2")
s, err = d1.Services("TestAdvertiseService2")
require.Error(t, err)
_, exists := d1.watchedServices["TestAdvertiseService2"]
require.False(t, exists)
} | explode_data.jsonl/46865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 616
} | [
2830,
3393,
17082,
14567,
1155,
353,
8840,
836,
8,
341,
1903,
17,
1669,
94528,
1944,
7121,
741,
20832,
11,
521,
11,
716,
1669,
274,
17,
43851,
2822,
2233,
329,
18573,
1669,
5975,
7121,
445,
2152,
375,
1138,
1444,
1669,
220,
15,
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... | 4 |
func TestEventfNoNamespace(t *testing.T) {
testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo",
Name: "foo",
UID: "bar",
},
}
testRef, err := ref.GetPartialReference(scheme.Scheme, testPod, "spec.containers[2]")
if err != nil {
t.Fatal(err)
}
table := []struct {
obj k8sruntime.Object
eventtype string
reason string
messageFmt string
elements []interface{}
expect *v1.Event
expectLog string
expectUpdate bool
}{
{
obj: testRef,
eventtype: v1.EventTypeNormal,
reason: "Started",
messageFmt: "some verbose message: %v",
elements: []interface{}{1},
expect: &v1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "default",
},
InvolvedObject: v1.ObjectReference{
Kind: "Pod",
Name: "foo",
Namespace: "",
UID: "bar",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
Message: "some verbose message: 1",
Source: v1.EventSource{Component: "eventTest"},
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
}
testCache := map[string]*v1.Event{}
logCalled := make(chan struct{})
createEvent := make(chan *v1.Event)
updateEvent := make(chan *v1.Event)
patchEvent := make(chan *v1.Event)
testEvents := testEventSink{
OnCreate: OnCreateFactory(testCache, createEvent),
OnUpdate: func(event *v1.Event) (*v1.Event, error) {
updateEvent <- event
return event, nil
},
OnPatch: OnPatchFactory(testCache, patchEvent),
}
eventBroadcaster := NewBroadcasterForTests(0)
sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
clock := clock.NewFakeClock(time.Now())
recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
for index, item := range table {
clock.Step(1 * time.Second)
logWatcher := eventBroadcaster.StartLogging(func(formatter string, args ...interface{}) {
if e, a := item.expectLog, fmt.Sprintf(formatter, args...); e != a {
t.Errorf("Expected '%v', got '%v'", e, a)
}
logCalled <- struct{}{}
})
recorder.Eventf(item.obj, item.eventtype, item.reason, item.messageFmt, item.elements...)
<-logCalled
// validate event
if item.expectUpdate {
actualEvent := <-patchEvent
validateEvent(strconv.Itoa(index), actualEvent, item.expect, t)
} else {
actualEvent := <-createEvent
validateEvent(strconv.Itoa(index), actualEvent, item.expect, t)
}
logWatcher.Stop()
}
sinkWatcher.Stop()
} | explode_data.jsonl/25870 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1205
} | [
2830,
3393,
1556,
69,
2753,
22699,
1155,
353,
8840,
836,
8,
341,
18185,
23527,
1669,
609,
85,
16,
88823,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
7568,
490,
3939,
25,
3521,
2068,
64413,
4322,
29697,
60555,
756,
298,
212... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpanSlice_CopyTo(t *testing.T) {
dest := NewSpanSlice()
// Test CopyTo to empty
NewSpanSlice().CopyTo(dest)
assert.EqualValues(t, NewSpanSlice(), dest)
// Test CopyTo larger slice
generateTestSpanSlice().CopyTo(dest)
assert.EqualValues(t, generateTestSpanSlice(), dest)
// Test CopyTo same size slice
generateTestSpanSlice().CopyTo(dest)
assert.EqualValues(t, generateTestSpanSlice(), dest)
} | explode_data.jsonl/63257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
12485,
33236,
77637,
1249,
1155,
353,
8840,
836,
8,
341,
49616,
1669,
1532,
12485,
33236,
741,
197,
322,
3393,
14540,
1249,
311,
4287,
198,
197,
3564,
12485,
33236,
1005,
12106,
1249,
27010,
340,
6948,
12808,
6227,
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 TestParseBuildTargetFlag(t *testing.T) {
androidArchs := strings.Join(allArchs("android"), ",")
iosArchs := strings.Join(allArchs("ios"), ",")
tests := []struct {
in string
wantErr bool
wantOS string
wantArchs string
}{
{"android", false, "android", androidArchs},
{"android,android/arm", false, "android", androidArchs},
{"android/arm", false, "android", "arm"},
{"ios", false, "ios", iosArchs},
{"ios,ios/arm64", false, "ios", iosArchs},
{"ios/arm64", false, "ios", "arm64"},
{"ios/amd64", false, "ios", "amd64"},
{"", true, "", ""},
{"linux", true, "", ""},
{"android/x86", true, "", ""},
{"android/arm5", true, "", ""},
{"ios/mips", true, "", ""},
{"android,ios", true, "", ""},
{"ios,android", true, "", ""},
}
for _, tc := range tests {
gotOS, gotArchs, err := parseBuildTarget(tc.in)
if tc.wantErr {
if err == nil {
t.Errorf("-target=%q; want error, got (%q, %q, nil)", tc.in, gotOS, gotArchs)
}
continue
}
if err != nil || gotOS != tc.wantOS || strings.Join(gotArchs, ",") != tc.wantArchs {
t.Errorf("-target=%q; want (%v, [%v], nil), got (%q, %q, %v)",
tc.in, tc.wantOS, tc.wantArchs, gotOS, gotArchs, err)
}
}
} | explode_data.jsonl/33975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 531
} | [
2830,
3393,
14463,
11066,
6397,
12135,
1155,
353,
8840,
836,
8,
341,
197,
5954,
18727,
82,
1669,
9069,
22363,
20388,
18727,
82,
445,
5954,
3975,
3670,
1138,
197,
3530,
18727,
82,
1669,
9069,
22363,
20388,
18727,
82,
445,
3530,
3975,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestBoringServerCipherSuites(t *testing.T) {
serverConfig := testConfig.Clone()
serverConfig.CipherSuites = allCipherSuites()
serverConfig.Certificates = make([]Certificate, 1)
for _, id := range allCipherSuites() {
if isECDSA(id) {
serverConfig.Certificates[0].Certificate = [][]byte{testECDSACertificate}
serverConfig.Certificates[0].PrivateKey = testECDSAPrivateKey
} else {
serverConfig.Certificates[0].Certificate = [][]byte{testRSACertificate}
serverConfig.Certificates[0].PrivateKey = testRSAPrivateKey
}
serverConfig.BuildNameToCertificate()
t.Run(fmt.Sprintf("suite=%#x", id), func(t *testing.T) {
clientHello := &clientHelloMsg{
vers: VersionTLS12,
random: make([]byte, 32),
cipherSuites: []uint16{id},
compressionMethods: []uint8{compressionNone},
supportedCurves: defaultCurvePreferences,
supportedPoints: []uint8{pointFormatUncompressed},
}
testClientHello(t, serverConfig, clientHello)
t.Run("fipstls", func(t *testing.T) {
fipstls.Force()
defer fipstls.Abandon()
msg := ""
if !isBoringCipherSuite(id) {
msg = "no cipher suite supported by both client and server"
}
testClientHelloFailure(t, serverConfig, clientHello, msg)
})
})
}
} | explode_data.jsonl/9397 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 538
} | [
2830,
3393,
33,
5503,
5475,
79460,
62898,
288,
1155,
353,
8840,
836,
8,
341,
41057,
2648,
1669,
1273,
2648,
64463,
741,
41057,
2648,
727,
10558,
62898,
288,
284,
678,
79460,
62898,
288,
741,
41057,
2648,
727,
529,
24405,
284,
1281,
1055... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRow(t *testing.T) {
user1 := User{Name: "RowUser1", Age: 1, Birthday: parseTime("2000-1-1")}
user2 := User{Name: "RowUser2", Age: 10, Birthday: parseTime("2010-1-1")}
user3 := User{Name: "RowUser3", Age: 20, Birthday: parseTime("2020-1-1")}
DB.Save(&user1).Save(&user2).Save(&user3)
row := DB.Table("users").Where("name = ?", user2.Name).Select("age").Row()
var age int64
row.Scan(&age)
if age != 10 {
t.Errorf("Scan with Row")
}
} | explode_data.jsonl/28046 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
3102,
1155,
353,
8840,
836,
8,
341,
19060,
16,
1669,
2657,
63121,
25,
330,
3102,
1474,
16,
497,
13081,
25,
220,
16,
11,
36240,
25,
4715,
1462,
445,
17,
15,
15,
15,
12,
16,
12,
16,
42132,
19060,
17,
1669,
2657,
63121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAtomicUpdate(t *testing.T) {
fakeClient := NewFakeEtcdClient(t)
fakeClient.TestIndex = true
codec := scheme
helper := EtcdHelper{fakeClient, codec, runtime.NewJSONBaseResourceVersioner()}
// Create a new node.
fakeClient.ExpectNotFoundGet("/some/key")
obj := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: 1}
err := helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
return obj, nil
})
if err != nil {
t.Errorf("Unexpected error %#v", err)
}
data, err := codec.Encode(obj)
if err != nil {
t.Errorf("Unexpected error %#v", err)
}
expect := string(data)
got := fakeClient.Data["/some/key"].R.Node.Value
if expect != got {
t.Errorf("Wanted %v, got %v", expect, got)
}
// Update an existing node.
callbackCalled := false
objUpdate := &TestResource{JSONBase: api.JSONBase{ID: "foo"}, Value: 2}
err = helper.AtomicUpdate("/some/key", &TestResource{}, func(in runtime.Object) (runtime.Object, error) {
callbackCalled = true
if in.(*TestResource).Value != 1 {
t.Errorf("Callback input was not current set value")
}
return objUpdate, nil
})
if err != nil {
t.Errorf("Unexpected error %#v", err)
}
data, err = codec.Encode(objUpdate)
if err != nil {
t.Errorf("Unexpected error %#v", err)
}
expect = string(data)
got = fakeClient.Data["/some/key"].R.Node.Value
if expect != got {
t.Errorf("Wanted %v, got %v", expect, got)
}
if !callbackCalled {
t.Errorf("tryUpdate callback should have been called.")
}
} | explode_data.jsonl/28146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 574
} | [
2830,
3393,
65857,
4289,
1155,
353,
8840,
836,
8,
341,
1166,
726,
2959,
1669,
1532,
52317,
31860,
4385,
2959,
1155,
340,
1166,
726,
2959,
8787,
1552,
284,
830,
198,
43343,
66,
1669,
12859,
198,
9598,
2947,
1669,
18888,
4385,
5511,
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... | 1 |
func TestTransformEnums(t *testing.T) {
schema := []byte(`
syntax = "proto3";
package test;
enum Corpus {
UNIVERSAL = 0;
WEB = 1;
IMAGES = 2;
LOCAL = 3;
NEWS = 4;
PRODUCTS = 5;
VIDEO = 6;
}
`)
input := new(bytes.Buffer)
input.Write(schema)
output := new(bytes.Buffer)
transformer := proto2gql.NewTransformer(output)
if err := transformer.Transform(input); err != nil {
t.Fatal(err)
}
expected := `
enum TestCorpus {
UNIVERSAL
WEB
IMAGES
LOCAL
NEWS
PRODUCTS
VIDEO
}
`
expected = strings.TrimSpace(expected)
actual := strings.TrimSpace(output.String())
if expected != actual {
t.Fatalf("Expected %s to equal to %s", expected, actual)
}
} | explode_data.jsonl/2069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
8963,
71586,
1155,
353,
8840,
836,
8,
341,
1903,
3416,
1669,
3056,
3782,
61528,
197,
1903,
13662,
284,
330,
15110,
18,
876,
197,
197,
1722,
1273,
401,
197,
37777,
75734,
341,
298,
76143,
38510,
969,
284,
220,
15,
280,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_DecodeVaultConfig(t *testing.T) {
cases := map[string]struct {
yaml string
expected *secrets.VaultConfig
}{
"happy path - userpass auth": {
yaml: userpassYaml,
expected: &secrets.VaultConfig{
Enabled: true,
Url: "https://vault.com",
AuthMethod: "USERPASS",
Username: "name",
Password: "pw",
UserAuthPath: "userpass",
},
},
"happy path - kubernetes auth with namespace": {
yaml: kubernetesYaml,
expected: &secrets.VaultConfig{
Enabled: true,
Url: "https://vault.com",
AuthMethod: "KUBERNETES",
Path: "kubernetes",
Role: "my-role",
Namespace: "ent-namespace",
},
},
"happy path - token auth": {
yaml: tokenYaml,
expected: &secrets.VaultConfig{
Enabled: true,
Url: "https://vault.com",
AuthMethod: "TOKEN",
},
},
"happy path - disabled": {
yaml: disabledYaml,
expected: &secrets.VaultConfig{
Enabled: false,
Url: "https://vault.com",
AuthMethod: "TOKEN",
},
},
}
for testName, c := range cases {
t.Run(testName, func(t *testing.T) {
any := map[interface{}]interface{}{}
err := yaml.Unmarshal([]byte(c.yaml), &any)
assert.Nil(t, err)
config := extractVaultConfig(any)
assert.EqualValues(t, c.expected, config)
})
}
} | explode_data.jsonl/4150 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 655
} | [
2830,
3393,
78668,
534,
79177,
2648,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
14522,
9467,
914,
198,
197,
42400,
353,
325,
52710,
5058,
945,
2648,
198,
197,
59403,
197,
197,
1,
56521,
1815,
481,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetAgentValue(t *testing.T) {
// Test nil safe
var attrs *Attributes
outstr, outother := attrs.GetAgentValue(attributeRequestURI, destTxnTrace)
if outstr != "" || outother != nil {
t.Error(outstr, outother)
}
c := sampleAttributeConfigInput
c.TransactionTracer.Exclude = []string{"request.uri"}
cfg := CreateAttributeConfig(c, true)
attrs = NewAttributes(cfg)
attrs.Agent.Add(attributeResponseHeadersContentLength, "", 123)
attrs.Agent.Add(attributeRequestMethod, "GET", nil)
attrs.Agent.Add(attributeRequestURI, "/url", nil) // disabled by configuration
outstr, outother = attrs.GetAgentValue(attributeResponseHeadersContentLength, destTxnTrace)
if outstr != "" || outother != 123 {
t.Error(outstr, outother)
}
outstr, outother = attrs.GetAgentValue(attributeRequestMethod, destTxnTrace)
if outstr != "GET" || outother != nil {
t.Error(outstr, outother)
}
outstr, outother = attrs.GetAgentValue(attributeRequestURI, destTxnTrace)
if outstr != "" || outother != nil {
t.Error(outstr, outother)
}
} | explode_data.jsonl/20605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
1949,
16810,
1130,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
2092,
6092,
198,
2405,
16204,
353,
10516,
198,
13967,
495,
11,
700,
1575,
1669,
16204,
2234,
16810,
1130,
45407,
1900,
10301,
11,
3201,
31584,
77,
6550,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestRouteNameFuncs(t *testing.T) {
v4CIDR := "10.0.0.1/16"
v6CIDR := "fd3e:5f02:6ec0:30ba::/64"
nodeName := "thisNode"
routeName := mapNodeNameToRouteName(types.NodeName(nodeName), v4CIDR)
outNodeName := mapRouteNameToNodeName(routeName)
assert.Equal(t, string(outNodeName), nodeName)
routeName = mapNodeNameToRouteName(types.NodeName(nodeName), v6CIDR)
outNodeName = mapRouteNameToNodeName(routeName)
assert.Equal(t, string(outNodeName), nodeName)
} | explode_data.jsonl/70936 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
4899,
675,
9626,
82,
1155,
353,
8840,
836,
8,
341,
5195,
19,
54146,
49,
1669,
330,
16,
15,
13,
15,
13,
15,
13,
16,
14,
16,
21,
698,
5195,
21,
54146,
49,
1669,
330,
6902,
18,
68,
25,
20,
69,
15,
17,
25,
21,
757,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFailGracefullyMissingArg(t *testing.T) {
err := add("localboot", []string{})
if err.Error() != "you need to provide method" {
t.Error("error message should be: you need to provide method")
}
err = add("localboot", []string{"path"})
if err.Error() != "you need to pass DeviceGUID and Kernel path" {
t.Error("error message should be: you need to pass DeviceGUID and Kernel path")
}
err = add("localboot", []string{"path", "device"})
if err.Error() != "you need to pass DeviceGUID and Kernel path" {
t.Error("error message should be: you need to pass DeviceGUID and Kernel path")
}
err = add("netboot", []string{})
if err.Error() != "you need to pass method and MAC address" {
t.Error("error message should be: you need to pass method and MAC address")
}
err = add("netboot", []string{"dhcpv6"})
if err.Error() != "you need to pass method and MAC address" {
t.Error("error message should be: you need to pass method and MAC address")
}
} | explode_data.jsonl/25076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
19524,
86543,
3641,
25080,
2735,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
912,
445,
2438,
4619,
497,
3056,
917,
37790,
743,
1848,
6141,
368,
961,
330,
9330,
1184,
311,
3410,
1714,
1,
341,
197,
3244,
6141,
445,
841,
1943,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_GetCallbackID(t *testing.T) {
t.Run("test", func(t *testing.T) {
assert := base.NewAssert(t)
for i := 0; i < 1000; i++ {
v := NewStream()
id := rand.Uint64()
v.SetCallbackID(id)
assert(v.GetCallbackID()).Equals(id)
v.Release()
}
})
} | explode_data.jsonl/21178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
3027,
13614,
7494,
915,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
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... | 2 |
func TestTaskUpdateNoCert(t *testing.T) {
gd, err := startDispatcher(DefaultConfig())
assert.NoError(t, err)
defer gd.Close()
testTask1 := &api.Task{
ID: "testTask1",
}
err = gd.Store.Update(func(tx store.Tx) error {
assert.NoError(t, store.CreateTask(tx, testTask1))
return nil
})
assert.NoError(t, err)
testTask1.Status = api.TaskStatus{State: api.TaskStateAssigned}
updReq := &api.UpdateTaskStatusRequest{
Updates: []*api.UpdateTaskStatusRequest_TaskStatusUpdate{
{
TaskID: testTask1.ID,
Status: &testTask1.Status,
},
},
}
// without correct SessionID should fail
resp, err := gd.Clients[2].UpdateTaskStatus(context.Background(), updReq)
assert.Nil(t, resp)
assert.Error(t, err)
assert.EqualError(t, err, "rpc error: code = 7 desc = Permission denied: unauthorized peer role: rpc error: code = 7 desc = no client certificates in request")
} | explode_data.jsonl/13856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
6262,
4289,
2753,
36934,
1155,
353,
8840,
836,
8,
341,
3174,
67,
11,
1848,
1669,
1191,
21839,
87874,
2648,
2398,
6948,
35699,
1155,
11,
1848,
340,
16867,
32630,
10421,
2822,
18185,
6262,
16,
1669,
609,
2068,
28258,
515,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApplyAndReturnValidatorSetUpdatesMultipleValueChange(t *testing.T) {
app, ctx, addrs, _ := bootstrapValidatorTest(t, 1000, 20)
powers := []int64{10, 20}
var validators [2]types.Validator
for i, power := range powers {
validators[i] = types.NewValidator(sdk.ValAddress(addrs[i]), PKs[i], types.Description{})
tokens := sdk.TokensFromConsensusPower(power)
validators[i], _ = validators[i].AddTokensFromDel(tokens)
}
validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], false)
validators[1] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[1], false)
require.Equal(t, 2, len(app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)))
// test multiple value change
// tendermintUpdate set: {c1, c3} -> {c1', c3'}
delTokens1 := sdk.TokensFromConsensusPower(190)
delTokens2 := sdk.TokensFromConsensusPower(80)
validators[0], _ = validators[0].AddTokensFromDel(delTokens1)
validators[1], _ = validators[1].AddTokensFromDel(delTokens2)
validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], false)
validators[1] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[1], false)
updates := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, 2, len(updates))
require.Equal(t, validators[0].ABCIValidatorUpdate(), updates[0])
require.Equal(t, validators[1].ABCIValidatorUpdate(), updates[1])
} | explode_data.jsonl/6105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 520
} | [
2830,
3393,
28497,
3036,
5598,
14256,
1649,
37091,
32089,
1130,
4072,
1155,
353,
8840,
836,
8,
341,
28236,
11,
5635,
11,
912,
5428,
11,
716,
1669,
26925,
14256,
2271,
1155,
11,
220,
16,
15,
15,
15,
11,
220,
17,
15,
692,
3223,
15965,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConsoleSocket(t *testing.T) {
for name, conf := range configs(t, all...) {
t.Run(name, func(t *testing.T) {
spec := testutil.NewSpecWithArgs("true")
spec.Process.Terminal = true
_, bundleDir, cleanup, err := testutil.SetupContainer(spec, conf)
if err != nil {
t.Fatalf("error setting up container: %v", err)
}
defer cleanup()
sock, err := socketPath(bundleDir)
if err != nil {
t.Fatalf("error getting socket path: %v", err)
}
srv, cleanup := createConsoleSocket(t, sock)
defer cleanup()
// Create the container and pass the socket name.
args := Args{
ID: testutil.RandomContainerID(),
Spec: spec,
BundleDir: bundleDir,
ConsoleSocket: sock,
}
c, err := New(conf, args)
if err != nil {
t.Fatalf("error creating container: %v", err)
}
defer c.Destroy()
// Make sure we get a console PTY.
ptyMaster, err := receiveConsolePTY(srv)
if err != nil {
t.Fatalf("error receiving console FD: %v", err)
}
ptyMaster.Close()
})
}
} | explode_data.jsonl/61626 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 451
} | [
2830,
3393,
12372,
10286,
1155,
353,
8840,
836,
8,
341,
2023,
829,
11,
2335,
1669,
2088,
42309,
1155,
11,
678,
32574,
341,
197,
3244,
16708,
3153,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
98100,
1669,
1273,
1314,
7121,
8327,
2354,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerragruntRemoteStateCodegenDoesNotGenerateWithSkip(t *testing.T) {
t.Parallel()
generateTestCase := filepath.Join(TEST_FIXTURE_CODEGEN_PATH, "remote-state", "skip")
cleanupTerraformFolder(t, generateTestCase)
cleanupTerragruntFolder(t, generateTestCase)
runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", generateTestCase))
assert.False(t, fileIsInFolder(t, "foo.tfstate", generateTestCase))
} | explode_data.jsonl/10171 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
51402,
68305,
3850,
24703,
1397,
2078,
4370,
21468,
2623,
31115,
2354,
35134,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3174,
13220,
16458,
1669,
26054,
22363,
50320,
42635,
41486,
10020,
11085,
7944,
11,
330,
18147... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKraken_GetOneOrder(t *testing.T) {
ord, err := k.GetOneOrder("ODCRMQ-RDEID-CY334C", goex.BTC_USD)
assert.Nil(t, err)
t.Log(ord)
} | explode_data.jsonl/44497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
81165,
3366,
13614,
3966,
4431,
1155,
353,
8840,
836,
8,
341,
197,
539,
11,
1848,
1669,
595,
2234,
3966,
4431,
445,
2069,
8973,
35169,
10911,
1150,
915,
7658,
56,
18,
18,
19,
34,
497,
728,
327,
1785,
7749,
13467,
35,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSetInitialVersion(t *testing.T) {
db := dbm.NewMemDB()
multi := newMultiStoreWithMounts(db, types.PruneNothing)
require.NoError(t, multi.LoadLatestVersion())
multi.SetInitialVersion(5)
require.Equal(t, int64(5), multi.initialVersion)
multi.Commit()
require.Equal(t, int64(5), multi.LastCommitID().Version)
ckvs := multi.GetCommitKVStore(multi.keysByName["store1"])
iavlStore, ok := ckvs.(*iavl.Store)
require.True(t, ok)
require.True(t, iavlStore.VersionExists(5))
} | explode_data.jsonl/44878 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
1649,
6341,
5637,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
2927,
76,
7121,
18816,
3506,
741,
2109,
7068,
1669,
501,
20358,
6093,
2354,
16284,
82,
9791,
11,
4494,
17947,
2886,
23780,
692,
17957,
35699,
1155,
11,
7299,
13969... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAllSchemesMet(t *testing.T) {
// Create of a map of scheme names and whether they are met
schemes := map[string]bool{
"a": true,
"b": true,
"c": false,
}
// Create the test cases
tc := []struct {
name string
error bool
}{
{
name: "/ok",
error: false,
},
{
name: "/error",
error: true,
},
}
// Create the swagger
swagger := openapi3.Swagger{
OpenAPI: "3.0.0",
Info: &openapi3.Info{
Title: "MyAPI",
Version: "0.1",
},
Paths: map[string]*openapi3.PathItem{},
Components: openapi3.Components{
SecuritySchemes: map[string]*openapi3.SecuritySchemeRef{},
},
}
// Add the security schemes to the swagger's components
for schemeName := range schemes {
swagger.Components.SecuritySchemes[schemeName] = &openapi3.SecuritySchemeRef{
Value: &openapi3.SecurityScheme{
Type: "http",
Scheme: "basic",
},
}
}
// Add the paths to the swagger
for _, tc := range tc {
// Create the security requirement for the path
securityRequirement := openapi3.SecurityRequirement{}
for scheme, valid := range schemes {
// If the scheme is valid or the test case is meant to return an error
if valid || tc.error {
// Add the scheme to the security requirement
securityRequirement[scheme] = []string{}
}
}
swagger.Paths[tc.name] = &openapi3.PathItem{
Get: &openapi3.Operation{
Security: &openapi3.SecurityRequirements{
securityRequirement,
},
Responses: make(openapi3.Responses),
},
}
}
// Create the router from the swagger
router := openapi3filter.NewRouter().WithSwagger(&swagger)
// Create the authentication function
authFunc := makeAuthFunc(schemes)
for _, tc := range tc {
// Create the request input for the path
tcUrl, err := url.Parse(tc.name)
require.NoError(t, err)
route, _, err := router.FindRoute(http.MethodGet, tcUrl)
require.NoError(t, err)
req := openapi3filter.RequestValidationInput{
Route: route,
Options: &openapi3filter.Options{
AuthenticationFunc: authFunc,
},
}
// Validate the security requirements
err = openapi3filter.ValidateSecurityRequirements(context.TODO(), &req, *route.Operation.Security)
// If there should have been an error
if tc.error {
require.Error(t, err)
} else {
require.NoError(t, err)
}
}
} | explode_data.jsonl/41698 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 905
} | [
2830,
3393,
2403,
50,
66346,
34673,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
315,
264,
2415,
315,
12859,
5036,
323,
3425,
807,
525,
2270,
198,
1903,
66346,
1669,
2415,
14032,
96436,
515,
197,
197,
56693,
788,
830,
345,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestAbstractClassMethod(t *testing.T) {
src := `<? abstract class Foo{ abstract public function bar(); }`
expected := &node.Root{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
EndPos: 56,
},
Stmts: []node.Node{
&stmt.Class{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
EndPos: 56,
},
PhpDocComment: "",
ClassName: &node.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 19,
EndPos: 21,
},
Value: "Foo",
},
Modifiers: []node.Node{
&node.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 4,
EndPos: 11,
},
Value: "abstract",
},
},
Stmts: []node.Node{
&stmt.ClassMethod{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 54,
},
ReturnsRef: false,
PhpDocComment: "",
MethodName: &node.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 49,
EndPos: 51,
},
Value: "bar",
},
Modifiers: []node.Node{
&node.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 24,
EndPos: 31,
},
Value: "abstract",
},
&node.Identifier{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 33,
EndPos: 38,
},
Value: "public",
},
},
Stmt: &stmt.Nop{
Position: &position.Position{
StartLine: 1,
EndLine: 1,
StartPos: 54,
EndPos: 54,
},
},
},
},
},
},
}
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
php7parser.Parse()
actual := php7parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
php5parser.Parse()
actual = php5parser.GetRootNode()
assert.DeepEqual(t, expected, actual)
} | explode_data.jsonl/65931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1233
} | [
2830,
3393,
15949,
1957,
3523,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
1565,
1316,
8115,
536,
33428,
90,
8115,
584,
729,
3619,
2129,
335,
19324,
42400,
1669,
609,
3509,
45345,
515,
197,
197,
3812,
25,
609,
3487,
21954,
515,
298,
65... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSpotBillDetailsForCurrency(t *testing.T) {
request := okgroup.GetSpotBillDetailsForCurrencyRequest{
Currency: currency.BTC.String(),
Limit: 100,
}
_, err := o.GetSpotBillDetailsForCurrency(request)
testStandardErrorHandling(t, err)
} | explode_data.jsonl/30153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
1949,
47049,
27476,
7799,
2461,
26321,
1155,
353,
8840,
836,
8,
341,
23555,
1669,
5394,
4074,
2234,
47049,
27476,
7799,
2461,
26321,
1900,
515,
197,
6258,
5088,
25,
11413,
1785,
7749,
6431,
3148,
197,
15070,
2353,
25,
262,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSizeGenerateConstArg(t *testing.T) {
target, rs, iters := initRandomTargetTest(t, "test", "64")
r := newRand(target, rs)
ForeachType(target.Syscalls, func(typ Type, ctx *TypeCtx) {
if _, ok := typ.(*IntType); !ok {
return
}
bits := typ.TypeBitSize()
limit := uint64(1<<bits - 1)
for i := 0; i < iters; i++ {
newArg, _ := typ.generate(r, nil, ctx.Dir)
newVal := newArg.(*ConstArg).Val
if newVal > limit {
t.Fatalf("invalid generated value: %d. (arg bitsize: %d; max value: %d)", newVal, bits, limit)
}
}
})
} | explode_data.jsonl/73780 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
1695,
31115,
19167,
2735,
1155,
353,
8840,
836,
8,
341,
28861,
11,
10036,
11,
432,
388,
1669,
2930,
13999,
6397,
2271,
1155,
11,
330,
1944,
497,
330,
21,
19,
1138,
7000,
1669,
501,
56124,
8637,
11,
10036,
340,
12727,
8539,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Token_TextNotEquals(t *testing.T) {
token := Token{
text: []Text{
[]byte("one"),
[]byte("two"),
},
}
assert.False(t, token.TextEquals("one-two"))
} | explode_data.jsonl/78429 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
1139,
1679,
20550,
2623,
4315,
1155,
353,
8840,
836,
8,
341,
43947,
1669,
9660,
515,
197,
15425,
25,
3056,
1178,
515,
298,
197,
1294,
3782,
445,
603,
4461,
298,
197,
1294,
3782,
445,
19789,
4461,
197,
197,
1583,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExists(t *testing.T) {
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
exists, err := client.Exists().Index(testIndexName).Type("comment").Id("1").Parent("tweet").Do()
if err != nil {
t.Fatal(err)
}
if !exists {
t.Fatal("expected document to exist")
}
} | explode_data.jsonl/43657 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
15575,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
6505,
2271,
2959,
3036,
4021,
1552,
3036,
2212,
63107,
1155,
8,
442,
11,
2573,
6550,
2201,
12531,
7121,
9638,
83225,
11,
7342,
220,
15,
19235,
8122,
1671,
11,
1848,
1669,
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... | 3 |
func TestServerKeepAliveAfterWriteError(t *testing.T) {
if testing.Short() {
t.Skip("skipping in -short mode")
}
defer afterTest(t)
const numReq = 3
addrc := make(chan string, numReq)
ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {
addrc <- r.RemoteAddr
time.Sleep(500 * time.Millisecond)
w.(Flusher).Flush()
}))
ts.Config.WriteTimeout = 250 * time.Millisecond
ts.Start()
defer ts.Close()
errc := make(chan error, numReq)
go func() {
defer close(errc)
for i := 0; i < numReq; i++ {
res, err := Get(ts.URL)
if res != nil {
res.Body.Close()
}
errc <- err
}
}()
timeout := time.NewTimer(numReq * 2 * time.Second) // 4x overkill
defer timeout.Stop()
addrSeen := map[string]bool{}
numOkay := 0
for {
select {
case v := <-addrc:
addrSeen[v] = true
case err, ok := <-errc:
if !ok {
if len(addrSeen) != numReq {
t.Errorf("saw %d unique client addresses; want %d", len(addrSeen), numReq)
}
if numOkay != 0 {
t.Errorf("got %d successful client requests; want 0", numOkay)
}
return
}
if err == nil {
numOkay++
}
case <-timeout.C:
t.Fatal("timeout waiting for requests to complete")
}
}
} | explode_data.jsonl/22479 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
5475,
19434,
32637,
6025,
7985,
1454,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
304,
481,
8676,
3856,
1138,
197,
532,
16867,
1283,
2271,
1155,
340,
4777,
1629,
27234,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClustersReplicationFactorMaxLower(t *testing.T) {
ctx := context.Background()
if nClusters < 5 {
t.Skip("Need at least 5 peers")
}
clusters, mock := createClusters(t)
defer shutdownClusters(t, clusters, mock)
for _, c := range clusters {
c.config.ReplicationFactorMin = 1
c.config.ReplicationFactorMax = nClusters
}
ttlDelay() // make sure we have places to pin
h := test.Cid1
_, err := clusters[0].Pin(ctx, h, api.PinOptions{})
if err != nil {
t.Fatal(err)
}
pinDelay()
p1, err := clusters[0].PinGet(ctx, h)
if err != nil {
t.Fatal(err)
}
if len(p1.Allocations) != nClusters {
t.Fatal("allocations should be nClusters")
}
opts := api.PinOptions{
ReplicationFactorMin: 1,
ReplicationFactorMax: 2,
}
_, err = clusters[0].Pin(ctx, h, opts)
if err != nil {
t.Fatal(err)
}
pinDelay()
p2, err := clusters[0].PinGet(ctx, h)
if err != nil {
t.Fatal(err)
}
if len(p2.Allocations) != 2 {
t.Fatal("allocations should have been reduced to 2")
}
} | explode_data.jsonl/66613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
94992,
18327,
1693,
20661,
5974,
9053,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
743,
308,
94992,
366,
220,
20,
341,
197,
3244,
57776,
445,
23657,
518,
3245,
220,
20,
25029,
1138,
197,
630,
39407,
14605,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestARP(t *testing.T) {
arp := filter.NewBuilder().
LD(filter.Half, filter.ABS, 12).
JEQ(filter.Const, "", "fail", 0x806).
RET(filter.Const, 0x40000).
Label("fail").
RET(filter.Const, 0x0).
Build()
if arp.String() != test_arp {
t.Fatalf("Program mismatch: %s", arp.String())
}
} | explode_data.jsonl/11713 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
42793,
1155,
353,
8840,
836,
8,
341,
262,
98598,
1669,
4051,
7121,
3297,
25829,
286,
28877,
19704,
3839,
3104,
11,
4051,
875,
7347,
11,
220,
16,
17,
4292,
286,
619,
54007,
19704,
4801,
267,
11,
7342,
330,
18403,
497,
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... | 2 |
func TestDevAutoSync(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
dir := "examples/jib-sync/"
tests := []struct {
description string
configFile string
profiles []string
uniqueStr string
}{
{
description: "jib maven auto sync",
configFile: "skaffold-maven.yaml",
uniqueStr: "maven-maven",
},
{
description: "jib gradle auto sync",
configFile: "skaffold-gradle.yaml",
uniqueStr: "gradle-gradle",
},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
// Run skaffold build first to fail quickly on a build failure
skaffold.Build().WithConfig(test.configFile).InDir(dir).RunOrFail(t)
ns, client := SetupNamespace(t)
output := skaffold.Dev("--trigger", "notify").WithConfig(test.configFile).InDir(dir).InNs(ns.Name).RunLive(t)
client.WaitForPodsReady("test-file-sync")
// give the server a chance to warm up, this integration test on slow environments (KIND on travis)
// fails because of a potential server race condition.
scanner := bufio.NewScanner(output)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, "Started Application") {
err := output.Close()
if err != nil {
t.Fatal("failed to close skaffold dev output reader during test")
}
return
}
}
// direct file sync (this file is an existing file checked in for this testdata)
directFile := "direct-file"
directFilePath := dir + "src/main/jib/" + directFile
directFileData := "direct-data"
if err := ioutil.WriteFile(directFilePath, []byte(directFileData), 0644); err != nil {
t.Fatalf("Failed to write local file to sync %s", directFilePath)
}
defer func() { os.Truncate(directFilePath, 0) }()
err := wait.PollImmediate(time.Millisecond*500, 1*time.Minute, func() (bool, error) {
out, _ := exec.Command("kubectl", "exec", "test-file-sync", "-n", ns.Name, "--", "cat", directFile).Output()
return string(out) == directFileData, nil
})
failNowIfError(t, err)
// compile and sync
generatedFileSrc := dir + "src/main/java/hello/HelloController.java"
if oldContents, err := ioutil.ReadFile(generatedFileSrc); err != nil {
t.Fatalf("Failed to read file %s", generatedFileSrc)
} else {
newContents := strings.Replace(string(oldContents), "text-to-replace", test.uniqueStr, 1)
if err := ioutil.WriteFile(generatedFileSrc, []byte(newContents), 0644); err != nil {
t.Fatalf("Failed to write new contents to file %s", generatedFileSrc)
}
defer func() {
ioutil.WriteFile(generatedFileSrc, oldContents, 0644)
}()
}
err = wait.PollImmediate(time.Millisecond*500, 1*time.Minute, func() (bool, error) {
// distroless debug only has wget, not curl
out, _ := exec.Command("kubectl", "exec", "test-file-sync", "-n", ns.Name, "--", "wget", "localhost:8080/", "-q", "-O", "-").Output()
return string(out) == test.uniqueStr, nil
})
failNowIfError(t, err)
})
}
} | explode_data.jsonl/4865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1192
} | [
2830,
3393,
14592,
13253,
12154,
1155,
353,
8840,
836,
8,
341,
197,
8949,
52464,
2271,
1155,
11,
2980,
6727,
26040,
38,
4672,
692,
48532,
1669,
330,
51668,
4437,
579,
65034,
85312,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue26977(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
result := tk.MustQuery("select a + 1 as f from (select cast(0xfffffffffffffff0 as unsigned) as a union select cast(1 as unsigned)) t having f != 2;")
result.Check(testkit.Rows("18446744073709551601"))
} | explode_data.jsonl/65606 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
42006,
17,
21,
24,
22,
22,
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,
9559,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNgramEditDist(t *testing.T) {
argument1 := "example text"
argument2 := "exampl text"
want := 1
got := ngramEditDist(argument1, argument2)
if got != want {
t.Errorf("ngramEditDist(%#v, %#v) = %d, wanted %d", argument1, argument2, got, want)
}
} | explode_data.jsonl/11614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
45,
1520,
4036,
23356,
1155,
353,
8840,
836,
8,
341,
197,
14479,
16,
1669,
330,
8687,
1467,
698,
197,
14479,
17,
1669,
330,
41616,
500,
1467,
698,
50780,
1669,
220,
16,
198,
3174,
354,
1669,
308,
1520,
4036,
23356,
68485,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTicker_C4(t *testing.T) {
//return
product := "btc_" + common.NativeToken
timeMap := GetTimes()
kline15s := prepareKlineMx(product, 15*60, 100.0, 100.0, 100.0, 100.0, []float64{100}, timeMap["-24h"], timeMap["-60m"])
kline1s1 := prepareKlineMx(product, 60, 40.0, 40.0, 40.0, 40.0, []float64{40, 60}, timeMap["-15m"], timeMap["-5m"])
kline1s2 := prepareKlineMx(product, 60, 98.0, 99.0, 98.0, 99.0, []float64{100}, timeMap["-5m"], timeMap["now"])
matches := prepareMatches(product, []float64{98.0, 99.0}, []float64{98, 2}, timeMap["now"])
var kline1s []interface{}
kline1s = append(kline1s, kline1s1...)
kline1s = append(kline1s, kline1s2...)
fakeLatestTickers := &map[string]*types.Ticker{}
orm, dbPath := orm.MockSqlite3ORM()
//defer DeleteDB(dbPath)
err := baseCaseRunner(t, product, nil, timeMap["-21d"], timeMap["-21d"]+1, kline15s, kline1s, matches,
nil, fakeLatestTickers, orm, true)
assert.True(t, err == nil)
tickerInNext1M := aTicker(product, 100.0, 99.0, 100.0, 40.0, 99.0, 300.0)
for i := 1; i <= 60; i++ {
err = baseCaseRunner(t, product, nil, timeMap["-24h"], timeMap["now"]+int64(i), kline15s, kline1s, matches, tickerInNext1M, fakeLatestTickers, orm, false)
require.Nil(t, err)
}
tickerInNext1M2M := tickerInNext1M
for i := 61; i <= 120; i++ {
err = baseCaseRunner(t, product, nil, timeMap["-24h"], timeMap["now"]+int64(i), kline15s, kline1s, matches, tickerInNext1M2M, fakeLatestTickers, orm, false)
require.Nil(t, err)
}
tickerInNext2M5M := tickerInNext1M
for i := 121; i <= 300; i++ {
err = baseCaseRunner(t, product, nil, timeMap["-24h"], timeMap["now"]+int64(i), kline15s, kline1s, matches, tickerInNext2M5M, fakeLatestTickers, orm, false)
require.Nil(t, err)
}
tickerInNext5M15M := tickerInNext1M
for i := 301; i <= 900; i++ {
expectTS := timeMap["now"] + int64(i)
tickerInNext5M15M.Timestamp = expectTS
err = baseCaseRunner(t, product, nil, timeMap["-24h"], expectTS, kline15s, kline1s, matches, tickerInNext5M15M, fakeLatestTickers, orm, false)
require.Nil(t, err)
}
fmt.Println(dbPath)
} | explode_data.jsonl/37823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 914
} | [
2830,
3393,
87278,
920,
19,
1155,
353,
8840,
836,
8,
341,
197,
322,
689,
271,
69288,
1669,
330,
92634,
18771,
488,
4185,
68624,
3323,
198,
21957,
2227,
1669,
2126,
18889,
741,
16463,
1056,
16,
20,
82,
1669,
10549,
42,
1056,
44,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_TransactionLostRequest(t *testing.T) {
mct := newMemcacheTest(defaultConfig)
trans := mct.genTransaction(
nil,
textParseNoFail(t, "STORED\r\n"),
)
assert.Equal(t, common.CLIENT_ERROR_STATUS, trans.Status)
assert.Equal(t, uint64(0), trans.BytesOut)
assert.Equal(t, uint64(8), trans.BytesIn)
assert.Equal(t, trans, mct.transactions[0])
event := makeTransactionEvent(t, trans)
assert.Equal(t, "memcache", event["type"])
assert.Equal(t, common.CLIENT_ERROR_STATUS, event["status"])
} | explode_data.jsonl/15062 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
34932,
1311,
47253,
1900,
1155,
353,
8840,
836,
8,
341,
2109,
302,
1669,
501,
18816,
9360,
2271,
18978,
2648,
340,
72453,
1669,
296,
302,
22822,
8070,
1006,
197,
84131,
345,
197,
15425,
14463,
2753,
19524,
1155,
11,
330,
439... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintRoleBindingRestriction(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
rbrs := mockRoleBindingRestriction()
tests := []struct {
name string
rbr *authorizationapi.RoleBindingRestriction
expectedOut string
expectedErr error
}{
{
name: "output check",
rbr: rbrs[0],
expectedOut: "match-serviceaccount\tServiceAccount\t/*\n",
},
}
for _, test := range tests {
if err := printRoleBindingRestriction(test.rbr, buf, kprinters.PrintOptions{}); err != test.expectedErr {
t.Errorf("error mismatch: expected %v, got %v", test.expectedErr, err)
continue
}
got := buf.String()
buf.Reset()
if !strings.Contains(got, test.expectedOut) {
t.Errorf("unexpected output:\n%s\nexpected to contain: %s", got, test.expectedOut)
continue
}
}
} | explode_data.jsonl/61176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 334
} | [
2830,
3393,
8994,
9030,
15059,
50360,
2479,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
5820,
7121,
4095,
10556,
3782,
37790,
7000,
1323,
82,
1669,
7860,
9030,
15059,
50360,
2479,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMongoDB_ConfigSvrDSN(t *testing.T) {
mongodb := &MongoDB{
ObjectMeta: metav1.ObjectMeta{
Name: "demo-name",
Namespace: "demo",
Labels: map[string]string{
"app": "kubedb",
},
},
Spec: MongoDBSpec{
Version: "3.6-v2",
ShardTopology: &MongoDBShardingTopology{
Shard: MongoDBShardNode{
Shards: 3,
MongoDBNode: MongoDBNode{
Replicas: 3,
},
Storage: &core.PersistentVolumeClaimSpec{
Resources: core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceStorage: resource.MustParse("1Gi"),
},
},
StorageClassName: types.StringP("standard"),
},
},
ConfigServer: MongoDBConfigNode{
MongoDBNode: MongoDBNode{
Replicas: 3,
},
Storage: &core.PersistentVolumeClaimSpec{
Resources: core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceStorage: resource.MustParse("1Gi"),
},
},
StorageClassName: types.StringP("standard"),
},
},
Mongos: MongoDBMongosNode{
MongoDBNode: MongoDBNode{
Replicas: 2,
},
},
},
},
}
configDSN := mongodb.ConfigSvrDSN()
t.Log(configDSN)
} | explode_data.jsonl/37754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 590
} | [
2830,
3393,
54998,
3506,
35412,
50,
18920,
5936,
45,
1155,
353,
8840,
836,
8,
341,
2109,
21225,
1669,
609,
54998,
3506,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
25762,
11494,
756,
298,
90823,
25,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTypeSystem_SchemaMustHaveObjectRootTypes_AcceptsASchemaWhoseQueryAndMutationTypesAreObjectType(t *testing.T) {
mutationObject := graphql.NewObject(graphql.ObjectConfig{
Name: "Mutation",
Fields: graphql.Fields{
"edit": &graphql.Field{
Type: graphql.String,
},
},
})
_, err := graphql.NewSchema(graphql.SchemaConfig{
Query: someObjectType,
Mutation: mutationObject,
})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
} | explode_data.jsonl/79137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
929,
2320,
1098,
3416,
31776,
12116,
1190,
8439,
4173,
1566,
66,
57771,
1911,
3416,
1639,
960,
2859,
3036,
53998,
4173,
11526,
49530,
1155,
353,
8840,
836,
8,
341,
2109,
22705,
1190,
1669,
48865,
7121,
1190,
24312,
1470,
8348,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidationNotEqualError_Error(t *testing.T) {
tests := []struct {
name string
v ValidationNotEqualError
want string
}{
{"Test Error", ValidationNotEqualError{}, "validation error"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.v.Error(); got != tt.want {
t.Errorf("ValidationNotEqualError.Error() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/32121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
13799,
2623,
2993,
1454,
28651,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
5195,
262,
18954,
2623,
2993,
1454,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
4913,
2271,
4600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAgent_PassCheck_ACLDeny(t *testing.T) {
t.Parallel()
a := NewTestAgent(t.Name(), TestACLConfig())
defer a.Shutdown()
chk := &structs.HealthCheck{Name: "test", CheckID: "test"}
chkType := &structs.CheckType{TTL: 15 * time.Second}
if err := a.AddCheck(chk, chkType, false, ""); err != nil {
t.Fatalf("err: %v", err)
}
t.Run("no token", func(t *testing.T) {
req, _ := http.NewRequest("PUT", "/v1/agent/check/pass/test", nil)
if _, err := a.srv.AgentCheckPass(nil, req); !acl.IsErrPermissionDenied(err) {
t.Fatalf("err: %v", err)
}
})
t.Run("root token", func(t *testing.T) {
req, _ := http.NewRequest("PUT", "/v1/agent/check/pass/test?token=root", nil)
if _, err := a.srv.AgentCheckPass(nil, req); err != nil {
t.Fatalf("err: %v", err)
}
})
} | explode_data.jsonl/33618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
16810,
1088,
395,
3973,
97627,
23619,
88,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
3393,
55393,
2648,
2398,
16867,
264,
10849,
18452,
2822,
23049,
74,
1669,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewMetric(t *testing.T) {
framework.
NewTest(t).
RequiresEnvironment(environment.Kube).
Run(func(ctx framework.TestContext) {
ctx.ApplyConfigOrFail(ctx, "",
bookinfo.DoubleMetric.LoadOrFail(ctx))
defer ctx.DeleteConfigOrFail(ctx, "",
bookinfo.DoubleMetric.LoadOrFail(ctx))
util.AllowRuleSync(t)
addr := ing.HTTPAddress()
url := fmt.Sprintf("http://%s/productpage", addr.String())
retry.UntilSuccessOrFail(t, func() error {
res := util.SendTraffic(ing, t, "Sending traffic", url, "", 10)
if res.RetCodes[200] < 1 {
return fmt.Errorf("unable to retrieve 200 from product page: %v", res.RetCodes)
}
return nil
}, retry.Delay(time.Second))
// We are expecting double request count, so we should see at least 2 requests here
util.ValidateMetric(t, prom, "sum(istio_double_request_count{message=\"twice the fun!\"})", "istio_double_request_count", 2)
})
} | explode_data.jsonl/51139 | {
"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,
3564,
54310,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
624,
197,
197,
3564,
2271,
1155,
4292,
197,
197,
46961,
12723,
67591,
11352,
3760,
4292,
197,
85952,
18552,
7502,
12626,
8787,
1972,
8,
341,
298,
20985,
36051,
2648,
460... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEndOfStreamError_Error(t *testing.T) {
tests := []struct {
name string
e EndOfStreamError
want string
}{
{"Test Error", EndOfStreamError{}, "unexpected end of stream"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.e.Error(); got != tt.want {
t.Errorf("EndOfStreamError.Error() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/32119 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
3727,
2124,
3027,
1454,
28651,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
3972,
2124,
3027,
1454,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
4913,
2271,
4600,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodeToStringNoProperties(t *testing.T) {
node := neo4j.Node{
Id: 2,
Labels: []string{`Something`},
Props: map[string]interface{}{},
}
actual := input.ToString(node)
expected := `(:Something)`
if actual != expected {
t.Fatalf(`expected '%v' but got '%v'`, expected, actual)
}
} | explode_data.jsonl/7073 | {
"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,
1955,
5870,
2753,
7903,
1155,
353,
8840,
836,
8,
341,
20831,
1669,
35082,
19,
73,
21714,
515,
197,
67211,
25,
257,
220,
17,
345,
197,
197,
23674,
25,
3056,
917,
90,
63,
23087,
63,
1583,
197,
197,
5992,
25,
220,
2415,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckSavepointHappyCase(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
ctx := context.Background()
response := SavepointResponse{
SavepointStatus: SavepointStatusResponse{
Status: SavePointInProgress,
},
}
responder, _ := httpmock.NewJsonResponder(200, response)
httpmock.RegisterResponder("GET", fakeSavepointURL, responder)
client := getTestJobManagerClient()
resp, err := client.CheckSavepointStatus(ctx, testURL, "1", "2")
assert.Equal(t, response, *resp)
assert.NoError(t, err)
} | explode_data.jsonl/32360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
3973,
8784,
2768,
32847,
4207,
1155,
353,
8840,
836,
8,
341,
28080,
16712,
14140,
731,
741,
16867,
1758,
16712,
8934,
16856,
3036,
14828,
741,
20985,
1669,
2266,
19047,
741,
21735,
1669,
10255,
2768,
2582,
515,
197,
7568,
523,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAssertionUnmarshaledFromYAML(t *testing.T) {
assertionsYAML := `
- equal:
- notEqual:
- matchRegex:
- notMatchRegex:
- contains:
- notContains:
- isNull:
- isNotNull:
- isEmpty:
- isNotEmpty:
- isKind:
- isAPIVersion:
- hasDocuments:
`
assertionsAsMap := make([]map[string]interface{}, 13)
yaml.Unmarshal([]byte(assertionsYAML), &assertionsAsMap)
assertions := make([]Assertion, 13)
yaml.Unmarshal([]byte(assertionsYAML), &assertions)
a := assert.New(t)
for idx, assertion := range assertions {
_, ok := assertionsAsMap[idx][assertion.AssertType]
a.True(ok)
a.False(assertion.Not)
}
} | explode_data.jsonl/62919 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
68639,
1806,
36239,
5838,
3830,
56,
31102,
1155,
353,
8840,
836,
8,
341,
6948,
908,
56,
31102,
1669,
22074,
12,
6144,
510,
12,
537,
2993,
510,
12,
2432,
32464,
510,
12,
537,
8331,
32464,
510,
12,
5610,
510,
12,
537,
2380... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_changeRefresh(t *testing.T) {
t.Run("valid", func(t *testing.T) {
config := newConfig()
config.view = config.views["activity"]
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
v := <-config.viewCh
assert.Equal(t, v.Refresh, 5*time.Second)
wg.Done()
}()
assert.Equal(t, "Refresh: ok", changeRefresh("5", config))
wg.Wait()
close(config.viewCh)
})
// test invalid input
t.Run("invalid input", func(t *testing.T) {
config := newConfig()
config.view = config.views["activity"]
testcases := map[string]string{
"": "Refresh: do nothing",
"a": "Refresh: do nothing, invalid input",
"0.5": "Refresh: do nothing, invalid input",
"-1": "Refresh: input value should be between 1 and 300",
"0": "Refresh: input value should be between 1 and 300",
"301": "Refresh: input value should be between 1 and 300",
}
for k, v := range testcases {
config.view.Refresh = 1 * time.Second
assert.Equal(t, v, changeRefresh(k, config))
assert.Equal(t, 1*time.Second, config.view.Refresh) // should not be 0
}
})
} | explode_data.jsonl/69236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 439
} | [
2830,
3393,
15947,
14567,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1891,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
25873,
1669,
501,
2648,
741,
197,
25873,
3792,
284,
2193,
22056,
1183,
7175,
7026,
197,
72079,
1669,
12811,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerSecureBadPassphrase(t *testing.T) {
withSSL(t, "127.0.0.1", "foo")
name := path.Join(tmpCertPath, t.Name())
cfg, err := common.NewConfigFrom(map[string]map[string]interface{}{
"ssl": {
"certificate": name + ".pem",
"key": name + ".key",
"key_passphrase": "bar",
},
})
assert.NoError(t, err)
_, _, err = setupServer(t, cfg, nil)
if assert.Error(t, err) {
b := strings.Contains(err.Error(), "no PEM blocks") ||
strings.Contains(err.Error(), "failed to parse private key")
assert.True(t, b, err.Error())
}
} | explode_data.jsonl/4948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
5475,
49813,
17082,
12187,
27710,
1155,
353,
8840,
836,
8,
341,
46948,
22594,
1155,
11,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
497,
330,
7975,
1138,
11609,
1669,
1815,
22363,
10368,
36934,
1820,
11,
259,
2967,
2398,
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... | 3 |
func TestResources_Invalidate(t *testing.T) {
tests := []struct {
name string
resources *v1beta1.TaskRunResources
wantErr *apis.FieldError
}{{
name: "duplicate task inputs",
resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "testresource1",
},
Name: "workspace",
},
}, {
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "testresource2",
},
Name: "workspace",
},
}},
},
wantErr: apis.ErrMultipleOneOf("spec.resources.inputs.name"),
}, {
name: "duplicate resource ref and resource spec",
resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "testresource",
},
ResourceSpec: &resource.PipelineResourceSpec{
Type: v1beta1.PipelineResourceTypeGit,
},
Name: "resource-dup",
},
}},
},
wantErr: apis.ErrDisallowedFields("spec.resources.inputs.name.resourceRef", "spec.resources.inputs.name.resourceSpec"),
}, {
name: "invalid resource spec",
resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceSpec: &resource.PipelineResourceSpec{
Type: "non-existent",
},
Name: "resource-inv",
},
}},
},
wantErr: apis.ErrInvalidValue("spec.type", "non-existent"),
}, {
name: "no resource ref", // and resource spec
resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "resource",
},
}},
},
wantErr: apis.ErrMissingField("spec.resources.inputs.name.resourceRef", "spec.resources.inputs.name.resourceSpec"),
}, {
name: "duplicate task outputs",
resources: &v1beta1.TaskRunResources{
Outputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "testresource1",
},
Name: "workspace",
},
}, {
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "testresource2",
},
Name: "workspace",
},
}},
},
wantErr: apis.ErrMultipleOneOf("spec.resources.outputs.name"),
}, {
name: "duplicate resource ref and resource spec",
resources: &v1beta1.TaskRunResources{
Outputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "testresource",
},
ResourceSpec: &resource.PipelineResourceSpec{
Type: v1beta1.PipelineResourceTypeGit,
},
Name: "resource-dup",
},
}},
},
wantErr: apis.ErrDisallowedFields("spec.resources.outputs.name.resourceRef", "spec.resources.outputs.name.resourceSpec"),
}, {
name: "invalid resource spec",
resources: &v1beta1.TaskRunResources{
Inputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
ResourceSpec: &resource.PipelineResourceSpec{
Type: "non-existent",
},
Name: "resource-inv",
},
}},
},
wantErr: apis.ErrInvalidValue("spec.type", "non-existent"),
}, {
name: "no resource ref ", // and resource spec
resources: &v1beta1.TaskRunResources{
Outputs: []v1beta1.TaskResourceBinding{{
PipelineResourceBinding: v1beta1.PipelineResourceBinding{
Name: "resource",
},
}},
},
wantErr: apis.ErrMissingField("spec.resources.outputs.name.resourceRef", "spec.resources.outputs.name.resourceSpec"),
}}
for _, ts := range tests {
t.Run(ts.name, func(t *testing.T) {
err := ts.resources.Validate(context.Background())
if d := cmp.Diff(err.Error(), ts.wantErr.Error()); d != "" {
t.Errorf("TaskRunInputs.Validate/%s %s", ts.name, diff.PrintWantGot(d))
}
})
}
} | explode_data.jsonl/82032 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1785
} | [
2830,
3393,
11277,
25972,
7067,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
10202,
2360,
353,
85,
16,
19127,
16,
28258,
6727,
11277,
198,
197,
50780,
7747,
256,
353,
13725,
17087,
1454,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetId(t *testing.T) {
entityId := "entity-id"
tests := map[string]struct {
entity *entity
expectedEntityId string
}{
"TestGetId": {
entity: &entity{entityId},
expectedEntityId: entityId,
},
"TestGetEmptyId": {
entity: &entity{},
expectedEntityId: "",
},
}
for testName, testCase := range tests {
t.Run(testName, func(t *testing.T) {
entityId := testCase.entity.GetId()
if !reflect.DeepEqual(testCase.expectedEntityId, entityId) {
t.Errorf(
"Expected entity id %+v, got %+v",
testCase.expectedEntityId,
entityId,
)
}
})
}
} | explode_data.jsonl/72413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
1949,
764,
1155,
353,
8840,
836,
8,
341,
52987,
764,
1669,
330,
2996,
12897,
1837,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
52987,
1843,
353,
2996,
198,
197,
42400,
3030,
764,
914,
198,
197,
59403,
197,
197,
1,
2271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSANNotEmptyName(t *testing.T) {
inputPath := "SANCaGood.pem"
expected := lint.Pass
out := test.TestLint("e_ext_san_empty_name", inputPath)
if out.Status != expected {
t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
}
} | explode_data.jsonl/75680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
68691,
27416,
675,
1155,
353,
8840,
836,
8,
341,
22427,
1820,
1669,
330,
68691,
22571,
15216,
49373,
698,
42400,
1669,
57920,
87768,
198,
13967,
1669,
1273,
8787,
47556,
445,
68,
9927,
87866,
15124,
1269,
497,
1946,
1820,
340,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_DeleteEmptyId(t *testing.T) {
// arrange
store := &orderTestRepo{
DeleteResult: struct{ Err error }{Err: nil},
}
svr := api.NewOrderServer(store)
ctx := context.Background()
// act
_, err := svr.Delete(ctx, &ordercomm.DeleteOrderRequest{Id: ""})
// assert
if err == nil {
t.Fatalf("expected error invoking delete with empty id, but none received")
}
sts := status.Convert(err)
if sts == nil {
t.Fatalf("error is not a status.Status error")
}
if expected := codes.InvalidArgument; sts.Code() != expected {
t.Errorf("expected status code %s, provided code %s", expected, sts.Code())
}
} | explode_data.jsonl/36871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
57418,
3522,
764,
1155,
353,
8840,
836,
8,
341,
197,
322,
30893,
198,
57279,
1669,
609,
1358,
2271,
25243,
515,
197,
96672,
2077,
25,
2036,
90,
15495,
1465,
335,
90,
7747,
25,
2092,
1583,
197,
532,
1903,
18920,
1669,
6330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShadowedVariables(t *testing.T) {
runTest(t, "testshadow", func(client *daptest.Client, fixture protest.Fixture) {
runDebugSessionWithBPs(t, client, "launch",
// Launch
func() {
client.LaunchRequestWithArgs(map[string]interface{}{
"mode": "exec", "program": fixture.Path, "showGlobalVariables": true,
})
},
// Breakpoints are set within the program
fixture.Source, []int{},
[]onBreakpoint{{
// Stop at line 13
execute: func() {
client.StackTraceRequest(1, 0, 20)
stack := client.ExpectStackTraceResponse(t)
checkStackFrames(t, stack, "main.main", 13, 1000, 3, 3)
client.ScopesRequest(1000)
scopes := client.ExpectScopesResponse(t)
checkScope(t, scopes, 0, "Arguments", 1000)
checkScope(t, scopes, 1, "Locals", 1001)
checkScope(t, scopes, 2, "Globals (package main)", 1002)
client.VariablesRequest(1001)
locals := client.ExpectVariablesResponse(t)
checkVarExact(t, locals, 0, "(a)", "a", "0", "int", !hasChildren)
checkVarExact(t, locals, 1, "a", "a", "1", "int", !hasChildren)
// Check that the non-shadowed of "a" is returned from evaluate request.
validateEvaluateName(t, client, locals, 1)
},
disconnect: false,
}})
})
} | explode_data.jsonl/17322 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 524
} | [
2830,
3393,
23667,
291,
22678,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
1155,
11,
330,
1944,
32952,
497,
2915,
12805,
353,
91294,
1944,
11716,
11,
12507,
8665,
991,
12735,
8,
341,
197,
56742,
7939,
5283,
2354,
33,
20420,
1155,
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... | 1 |
func TestStaticPath(t *testing.T) {
path := StaticPath("test")
p, err := path("")
if err != nil {
t.Fatal(err)
}
if p != "test" {
t.Fatalf("expected static path of \"test\" but received %q", p)
}
} | explode_data.jsonl/1196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
11690,
1820,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
23105,
1820,
445,
1944,
1138,
3223,
11,
1848,
1669,
1815,
31764,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
743,
281,
961,
330,
1944,
1,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.