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 TestGetTicker(t *testing.T) {
t.Parallel()
_, err := b.GetTicker("BTCUSD", url.Values{})
if err != nil {
t.Error("BitfinexGetTicker init error: ", err)
}
_, err = b.GetTicker("wigwham", url.Values{})
if err == nil {
t.Error("Test Failed - GetTicker() error")
}
} | explode_data.jsonl/79927 | {
"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,
1949,
87278,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
2234,
87278,
445,
59118,
26749,
497,
2515,
35145,
37790,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
445,
8344,
5472,
327,
1949,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSPackUnpack(t *testing.T) {
doTestSPackUnpack(t, 2, 32, 1, 2)
doTestSPackUnpack(t, 2, 32, 2, 1)
doTestSPackUnpack(t, 2, 32, (1<<31)-1, (1<<31)-1)
doTestSPackUnpack(t, 2, 2, 1, 1)
doTestSPackUnpack(t, 2, 32, -1, -2)
doTestSPackUnpack(t, 2, 32, -2, -1)
doTestSPackUnpack(t, 2, 32, -((1 << 31) - 1), -((1 << 31) - 1))
doTestSPackUnpack(t, 2, 2, -1, -1)
doTestSPackUnpack(t, 3, 21, 1, 2, 4)
doTestSPackUnpack(t, 3, 21, 4, 2, 1)
doTestSPackUnpack(t, 3, 21, (1<<20)-1, (1<<20)-1, (1<<20)-1)
doTestSPackUnpack(t, 3, 2, 1, 1, 1)
doTestSPackUnpack(t, 3, 21, -1, -2, -4)
doTestSPackUnpack(t, 3, 21, -4, -2, -1)
doTestSPackUnpack(t, 3, 21, -((1 << 20) - 1), -((1 << 20) - 1), -((1 << 20) - 1))
doTestSPackUnpack(t, 3, 2, -1, -1, -1)
doTestSPackUnpack(t, 4, 16, 1, 2, 4, 8)
doTestSPackUnpack(t, 4, 16, 8, 4, 2, 1)
doTestSPackUnpack(t, 4, 16, (1<<15)-1, (1<<15)-1, (1<<15)-1, (1<<15)-1)
doTestSPackUnpack(t, 4, 2, 1, 1, 1, 1)
doTestSPackUnpack(t, 4, 16, -1, -2, -4, -8)
doTestSPackUnpack(t, 4, 16, -8, -4, -2, -1)
doTestSPackUnpack(t, 4, 16, -((1 << 15) - 1), -((1 << 15) - 1), -((1 << 15) - 1), -((1 << 15) - 1))
doTestSPackUnpack(t, 4, 2, -1, -1, -1, -1)
doTestSPackUnpack(t, 6, 10, 1, 2, 4, 8, 16, 32)
doTestSPackUnpack(t, 6, 10, 32, 16, 8, 4, 2, 1)
doTestSPackUnpack(t, 6, 10, 511, 511, 511, 511, 511, 511)
doTestSPackUnpack(t, 6, 10, -1, -2, -4, -8, -16, -32)
doTestSPackUnpack(t, 6, 10, -32, -16, -8, -4, -2, -1)
doTestSPackUnpack(t, 6, 10, -511, -511, -511, -511, -511, -511)
values := make([]int64, 32)
for i := 0; i < 32; i++ {
values[i] = int64(1 - 2*(i%2))
}
doTestSPackUnpack(t, 32, 2, values...)
} | explode_data.jsonl/52625 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 907
} | [
2830,
3393,
4592,
473,
1806,
4748,
1155,
353,
8840,
836,
8,
341,
19935,
2271,
4592,
473,
1806,
4748,
1155,
11,
220,
17,
11,
220,
18,
17,
11,
220,
16,
11,
220,
17,
340,
19935,
2271,
4592,
473,
1806,
4748,
1155,
11,
220,
17,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRequiredPositional(t *testing.T) {
var args struct {
Input string `arg:"positional"`
Output string `arg:"positional,required"`
}
err := parse("foo", &args)
assert.Error(t, err)
} | explode_data.jsonl/13002 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
8164,
3812,
278,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
66588,
220,
914,
1565,
858,
2974,
966,
3005,
8805,
197,
80487,
914,
1565,
858,
2974,
966,
3005,
11,
6279,
8805,
197,
532,
9859,
1669,
4715,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestWatchSet_Interpolate(t *testing.T) {
_ = os.Setenv("HOST_IP", "172.10.0.1")
_ = os.Setenv("ANOTHER_IP", "172.10.0.2")
set := WatchSet{
ConsulWatches: []ConsulWatchSpec{
{ConsulAddress: "${HOST_IP}", ServiceName: "foo-in-consul", Datacenter: "dc1"},
{ConsulAddress: "$ANOTHER_IP", ServiceName: "bar-in-consul", Datacenter: "dc1"},
{ConsulAddress: "127.0.0.1", ServiceName: "baz-in-consul", Datacenter: "dc1"},
},
}
interpolated := set.Interpolate()
assert.Equal(t,
ConsulWatchSpec{ConsulAddress: "172.10.0.1", ServiceName: "foo-in-consul", Datacenter: "dc1"},
interpolated.ConsulWatches[0])
assert.Equal(t,
ConsulWatchSpec{ConsulAddress: "172.10.0.2", ServiceName: "bar-in-consul", Datacenter: "dc1"},
interpolated.ConsulWatches[1])
assert.Equal(t,
ConsulWatchSpec{ConsulAddress: "127.0.0.1", ServiceName: "baz-in-consul", Datacenter: "dc1"},
interpolated.ConsulWatches[2])
} | explode_data.jsonl/20623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
14247,
1649,
79717,
45429,
1155,
353,
8840,
836,
8,
341,
197,
62,
284,
2643,
4202,
3160,
445,
28687,
16607,
497,
330,
16,
22,
17,
13,
16,
15,
13,
15,
13,
16,
1138,
197,
62,
284,
2643,
4202,
3160,
445,
1093,
30267,
1660... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateParamResults_Success(t *testing.T) {
tests := []struct {
name string
tasks []PipelineTask
}{{
name: "invalid pipeline task referencing task result along with parameter variable",
tasks: []PipelineTask{{
TaskSpec: &TaskSpec{
Results: []TaskResult{{
Name: "output",
}},
Steps: []Step{{
Container: corev1.Container{Name: "foo", Image: "bar"},
}},
},
Name: "a-task",
}, {
Name: "foo",
TaskRef: &TaskRef{Name: "foo-task"},
Params: []Param{{
Name: "a-param", Value: ArrayOrString{Type: ParamTypeString, StringVal: "$(params.foo) and $(tasks.a-task.results.output)"},
}},
}},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := validateParamResults(tt.tasks)
if err != nil {
t.Errorf("Pipeline.validateParamResults() returned error: %v", err)
}
})
}
} | explode_data.jsonl/26533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
17926,
2001,
9801,
87161,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
3244,
4604,
3056,
34656,
6262,
198,
197,
15170,
515,
197,
11609,
25,
330,
11808,
15301,
3383,
56516,
3383,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeployableTemplateConversion(t *testing.T) {
g := gomega.NewGomegaWithT(t)
tpChnKey := types.NamespacedName{
Name: "test-chn",
Namespace: "tp-chn-namespace",
}
cfgMapKey := types.NamespacedName{
Name: "skip-cert-verify",
Namespace: tpChnKey.Namespace,
}
tpCfgMap := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "ConfigMap",
},
ObjectMeta: metav1.ObjectMeta{
Name: cfgMapKey.Name,
Namespace: cfgMapKey.Namespace,
},
Data: map[string]string{
"insecureSkipVerify": "true",
},
}
dplCm := &dplv1.Deployable{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps.open-cluster-management.io/v1",
Kind: "Deployable",
},
ObjectMeta: metav1.ObjectMeta{
Name: "dpl-cm",
Namespace: tpChnKey.Namespace,
},
Spec: dplv1.DeployableSpec{
Template: &runtime.RawExtension{
Object: tpCfgMap,
},
},
}
selector := map[string]string{"a": "b"}
tDeploy := &apps.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
},
ObjectMeta: metav1.ObjectMeta{
Name: "dpl-deployment",
Namespace: tpChnKey.Namespace,
},
Spec: apps.DeploymentSpec{
Replicas: func() *int32 { i := int32(1); return &i }(),
Selector: &metav1.LabelSelector{MatchLabels: selector},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: selector,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Image: "foo/bar",
},
},
},
},
},
}
dplDeploy := &dplv1.Deployable{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps.open-cluster-management.io/v1",
Kind: "Deployable",
},
ObjectMeta: metav1.ObjectMeta{
Name: "dpl-deploy",
Namespace: tpChnKey.Namespace,
},
Spec: dplv1.DeployableSpec{
Template: &runtime.RawExtension{
Object: tDeploy,
},
},
}
var tests = []struct {
name string
given *dplv1.Deployable
expected string
}{
{"template as configmap", dplCm, "ConfigMap"},
{"template as deployment", dplDeploy, "Deployment"},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
actual, err := GetDeployableTemplateAsUnstructrure(tt.given)
g.Expect(err).Should(gomega.Succeed())
if actual.GetKind() != tt.expected {
t.Errorf("(%s): expected %s, actual %s", ObjectString(tt.given), tt.expected, actual.GetKind())
}
})
}
} | explode_data.jsonl/51109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1132
} | [
2830,
3393,
69464,
480,
7275,
48237,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
73423,
1143,
77,
1592,
1669,
4494,
98932,
68552,
675,
515,
197,
21297,
25,
414,
330,
1944,
12,
2125,
756,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCaptchaJWTToken(t *testing.T) {
g := initTestGoogleCaptcha(t)
tests := []struct {
name string
testFunc func()
}{
{
name: "test cookie",
testFunc: func() {
req, err := http.NewRequest(http.MethodPost, testproxyhelpers.DefaultFakeCaptchaURL+testproxyhelpers.DefaultFakeCaptchaEndpoint, nil)
require.Nil(t, err)
cookie := http.Cookie{Name: testCaptchaCookie, Value: testJWTToken, Expires: time.Now(), HttpOnly: true}
req.AddCookie(&cookie)
jwtToken := g.getCaptchaJWTToken(req)
require.Equal(t, testJWTToken, jwtToken)
},
},
{
name: "test header",
testFunc: func() {
req, err := http.NewRequest(http.MethodPost, testproxyhelpers.DefaultFakeCaptchaURL+testproxyhelpers.DefaultFakeCaptchaEndpoint, nil)
require.Nil(t, err)
req.Header.Set(testCaptchaHeader, testJWTToken)
jwtToken := g.getCaptchaJWTToken(req)
require.Equal(t, testJWTToken, jwtToken)
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
tt.testFunc()
})
}
} | explode_data.jsonl/60456 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 462
} | [
2830,
3393,
1949,
34,
25431,
55172,
3323,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
2930,
2271,
14444,
34,
25431,
1155,
340,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
18185,
9626,
2915,
741,
197,
59403,
197,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRewriteNoScriptImageWithNoScriptTag(t *testing.T) {
content := `<figure><img src="https://developer.mozilla.org/static/img/favicon144.png" alt="The beautiful MDN logo."><noscript><img src="http://example.org/logo.svg"></noscript><figcaption>MDN Logo</figcaption></figure>`
expected := `<figure><img src="http://example.org/logo.svg"/><figcaption>MDN Logo</figcaption></figure>`
output := Rewriter("https://example.org/article", content, "use_noscript_figure_images")
output = strings.TrimSpace(output)
if expected != output {
t.Errorf(`Not expected output: %s`, output)
}
} | explode_data.jsonl/21489 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
58465,
1247,
2753,
5910,
1906,
2354,
2753,
5910,
5668,
1155,
353,
8840,
836,
8,
341,
27751,
1669,
30586,
17781,
1784,
1892,
2286,
428,
2428,
1110,
34401,
53834,
2659,
36643,
13670,
48557,
16,
19,
19,
3508,
1,
4797,
428,
785,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCanvas_ChildMinSizeChangeAffectsAncestorsUpToRoot(t *testing.T) {
c := NewCanvas().(*mobileCanvas)
leftObj1 := canvas.NewRectangle(color.Black)
leftObj1.SetMinSize(fyne.NewSize(100, 50))
leftObj2 := canvas.NewRectangle(color.Black)
leftObj2.SetMinSize(fyne.NewSize(100, 50))
leftCol := container.NewVBox(leftObj1, leftObj2)
rightObj1 := canvas.NewRectangle(color.Black)
rightObj1.SetMinSize(fyne.NewSize(100, 50))
rightObj2 := canvas.NewRectangle(color.Black)
rightObj2.SetMinSize(fyne.NewSize(100, 50))
rightCol := container.NewVBox(rightObj1, rightObj2)
content := container.NewHBox(leftCol, rightCol)
c.SetContent(fyne.NewContainerWithLayout(layout.NewCenterLayout(), content))
c.resize(fyne.NewSize(300, 300))
oldContentSize := fyne.NewSize(200+theme.Padding(), 100+theme.Padding())
assert.Equal(t, oldContentSize, content.Size())
leftObj1.SetMinSize(fyne.NewSize(110, 60))
c.ensureMinSize()
expectedContentSize := oldContentSize.Add(fyne.NewSize(10, 10))
assert.Equal(t, expectedContentSize, content.Size())
} | explode_data.jsonl/43158 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 390
} | [
2830,
3393,
18226,
27588,
695,
6217,
1695,
4072,
32,
39927,
2082,
15184,
1087,
2324,
1249,
8439,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
18226,
1005,
4071,
14933,
18226,
340,
35257,
5261,
16,
1669,
10041,
7121,
21095,
13441,
28829... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigLoadConfigurationFailUnreadableConfig(t *testing.T) {
if os.Geteuid() == 0 {
t.Skip(testDisabledNeedNonRoot)
}
tmpdir, err := ioutil.TempDir(testDir, "runtime-config-")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
testLoadConfiguration(t, tmpdir,
func(config testRuntimeConfig, configFile string, ignoreLogging bool) (bool, error) {
expectFail := true
// make file unreadable by non-root user
err = os.Chmod(config.ConfigPath, 0000)
if err != nil {
return expectFail, err
}
return expectFail, nil
})
} | explode_data.jsonl/5120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
2648,
5879,
7688,
19524,
1806,
878,
480,
2648,
1155,
353,
8840,
836,
8,
341,
743,
2643,
2234,
68,
2423,
368,
621,
220,
15,
341,
197,
3244,
57776,
8623,
25907,
23657,
8121,
8439,
340,
197,
630,
20082,
3741,
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... | 2 |
func TestTerragruntRunAllCommandPrompt(t *testing.T) {
t.Parallel()
s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))
tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_OUTPUT_ALL)
rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL, config.DefaultTerragruntConfigPath)
copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, "not-used", "not-used")
environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL)
stdout := bytes.Buffer{}
stderr := bytes.Buffer{}
err := runTerragruntCommand(t, fmt.Sprintf("terragrunt run-all apply --terragrunt-working-dir %s", environmentPath), &stdout, &stderr)
logBufferContentsLineByLine(t, stdout, "stdout")
logBufferContentsLineByLine(t, stderr, "stderr")
assert.Contains(t, stderr.String(), "Are you sure you want to run 'terragrunt apply' in each folder of the stack described above? (y/n)")
assert.Error(t, err)
} | explode_data.jsonl/10179 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 383
} | [
2830,
3393,
51402,
68305,
3850,
6727,
2403,
4062,
54615,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1903,
18,
36018,
675,
1669,
8879,
17305,
445,
465,
4101,
81,
3850,
16839,
1455,
11152,
11069,
82,
497,
9069,
29983,
53440,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCollectStr(t *testing.T) {
v := &Value{data: []string{string("hello"), string("hello"), string("hello"), string("hello"), string("hello"), string("hello")}}
collected := v.CollectStr(func(index int, val string) interface{} {
return index
})
collectedArr := collected.MustInterSlice()
if assert.Equal(t, 6, len(collectedArr)) {
assert.Equal(t, collectedArr[0], 0)
assert.Equal(t, collectedArr[1], 1)
assert.Equal(t, collectedArr[2], 2)
assert.Equal(t, collectedArr[3], 3)
assert.Equal(t, collectedArr[4], 4)
assert.Equal(t, collectedArr[5], 5)
}
} | explode_data.jsonl/23415 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
47504,
2580,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
3056,
917,
90,
917,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWithShutdown_ReturnError(t *testing.T) {
want := errors.New("my_error")
shutdownErr := func(context.Context) error { return want }
bp := newBaseProcessor(testFullName, WithShutdown(shutdownErr))
assert.Equal(t, want, bp.Shutdown(context.Background()))
} | explode_data.jsonl/4009 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
2354,
62004,
53316,
1454,
1155,
353,
8840,
836,
8,
341,
50780,
1669,
5975,
7121,
445,
2408,
4096,
1138,
36196,
18452,
7747,
1669,
2915,
5378,
9328,
8,
1465,
314,
470,
1366,
555,
2233,
79,
1669,
501,
3978,
22946,
8623,
36217,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerHappyPathSingleServerWithServerOptions(t *testing.T) {
const (
headerKey = "X-TEST-HEADER"
headerVal = "go-kit-proxy"
)
originServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if want, have := headerVal, r.Header.Get(headerKey); want != have {
t.Errorf("want %q, have %q", want, have)
}
w.WriteHeader(http.StatusOK)
w.Write([]byte("hey"))
}))
defer originServer.Close()
originURL, _ := url.Parse(originServer.URL)
handler := httptransport.NewServer(
originURL,
httptransport.ServerBefore(func(ctx context.Context, r *http.Request) context.Context {
r.Header.Add(headerKey, headerVal)
return ctx
}),
)
proxyServer := httptest.NewServer(handler)
defer proxyServer.Close()
resp, _ := http.Get(proxyServer.URL)
if want, have := http.StatusOK, resp.StatusCode; want != have {
t.Errorf("want %d, have %d", want, have)
}
responseBody, _ := ioutil.ReadAll(resp.Body)
if want, have := "hey", string(responseBody); want != have {
t.Errorf("want %q, have %q", want, have)
}
} | explode_data.jsonl/15687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 411
} | [
2830,
3393,
5475,
32847,
1820,
10888,
5475,
2354,
5475,
3798,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
20883,
1592,
284,
330,
55,
12,
10033,
12,
38098,
698,
197,
20883,
2208,
284,
330,
3346,
91476,
83701,
698,
197,
692,
197,
861... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIncompatibleBadgerStorageForProduction(t *testing.T) {
jaeger := &v1.Jaeger{
Spec: v1.JaegerSpec{
Strategy: v1.DeploymentStrategyProduction,
Storage: v1.JaegerStorageSpec{
Type: "badger",
},
},
}
normalize(context.Background(), jaeger)
assert.Equal(t, v1.DeploymentStrategyAllInOne, jaeger.Spec.Strategy)
} | explode_data.jsonl/21848 | {
"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,
641,
34842,
17082,
1389,
5793,
2461,
44967,
1155,
353,
8840,
836,
8,
341,
197,
5580,
1878,
1669,
609,
85,
16,
3503,
64,
1878,
515,
197,
7568,
992,
25,
348,
16,
3503,
64,
1878,
8327,
515,
298,
197,
19816,
25,
348,
16,
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 Test_Auto_HTML_Create_Redirect_Error(t *testing.T) {
r := require.New(t)
err := withHTMLFile("cars/new.html", "Create: <%= car.Name %>", func(e *render.Engine) {
app := buffalo.New(buffalo.Options{})
app.POST("/cars", func(c buffalo.Context) error {
b := Car{
Name: "Honda",
}
return c.Render(422, e.Auto(c, b))
})
w := willie.New(app)
res := w.HTML("/cars").Post(nil)
r.Equal(422, res.Code)
r.Contains(res.Body.String(), "Create: Honda")
})
r.NoError(err)
} | explode_data.jsonl/2627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
1566,
1535,
56726,
34325,
92940,
1226,
28651,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1373,
7121,
1155,
692,
9859,
1669,
448,
5835,
1703,
445,
50708,
25376,
2564,
497,
330,
4021,
25,
90194,
1803,
2967,
1018,
21156,
2915,
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 Test_EHR_Sample_Failed(t *testing.T) {
as := assert.New(t)
t.Run("request failed", func(t *testing.T) {
cli := AppAllPermission.Ins()
cli.Mock().MockGetTenantAccessToken(mockGetTenantAccessTokenFailed)
cli.Mock().MockGetAppAccessToken(mockGetTenantAccessTokenFailed)
moduleCli := cli.EHR
t.Run("", func(t *testing.T) {
_, _, err := moduleCli.GetEHREmployeeList(ctx, &lark.GetEHREmployeeListReq{})
as.NotNil(err)
as.Equal(err.Error(), "failed")
})
t.Run("", func(t *testing.T) {
_, _, err := moduleCli.DownloadEHRAttachments(ctx, &lark.DownloadEHRAttachmentsReq{})
as.NotNil(err)
as.Equal(err.Error(), "failed")
})
})
t.Run("request mock failed", func(t *testing.T) {
cli := AppAllPermission.Ins()
moduleCli := cli.EHR
t.Run("", func(t *testing.T) {
cli.Mock().MockEHRGetEHREmployeeList(func(ctx context.Context, request *lark.GetEHREmployeeListReq, options ...lark.MethodOptionFunc) (*lark.GetEHREmployeeListResp, *lark.Response, error) {
return nil, nil, fmt.Errorf("mock-failed")
})
defer cli.Mock().UnMockEHRGetEHREmployeeList()
_, _, err := moduleCli.GetEHREmployeeList(ctx, &lark.GetEHREmployeeListReq{})
as.NotNil(err)
as.Equal(err.Error(), "mock-failed")
})
t.Run("", func(t *testing.T) {
cli.Mock().MockEHRDownloadEHRAttachments(func(ctx context.Context, request *lark.DownloadEHRAttachmentsReq, options ...lark.MethodOptionFunc) (*lark.DownloadEHRAttachmentsResp, *lark.Response, error) {
return nil, nil, fmt.Errorf("mock-failed")
})
defer cli.Mock().UnMockEHRDownloadEHRAttachments()
_, _, err := moduleCli.DownloadEHRAttachments(ctx, &lark.DownloadEHRAttachmentsReq{})
as.NotNil(err)
as.Equal(err.Error(), "mock-failed")
})
})
t.Run("response is failed", func(t *testing.T) {
cli := AppNoPermission.Ins()
moduleCli := cli.EHR
t.Run("", func(t *testing.T) {
_, _, err := moduleCli.GetEHREmployeeList(ctx, &lark.GetEHREmployeeListReq{})
as.NotNil(err)
as.True(lark.GetErrorCode(err) > 0, fmt.Sprintf("need get lark err, but get %s", err))
})
t.Run("", func(t *testing.T) {
_, _, err := moduleCli.DownloadEHRAttachments(ctx, &lark.DownloadEHRAttachmentsReq{
Token: "x",
})
as.NotNil(err)
as.True(lark.GetErrorCode(err) > 0, fmt.Sprintf("need get lark err, but get %s", err))
})
})
t.Run("fake request is failed", func(t *testing.T) {
cli := AppAllPermission.Ins()
moduleCli := cli.EHR
cli.Mock().MockRawRequest(func(ctx context.Context, req *lark.RawRequestReq, resp interface{}) (response *lark.Response, err error) {
return nil, fmt.Errorf("fake raw request")
})
t.Run("", func(t *testing.T) {
_, _, err := moduleCli.GetEHREmployeeList(ctx, &lark.GetEHREmployeeListReq{})
as.NotNil(err)
as.Equal("fake raw request", err.Error())
})
t.Run("", func(t *testing.T) {
_, _, err := moduleCli.DownloadEHRAttachments(ctx, &lark.DownloadEHRAttachmentsReq{
Token: "x",
})
as.NotNil(err)
as.Equal("fake raw request", err.Error())
})
})
} | explode_data.jsonl/52187 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1353
} | [
2830,
3393,
2089,
17088,
1098,
1516,
1400,
5687,
1155,
353,
8840,
836,
8,
341,
60451,
1669,
2060,
7121,
1155,
692,
3244,
16708,
445,
2035,
4641,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
86448,
1669,
1845,
2403,
14966,
5337,
82,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_getDataFromRegistrySecret(t *testing.T) {
testCases := []struct {
name string
secret *corev1.Secret
expected string
}{
{
name: "retrieves username and password from a dockerconfigjson",
secret: &corev1.Secret{
Data: map[string][]byte{
".dockerconfigjson": []byte(`{"auths":{"foo":{"username":"foo","password":"bar"}}}`),
},
},
// Basic: base64(foo:bar)
expected: "Basic Zm9vOmJhcg==",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
auth, err := getDataFromRegistrySecret(".dockerconfigjson", tc.secret)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
if auth != tc.expected {
t.Errorf("Expecting %s, got %s", tc.expected, auth)
}
})
}
} | explode_data.jsonl/75001 | {
"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,
3062,
1043,
3830,
15603,
19773,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
197,
20474,
256,
353,
98645,
16,
74779,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
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... | 3 |
func TestFindStringSubmatchIndex(t *testing.T) {
for _, test := range findTests {
testFindSubmatchIndex(&test, MustCompile(test.pat).FindStringSubmatchIndex(test.text), t)
}
} | explode_data.jsonl/55094 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
9885,
703,
3136,
6347,
1552,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
1477,
18200,
341,
197,
18185,
9885,
3136,
6347,
1552,
2099,
1944,
11,
15465,
46126,
8623,
96534,
568,
9885,
703,
3136,
6347,
1552,
8623... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTabable(t *testing.T) {
entry := &widget.Entry{}
t.Run("Multiline_Tab_Default", func(t *testing.T) {
entry.MultiLine = true
entry.SetText("a")
typeKeys(entry, fyne.KeyTab)
assert.Equal(t, "\ta", entry.Text)
})
t.Run("Singleline_Tab_Default", func(t *testing.T) {
entry.MultiLine = false
assert.False(t, entry.AcceptsTab())
})
} | explode_data.jsonl/12374 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
8582,
480,
1155,
353,
8840,
836,
8,
341,
48344,
1669,
609,
9797,
22330,
16094,
3244,
16708,
445,
40404,
26560,
92842,
60336,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
48344,
57706,
2460,
284,
830,
198,
197,
48344,
92259,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVMNetworkSuite(t *testing.T) {
sonoPath := os.Getenv("SONOBUOY_PATH")
if sonoPath == "" {
t.Fatal("SONOBUOY_PATH env needs to be set")
}
s := NetworkSuite{
common.VMSuite{},
sonoPath,
}
suite.Run(t, &s)
} | explode_data.jsonl/43734 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
11187,
12320,
28000,
1155,
353,
8840,
836,
8,
341,
197,
73122,
1820,
1669,
2643,
64883,
445,
2703,
46,
14928,
46,
56,
7944,
1138,
743,
20821,
1820,
621,
1591,
341,
197,
3244,
26133,
445,
2703,
46,
14928,
46,
56,
7944,
6105... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKafkaBinding(t *testing.T) {
tests := map[string]struct {
messageKey string
messageHeaders map[string]string
messagePayload string
expectedData string
}{
"no_event": {
messageKey: "0",
messageHeaders: map[string]string{
"content-type": "application/json",
},
messagePayload: `{"value":5}`,
expectedData: `{"value":5}`,
},
"structured": {
messageKey: "0",
messageHeaders: map[string]string{
"content-type": "application/cloudevents+json",
},
messagePayload: mustJsonMarshal(t, map[string]interface{}{
"specversion": "1.0",
"type": "com.github.pull.create",
"source": "https://github.com/cloudevents/spec/pull",
"subject": "123",
"id": "A234-1234-1234",
"time": "2018-04-05T17:31:00Z",
"comexampleextension1": "value",
"comexampleothervalue": 5,
"datacontenttype": "application/json",
"data": map[string]string{
"hello": "Francesco",
},
}),
expectedData: `{"hello":"Francesco"}`,
},
}
for name, tc := range tests {
tc := tc
t.Run(name, func(t *testing.T) {
testKafkaBinding(t, tc.messageKey, tc.messageHeaders, tc.messagePayload, tc.expectedData)
})
}
} | explode_data.jsonl/23607 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 612
} | [
2830,
3393,
42,
21883,
15059,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
24753,
1592,
257,
914,
198,
197,
24753,
10574,
2415,
14032,
30953,
198,
197,
24753,
29683,
914,
198,
197,
42400,
1043,
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 TestPreparedCommand_RunE(t *testing.T) {
os.Setenv(mg.VerboseEnv, "true")
defer os.Unsetenv(mg.VerboseEnv)
stdout := shx.RecordStdout()
defer stdout.Release()
err := shx.RunE("go", "run", "echo.go", "hello world")
gotStdout := stdout.Output()
if err != nil {
t.Fatal(err)
}
assert.Empty(t, gotStdout)
} | explode_data.jsonl/57095 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
4703,
7212,
4062,
84158,
36,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
1255,
70,
42505,
8297,
14359,
11,
330,
1866,
1138,
16867,
2643,
10616,
746,
3160,
1255,
70,
42505,
8297,
14359,
692,
6736,
411,
1669,
557,
87,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBadRefresh2(t *testing.T) {
s2 := zktest.New()
z, ch, _ := s2.Connect()
badForce := errors.New("nope")
c := 0
z.SetErrorCheck(func(s string) error {
if s == "getw" {
c++
if c > 1 {
return badForce
}
return nil
}
return nil
})
zkp, err := zkplus.NewBuilder().PathPrefix("/test").Connector(&zkplus.StaticConnector{C: z, Ch: ch}).Build()
zkConnFunc := ZkConnCreatorFunc(func() (ZkConn, <-chan zk.Event, error) {
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",
}
require.Equal(t, badForce, errors.Tail(s.refresh(zkp)))
} | explode_data.jsonl/46866 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 361
} | [
2830,
3393,
17082,
14567,
17,
1155,
353,
8840,
836,
8,
341,
1903,
17,
1669,
94528,
1944,
7121,
741,
20832,
11,
521,
11,
716,
1669,
274,
17,
43851,
741,
2233,
329,
18573,
1669,
5975,
7121,
445,
2152,
375,
1138,
1444,
1669,
220,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNew(t *testing.T) {
subject, err := tweeter.New(tweeter.Config{
ApiKey: "apiKey",
ApiKeySecret: "apiKeySecret",
AccessToken: "accessToken",
AccessTokenSecret: "accessTokenSecret",
})
if err != nil {
t.Error(err, "config should be valid")
}
if subject == nil {
t.Error("subject should not be nil")
}
} | explode_data.jsonl/65412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
28624,
583,
11,
1848,
1669,
14545,
1404,
7121,
1155,
896,
1404,
10753,
515,
197,
197,
95931,
25,
310,
330,
57371,
756,
197,
197,
95931,
19773,
25,
414,
330,
57371,
19773,
756,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTransactionSigHash(t *testing.T) {
var homestead HomesteadSigner
if homestead.Hash(emptyTx) != common.HexToHash("c775b99e7ad12f50d819fcd602390467e28141316969f4b57f0626f74fe3b386") {
t.Errorf("empty transaction hash mismatch, got %x", emptyTx.Hash())
}
if homestead.Hash(rightvrsTx) != common.HexToHash("fe7a79529ed5f7c3375d06b26b186a8644e0e16c373d7a12be41c62d6042b77a") {
t.Errorf("RightVRS transaction hash mismatch, got %x", rightvrsTx.Hash())
}
} | explode_data.jsonl/29920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
8070,
47246,
6370,
1155,
353,
8840,
836,
8,
341,
2405,
4998,
72337,
13222,
72337,
7264,
261,
198,
743,
4998,
72337,
15103,
24216,
31584,
8,
961,
4185,
91538,
1249,
6370,
445,
66,
22,
22,
20,
65,
24,
24,
68,
22,
329,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestConfigFindMissingBrowser(t *testing.T) {
confFile := configfile(`{}`)
defer os.Remove(confFile)
conf := config.NewConfig()
conf.Load(confFile, logConfPath)
_, _, ok := conf.Find("firefox", "")
AssertThat(t, ok, Is{false})
} | explode_data.jsonl/37920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
2648,
9885,
25080,
17878,
1155,
353,
8840,
836,
8,
341,
67850,
1703,
1669,
2193,
1192,
5809,
90,
27085,
16867,
2643,
13270,
29879,
1703,
340,
67850,
1669,
2193,
7121,
2648,
741,
67850,
13969,
29879,
1703,
11,
1487,
15578,
1820... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteReminder(t *testing.T) {
testActorsRuntime := newTestActorsRuntime()
actorType, actorID := getTestActorTypeAndID()
reminder := createReminder(actorID, actorType, "reminder1", "1s", "1s", "")
testActorsRuntime.CreateReminder(&reminder)
assert.Equal(t, 1, len(testActorsRuntime.reminders[actorType]))
err := testActorsRuntime.DeleteReminder(&DeleteReminderRequest{
Name: "reminder1",
ActorID: actorID,
ActorType: actorType,
})
assert.Nil(t, err)
assert.Equal(t, 0, len(testActorsRuntime.reminders[actorType]))
} | explode_data.jsonl/12879 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
6435,
95359,
1155,
353,
8840,
836,
8,
341,
18185,
2414,
1087,
15123,
1669,
501,
2271,
2414,
1087,
15123,
741,
93410,
929,
11,
12089,
915,
1669,
633,
2271,
18870,
929,
3036,
915,
741,
197,
77905,
1669,
1855,
95359,
65451,
915... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue27233(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("drop table if exists t;")
tk.MustExec("CREATE TABLE `t` (\n `COL1` tinyint(45) NOT NULL,\n `COL2` tinyint(45) NOT NULL,\n PRIMARY KEY (`COL1`,`COL2`) /*T![clustered_index] NONCLUSTERED */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;")
tk.MustExec("insert into t values(122,100),(124,-22),(124,34),(127,103);")
tk.MustQuery("SELECT col2 FROM t AS T1 WHERE ( SELECT count(DISTINCT COL1, COL2) FROM t AS T2 WHERE T2.COL1 > T1.COL1 ) > 2 ;").
Check(testkit.Rows("100"))
} | explode_data.jsonl/65604 | {
"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,
42006,
17,
22,
17,
18,
18,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNameBytesAreAligned(t *testing.T) {
typ := TypeOf(embed{})
b := FirstMethodNameBytes(typ)
v := uintptr(unsafe.Pointer(b))
if v%unsafe.Alignof((*byte)(nil)) != 0 {
t.Errorf("reflect.name.bytes pointer is not aligned: %x", v)
}
} | explode_data.jsonl/29638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
675,
7078,
11526,
93305,
1155,
353,
8840,
836,
8,
341,
25314,
1669,
3990,
2124,
49725,
37790,
2233,
1669,
5512,
75648,
7078,
66783,
340,
5195,
1669,
38190,
7,
38157,
41275,
1883,
1171,
743,
348,
4,
38157,
74222,
1055,
26609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListenSynRcvdQueueFull(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
// Create TCP endpoint.
var err *tcpip.Error
c.EP, err = c.Stack().NewEndpoint(tcp.ProtocolNumber, ipv4.ProtocolNumber, &c.WQ)
if err != nil {
t.Fatalf("NewEndpoint failed: %v", err)
}
// Bind to wildcard.
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %v", err)
}
// Test acceptance.
// Start listening.
listenBacklog := 1
if err := c.EP.Listen(listenBacklog); err != nil {
t.Fatalf("Listen failed: %v", err)
}
// Send two SYN's the first one should get a SYN-ACK, the
// second one should not get any response and is dropped as
// the synRcvd count will be equal to backlog.
irs := seqnum.Value(789)
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagSyn,
SeqNum: seqnum.Value(789),
RcvWnd: 30000,
})
// Receive the SYN-ACK reply.
b := c.GetPacket()
tcp := header.TCP(header.IPv4(b).Payload())
iss := seqnum.Value(tcp.SequenceNumber())
tcpCheckers := []checker.TransportChecker{
checker.SrcPort(context.StackPort),
checker.DstPort(context.TestPort),
checker.TCPFlags(header.TCPFlagAck | header.TCPFlagSyn),
checker.AckNum(uint32(irs) + 1),
}
checker.IPv4(t, b, checker.TCP(tcpCheckers...))
// Now execute send one more SYN. The stack should not respond as the backlog
// is full at this point.
//
// NOTE: we did not complete the handshake for the previous one so the
// accept backlog should be empty and there should be one connection in
// synRcvd state.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort + 1,
DstPort: context.StackPort,
Flags: header.TCPFlagSyn,
SeqNum: seqnum.Value(889),
RcvWnd: 30000,
})
c.CheckNoPacketTimeout("unexpected packet received", 50*time.Millisecond)
// Now complete the previous connection and verify that there is a connection
// to accept.
// Send ACK.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagAck,
SeqNum: irs + 1,
AckNum: iss + 1,
RcvWnd: 30000,
})
// Try to accept the connections in the backlog.
we, ch := waiter.NewChannelEntry(nil)
c.WQ.EventRegister(&we, waiter.EventIn)
defer c.WQ.EventUnregister(&we)
newEP, _, err := c.EP.Accept()
if err == tcpip.ErrWouldBlock {
// Wait for connection to be established.
select {
case <-ch:
newEP, _, err = c.EP.Accept()
if err != nil {
t.Fatalf("Accept failed: %v", err)
}
case <-time.After(1 * time.Second):
t.Fatalf("Timed out waiting for accept")
}
}
// Now verify that the TCP socket is usable and in a connected state.
data := "Don't panic"
newEP.Write(tcpip.SlicePayload(buffer.NewViewFromBytes([]byte(data))), tcpip.WriteOptions{})
pkt := c.GetPacket()
tcp = header.TCP(header.IPv4(pkt).Payload())
if string(tcp.Payload()) != data {
t.Fatalf("Unexpected data: got %v, want %v", string(tcp.Payload()), data)
}
} | explode_data.jsonl/22335 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1202
} | [
2830,
3393,
38714,
37134,
49,
13122,
67,
7554,
9432,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
197,
322,
4230,
26656,
14887,
624,
2405,
1848,
353,
27161,
573,
61... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStrArray_Json(t *testing.T) {
// array pointer
gtest.C(t, func(t *gtest.T) {
s1 := []string{"a", "b", "d", "c"}
a1 := garray.NewStrArrayFrom(s1)
b1, err1 := json.Marshal(a1)
b2, err2 := json.Marshal(s1)
t.Assert(b1, b2)
t.Assert(err1, err2)
a2 := garray.NewStrArray()
err1 = json.UnmarshalUseNumber(b2, &a2)
t.Assert(a2.Slice(), s1)
var a3 garray.StrArray
err := json.UnmarshalUseNumber(b2, &a3)
t.Assert(err, nil)
t.Assert(a3.Slice(), s1)
})
// array value
gtest.C(t, func(t *gtest.T) {
s1 := []string{"a", "b", "d", "c"}
a1 := *garray.NewStrArrayFrom(s1)
b1, err1 := json.Marshal(a1)
b2, err2 := json.Marshal(s1)
t.Assert(b1, b2)
t.Assert(err1, err2)
a2 := garray.NewStrArray()
err1 = json.UnmarshalUseNumber(b2, &a2)
t.Assert(a2.Slice(), s1)
var a3 garray.StrArray
err := json.UnmarshalUseNumber(b2, &a3)
t.Assert(err, nil)
t.Assert(a3.Slice(), s1)
})
// array pointer
gtest.C(t, func(t *gtest.T) {
type User struct {
Name string
Scores *garray.StrArray
}
data := g.Map{
"Name": "john",
"Scores": []string{"A+", "A", "A"},
}
b, err := json.Marshal(data)
t.Assert(err, nil)
user := new(User)
err = json.UnmarshalUseNumber(b, user)
t.Assert(err, nil)
t.Assert(user.Name, data["Name"])
t.Assert(user.Scores, data["Scores"])
})
// array value
gtest.C(t, func(t *gtest.T) {
type User struct {
Name string
Scores garray.StrArray
}
data := g.Map{
"Name": "john",
"Scores": []string{"A+", "A", "A"},
}
b, err := json.Marshal(data)
t.Assert(err, nil)
user := new(User)
err = json.UnmarshalUseNumber(b, user)
t.Assert(err, nil)
t.Assert(user.Name, data["Name"])
t.Assert(user.Scores, data["Scores"])
})
} | explode_data.jsonl/53113 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 903
} | [
2830,
3393,
2580,
1857,
62,
5014,
1155,
353,
8840,
836,
8,
341,
197,
322,
1334,
7445,
198,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
1903,
16,
1669,
3056,
917,
4913,
64,
497,
330,
65,
497,
330,
67,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDownload(t *testing.T) {
if testing.Short() {
return
}
file, err := Download(log.NewNopLogger(), "")
if err != nil {
t.Fatal(err)
}
if file == "" {
t.Fatal("no CSL file")
}
defer os.RemoveAll(filepath.Dir(file))
if !strings.EqualFold("csl.csv", filepath.Base(file)) {
t.Errorf("unknown file %s", file)
}
} | explode_data.jsonl/41339 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
11377,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
853,
198,
197,
630,
17661,
11,
1848,
1669,
8577,
12531,
7121,
45,
453,
7395,
1507,
14676,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestClientSeedBrokers(t *testing.T) {
seedBroker := NewMockBroker(t, 1)
metadataResponse := new(MetadataResponse)
metadataResponse.AddBroker("localhost:12345", 2)
seedBroker.Returns(metadataResponse)
client, err := NewClient([]string{seedBroker.Addr()}, NewTestConfig())
if err != nil {
t.Fatal(err)
}
seedBroker.Close()
safeClose(t, client)
} | explode_data.jsonl/54399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
2959,
41471,
26272,
26177,
1155,
353,
8840,
836,
8,
341,
197,
22602,
65545,
1669,
1532,
11571,
65545,
1155,
11,
220,
16,
692,
2109,
7603,
2582,
1669,
501,
3189,
7603,
2582,
340,
2109,
7603,
2582,
1904,
65545,
445,
8301,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReceiveEndpointsBeforeService(t *testing.T) {
h, l := newHandler()
expectedVersion := 0
t.Run("AddNode", func(t *testing.T) {
h.Handle(resource.Event{
Kind: resource.Added,
Entry: nodeEntry(nodeName, "v1", region, zone),
})
expectNoNotification(t, l)
})
t.Run("AddPod", func(t *testing.T) {
h.Handle(resource.Event{
Kind: resource.Added,
Entry: podEntry(name(namespace, "pod1"), "v1", pod1IP, nodeName, "sa1", coreV1.PodRunning),
})
expectNoNotification(t, l)
})
var endpoints resource.Entry
t.Run("AddEndpoints", func(t *testing.T) {
endpoints = entryForEndpoints(serviceName, createTime, "v1", pod1IP)
h.Handle(resource.Event{
Kind: resource.Added,
Entry: endpoints,
})
expectNoNotification(t, l)
expectEmptySnapshot(t, h, expectedVersion)
})
t.Run("AddService", func(t *testing.T) {
service := entryForService(serviceName, createTime, "v1")
h.Handle(resource.Event{
Kind: resource.Added,
Entry: service,
})
expectNotification(t, l)
expectedMetadata := newExpectedMetadata(service, &endpoints, expectedVersion)
expectedVersion++
expectedBody := newBuilder().ServiceName(serviceName).Region(region).Zone(zone).IPs(pod1IP).
ServiceAccounts("sa1").Build()
expectResource(t, h, expectedVersion, expectedMetadata, expectedBody)
})
} | explode_data.jsonl/37581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 510
} | [
2830,
3393,
14742,
80786,
10227,
1860,
1155,
353,
8840,
836,
8,
341,
9598,
11,
326,
1669,
501,
3050,
2822,
42400,
5637,
1669,
220,
15,
198,
3244,
16708,
445,
2212,
1955,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
9598,
31421,
23599... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVersion(t *testing.T) {
dm, err := getDockerManager()
if err != nil {
t.Errorf("test new docker manager failed. %v", err)
}
version, err := dm.Version()
if err != nil {
t.Errorf("test Version failed, err [%v]", err)
}
t.Logf("test version: %+v\n", version)
} | explode_data.jsonl/24916 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
5637,
1155,
353,
8840,
836,
8,
341,
2698,
76,
11,
1848,
1669,
633,
35,
13659,
2043,
741,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
1944,
501,
26588,
6645,
4641,
13,
1018,
85,
497,
1848,
340,
197,
532,
74954,
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... | 3 |
func TestEmptyDirOpenCWD(t *testing.T) {
test := func(d Dir) {
name := "fs_test.go"
f, err := d.Open(name)
if err != nil {
t.Fatalf("open of %s: %v", name, err)
}
defer f.Close()
}
test(Dir(""))
test(Dir("."))
test(Dir("./"))
} | explode_data.jsonl/48230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
3522,
6184,
5002,
34,
17563,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
2915,
1500,
30094,
8,
341,
197,
11609,
1669,
330,
3848,
4452,
18002,
698,
197,
1166,
11,
1848,
1669,
294,
12953,
3153,
340,
197,
743,
1848,
961,
2092,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPropertyProfile_GremlinDialect(t *testing.T) {
// GIVEN
graphName := "mygraph"
g := NewGraph(graphName)
require.NotNil(t, g)
v := NewVertexG(g)
require.NotNil(t, v)
p := NewPropertyV(v)
require.NotNil(t, p)
// WHEN
SetQueryLanguageTo(QueryLanguageTinkerpopGremlin)
qb := p.Profile()
SetQueryLanguageTo(QueryLanguageCosmosDB)
// THEN
assert.NotNil(t, qb)
assert.Equal(t, fmt.Sprintf("%s.profile()", graphName), p.String())
} | explode_data.jsonl/38217 | {
"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,
3052,
8526,
2646,
265,
40926,
35,
55056,
1155,
353,
8840,
836,
8,
1476,
197,
322,
89836,
198,
66616,
675,
1669,
330,
2408,
4439,
698,
3174,
1669,
1532,
11212,
24312,
675,
340,
17957,
93882,
1155,
11,
342,
340,
5195,
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 TestConfiguration(t *testing.T) {
t.Run("null configuration", func(t *testing.T) {
plugin := &MatterpollPlugin{}
assert.Equal(t, &configuration{}, plugin.getConfiguration())
})
t.Run("changing configuration", func(t *testing.T) {
plugin := &MatterpollPlugin{}
config1 := &configuration{Trigger: "poll"}
plugin.setConfiguration(config1)
assert.Equal(t, config1, plugin.getConfiguration())
config2 := &configuration{Trigger: "otherTrigger"}
plugin.setConfiguration(config2)
assert.Equal(t, config2, plugin.getConfiguration())
assert.NotEqual(t, config1, plugin.getConfiguration())
assert.False(t, plugin.getConfiguration() == config1)
assert.True(t, plugin.getConfiguration() == config2)
})
t.Run("setting same configuration", func(t *testing.T) {
plugin := &MatterpollPlugin{}
config := &configuration{}
plugin.setConfiguration(config)
assert.Panics(t, func() {
plugin.setConfiguration(config)
})
})
t.Run("clearing configuration", func(t *testing.T) {
plugin := &MatterpollPlugin{}
config := &configuration{Trigger: "poll"}
plugin.setConfiguration(config)
assert.NotPanics(t, func() {
plugin.setConfiguration(nil)
})
assert.NotNil(t, plugin.getConfiguration())
assert.NotEqual(t, plugin, plugin.getConfiguration())
})
} | explode_data.jsonl/72788 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 446
} | [
2830,
3393,
7688,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2921,
6546,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197,
9138,
1669,
609,
44,
1650,
30141,
11546,
31483,
197,
6948,
12808,
1155,
11,
609,
21138,
22655,
9006,
670,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeepEqual(t *testing.T) {
a := map[int]string{1: "one", 2: "two", 3: "three"}
b := map[int]string{1: "one", 2: "two", 3: "three"}
fmt.Println(a == nil) // 只能和nil比较
// fmt.Println(a == b) // map 无法==比较
fmt.Println(reflect.DeepEqual(a, b))
s1 := []int{1, 2, 3}
s2 := []int{1, 2, 3}
s3 := []int{2, 3, 1}
t.Log("s1 == s2?", reflect.DeepEqual(s1, s2))
t.Log("s1 == s3?", reflect.DeepEqual(s1, s3))
c1 := Customer{"1", "Mike", 40}
c2 := Customer{"1", "Mike", 40}
fmt.Println(c1 == c2)
} | explode_data.jsonl/34893 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 270
} | [
2830,
3393,
33464,
2993,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2415,
18640,
30953,
90,
16,
25,
330,
603,
497,
220,
17,
25,
330,
19789,
497,
220,
18,
25,
330,
27856,
16707,
2233,
1669,
2415,
18640,
30953,
90,
16,
25,
330,
603,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegrationInvalidBasicAuth(t *testing.T) {
if testing.Short() || testRundeckRunning() == false {
t.Skip("skipping integration testing")
}
client, err := rundeck.NewBasicAuthClient("bob", "bob", testIntegrationURL)
require.NoError(t, err)
info, infoErr := client.GetSystemInfo()
require.Error(t, infoErr)
require.Nil(t, info)
} | explode_data.jsonl/63132 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
52464,
7928,
15944,
5087,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
1369,
1273,
49,
28865,
377,
18990,
368,
621,
895,
341,
197,
3244,
57776,
445,
4886,
5654,
17590,
7497,
1138,
220,
456,
2303,
220,
2943,
11,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeamsService_IsTeamRepoBySlug_invalidOwner(t *testing.T) {
client, _, _, teardown := setup()
defer teardown()
ctx := context.Background()
_, _, err := client.Teams.IsTeamRepoBySlug(ctx, "o", "s", "%", "r")
testURLParseError(t, err)
} | explode_data.jsonl/4533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
60669,
1860,
31879,
14597,
25243,
1359,
54968,
31433,
13801,
1155,
353,
8840,
836,
8,
341,
25291,
11,
8358,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
20985,
1669,
2266,
19047,
741,
197,
6878,
8358,
1848,
1669,
2943,
94... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_unmarshal_general_struct_of_struct(t *testing.T) {
should := require.New(t)
for _, c := range test.Combinations {
buf, proto := c.CreateProtocol()
proto.WriteStructBegin("hello")
proto.WriteFieldBegin("field1", thrift.STRUCT, 1)
proto.WriteStructBegin("hello")
proto.WriteFieldBegin("field1", thrift.STRING, 1)
proto.WriteString("abc")
proto.WriteFieldEnd()
proto.WriteFieldStop()
proto.WriteStructEnd()
proto.WriteFieldEnd()
proto.WriteFieldStop()
proto.WriteStructEnd()
var val general.Struct
should.NoError(c.Unmarshal(buf.Bytes(), &val))
should.Equal(general.Struct{
protocol.FieldId(1): "abc",
}, val[protocol.FieldId(1)])
}
} | explode_data.jsonl/47460 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
4907,
27121,
39177,
15126,
3575,
15126,
1155,
353,
8840,
836,
8,
341,
197,
5445,
1669,
1373,
7121,
1155,
340,
2023,
8358,
272,
1669,
2088,
1273,
727,
2855,
12634,
341,
197,
26398,
11,
18433,
1669,
272,
7251,
20689,
741,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSearchPostsWithDateFlags(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.LoginBasic()
Client := th.Client
message := "sgtitlereview\n with return"
createDate := time.Date(2018, 8, 1, 5, 0, 0, 0, time.UTC)
_ = th.CreateMessagePostNoClient(th.BasicChannel, message, utils.MillisFromTime(createDate))
message = "other message with no return"
createDate = time.Date(2018, 8, 2, 5, 0, 0, 0, time.UTC)
_ = th.CreateMessagePostNoClient(th.BasicChannel, message, utils.MillisFromTime(createDate))
message = "other message with no return"
createDate = time.Date(2018, 8, 3, 5, 0, 0, 0, time.UTC)
_ = th.CreateMessagePostNoClient(th.BasicChannel, message, utils.MillisFromTime(createDate))
posts, _ := Client.SearchPosts(th.BasicTeam.Id, "return", false)
require.Len(t, posts.Order, 3, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "on:", false)
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "after:", false)
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:", false)
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "on:2018-08-01", false)
require.Len(t, posts.Order, 1, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "after:2018-08-01", false)
resultCount := 0
for _, post := range posts.Posts {
if post.UserId == th.BasicUser.Id {
resultCount = resultCount + 1
}
}
require.Equal(t, 2, resultCount, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-02", false)
require.Len(t, posts.Order, 1, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-02", false)
require.Empty(t, posts.Order, "wrong number of posts")
posts, _ = Client.SearchPosts(th.BasicTeam.Id, "before:2018-08-03 after:2018-08-01", false)
require.Len(t, posts.Order, 1, "wrong number of posts")
} | explode_data.jsonl/5261 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 736
} | [
2830,
3393,
5890,
4133,
16056,
1916,
9195,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
70479,
32499,
15944,
741,
71724,
1669,
270,
11716,
271,
24753,
1669,
330,
1991,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateStringNoVariables(t *testing.T) {
tests := []string{
"string",
"endWith$",
"withNumber$1",
"abcййй",
"abcййй$1",
"",
}
for _, test := range tests {
allErrs := validateStringNoVariables(test, field.NewPath("rewritePath"))
if len(allErrs) != 0 {
t.Errorf("validateStringNoVariables(%v) returned errors for valid input: %v", test, allErrs)
}
}
} | explode_data.jsonl/65906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
17926,
703,
2753,
22678,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
917,
515,
197,
197,
1,
917,
756,
197,
197,
1,
408,
2354,
3,
756,
197,
197,
1,
4197,
2833,
3,
16,
756,
197,
197,
1,
13683,
12141,
12141,
12141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJob_Cancel(t *testing.T) {
var (
myClock = Default().Reset()
interval = time.Microsecond
waitChan1 = make(chan struct{})
waitChan2 = make(chan struct{})
jobFunc = func() {
//do nothing
}
)
job, inserted := myClock.AddJobRepeat(interval, 0, jobFunc)
if !inserted {
t.Error("add repeat job failure")
}
go func() {
expect := uint64(1)
for i := 0; i < 500; i++ {
time.Sleep(time.Millisecond * 10)
waitJobs := myClock.WaitJobs()
if waitJobs != expect {
t.Errorf("waitJobs=%v are inconsistent with expectations\n", waitJobs)
}
if i == 200 {
waitChan1 <- struct{}{}
expect = 0
}
}
waitChan2 <- struct{}{}
}()
<-waitChan1
job.Cancel()
<-waitChan2
if myClock.WaitJobs() != 0 {
t.Error("数据列表操作获取的数据与Clock实际情况不一致!")
}
} | explode_data.jsonl/2017 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
12245,
97485,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
13624,
26104,
256,
284,
7899,
1005,
14828,
741,
197,
2084,
6152,
220,
284,
882,
1321,
2754,
5569,
198,
197,
48750,
46019,
16,
284,
1281,
35190,
2036,
37790,
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 TestCAloadAffiliationsTableR(t *testing.T) {
testDirClean(t)
cfg = CAConfig{}
ca, err := newCA(configFile, &cfg, &srv, true)
if err != nil {
t.Fatal("newCA FAILED", err)
}
//Failure to write to DB; non-valid accessor
dbAccessor := new(Accessor)
ca.registry = dbAccessor
i := make([]interface{}, 3)
i[1] = []string{"", "root", "root"}
ca.Config.Affiliations = make(map[string]interface{}, 3)
ca.Config.Affiliations["a"] = i
err = ca.loadAffiliationsTable()
t.Log("ca.loadAffiliationsTable error: ", err)
if err == nil {
t.Error("ca.loadAffiliationsTableR should have failed ", err)
}
err = ca.loadAffiliationsTableR(i[1], "")
t.Log("ca.loadAffiliationsTableR error: ", err)
if err == nil {
t.Error("ca.loadAffiliationsTableR should have failed ", err)
}
err = ca.loadAffiliationsTableR(i, "root")
t.Log("ca.loadAffiliationsTableR error: ", err)
if err == nil {
t.Error("ca.loadAffiliationsTableR should have failed ", err)
}
CAclean(ca, t)
} | explode_data.jsonl/82706 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 390
} | [
2830,
3393,
5049,
1078,
25841,
3921,
804,
2556,
49,
1155,
353,
8840,
836,
8,
341,
18185,
6184,
27529,
1155,
340,
50286,
284,
9183,
2648,
16094,
197,
924,
11,
1848,
1669,
501,
5049,
8754,
1703,
11,
609,
14072,
11,
609,
40020,
11,
830,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoginWithDeviceId(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient
user := th.BasicUser
Client.Must(Client.Logout())
deviceId := model.NewId()
if result, err := Client.LoginWithDevice(user.Email, user.Password, deviceId); err != nil {
t.Fatal(err)
} else {
ruser := result.Data.(*model.User)
if ssresult, err := Client.GetSessions(ruser.Id); err != nil {
t.Fatal(err)
} else {
sessions := ssresult.Data.([]*model.Session)
if _, err := Client.LoginWithDevice(user.Email, user.Password, deviceId); err != nil {
t.Fatal(err)
}
if sresult := <-app.Srv.Store.Session().Get(sessions[0].Id); sresult.Err == nil {
t.Fatal("session should have been removed")
}
}
}
} | explode_data.jsonl/13800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
6231,
2354,
6985,
764,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
741,
71724,
1669,
270,
48868,
2959,
198,
19060,
1669,
270,
48868,
1474,
198,
71724,
50463,
46851,
5247,
411,
12367,
54719,
764,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGetVolumeLabels(t *testing.T) {
awsServices := newMockedFakeAWSServices(TestClusterId)
c, err := newAWSCloud(strings.NewReader("[global]"), awsServices)
assert.Nil(t, err, "Error building aws cloud: %v", err)
volumeId := awsVolumeID("vol-VolumeId")
expectedVolumeRequest := &ec2.DescribeVolumesInput{VolumeIds: []*string{volumeId.awsString()}}
awsServices.ec2.(*MockedFakeEC2).On("DescribeVolumes", expectedVolumeRequest).Return([]*ec2.Volume{
{
VolumeId: volumeId.awsString(),
AvailabilityZone: aws.String("us-east-1a"),
},
})
labels, err := c.GetVolumeLabels(KubernetesVolumeID("aws:///" + string(volumeId)))
assert.Nil(t, err, "Error creating Volume %v", err)
assert.Equal(t, map[string]string{
kubeletapis.LabelZoneFailureDomain: "us-east-1a",
kubeletapis.LabelZoneRegion: "us-east-1"}, labels)
awsServices.ec2.(*MockedFakeEC2).AssertExpectations(t)
} | explode_data.jsonl/29215 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
1949,
18902,
23674,
1155,
353,
8840,
836,
8,
341,
197,
8635,
11025,
1669,
501,
11571,
291,
52317,
14419,
1220,
2161,
31159,
28678,
764,
340,
1444,
11,
1848,
1669,
501,
14419,
3540,
52178,
51442,
68587,
10937,
9752,
60,
3975,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_ddosxDomainWAFAdvancedRuleCreate(t *testing.T) {
t.Run("DefaultCreate", func(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
service := mocks.NewMockDDoSXService(mockCtrl)
cmd := ddosxDomainWAFAdvancedRuleCreateCmd()
cmd.Flags().Set("section", "REQUEST_URI")
cmd.Flags().Set("modifier", "contains")
cmd.Flags().Set("phrase", "testphrase")
cmd.Flags().Set("ip", "1.2.3.4")
expectedRequest := ddosx.CreateWAFAdvancedRuleRequest{
Section: "REQUEST_URI",
Modifier: ddosx.WAFAdvancedRuleModifierContains,
Phrase: "testphrase",
IP: "1.2.3.4",
}
gomock.InOrder(
service.EXPECT().CreateDomainWAFAdvancedRule("testdomain1.co.uk", gomock.Eq(expectedRequest)).Return("00000000-0000-0000-0000-000000000000", nil),
service.EXPECT().GetDomainWAFAdvancedRule("testdomain1.co.uk", "00000000-0000-0000-0000-000000000000").Return(ddosx.WAFAdvancedRule{}, nil),
)
ddosxDomainWAFAdvancedRuleCreate(service, cmd, []string{"testdomain1.co.uk"})
})
t.Run("InvalidModifier_OutputsFatal", func(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
service := mocks.NewMockDDoSXService(mockCtrl)
cmd := ddosxDomainWAFAdvancedRuleCreateCmd()
cmd.Flags().Set("section", "REQUEST_URI")
cmd.Flags().Set("modifier", "invalidmodifier")
cmd.Flags().Set("phrase", "testphrase")
cmd.Flags().Set("ip", "1.2.3.4")
test_output.AssertFatalOutputFunc(t, func(stdErr string) {
assert.Contains(t, stdErr, "Invalid ddosx.WAFAdvancedRuleModifier")
}, func() {
ddosxDomainWAFAdvancedRuleCreate(service, cmd, []string{"testdomain1.co.uk"})
})
})
t.Run("CreateDomainWAFAdvancedRuleError_OutputsFatal", func(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
service := mocks.NewMockDDoSXService(mockCtrl)
cmd := ddosxDomainWAFAdvancedRuleCreateCmd()
cmd.Flags().Set("section", "REQUEST_URI")
cmd.Flags().Set("modifier", "contains")
cmd.Flags().Set("phrase", "testphrase")
cmd.Flags().Set("ip", "1.2.3.4")
service.EXPECT().CreateDomainWAFAdvancedRule("testdomain1.co.uk", gomock.Any()).Return("00000000-0000-0000-0000-000000000000", errors.New("test error")).Times(1)
test_output.AssertFatalOutput(t, "Error creating domain WAF advanced rule: test error\n", func() {
ddosxDomainWAFAdvancedRuleCreate(service, cmd, []string{"testdomain1.co.uk"})
})
})
t.Run("GetDomainWAFAdvancedRuleError_OutputsFatal", func(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
service := mocks.NewMockDDoSXService(mockCtrl)
cmd := ddosxDomainWAFAdvancedRuleCreateCmd()
cmd.Flags().Set("section", "REQUEST_URI")
cmd.Flags().Set("modifier", "contains")
cmd.Flags().Set("phrase", "testphrase")
cmd.Flags().Set("ip", "1.2.3.4")
gomock.InOrder(
service.EXPECT().CreateDomainWAFAdvancedRule("testdomain1.co.uk", gomock.Any()).Return("00000000-0000-0000-0000-000000000000", nil),
service.EXPECT().GetDomainWAFAdvancedRule("testdomain1.co.uk", "00000000-0000-0000-0000-000000000000").Return(ddosx.WAFAdvancedRule{}, errors.New("test error")),
)
test_output.AssertFatalOutput(t, "Error retrieving new domain WAF advanced rule [00000000-0000-0000-0000-000000000000]: test error\n", func() {
ddosxDomainWAFAdvancedRuleCreate(service, cmd, []string{"testdomain1.co.uk"})
})
})
} | explode_data.jsonl/43034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1291
} | [
2830,
3393,
43174,
436,
87,
13636,
54,
8276,
35457,
11337,
4021,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
3675,
4021,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGoManager_Unselect(t *testing.T) {
validVersion := version.Must(version.NewVersion("1.15.2"))
tempDir := t.TempDir()
sdkPath := filepath.Join(tempDir, fmt.Sprintf("go%s", validVersion))
selectedPath := filepath.Join(tempDir, selectedDirectoryName)
setupInstallation(t, tempDir, true, validVersion.String())
sut := &GoManager{
RootDirectory: tempDir,
InstalledVersions: version.Collection{validVersion},
SelectedVersion: nil,
task: &tasks.Task{
ErrorExitCode: 1,
Output: os.Stdout,
Error: os.Stderr,
},
}
assert.Error(t, sut.Unselect())
assert.False(t, fileutil.PathExists(selectedPath))
require.NoError(t, link(sdkPath, selectedPath))
sut.SelectedVersion = validVersion
assert.NoError(t, sut.Unselect())
assert.False(t, fileutil.PathExists(selectedPath))
assert.DirExists(t, sdkPath)
} | explode_data.jsonl/19006 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
10850,
2043,
40687,
1742,
1155,
353,
8840,
836,
8,
341,
56322,
5637,
1669,
2319,
50463,
37770,
7121,
5637,
445,
16,
13,
16,
20,
13,
17,
28075,
16280,
6184,
1669,
259,
65009,
6184,
741,
1903,
7584,
1820,
1669,
26054,
22363,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestK8SServiceVolumeConfigMapWithKeyFilePathAddsVolumeWithKeyFilePathToPod(t *testing.T) {
t.Parallel()
deployment := renderK8SServiceDeploymentWithSetValues(
t,
map[string]string{
"configMaps.dbsettings.as": "volume",
"configMaps.dbsettings.mountPath": "/etc/db",
"configMaps.dbsettings.items.host.filePath": "host.txt",
},
)
// Verify that there is only one volume
renderedPodVolumes := deployment.Spec.Template.Spec.Volumes
require.Equal(t, len(renderedPodVolumes), 1)
podVolume := renderedPodVolumes[0]
// Check that the pod volume is a configmap volume and has a file path instruction for host key
assert.Equal(t, podVolume.Name, "dbsettings-volume")
require.NotNil(t, podVolume.ConfigMap)
assert.Equal(t, podVolume.ConfigMap.Name, "dbsettings")
require.Equal(t, len(podVolume.ConfigMap.Items), 1)
keyToPath := podVolume.ConfigMap.Items[0]
assert.Equal(t, keyToPath.Key, "host")
assert.Equal(t, keyToPath.Path, "host.txt")
} | explode_data.jsonl/59758 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
42,
23,
1220,
1017,
18902,
2648,
2227,
2354,
1592,
19090,
72111,
18902,
2354,
1592,
19090,
1249,
23527,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
82213,
1669,
3141,
42,
23,
1220,
1017,
75286,
2354,
1649,
62... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFileOpsCollection_DeleteAtIndex_03(t *testing.T) {
sf := make([]string, 5, 10)
sf[0] = "../filesfortest/levelfilesfortest/level_0_0_test.txt"
sf[1] = "../filesfortest/levelfilesfortest/level_0_1_test.txt"
sf[2] = "../filesfortest/levelfilesfortest/level_0_2_test.txt"
sf[3] = "../filesfortest/levelfilesfortest/level_0_3_test.txt"
sf[4] = "../filesfortest/levelfilesfortest/level_0_4_test.txt"
df := make([]string, 5, 10)
df[0] = "../dirmgrtests/level_0_0_test.txt"
df[1] = "../dirmgrtests/level_0_1_test.txt"
df[2] = "../dirmgrtests/level_0_2_test.txt"
df[3] = "../dirmgrtests/level_0_3_test.txt"
df[4] = "../dirmgrtests/level_0_4_test.txt"
fOpsCol := FileOpsCollection{}.New()
for i := 0; i < 5; i++ {
err := fOpsCol.AddByPathFileNameExtStrs(sf[i], df[i])
if err != nil {
t.Errorf("Error returned by fOpsCol.AddByPathFileNameExtStrs(sf[i], df[i]). "+
"i='%v' Error='%v' ", i, err.Error())
return
}
}
err := fOpsCol.DeleteAtIndex(-1)
if err == nil {
t.Error("Expected an error return from fOpsCol.DeleteAtIndex(-1) because\n"+
"the input parameter -1 is an invalid index.\n" +
"However, NO ERROR WAS RETURNED!!!\n")
}
} | explode_data.jsonl/76444 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 547
} | [
2830,
3393,
1703,
38904,
6482,
57418,
22556,
62,
15,
18,
1155,
353,
8840,
836,
8,
1476,
220,
13124,
1669,
1281,
10556,
917,
11,
220,
20,
11,
220,
16,
15,
692,
220,
13124,
58,
15,
60,
284,
7005,
7198,
3969,
477,
14,
3449,
490,
3658... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateByTagAndValue(t *testing.T) {
validate := New()
val := "test"
field := "test"
errs := validate.VarWithValue(val, field, "required")
Equal(t, errs, nil)
fn := func(fl FieldLevel) bool {
return fl.Parent().String() == fl.Field().String()
}
errs = validate.RegisterValidation("isequaltestfunc", fn)
Equal(t, errs, nil)
errs = validate.VarWithValue(val, field, "isequaltestfunc")
Equal(t, errs, nil)
val = "unequal"
errs = validate.VarWithValue(val, field, "isequaltestfunc")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "isequaltestfunc")
} | explode_data.jsonl/77304 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
17926,
1359,
5668,
3036,
1130,
1155,
353,
8840,
836,
8,
341,
197,
7067,
1669,
1532,
2822,
19302,
1669,
330,
1944,
698,
39250,
1669,
330,
1944,
698,
9859,
82,
1669,
9593,
87968,
22767,
9098,
11,
2070,
11,
330,
6279,
1138,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddr2Liner(t *testing.T) {
const offset = 0x500
a := addr2Liner{rw: &mockAddr2liner{}, base: offset}
for i := 1; i < 8; i++ {
addr := i*0x1000 + offset
s, err := a.addrInfo(uint64(addr))
if err != nil {
t.Fatalf("addrInfo(%#x): %v", addr, err)
}
if len(s) != i {
t.Fatalf("addrInfo(%#x): got len==%d, want %d", addr, len(s), i)
}
for l, f := range s {
level := (len(s) - l) * 1000
want := plugin.Frame{Func: functionName(level), File: fmt.Sprintf("file%d", level), Line: level}
if f != want {
t.Errorf("AddrInfo(%#x)[%d]: = %+v, want %+v", addr, l, f, want)
}
}
}
s, err := a.addrInfo(0xFFFF)
if err != nil {
t.Fatalf("addrInfo(0xFFFF): %v", err)
}
if len(s) != 0 {
t.Fatalf("AddrInfo(0xFFFF): got len==%d, want 0", len(s))
}
a.rw.close()
} | explode_data.jsonl/74910 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
13986,
17,
43,
10453,
1155,
353,
8840,
836,
8,
341,
4777,
4347,
284,
220,
15,
87,
20,
15,
15,
271,
11323,
1669,
10789,
17,
43,
10453,
90,
31768,
25,
609,
16712,
13986,
17,
61798,
22655,
2331,
25,
4347,
532,
2023,
600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCompressionHC(t *testing.T) {
input := []byte(strings.Repeat("Hello world, this is quite something", 10))
output := make([]byte, CompressBound(input))
outSize, err := CompressHC(output, input)
if err != nil {
t.Fatalf("Compression failed: %v", err)
}
if outSize == 0 {
t.Fatal("Output buffer is empty.")
}
output = output[:outSize]
decompressed := make([]byte, len(input))
_, err = Uncompress(decompressed, output)
if err != nil {
t.Fatalf("Decompression failed: %v", err)
}
if string(decompressed) != string(input) {
t.Fatalf("Decompressed output != input: %q != %q", decompressed, input)
}
} | explode_data.jsonl/62979 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
81411,
22455,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
3056,
3782,
51442,
2817,
10979,
445,
9707,
1879,
11,
419,
374,
5008,
2494,
497,
220,
16,
15,
1171,
21170,
1669,
1281,
10556,
3782,
11,
1198,
1873,
19568,
5384,
1171,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestNewEvm(t *testing.T) {
//---------------------stateDB test--------------------------------------
dbName := "htdfnewevmtestdata3"
dataPath, err := ioutil.TempDir("", dbName)
require.NoError(t, err)
db := dbm.NewDB("state", dbm.GoLevelDBBackend, dataPath)
cdc := newTestCodec1()
cms := store.NewCommitMultiStore(db)
cms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, nil)
cms.MountStoreWithDB(codeKey, sdk.StoreTypeIAVL, nil)
cms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, nil)
pk := params.NewKeeper(cdc, keyParams, tkeyParams)
ak := auth.NewAccountKeeper(cdc, accKey, pk.Subspace(auth.DefaultParamspace), newevmtypes.ProtoBaseAccount)
cms.MountStoreWithDB(accKey, sdk.StoreTypeIAVL, nil)
cms.MountStoreWithDB(storageKey, sdk.StoreTypeIAVL, nil)
cms.SetPruning(store.PruneNothing)
err = cms.LoadLatestVersion()
require.NoError(t, err)
ms := cms.CacheMultiStore()
ctx := sdk.NewContext(ms, abci.Header{ChainID: "test-chain-id"}, false, log.NewNopLogger())
stateDB, err := evmtypes.NewCommitStateDB(ctx, &ak, storageKey, codeKey)
must(err)
fmt.Printf("addr=%s|testBalance=%v\n", fromAddress.String(), stateDB.GetBalance(fromAddress))
stateDB.AddBalance(fromAddress, big.NewInt(1e18))
fmt.Printf("addr=%s|testBalance=%v\n", fromAddress.String(), stateDB.GetBalance(fromAddress))
assert.Equal(t, stateDB.GetBalance(fromAddress).String() == "1000000000000000000", true)
//---------------------call evm--------------------------------------
abiFileName := "../../tests/evm/coin/coin_sol_Coin.abi"
binFileName := "../../tests/evm/coin/coin_sol_Coin.bin"
data := loadBin(binFileName)
config := appParams.MainnetChainConfig
logConfig := vm.LogConfig{}
structLogger := vm.NewStructLogger(&logConfig)
vmConfig := vm.Config{Debug: true, Tracer: structLogger /*, JumpTable: vm.NewByzantiumInstructionSet()*/}
msg := NewMessage(fromAddress, &toAddress, nonce, amount, gasLimit, big.NewInt(0), data, false)
// evmCtx := evmcore.NewEVMContext(msg, &fromAddress, 1000)
// evmCtx := evmcore.NewEVMContext(msg, &fromAddress, 1000, ctx.BlockHeader().Time)
// evm := vm.NewEVM(evmCtx, stateDB, config, vmConfig)
blockCtx := evmcore.NewEVMBlockContext(ctx.BlockHeader(), &evmcore.FakeChainContext{}, &fromAddress)
txCtx := evmcore.NewEVMTxContext(msg)
evm := vm.NewEVM(blockCtx, txCtx, stateDB, config, vmConfig)
contractRef := vm.AccountRef(fromAddress)
contractCode, contractAddr, gasLeftover, vmerr := evm.Create(contractRef, data, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("BlockNumber=%d|IsEIP158=%v\n", evm.Context.BlockNumber.Uint64(), evm.ChainConfig().IsEIP158(evm.Context.BlockNumber))
testChainConfig(t, evm)
fmt.Printf("Create|str_contractAddr=%s|gasLeftOver=%d|contractCode=%x\n", contractAddr.String(), gasLeftover, contractCode)
stateDB.SetBalance(fromAddress, big.NewInt(0).SetUint64(gasLeftover))
testBalance := stateDB.GetBalance(fromAddress)
fmt.Println("after create contract, testBalance =", testBalance)
abiObj := loadAbi(abiFileName)
input, err := abiObj.Pack("minter")
must(err)
outputs, gasLeftover, vmerr := evm.Call(contractRef, contractAddr, input, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("smartcontract func, minter|the minter addr=%s\n", common.BytesToAddress(outputs).String())
sender := common.BytesToAddress(outputs)
fmt.Printf("sender=%s|fromAddress=%s\n", sender.String(), fromAddress.String())
if !bytes.Equal(sender.Bytes(), fromAddress.Bytes()) {
fmt.Println("caller are not equal to minter!!")
os.Exit(-1)
}
senderAcc := vm.AccountRef(sender)
input, err = abiObj.Pack("mint", sender, big.NewInt(1000000))
must(err)
outputs, gasLeftover, vmerr = evm.Call(senderAcc, contractAddr, input, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("smartcontract func, mint|senderAcc=%s\n", sender.String())
stateDB.SetBalance(fromAddress, big.NewInt(0).SetUint64(gasLeftover))
testBalance = evm.StateDB.GetBalance(fromAddress)
input, err = abiObj.Pack("send", toAddress, big.NewInt(11))
outputs, gasLeftover, vmerr = evm.Call(senderAcc, contractAddr, input, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("smartcontract func, send 1|senderAcc=%s|toAddress=%s\n", senderAcc.Address().String(), toAddress.String())
//send
input, err = abiObj.Pack("send", toAddress, big.NewInt(19))
must(err)
outputs, gasLeftover, vmerr = evm.Call(senderAcc, contractAddr, input, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("smartcontract func, send 2|senderAcc=%s|toAddress=%s\n", senderAcc.Address().String(), toAddress.String())
// get balance
input, err = abiObj.Pack("balances", toAddress)
must(err)
outputs, gasLeftover, vmerr = evm.Call(contractRef, contractAddr, input, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("smartcontract func, balances|toAddress=%s|balance=%x\n", toAddress.String(), outputs)
toAddressBalance := outputs
// get balance
input, err = abiObj.Pack("balances", sender)
must(err)
outputs, gasLeftover, vmerr = evm.Call(contractRef, contractAddr, input, stateDB.GetBalance(fromAddress).Uint64(), big.NewInt(0))
must(vmerr)
fmt.Printf("smartcontract func, balances|sender=%s|balance=%x\n", sender.String(), outputs)
// get event
logs := stateDB.Logs()
for _, log := range logs {
fmt.Printf("%#v\n", log)
for _, topic := range log.Topics {
fmt.Printf("topic: %#v\n", topic)
}
fmt.Printf("data: %#v\n", log.Data)
}
testBalance = stateDB.GetBalance(fromAddress)
fmt.Println("get testBalance =", testBalance)
//commit
stateDB.Commit(false)
ms.Write()
cms.Commit()
db.Close()
if !bytes.Equal(contractCode, stateDB.GetCode(contractAddr)) {
fmt.Println("BUG!,the code was changed!")
os.Exit(-1)
}
//reopen DB
err = reOpenDB(t, contractCode, contractAddr.String(), toAddressBalance, dataPath)
must(err)
//remove DB dir
cleanup(dataPath)
} | explode_data.jsonl/70885 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2273
} | [
2830,
3393,
3564,
36,
7338,
1155,
353,
8840,
836,
8,
1476,
197,
61683,
15081,
2454,
3506,
1273,
1408,
26409,
20939,
675,
1669,
330,
426,
2940,
931,
5120,
76,
92425,
18,
698,
8924,
1820,
11,
1848,
1669,
43144,
65009,
6184,
19814,
75564,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNew(t *testing.T) {
exp := fmt.Errorf("my bad %d", 42)
err := errstack.New(exp)
if err == nil {
t.Fatalf("expected a non-nil error. got=%#v\n", err)
}
if err, ok := err.(*errstack.Error); !ok {
t.Fatalf("expected an *errstack.Error. got=%T\n", err)
} else {
if !reflect.DeepEqual(err.Err, exp) {
t.Fatalf("expected err.Err=%v.\ngot=%v\n", exp, err.Err)
}
}
} | explode_data.jsonl/39237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
48558,
1669,
8879,
13080,
445,
2408,
3873,
1018,
67,
497,
220,
19,
17,
692,
9859,
1669,
1848,
7693,
7121,
25865,
340,
743,
1848,
621,
2092,
341,
197,
3244,
30762,
445,
7325,
264,
2477,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUsageWithDescription(t *testing.T) {
expectedUsage := "Usage: example"
expectedHelp := `
this program does this and that
Usage: example
Options:
--help, -h display this help and exit
`
os.Args[0] = "example"
p, err := NewParser(Config{}, &described{})
require.NoError(t, err)
var help bytes.Buffer
p.WriteHelp(&help)
assert.Equal(t, expectedHelp[1:], help.String())
var usage bytes.Buffer
p.WriteUsage(&usage)
assert.Equal(t, expectedUsage, strings.TrimSpace(usage.String()))
} | explode_data.jsonl/20495 | {
"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,
14783,
2354,
5009,
1155,
353,
8840,
836,
8,
341,
42400,
14783,
1669,
330,
14783,
25,
3110,
1837,
42400,
12689,
1669,
22074,
574,
2025,
1558,
419,
323,
429,
198,
14783,
25,
3110,
271,
3798,
510,
220,
1177,
8653,
11,
481,
71... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVarSum(t *testing.T) {
protest.AllowRecording(t)
withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) {
assertNoError(p.Continue(), t, "Continue()")
sumvar := evalVariable(p, t, "s1[0] + s1[1]")
sumvarstr := constant.StringVal(sumvar.Value)
if sumvarstr != "onetwo" {
t.Fatalf("s1[0] + s1[1] == %q (expected \"onetwo\")", sumvarstr)
}
if sumvar.Len != int64(len(sumvarstr)) {
t.Fatalf("sumvar.Len == %d (expected %d)", sumvar.Len, len(sumvarstr))
}
})
} | explode_data.jsonl/56284 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
3962,
9190,
1155,
353,
8840,
836,
8,
341,
197,
776,
1944,
29081,
52856,
1155,
340,
46948,
2271,
7423,
445,
1944,
18616,
17,
497,
259,
11,
2915,
1295,
353,
15782,
35016,
11,
12507,
8665,
991,
12735,
8,
341,
197,
6948,
2753,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSSHA_SuccessOnFly(t *testing.T) {
password := []byte("this-is-password")
h, err := ssha.GenerateSSHAFromPassword(password, 0)
if nil != err {
t.Errorf("failed on GenerateSSHAFromPassword: %v", err)
}
err = ssha.CompareHashAndPassword(h, password)
if nil != err {
t.Errorf("failed on CompareHashAndPassword: %v", err)
}
} | explode_data.jsonl/81457 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
1220,
17020,
87161,
1925,
53000,
1155,
353,
8840,
836,
8,
341,
58199,
1669,
3056,
3782,
445,
574,
30430,
33069,
1138,
9598,
11,
1848,
1669,
274,
15247,
57582,
1220,
17020,
3830,
4876,
22768,
11,
220,
15,
340,
743,
2092,
961,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAddWhileRunningWithDelay(t *testing.T) {
cron := New()
cron.Start()
defer cron.Stop()
time.Sleep(5 * time.Second)
var calls = 0
cron.AddFunc("* * * * * *", func() { calls += 1 })
<-time.After(ONE_SECOND)
if calls != 1 {
fmt.Printf("called %d times, expected 1\n", calls)
t.Fail()
}
} | explode_data.jsonl/10556 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
2212,
7983,
18990,
2354,
20039,
1155,
353,
8840,
836,
8,
341,
1444,
2248,
1669,
1532,
741,
1444,
2248,
12101,
741,
16867,
46582,
30213,
741,
21957,
31586,
7,
20,
353,
882,
32435,
340,
2405,
6738,
284,
220,
15,
198,
1444,
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 TestAggregatorMultiFunc(t *testing.T) {
testCases := []aggregatorTestCase{
{
aggFns: []distsqlpb.AggregatorSpec_Func{distsqlpb.AggregatorSpec_SUM, distsqlpb.AggregatorSpec_SUM},
aggCols: [][]uint32{
{2}, {1},
},
input: tuples{
{0, 1, 2},
{0, 1, 2},
},
colTypes: []types.T{types.Int64, types.Int64, types.Int64},
expected: tuples{
{4, 2},
},
name: "OutputOrder",
},
{
aggFns: []distsqlpb.AggregatorSpec_Func{distsqlpb.AggregatorSpec_SUM, distsqlpb.AggregatorSpec_SUM},
aggCols: [][]uint32{
{2}, {1},
},
input: tuples{
{0, 1, 1.3},
{0, 1, 1.6},
{0, 1, 0.5},
{1, 1, 1.2},
},
colTypes: []types.T{types.Int64, types.Int64, types.Decimal},
expected: tuples{
{3.4, 3},
{1.2, 1},
},
name: "SumMultiType",
convToDecimal: true,
},
{
aggFns: []distsqlpb.AggregatorSpec_Func{distsqlpb.AggregatorSpec_AVG, distsqlpb.AggregatorSpec_SUM},
aggCols: [][]uint32{
{1}, {1},
},
input: tuples{
{0, 1.1},
{0, 1.2},
{0, 2.3},
{1, 6.21},
{1, 2.43},
},
colTypes: []types.T{types.Int64, types.Decimal},
expected: tuples{
{"1.5333333333333333333", 4.6},
{4.32, 8.64},
},
name: "AvgSumSingleInputBatch",
convToDecimal: true,
},
}
for _, agg := range aggTypes {
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s/%s/Randomized", agg.name, tc.name), func(t *testing.T) {
if err := tc.init(); err != nil {
t.Fatal(err)
}
runTests(t, []tuples{tc.input}, func(t *testing.T, input []Operator) {
a, err := agg.new(
input[0],
tc.colTypes,
tc.aggFns,
tc.groupCols,
tc.aggCols,
)
if err != nil {
t.Fatal(err)
}
out := newOpTestOutput(a, []int{0, 1}, tc.expected)
if err := out.VerifyAnyOrder(); err != nil {
t.Fatal(err)
}
})
})
}
}
} | explode_data.jsonl/8883 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1066
} | [
2830,
3393,
9042,
58131,
20358,
9626,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
351,
58131,
16458,
515,
197,
197,
515,
298,
197,
15718,
37,
4412,
25,
3056,
67,
1671,
1470,
16650,
49850,
58131,
8327,
1400,
1347,
90,
67,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRestoreDatabaseVersusTable(t *testing.T) {
defer leaktest.AfterTest(t)()
const numAccounts = 1
_, tc, origDB, _, cleanupFn := BackupRestoreTestSetup(t, singleNode, numAccounts, InitNone)
defer cleanupFn()
args := base.TestServerArgs{ExternalIODir: tc.Servers[0].ClusterSettings().ExternalIODir}
for _, q := range []string{
`CREATE DATABASE d2`,
`CREATE DATABASE d3`,
`CREATE TABLE d3.foo (a INT)`,
`CREATE DATABASE d4`,
`CREATE TABLE d4.foo (a INT)`,
`CREATE TABLE d4.bar (a INT)`,
} {
origDB.Exec(t, q)
}
d4foo := "nodelocal://0/d4foo"
d4foobar := "nodelocal://0/d4foobar"
d4star := "nodelocal://0/d4star"
origDB.Exec(t, `BACKUP DATABASE data, d2, d3, d4 TO $1`, LocalFoo)
origDB.Exec(t, `BACKUP d4.foo TO $1`, d4foo)
origDB.Exec(t, `BACKUP d4.foo, d4.bar TO $1`, d4foobar)
origDB.Exec(t, `BACKUP d4.* TO $1`, d4star)
t.Run("incomplete-db", func(t *testing.T) {
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(context.Background())
sqlDB := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
sqlDB.Exec(t, `create database d5`)
sqlDB.ExpectErr(
t, "cannot RESTORE DATABASE from a backup of individual tables",
`RESTORE database d4 FROM $1`, d4foo,
)
sqlDB.ExpectErr(
t, "cannot RESTORE <database>.* from a backup of individual tables",
`RESTORE d4.* FROM $1 WITH into_db = 'd5'`, d4foo,
)
sqlDB.ExpectErr(
t, "cannot RESTORE DATABASE from a backup of individual tables",
`RESTORE database d4 FROM $1`, d4foobar,
)
sqlDB.ExpectErr(
t, "cannot RESTORE <database>.* from a backup of individual tables",
`RESTORE d4.* FROM $1 WITH into_db = 'd5'`, d4foobar,
)
sqlDB.ExpectErr(
t, "cannot RESTORE DATABASE from a backup of individual tables",
`RESTORE database d4 FROM $1`, d4foo,
)
sqlDB.Exec(t, `RESTORE database d4 FROM $1`, d4star)
})
t.Run("db", func(t *testing.T) {
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(context.Background())
sqlDB := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
sqlDB.Exec(t, `RESTORE DATABASE data, d2, d3 FROM $1`, LocalFoo)
})
t.Run("db-exists", func(t *testing.T) {
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(context.Background())
sqlDB := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
sqlDB.Exec(t, `CREATE DATABASE data`)
sqlDB.ExpectErr(t, "already exists", `RESTORE DATABASE data FROM $1`, LocalFoo)
})
t.Run("tables", func(t *testing.T) {
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(context.Background())
sqlDB := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
sqlDB.Exec(t, `CREATE DATABASE data`)
sqlDB.Exec(t, `RESTORE data.* FROM $1`, LocalFoo)
})
t.Run("tables-needs-db", func(t *testing.T) {
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(context.Background())
sqlDB := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
sqlDB.ExpectErr(t, "needs to exist", `RESTORE data.*, d4.* FROM $1`, LocalFoo)
})
t.Run("into_db", func(t *testing.T) {
tcRestore := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args})
defer tcRestore.Stopper().Stop(context.Background())
sqlDB := sqlutils.MakeSQLRunner(tcRestore.Conns[0])
sqlDB.ExpectErr(
t, `cannot use "into_db"`,
`RESTORE DATABASE data FROM $1 WITH into_db = 'other'`, LocalFoo,
)
})
} | explode_data.jsonl/57605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1543
} | [
2830,
3393,
56284,
5988,
83956,
355,
2556,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
4777,
1629,
41369,
284,
220,
16,
198,
197,
6878,
17130,
11,
2713,
3506,
11,
8358,
21290,
24911,
1669,
43438,
56284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalResponseUnmarshalError(t *testing.T) {
defer func() {
jsonUnmarshal = json.Unmarshal
}()
testErr := errors.New("ERROR")
jsonUnmarshal = func([]byte, interface{}) error { return testErr }
Convey("Given a byte message", t, func() {
var msg []byte
Convey("And MarshalResponse throws an error while unmarshalling", func() {
_, err := MarshalResponse(msg)
Convey("Then err should equal the test error", func() {
So(err, ShouldResemble, gremerror.NewUnmarshalError("MarshalResponse", msg, testErr))
})
})
})
} | explode_data.jsonl/79108 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
55438,
2582,
1806,
27121,
1454,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
368,
341,
197,
30847,
1806,
27121,
284,
2951,
38097,
198,
197,
69826,
18185,
7747,
1669,
5975,
7121,
445,
3682,
1138,
30847,
1806,
27121,
284,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleSpaceAfterDot(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
{
"SELECT * FROM sakila. film",
"SELECT film. length FROM film",
},
{
"SELECT * FROM sakila.film",
"SELECT film.length FROM film",
"SELECT * FROM t1, t2 WHERE t1.title = t2.title",
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleSpaceAfterDot()
if rule.Item != "STA.002" {
t.Error("Rule not match:", rule.Item, "Expect : STA.002")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleSpaceAfterDot()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76848 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
11337,
9914,
6025,
34207,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
515,
298,
197,
1,
4858,
353,
4295,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateAuthInfoExecNoVersion(t *testing.T) {
config := clientcmdapi.NewConfig()
config.AuthInfos["user"] = &clientcmdapi.AuthInfo{
Exec: &clientcmdapi.ExecConfig{
Command: "/bin/example",
},
}
test := configValidationTest{
config: config,
expectedErrorSubstring: []string{
"apiVersion must be specified for user to use exec authentication plugin",
},
}
test.testAuthInfo("user", t)
test.testConfig(t)
} | explode_data.jsonl/48045 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
17926,
5087,
1731,
10216,
2753,
5637,
1155,
353,
8840,
836,
8,
972,
25873,
1669,
2943,
8710,
2068,
7121,
2648,
3568,
25873,
25233,
38059,
1183,
872,
1341,
284,
609,
2972,
8710,
2068,
25233,
1731,
1666,
197,
197,
10216,
25,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSendOpenTSDBFormat(t *testing.T) {
s, port := tcpudp.NewUDPServer(&defaultConf, true)
defer s.Stop()
cs := otsdbserializer.New(128)
m := createTimelineManager(port, false, false, defaultTransportSize, time.Second, cs)
defer m.Shutdown()
m.Start(false)
items := []*otsdbserializer.ArrayItem{
{
Metric: "opentsdb-metric1",
Timestamp: time.Now().Unix(),
Value: float64(utils.RandomInt(0, 1000)),
Tags: []interface{}{
"tag1", "val1",
"tag2", "val2",
"tag3", "val3",
},
},
{
Metric: "opentsdb-metric2",
Timestamp: time.Now().Unix(),
Value: float64(utils.RandomInt(0, 1000)),
Tags: []interface{}{
"tag4", "val4",
"tag5", "val5",
},
},
{
Metric: "opentsdb-metric3",
Timestamp: time.Now().Unix(),
Value: float64(utils.RandomInt(0, 1000)),
Tags: []interface{}{
"tag6", "val6",
},
},
}
m.Send(items)
<-time.After(2 * time.Second)
expected := make([]string, len(items))
expected[0] = fmt.Sprintf("put %s %d %d tag1=val1 tag2=val2 tag3=val3\n", items[0].Metric, items[0].Timestamp, int(items[0].Value))
expected[1] = fmt.Sprintf("put %s %d %d tag4=val4 tag5=val5\n", items[1].Metric, items[1].Timestamp, int(items[1].Value))
expected[2] = fmt.Sprintf("put %s %d %d tag6=val6\n", items[2].Metric, items[2].Timestamp, int(items[2].Value))
for i := 0; i < len(items); i++ {
message := <-s.MessageChannel()
assert.Equal(t, expected[i], message.Message, "expected same data")
}
} | explode_data.jsonl/68118 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 680
} | [
2830,
3393,
11505,
5002,
9951,
3506,
4061,
1155,
353,
8840,
836,
8,
1476,
1903,
11,
2635,
1669,
28051,
31101,
7121,
4656,
5012,
2836,
2099,
2258,
15578,
11,
830,
340,
16867,
274,
30213,
2822,
71899,
1669,
297,
2576,
1999,
52718,
7121,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTx_Cursor(t *testing.T) {
db := MustOpenDB()
defer db.MustClose()
if err := db.Update(func(tx *bolt.Tx) error {
if _, err := tx.CreateBucket([]byte("widgets")); err != nil {
t.Fatal(err)
}
if _, err := tx.CreateBucket([]byte("woojits")); err != nil {
t.Fatal(err)
}
c := tx.Cursor()
if k, v := c.First(); !bytes.Equal(k, []byte("widgets")) {
t.Fatalf("unexpected key: %v", k)
} else if v != nil {
t.Fatalf("unexpected value: %v", v)
}
if k, v := c.Next(); !bytes.Equal(k, []byte("woojits")) {
t.Fatalf("unexpected key: %v", k)
} else if v != nil {
t.Fatalf("unexpected value: %v", v)
}
if k, v := c.Next(); k != nil {
t.Fatalf("unexpected key: %v", k)
} else if v != nil {
t.Fatalf("unexpected value: %v", k)
}
return nil
}); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/1684 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 391
} | [
2830,
3393,
31584,
920,
3823,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
15465,
5002,
3506,
741,
16867,
2927,
50463,
7925,
741,
743,
1848,
1669,
2927,
16689,
18552,
27301,
353,
52433,
81362,
8,
1465,
341,
197,
743,
8358,
1848,
1669,
985... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubscriptions_ToByteSubscriptions(t *testing.T) {
tests := []struct {
name string
sub Subscriptions
want ByteSubscriptions
}{
{
"ecspec_sample.csv -> ByteSubscriptions",
Subscriptions{
"http://localhost:8888/grai": []string{"urn:epc:pat:grai-96:3.123456.1.1"},
"http://localhost:8888/17365": []string{"urn:epc:pat:iso17365:25S.UN.ABC.0THANK0YOU0FOR0READING0THIS1"},
"http://localhost:8888/giai": []string{"urn:epc:pat:giai-96:3.02283922192.45325296932379"},
"http://localhost:8888/17363": []string{"urn:epc:pat:iso17363:7B.MTR"},
"http://localhost:8888/sgtin": []string{"urn:epc:pat:sgtin-96:3.999203.7757355"},
"http://localhost:8888/sscc": []string{"urn:epc:pat:sscc-96:3.00039579721"},
},
ByteSubscriptions{
"0011000001111011110011111100100011011101100101111000101011": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/sgtin"},
"001100010110010000000000010010110111111000001001001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/sscc"},
"001100110111100001111000100100000000000000000000000000000100000000000000000000000000000000000001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/grai"},
"0011010001100100000100010000010000111100011000100001010010011100100011110001110010001011000011011": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/giai"},
"110010110101010011010101001110000001000010000011110000010100001000000001001110001011110000011001001111010101110000000110001111010010110000010010000101000001000100001001001110000111110000010100001000001001010011110001": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/17365"},
"110111000010001101010100010010": &PartialSubscription{Offset: 0, ReportURI: "http://localhost:8888/17363"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.sub.ToByteSubscriptions()
for pfs, psub := range tt.want {
if gotPsub, ok := got[pfs]; !ok {
t.Errorf("Subscriptions.ToByteSubscriptions() = want %v", pfs)
} else if gotPsub.Offset != psub.Offset {
t.Errorf("Subscriptions.ToByteSubscriptions() = %q, want %q", gotPsub, psub)
} else if gotPsub.ReportURI != psub.ReportURI {
t.Errorf("Subscriptions.ToByteSubscriptions() = %q, want %q", gotPsub, psub)
}
}
})
}
} | explode_data.jsonl/38241 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1530
} | [
2830,
3393,
3136,
29966,
38346,
7153,
3136,
29966,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
28624,
220,
3719,
29966,
198,
197,
50780,
10906,
3136,
29966,
198,
197,
59403,
197,
197,
515,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestIncompatibleTiKV(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
wg := &sync.WaitGroup{}
// the minimum valid TiKV version is "4.0.0-rc.1"
incompatibilityVers := []string{"v2.1.10", "v3.0.10", "v3.1.0", "v4.0.0-rc"}
var genLock sync.Mutex
nextVer := -1
call := int32(0)
versionGenCallBoundary := int32(8)
gen := func() string {
genLock.Lock()
defer genLock.Unlock()
atomic.AddInt32(&call, 1)
if atomic.LoadInt32(&call) < versionGenCallBoundary {
nextVer = (nextVer + 1) % len(incompatibilityVers)
return incompatibilityVers[nextVer]
}
return defaultVersionGen()
}
var requestIds sync.Map
ch1 := make(chan *cdcpb.ChangeDataEvent, 10)
srv1 := newMockChangeDataService(t, ch1)
srv1.recvLoop = func(server cdcpb.ChangeData_EventFeedServer) {
for {
req, err := server.Recv()
if err != nil {
log.Error("mock server error", zap.Error(err))
return
}
requestIds.Store(req.RegionId, req.RequestId)
}
}
server1, addr1 := newMockService(ctx, t, srv1, wg)
defer func() {
close(ch1)
server1.Stop()
wg.Wait()
}()
rpcClient, cluster, pdClient, err := testutils.NewMockTiKV("", mockcopr.NewCoprRPCHandler())
require.Nil(t, err)
pdClient = &mockPDClient{Client: pdClient, versionGen: gen}
kvStorage, err := tikv.NewTestTiKVStore(rpcClient, pdClient, nil, nil, 0)
require.Nil(t, err)
defer kvStorage.Close() //nolint:errcheck
regionID := uint64(3)
cluster.AddStore(1, addr1)
cluster.Bootstrap(regionID, []uint64{1}, []uint64{4}, 4)
err = failpoint.Enable("github.com/pingcap/tiflow/cdc/kv/kvClientDelayWhenIncompatible", "return(true)")
require.Nil(t, err)
defer func() {
_ = failpoint.Disable("github.com/pingcap/tiflow/cdc/kv/kvClientDelayWhenIncompatible")
}()
lockResolver := txnutil.NewLockerResolver(kvStorage,
model.DefaultChangeFeedID("changefeed-test"),
util.RoleTester)
isPullInit := &mockPullerInit{}
grpcPool := NewGrpcPoolImpl(ctx, &security.Credential{})
defer grpcPool.Close()
regionCache := tikv.NewRegionCache(pdClient)
defer regionCache.Close()
cdcClient := NewCDCClient(
ctx, pdClient, grpcPool, regionCache, pdutil.NewClock4Test(),
model.DefaultChangeFeedID(""),
config.GetDefaultServerConfig().KVClient)
// NOTICE: eventCh may block the main logic of EventFeed
eventCh := make(chan model.RegionFeedEvent, 128)
wg.Add(1)
go func() {
defer wg.Done()
err := cdcClient.EventFeed(ctx,
regionspan.ComparableSpan{Start: []byte("a"), End: []byte("b")},
100, lockResolver, isPullInit, eventCh)
require.Equal(t, context.Canceled, errors.Cause(err))
}()
err = retry.Do(context.Background(), func() error {
if atomic.LoadInt32(&call) >= versionGenCallBoundary {
return nil
}
return errors.Errorf("version generator is not updated in time, call time %d", atomic.LoadInt32(&call))
}, retry.WithBackoffBaseDelay(500), retry.WithBackoffMaxDelay(60*1000), retry.WithMaxTries(20))
require.Nil(t, err)
err = retry.Do(context.Background(), func() error {
_, ok := requestIds.Load(regionID)
if ok {
return nil
}
return errors.New("waiting for kv client requests received by server")
}, retry.WithBackoffBaseDelay(200), retry.WithBackoffMaxDelay(60*1000), retry.WithMaxTries(10))
require.Nil(t, err)
reqID, _ := requestIds.Load(regionID)
initialized := mockInitializedEvent(regionID, reqID.(uint64))
ch1 <- initialized
select {
case event := <-eventCh:
require.NotNil(t, event.Resolved)
require.Equal(t, regionID, event.RegionID)
case <-time.After(time.Second):
require.Fail(t, "expected events are not receive")
}
cancel()
} | explode_data.jsonl/32872 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1429
} | [
2830,
3393,
641,
34842,
45351,
82707,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
72079,
1669,
609,
12996,
28384,
2808,
31483,
197,
322,
279,
8028,
2697,
22325,
82707,
2319,
374,
330,
19,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLevelDBReceiptsGetReceiptErrorGeneratedID(t *testing.T) {
assert := assert.New(t)
kvstoreMock := &mockKVStore{
err: fmt.Errorf("pop"),
getFailIdx: 1,
getVal: []byte("generated-id"),
}
r := &levelDBReceipts{
conf: &LevelDBReceiptStoreConf{},
store: kvstoreMock,
}
_, err := r.GetReceipt("receipt1")
assert.EqualError(err, "Failed to retrieve the entry for the generated ID: receipt1. pop")
} | explode_data.jsonl/21462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
4449,
3506,
67461,
82,
1949,
67461,
1454,
15741,
915,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
16463,
85,
4314,
11571,
1669,
609,
16712,
82707,
6093,
515,
197,
9859,
25,
286,
8879,
13080,
445,
8374,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStateNonServing(t *testing.T) {
ctx := context.Background()
ts := memorytopo.NewServer("cell1")
tm := newTestTM(t, ts, 1, "ks", "0")
defer tm.Stop()
tm.tmState.mu.Lock()
tm.tmState.tablet.Type = topodatapb.TabletType_SPARE
tm.tmState.updateLocked(ctx)
tm.tmState.mu.Unlock()
qsc := tm.QueryServiceControl.(*tabletservermock.Controller)
assert.Equal(t, topodatapb.TabletType_SPARE, qsc.CurrentTarget().TabletType)
assert.False(t, qsc.IsServing())
} | explode_data.jsonl/75590 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
1397,
8121,
50,
19505,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
57441,
1669,
4938,
3481,
78,
7121,
5475,
445,
5873,
16,
1138,
3244,
76,
1669,
501,
2271,
22034,
1155,
11,
10591,
11,
220,
16,
11,
330,
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 TestMemberCancelInviteSocial(t *testing.T) {
tc, _, name := memberSetup(t)
defer tc.Cleanup()
tc.G.SetServices(externals.GetServices())
username := "not_on_kb_yet@twitter"
_, err := AddMember(context.TODO(), tc.G, name, username, keybase1.TeamRole_READER)
if err != nil {
t.Fatal(err)
}
assertInvite(tc, name, "not_on_kb_yet", "twitter", keybase1.TeamRole_READER)
if err := RemoveMember(context.TODO(), tc.G, name, username); err != nil {
t.Fatal(err)
}
assertNoInvite(tc, name, "not_on_kb_yet", "twitter")
} | explode_data.jsonl/13535 | {
"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,
9366,
9269,
93540,
26317,
1155,
353,
8840,
836,
8,
341,
78255,
11,
8358,
829,
1669,
4462,
21821,
1155,
340,
16867,
17130,
727,
60639,
2822,
78255,
1224,
4202,
11025,
7,
4301,
1127,
2234,
11025,
12367,
72358,
1669,
330,
1921,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseRemittanceOriginatorWrongLength(t *testing.T) {
var line = "{8300}OICUSTName 111111 Bank ADDRDepartment Sub-Department Street Name 16 19405 AnyTown PA UAAddress Line One Address Line Two Address Line Three Address Line Four Address Line Five Address Line Six Address Line Seven USContact Name 5551231212 5551231212 5551231212 http://www.moov.io Contact Other "
r := NewReader(strings.NewReader(line))
r.line = line
err := r.parseRemittanceOriginator()
require.EqualError(t, err, r.parseError(NewTagWrongLengthErr(3442, len(r.line))).Error())
} | explode_data.jsonl/32952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3312
} | [
2830,
3393,
14463,
6590,
87191,
13298,
850,
29185,
4373,
1155,
353,
8840,
836,
8,
341,
2405,
1555,
284,
13868,
23,
18,
15,
15,
92,
46,
1317,
8553,
675,
5238,
22335,
220,
16,
16,
16,
16,
16,
16,
6526,
8547,
5238,
18749,
80514,
26627,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoOpTracerWithLogger_Logger(t *testing.T) {
// reset default tracer after the test completes
t.Cleanup(func() {
tab.Register(&tab.NoOpTracer{})
})
// span attributes that we expect the logger to propagate to log entries
attrs := []tab.Attribute{
{Key: "somestring", Value: "xyz"},
{Key: "someint", Value: 42},
{Key: "somebool", Value: false},
}
ctx := context.Background()
t.Run("info level", func(t *testing.T) {
var logOutput bytes.Buffer
tracer := newLogTracer(&logOutput)
logger := tracer.FromContext(ctx).Logger()
logger.Info("test message", attrs...)
const expect = `{"level":"info","msg":"test message","somestring":"xyz","someint":42,"somebool":false}` + "\n"
if got := logOutput.String(); got != expect {
t.Errorf("Expected\n %sgot\n %s", expect, got)
}
})
t.Run("error level", func(t *testing.T) {
var logOutput bytes.Buffer
tracer := newLogTracer(&logOutput)
logger := tracer.FromContext(ctx).Logger()
logger.Error(fmt.Errorf("test message"), attrs...)
const expect = `{"level":"error","msg":"test message","somestring":"xyz","someint":42,"somebool":false}` + "\n"
if got := logOutput.String(); got != expect {
t.Errorf("Expected\n %sgot\n %s", expect, got)
}
})
t.Run("fatal level", func(t *testing.T) {
var logOutput bytes.Buffer
tracer := newLogTracer(&logOutput,
// zap calls os.Exit(1) by default on Fatal, which is
// difficult to handle in tests. WriteThenNoop is
// unfortunately explicitly rejected by zap on Fatal,
// so we fallback to WriteThenPanic and call recover().
zap.OnFatal(zapcore.WriteThenPanic),
)
logger := tracer.FromContext(ctx).Logger()
func() {
defer func() { _ = recover() }()
logger.Fatal("test message", attrs...)
}()
const expect = `{"level":"fatal","msg":"test message","somestring":"xyz","someint":42,"somebool":false}` + "\n"
if got := logOutput.String(); got != expect {
t.Errorf("Expected\n %sgot\n %s", expect, got)
}
})
t.Run("debug level", func(t *testing.T) {
var logOutput bytes.Buffer
tracer := newLogTracer(&logOutput)
logger := tracer.FromContext(ctx).Logger()
logger.Debug("test message", attrs...)
const expect = `{"level":"debug","msg":"test message","somestring":"xyz","someint":42,"somebool":false}` + "\n"
if got := logOutput.String(); got != expect {
t.Errorf("Expected\n %sgot\n %s", expect, got)
}
})
} | explode_data.jsonl/67911 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 916
} | [
2830,
3393,
2753,
7125,
1282,
9584,
2354,
7395,
62,
7395,
1155,
353,
8840,
836,
8,
341,
197,
322,
7585,
1638,
64306,
1283,
279,
1273,
44595,
198,
3244,
727,
60639,
18552,
368,
341,
197,
58149,
19983,
2099,
6192,
16766,
7125,
1282,
9584,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateGenesisState(t *testing.T) {
specs := map[string]struct {
srcMutator func(*GenesisState)
expError bool
}{
"all good": {
srcMutator: func(s *GenesisState) {},
},
"params invalid": {
srcMutator: func(s *GenesisState) {
s.Params = Params{}
},
expError: true,
},
"codeinfo invalid": {
srcMutator: func(s *GenesisState) {
s.Codes[0].CodeInfo.CodeHash = nil
},
expError: true,
},
"contract invalid": {
srcMutator: func(s *GenesisState) {
s.Contracts[0].ContractAddress = "invalid"
},
expError: true,
},
"sequence invalid": {
srcMutator: func(s *GenesisState) {
s.Sequences[0].IDKey = nil
},
expError: true,
},
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
state := GenesisFixture(spec.srcMutator)
got := state.ValidateBasic()
if spec.expError {
require.Error(t, got)
return
}
require.NoError(t, got)
})
}
} | explode_data.jsonl/13136 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 435
} | [
2830,
3393,
17926,
84652,
1397,
1155,
353,
8840,
836,
8,
341,
98100,
82,
1669,
2415,
14032,
60,
1235,
341,
197,
41144,
51440,
850,
2915,
4071,
84652,
1397,
340,
197,
48558,
1454,
256,
1807,
198,
197,
59403,
197,
197,
1,
541,
1661,
788... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStructOfWithInterface(t *testing.T) {
const want = 42
type Iface interface {
Get() int
}
for i, table := range []struct {
typ Type
val Value
impl bool
}{
{
typ: TypeOf(StructI(want)),
val: ValueOf(StructI(want)),
impl: true,
},
{
typ: PtrTo(TypeOf(StructI(want))),
val: ValueOf(func() interface{} {
v := StructI(want)
return &v
}()),
impl: true,
},
{
typ: PtrTo(TypeOf(StructIPtr(want))),
val: ValueOf(func() interface{} {
v := StructIPtr(want)
return &v
}()),
impl: true,
},
{
typ: TypeOf(StructIPtr(want)),
val: ValueOf(StructIPtr(want)),
impl: false,
},
// {
// typ: TypeOf((*Iface)(nil)).Elem(), // FIXME(sbinet): fix method.ifn/tfn
// val: ValueOf(StructI(want)),
// impl: true,
// },
} {
rt := StructOf(
[]StructField{
{
Name: "",
PkgPath: "",
Type: table.typ,
},
},
)
rv := New(rt).Elem()
rv.Field(0).Set(table.val)
if _, ok := rv.Interface().(Iface); ok != table.impl {
if table.impl {
t.Errorf("test-%d: type=%v fails to implement Iface.\n", i, table.typ)
} else {
t.Errorf("test-%d: type=%v should NOT implement Iface\n", i, table.typ)
}
continue
}
if !table.impl {
continue
}
v := rv.Interface().(Iface).Get()
if v != want {
t.Errorf("test-%d: x.Get()=%v. want=%v\n", i, v, want)
}
fct := rv.MethodByName("Get")
out := fct.Call(nil)
if !DeepEqual(out[0].Interface(), want) {
t.Errorf("test-%d: x.Get()=%v. want=%v\n", i, out[0].Interface(), want)
}
}
} | explode_data.jsonl/29607 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 792
} | [
2830,
3393,
9422,
2124,
2354,
5051,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
220,
19,
17,
198,
13158,
1416,
578,
3749,
341,
197,
37654,
368,
526,
198,
197,
532,
2023,
600,
11,
1965,
1669,
2088,
3056,
1235,
341,
197,
25314,
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... | 1 |
func TestEndpointsDiscoveryDelete(t *testing.T) {
n, _, eps, _ := makeTestEndpointsDiscovery()
eps.GetStore().Add(makeEndpoints())
k8sDiscoveryTest{
discovery: n,
afterStart: func() { go func() { eps.Delete(makeEndpoints()) }() },
expectedRes: []*targetgroup.Group{
{
Source: "endpoints/default/testendpoints",
},
},
}.Run(t)
} | explode_data.jsonl/36698 | {
"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,
80786,
67400,
6435,
1155,
353,
8840,
836,
8,
341,
9038,
11,
8358,
17986,
11,
716,
1669,
1281,
2271,
80786,
67400,
741,
197,
7124,
2234,
6093,
1005,
2212,
36944,
80786,
12367,
16463,
23,
82,
67400,
2271,
515,
197,
34597,
7449... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterInstance(t *testing.T) {
testCases := []struct {
desc string
instanceInfo ecsInstance
exposedByDefault bool
expected bool
}{
{
desc: "Instance without enable label and exposed by default enabled should be not filtered",
instanceInfo: simpleEcsInstance(map[string]*string{}),
exposedByDefault: true,
expected: true,
},
{
desc: "Instance without enable label and exposed by default disabled should be filtered",
instanceInfo: simpleEcsInstance(map[string]*string{}),
exposedByDefault: false,
expected: false,
},
{
desc: "Instance with enable label set to false and exposed by default enabled should be filtered",
instanceInfo: simpleEcsInstance(map[string]*string{
label.TraefikEnable: aws.String("false"),
}),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with enable label set to true and exposed by default disabled should be not filtered",
instanceInfo: simpleEcsInstance(map[string]*string{
label.TraefikEnable: aws.String("true"),
}),
exposedByDefault: false,
expected: true,
},
{
desc: "Instance with nil private ip and exposed by default enabled should be filtered",
instanceInfo: func() ecsInstance {
nilPrivateIP := simpleEcsInstance(map[string]*string{})
nilPrivateIP.machine.PrivateIpAddress = nil
return nilPrivateIP
}(),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with nil machine and exposed by default enabled should be filtered",
instanceInfo: func() ecsInstance {
nilMachine := simpleEcsInstance(map[string]*string{})
nilMachine.machine = nil
return nilMachine
}(),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with nil machine state and exposed by default enabled should be filtered",
instanceInfo: func() ecsInstance {
nilMachineState := simpleEcsInstance(map[string]*string{})
nilMachineState.machine.State = nil
return nilMachineState
}(),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with nil machine state name and exposed by default enabled should be filtered",
instanceInfo: func() ecsInstance {
nilMachineStateName := simpleEcsInstance(map[string]*string{})
nilMachineStateName.machine.State.Name = nil
return nilMachineStateName
}(),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with invalid machine state and exposed by default enabled should be filtered",
instanceInfo: func() ecsInstance {
invalidMachineState := simpleEcsInstance(map[string]*string{})
invalidMachineState.machine.State.Name = aws.String(ec2.InstanceStateNameStopped)
return invalidMachineState
}(),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with no port mappings should be filtered",
instanceInfo: simpleEcsInstanceNoNetwork(map[string]*string{}),
exposedByDefault: true,
expected: false,
},
{
desc: "Instance with no port mapping and with label should not be filtered",
instanceInfo: simpleEcsInstanceNoNetwork(map[string]*string{
label.TraefikPort: aws.String("80"),
}),
exposedByDefault: true,
expected: true,
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
prov := &Provider{
ExposedByDefault: test.exposedByDefault,
}
actual := prov.filterInstance(test.instanceInfo)
assert.Equal(t, test.expected, actual)
})
}
} | explode_data.jsonl/51266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1399
} | [
2830,
3393,
5632,
2523,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
1797,
914,
198,
197,
56256,
1731,
257,
78422,
2523,
198,
197,
8122,
3865,
1359,
3675,
1807,
198,
197,
42400,
260,
1807,
198,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCanExtractSubvalues(t *testing.T) {
subkey, subvalue, err := ExtractSubs("SHA1: abc123", ":")
if err != nil {
t.Errorf("got error when calling extractSubs: %v", err)
}
if subkey != "SHA1" {
t.Errorf("got %v for subkey", subkey)
}
if subvalue != "abc123" {
t.Errorf("got %v for subvalue", subvalue)
}
} | explode_data.jsonl/52723 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 136
} | [
2830,
3393,
6713,
28959,
3136,
3661,
1155,
353,
8840,
836,
8,
341,
28624,
792,
11,
1186,
957,
11,
1848,
1669,
22826,
3136,
82,
445,
33145,
16,
25,
39022,
16,
17,
18,
497,
13022,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestVerifyFailBadSignature(t *testing.T) {
t.Parallel()
fName := "TestVerifyFailBadSignature"
defer cleanup(fName)
writeOldFile(fName, t)
opts := Options{
TargetPath: fName,
Signature: []byte{0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA},
}
err := opts.SetPublicKeyPEM([]byte(ecdsaPublicKey))
if err != nil {
t.Fatalf("Could not parse public key: %v", err)
}
err = Apply(bytes.NewReader(newFile), opts)
if err == nil {
t.Fatalf("Did not fail with bad signature")
}
} | explode_data.jsonl/73989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
32627,
19524,
17082,
25088,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
675,
1669,
330,
2271,
32627,
19524,
17082,
25088,
698,
16867,
21290,
955,
675,
340,
24945,
18284,
1703,
955,
675,
11,
259,
692,
64734,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_QueryRow(t *testing.T) {
ctx := context.Background()
conn, err := sql.Open("pgx", "postgres://postgres:postgres@localhost:5432/postgres")
require.NoError(t, err)
defer conn.Close()
t.Run("happy-path", func(t *testing.T) {
r := &mockRecord{}
err = builder.With(conn).
Select("id", "name").
FromTable("sample_table").
Where(sqlb.Equal("id", 1)).
QueryRow(ctx, r)
require.NoError(t, err)
require.Equal(t, 1, r.ID)
require.Equal(t, "One", r.Name)
})
t.Run("missing-name", func(t *testing.T) {
r := &mockRecord{}
err := builder.With(conn).
Select("id", "name as notfound").
FromTable("sample_table").
Where(sqlb.Equal("id", 1)).
QueryRow(ctx, r)
require.EqualError(t, err, "notfound doesn't exist")
})
t.Run("no-record", func(t *testing.T) {
r := &mockRecord{}
err = builder.With(conn).
Select("id", "name").
FromTable("sample_table").
Where(sqlb.Equal("id", 2)).
QueryRow(ctx, r)
require.Equal(t, sql.ErrNoRows, err)
})
t.Run("no-record", func(t *testing.T) {
r := &mockRecord{}
err = builder.With(conn).
Select("id", "name").
FromTable("nonexist_table").
QueryRow(ctx, r)
require.EqualError(t, err, "ERROR: relation \"nonexist_table\" does not exist (SQLSTATE 42P01)")
})
t.Run("wrong column type", func(t *testing.T) {
r := &mockRecord{}
err = builder.With(conn).
Select("name as number").
FromTable("sample_table").
Where(sqlb.Equal("id", 1)).
QueryRow(ctx, r)
require.EqualError(t, err, "sql: Scan error on column index 0, name \"number\": converting driver.Value type string (\"One\") to a int: invalid syntax")
})
} | explode_data.jsonl/68953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 691
} | [
2830,
3393,
48042,
3102,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
32917,
11,
1848,
1669,
5704,
12953,
445,
3517,
87,
497,
330,
43070,
1110,
43070,
25,
43070,
31,
8301,
25,
20,
19,
18,
17,
29996,
17818,
1138,
17957,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserLoader(t *testing.T) {
var fetches [][]int
var mu sync.Mutex
dl := &UserSliceLoader{
wait: 10 * time.Millisecond,
maxBatch: 5,
fetch: func(keys []int, params ...[]interface{}) (users [][]example.User, errors []error) {
mu.Lock()
fetches = append(fetches, keys)
mu.Unlock()
users = make([][]example.User, len(keys))
errors = make([]error, len(keys))
for i, key := range keys {
if key%10 == 0 { // anything ending in zero is bad
errors[i] = fmt.Errorf("users not found")
} else {
users[i] = []example.User{
{ID: strconv.Itoa(key), Name: "user " + strconv.Itoa(key)},
{ID: strconv.Itoa(key), Name: "user " + strconv.Itoa(key)},
}
}
}
return users, errors
},
}
t.Run("fetch concurrent data", func(t *testing.T) {
t.Run("load user successfully", func(t *testing.T) {
t.Parallel()
u, err := dl.Load(1)
require.NoError(t, err)
require.Equal(t, u[0].ID, "1")
require.Equal(t, u[1].ID, "1")
})
t.Run("load failed user", func(t *testing.T) {
t.Parallel()
u, err := dl.Load(10)
require.Error(t, err)
require.Nil(t, u)
})
t.Run("load many users", func(t *testing.T) {
t.Parallel()
u, err := dl.LoadAll([]int{2, 10, 20, 4})
require.Equal(t, u[0][0].Name, "user 2")
require.Error(t, err[1])
require.Error(t, err[2])
require.Equal(t, u[3][0].Name, "user 4")
})
t.Run("load thunk", func(t *testing.T) {
t.Parallel()
thunk1 := dl.LoadThunk(5)
thunk2 := dl.LoadThunk(50)
u1, err1 := thunk1()
require.NoError(t, err1)
require.Equal(t, "user 5", u1[0].Name)
u2, err2 := thunk2()
require.Error(t, err2)
require.Nil(t, u2)
})
})
t.Run("it sent two batches", func(t *testing.T) {
mu.Lock()
defer mu.Unlock()
require.Len(t, fetches, 2)
assert.Len(t, fetches[0], 5)
assert.Len(t, fetches[1], 3)
})
t.Run("fetch more", func(t *testing.T) {
t.Run("previously cached", func(t *testing.T) {
t.Parallel()
u, err := dl.Load(1)
require.NoError(t, err)
require.Equal(t, u[0].ID, "1")
})
t.Run("load many users", func(t *testing.T) {
t.Parallel()
u, err := dl.LoadAll([]int{2, 4})
require.NoError(t, err[0])
require.NoError(t, err[1])
require.Equal(t, u[0][0].Name, "user 2")
require.Equal(t, u[1][0].Name, "user 4")
})
})
t.Run("no round trips", func(t *testing.T) {
mu.Lock()
defer mu.Unlock()
require.Len(t, fetches, 2)
})
t.Run("fetch partial", func(t *testing.T) {
t.Run("errors not in cache cache value", func(t *testing.T) {
t.Parallel()
u, err := dl.Load(20)
require.Nil(t, u)
require.Error(t, err)
})
t.Run("load all", func(t *testing.T) {
t.Parallel()
u, err := dl.LoadAll([]int{1, 4, 10, 9, 5})
require.Equal(t, u[0][0].ID, "1")
require.Equal(t, u[1][0].ID, "4")
require.Error(t, err[2])
require.Equal(t, u[3][0].ID, "9")
require.Equal(t, u[4][0].ID, "5")
})
})
t.Run("one partial trip", func(t *testing.T) {
mu.Lock()
defer mu.Unlock()
require.Len(t, fetches, 3)
require.Len(t, fetches[2], 3) // E1 U9 E2 in some random order
})
t.Run("primed reads dont hit the fetcher", func(t *testing.T) {
dl.Prime(99, []example.User{
{ID: "U99", Name: "Primed user"},
{ID: "U99", Name: "Primed user"},
})
u, err := dl.Load(99)
require.NoError(t, err)
require.Equal(t, "Primed user", u[0].Name)
require.Len(t, fetches, 3)
})
t.Run("priming in a loop is safe", func(t *testing.T) {
users := [][]example.User{
{{ID: "123", Name: "Alpha"}, {ID: "123", Name: "Alpha"}},
{{ID: "124", Name: "Omega"}, {ID: "124", Name: "Omega"}},
}
for _, user := range users {
id, _ := strconv.Atoi(user[0].ID)
dl.Prime(id, user)
}
u, err := dl.Load(123)
require.NoError(t, err)
require.Equal(t, "Alpha", u[0].Name)
u, err = dl.Load(124)
require.NoError(t, err)
require.Equal(t, "Omega", u[0].Name)
require.Len(t, fetches, 3)
})
t.Run("cleared results will go back to the fetcher", func(t *testing.T) {
dl.Clear(99)
u, err := dl.Load(99)
require.NoError(t, err)
require.Equal(t, "user 99", u[0].Name)
require.Len(t, fetches, 4)
})
t.Run("load all thunk", func(t *testing.T) {
thunk1 := dl.LoadAllThunk([]int{5, 6})
thunk2 := dl.LoadAllThunk([]int{6, 60})
users1, err1 := thunk1()
require.NoError(t, err1[0])
require.NoError(t, err1[1])
require.Equal(t, "user 5", users1[0][0].Name)
require.Equal(t, "user 6", users1[1][0].Name)
users2, err2 := thunk2()
require.NoError(t, err2[0])
require.Error(t, err2[1])
require.Equal(t, "user 6", users2[0][0].Name)
})
} | explode_data.jsonl/40551 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2247
} | [
2830,
3393,
1474,
9181,
1155,
353,
8840,
836,
8,
341,
2405,
7807,
288,
52931,
396,
198,
2405,
11834,
12811,
99014,
271,
2698,
75,
1669,
609,
1474,
33236,
9181,
515,
197,
48750,
25,
257,
220,
16,
15,
353,
882,
71482,
345,
197,
22543,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBoolDeclConforms(t *testing.T) {
checkConforms(t,
context{},
&BoolDecl{},
[]conformTest{
conformOk{false},
conformOk{true},
conformFail{nil, "expecting bool"},
conformFail{"foo", "expecting bool"},
conformFail{42, "expecting bool"},
conformFail{int64(42), "expecting bool"},
},
)
} | explode_data.jsonl/21393 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
11233,
21629,
1109,
9807,
1155,
353,
8840,
836,
8,
341,
25157,
1109,
9807,
1155,
345,
197,
28413,
38837,
197,
197,
5,
11233,
21629,
38837,
197,
197,
1294,
443,
627,
2271,
515,
298,
37203,
627,
11578,
90,
3849,
1583,
298,
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 TestMergeStrSlicesOverlap(t *testing.T) {
orig := []string{"a"}
new := []string{"a", "b"}
res := mergeStrSlices(orig, new)
require.Len(t, res, 2)
require.Equal(t, "a", res[0])
require.Equal(t, "b", res[1])
} | explode_data.jsonl/66960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
52096,
2580,
50,
37414,
82171,
1155,
353,
8840,
836,
8,
341,
197,
4670,
1669,
3056,
917,
4913,
64,
16707,
8638,
1669,
3056,
917,
4913,
64,
497,
330,
65,
63159,
10202,
1669,
10880,
2580,
50,
37414,
54837,
11,
501,
340,
1795... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSnowflakeClient(t *testing.T) {
Convey("Peers", t, func() {
Convey("Can construct", func() {
d := &FakeDialer{max: 1}
p, _ := NewPeers(d)
So(p.Tongue.GetMax(), ShouldEqual, 1)
So(p.snowflakeChan, ShouldNotBeNil)
So(cap(p.snowflakeChan), ShouldEqual, 1)
})
Convey("Collecting a Snowflake requires a Tongue.", func() {
p, err := NewPeers(nil)
So(err, ShouldNotBeNil)
// Set the dialer so that collection is possible.
d := &FakeDialer{max: 1}
p, err = NewPeers(d)
_, err = p.Collect()
So(err, ShouldBeNil)
So(p.Count(), ShouldEqual, 1)
// S
_, err = p.Collect()
})
Convey("Collection continues until capacity.", func() {
c := 5
p, _ := NewPeers(FakeDialer{max: c})
// Fill up to capacity.
for i := 0; i < c; i++ {
fmt.Println("Adding snowflake ", i)
_, err := p.Collect()
So(err, ShouldBeNil)
So(p.Count(), ShouldEqual, i+1)
}
// But adding another gives an error.
So(p.Count(), ShouldEqual, c)
_, err := p.Collect()
So(err, ShouldNotBeNil)
So(p.Count(), ShouldEqual, c)
// But popping allows it to continue.
s := p.Pop()
s.Close()
So(s, ShouldNotBeNil)
So(p.Count(), ShouldEqual, c-1)
_, err = p.Collect()
So(err, ShouldBeNil)
So(p.Count(), ShouldEqual, c)
})
Convey("Count correctly purges peers marked for deletion.", func() {
p, _ := NewPeers(FakeDialer{max: 5})
p.Collect()
p.Collect()
p.Collect()
p.Collect()
So(p.Count(), ShouldEqual, 4)
s := p.Pop()
s.Close()
So(p.Count(), ShouldEqual, 3)
s = p.Pop()
s.Close()
So(p.Count(), ShouldEqual, 2)
})
Convey("End Closes all peers.", func() {
cnt := 5
p, _ := NewPeers(FakeDialer{max: cnt})
for i := 0; i < cnt; i++ {
p.activePeers.PushBack(&WebRTCPeer{closed: make(chan struct{})})
}
So(p.Count(), ShouldEqual, cnt)
p.End()
<-p.Melted()
So(p.Count(), ShouldEqual, 0)
})
Convey("Pop skips over closed peers.", func() {
p, _ := NewPeers(FakeDialer{max: 4})
wc1, _ := p.Collect()
wc2, _ := p.Collect()
wc3, _ := p.Collect()
So(wc1, ShouldNotBeNil)
So(wc2, ShouldNotBeNil)
So(wc3, ShouldNotBeNil)
wc1.Close()
r := p.Pop()
So(p.Count(), ShouldEqual, 2)
So(r, ShouldEqual, wc2)
wc4, _ := p.Collect()
wc2.Close()
wc3.Close()
r = p.Pop()
So(r, ShouldEqual, wc4)
})
Convey("Terminate Connect() loop", func() {
p, _ := NewPeers(FakeDialer{max: 4})
go func() {
for {
p.Collect()
select {
case <-p.Melted():
return
default:
}
}
}()
<-time.After(10 * time.Second)
p.End()
<-p.Melted()
So(p.Count(), ShouldEqual, 0)
})
})
Convey("Dialers", t, func() {
Convey("Can construct WebRTCDialer.", func() {
broker := &BrokerChannel{}
d := NewWebRTCDialer(broker, nil, 1)
So(d, ShouldNotBeNil)
So(d.BrokerChannel, ShouldNotBeNil)
})
SkipConvey("WebRTCDialer can Catch a snowflake.", func() {
broker := &BrokerChannel{}
d := NewWebRTCDialer(broker, nil, 1)
conn, err := d.Catch()
So(conn, ShouldBeNil)
So(err, ShouldNotBeNil)
})
})
} | explode_data.jsonl/9148 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1526
} | [
2830,
3393,
62285,
63456,
2959,
1155,
353,
8840,
836,
8,
1476,
93070,
5617,
445,
10197,
388,
497,
259,
11,
2915,
368,
341,
197,
93070,
5617,
445,
6713,
9245,
497,
2915,
368,
341,
298,
2698,
1669,
609,
52317,
35,
530,
261,
90,
2810,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeLoadBalancerOnUpdate(t *testing.T) {
awsServices := newMockedFakeAWSServices(TestClusterId)
c, _ := newAWSCloud(strings.NewReader("[global]"), awsServices)
awsServices.elb.(*MockedFakeELB).expectDescribeLoadBalancers("aid")
c.UpdateLoadBalancer(context.TODO(), TestClusterName, &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "myservice", UID: "id"}}, []*v1.Node{})
} | explode_data.jsonl/29217 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
74785,
5879,
93825,
1925,
4289,
1155,
353,
8840,
836,
8,
341,
197,
8635,
11025,
1669,
501,
11571,
291,
52317,
14419,
1220,
2161,
31159,
28678,
764,
340,
1444,
11,
716,
1669,
501,
14419,
3540,
52178,
51442,
68587,
10937,
9752,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleTblCommentCheck(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := []string{
"CREATE TABLE `test1`( `ID` bigint(20) NOT NULL AUTO_INCREMENT," +
" `c1` varchar(128) DEFAULT NULL, `c2` varchar(300) DEFAULT NULL," +
" `c3` varchar(32) DEFAULT NULL, `c4` int(11) NOT NULL, `c5` double NOT NULL," +
" `c6` text NOT NULL, PRIMARY KEY (`ID`), KEY `idx_c3_c2_c4_c5_c6` " +
"(`c3`,`c2`(255),`c4`,`c5`,`c6`(255)), KEY `idx_c3_c2_c4` (`c3`,`c2`,`c4`)) " +
"ENGINE = InnoDB DEFAULT CHARSET=utf8",
}
for _, sql := range sqls {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleTblCommentCheck()
if rule.Item != "CLA.011" {
t.Error("Rule not match:", rule.Item, "Expect : CLA.011")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76755 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 423
} | [
2830,
3393,
11337,
91325,
10677,
3973,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
3056,
917,
515,
197,
197,
1,
22599,
14363,
1565,
1944,
16,
8155... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceCreateImage(t *testing.T) {
action, created, output, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "--no-wait"}, false)
if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
t.Fatalf("Bad action %v", action)
}
template := &created.Spec.Template
if err != nil {
t.Fatal(err)
} else if template.Spec.Containers[0].Image != "gcr.io/foo/bar:baz" {
t.Fatalf("wrong image set: %v", template.Spec.Containers[0].Image)
} else if !strings.Contains(output, "foo") || !strings.Contains(output, "created") ||
!strings.Contains(output, commands.FakeNamespace) {
t.Fatalf("wrong stdout message: %v", output)
}
} | explode_data.jsonl/42438 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
1860,
4021,
1906,
1155,
353,
8840,
836,
8,
341,
38933,
11,
3465,
11,
2550,
11,
1848,
1669,
12418,
1860,
4021,
10556,
917,
515,
197,
197,
1,
7936,
497,
330,
3182,
497,
330,
7975,
497,
14482,
1805,
497,
330,
70,
5082,
4245... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLiveUpdateDockerBuildLocalContainerSameImgMultipleContainers(t *testing.T) {
f := newBDFixture(t, k8s.EnvDockerDesktop, container.RuntimeDocker)
defer f.TearDown()
m := NewSanchoLiveUpdateManifest(f)
cIDs := []container.ID{"c1", "c2", "c3"}
tCase := testCase{
manifest: m,
runningContainersByTarget: map[model.TargetID][]container.ID{m.ImageTargetAt(0).ID(): cIDs},
changedFiles: []string{"a.txt"},
expectDockerBuildCount: 0,
expectDockerPushCount: 0,
// one of each operation per container
expectDockerCopyCount: 3,
expectDockerExecCount: 3,
expectDockerRestartCount: 3,
}
runTestCase(t, f, tCase)
} | explode_data.jsonl/35153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 291
} | [
2830,
3393,
20324,
4289,
35,
13659,
11066,
7319,
4502,
19198,
13033,
32089,
74632,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
33,
5262,
12735,
1155,
11,
595,
23,
82,
81214,
35,
13659,
23597,
11,
5476,
16706,
35,
13659,
340,
16867,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetSystclsFromAnnotations(t *testing.T) {
tests := []struct {
annotations map[string]string
expectedSysctls map[string]string
}{{
annotations: map[string]string{
api.SysctlsPodAnnotationKey: "kernel.shmmni=32768,kernel.shmmax=1000000000",
api.UnsafeSysctlsPodAnnotationKey: "knet.ipv4.route.min_pmtu=1000",
},
expectedSysctls: map[string]string{
"kernel.shmmni": "32768",
"kernel.shmmax": "1000000000",
"knet.ipv4.route.min_pmtu": "1000",
},
}, {
annotations: map[string]string{
api.SysctlsPodAnnotationKey: "kernel.shmmni=32768,kernel.shmmax=1000000000",
},
expectedSysctls: map[string]string{
"kernel.shmmni": "32768",
"kernel.shmmax": "1000000000",
},
}, {
annotations: map[string]string{
api.UnsafeSysctlsPodAnnotationKey: "knet.ipv4.route.min_pmtu=1000",
},
expectedSysctls: map[string]string{
"knet.ipv4.route.min_pmtu": "1000",
},
}}
for i, test := range tests {
actual, err := getSysctlsFromAnnotations(test.annotations)
assert.NoError(t, err, "TestCase[%d]", i)
assert.Len(t, actual, len(test.expectedSysctls), "TestCase[%d]", i)
assert.Equal(t, test.expectedSysctls, actual, "TestCase[%d]", i)
}
} | explode_data.jsonl/74427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 552
} | [
2830,
3393,
1949,
50,
597,
18074,
3830,
21418,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
39626,
257,
2415,
14032,
30953,
198,
197,
42400,
32792,
302,
4730,
2415,
14032,
30953,
198,
197,
15170,
515,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestApplicationRegistryJobsPresubmit(t *testing.T) {
// WHEN
jobConfig, err := tester.ReadJobConfig("./../../../../prow/jobs/kyma/components/application-registry/application-registry.yaml")
// THEN
require.NoError(t, err)
assert.Len(t, jobConfig.Presubmits, 1)
kymaPresubmits, ex := jobConfig.Presubmits["kyma-project/kyma"]
assert.True(t, ex)
assert.Len(t, kymaPresubmits, 1)
actualPresubmit := kymaPresubmits[0]
expName := "kyma-components-application-registry"
assert.Equal(t, expName, actualPresubmit.Name)
assert.Equal(t, []string{"master"}, actualPresubmit.Branches)
assert.Equal(t, 10, actualPresubmit.MaxConcurrency)
assert.True(t, actualPresubmit.SkipReport)
assert.True(t, actualPresubmit.Decorate)
assert.Equal(t, "github.com/kyma-project/kyma", actualPresubmit.PathAlias)
tester.AssertThatHasExtraRefTestInfra(t, actualPresubmit.JobBase.UtilityConfig)
tester.AssertThatHasPresets(t, actualPresubmit.JobBase, tester.PresetDindEnabled, tester.PresetDockerPushRepo, tester.PresetGcrPush, tester.PresetBuildPr)
tester.AssertThatJobRunIfChanged(t, actualPresubmit, "components/application-registry/internal")
assert.Equal(t, "^components/application-registry/", actualPresubmit.RunIfChanged)
assert.Equal(t, tester.ImageGolangBuildpackLatest, actualPresubmit.Spec.Containers[0].Image)
assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/test-infra/prow/scripts/build.sh"}, actualPresubmit.Spec.Containers[0].Command)
assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/kyma/components/application-registry"}, actualPresubmit.Spec.Containers[0].Args)
} | explode_data.jsonl/39031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 605
} | [
2830,
3393,
4988,
15603,
40667,
14367,
392,
1763,
1155,
353,
8840,
836,
8,
341,
197,
322,
33633,
198,
68577,
2648,
11,
1848,
1669,
37111,
6503,
12245,
2648,
13988,
84257,
79,
651,
4437,
5481,
14109,
1600,
64,
20261,
33032,
12,
29172,
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 TestEncryptDecrypt(t *testing.T) {
var tests = []struct {
chunkLength int
}{
{10},
{100},
{1000},
{4095},
{4096},
{4097},
{1000000},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("Encrypt %d bytes", tt.chunkLength), func(t *testing.T) {
store := mock.NewStorer()
g := mockbytes.New(0, mockbytes.MockTypeStandard).WithModulus(255)
testData, err := g.SequentialBytes(tt.chunkLength)
if err != nil {
t.Fatal(err)
}
ctx := context.Background()
pipe := builder.NewPipelineBuilder(ctx, store, storage.ModePutUpload, true)
testDataReader := bytes.NewReader(testData)
resultAddress, err := builder.FeedPipeline(ctx, pipe, testDataReader, int64(len(testData)))
if err != nil {
t.Fatal(err)
}
reader, l, err := joiner.New(context.Background(), store, resultAddress)
if err != nil {
t.Fatal(err)
}
if l != int64(len(testData)) {
t.Fatalf("expected join data length %d, got %d", len(testData), l)
}
totalGot := make([]byte, tt.chunkLength)
index := 0
resultBuffer := make([]byte, swarm.ChunkSize)
for index < tt.chunkLength {
n, err := reader.Read(resultBuffer)
if err != nil && err != io.EOF {
t.Fatal(err)
}
copy(totalGot[index:], resultBuffer[:n])
index += n
}
if !bytes.Equal(testData, totalGot) {
t.Fatal("input data and output data does not match")
}
})
}
} | explode_data.jsonl/51986 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 615
} | [
2830,
3393,
61520,
89660,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
23049,
3122,
4373,
526,
198,
197,
59403,
197,
197,
90,
16,
15,
1583,
197,
197,
90,
16,
15,
15,
1583,
197,
197,
90,
16,
15,
15,
15,
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... | 9 |
func TestListCommandRunEClosureWithJSONOutput(t *testing.T) {
assert := assert.New(t)
cli := test.NewCLI()
testUsers := []corev2.User{
*corev2.FixtureUser("user1"),
*corev2.FixtureUser("user2"),
}
expected, err := json.Marshal(testUsers)
if err != nil {
t.Fatal(err)
}
client := cli.Client.(*client.MockClient)
resources := []corev2.User{}
client.On("List", mock.Anything, &resources, mock.Anything, mock.Anything).Return(nil).Run(
func(args mock.Arguments) {
resources := args[1].(*[]corev2.User)
*resources = testUsers
},
)
cmd := ListCommand(cli)
require.NoError(t, cmd.Flags().Set("format", "json"))
out, err := test.RunCmd(cmd, []string{})
assert.NoError(err)
assert.NotEmpty(out)
assert.JSONEq(string(expected), out)
} | explode_data.jsonl/11556 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
852,
4062,
6727,
7498,
11653,
2354,
5370,
5097,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
86448,
1669,
1273,
7121,
63959,
2822,
18185,
7137,
1669,
3056,
98645,
17,
7344,
515,
197,
197,
9,
98645,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestShouldRaiseWhenTargetUrlIsMalformed(t *testing.T) {
mock := mocks.NewMockAutheliaCtx(t)
defer mock.Close()
mock.Ctx.Request.Header.Set("X-Forwarded-Proto", "https")
mock.Ctx.Request.Header.Set("X-Forwarded-Host", "home.example.com")
mock.Ctx.Request.Header.Set("X-Forwarded-URI", "/abc")
originalURL, err := mock.Ctx.GetOriginalURL()
assert.NoError(t, err)
expectedURL, err := url.ParseRequestURI("https://home.example.com/abc")
assert.NoError(t, err)
assert.Equal(t, expectedURL, originalURL)
} | explode_data.jsonl/20173 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
14996,
93101,
4498,
6397,
2864,
3872,
29600,
10155,
1155,
353,
8840,
836,
8,
341,
77333,
1669,
68909,
7121,
11571,
5087,
35929,
23684,
1155,
340,
16867,
7860,
10421,
741,
77333,
727,
3998,
9659,
15753,
4202,
445,
55,
12,
25925... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindCommitmentDeadline(t *testing.T) {
// Create a testing channel arbitrator.
log := &mockArbitratorLog{
state: StateDefault,
newStates: make(chan ArbitratorState, 5),
}
chanArbCtx, err := createTestChannelArbitrator(t, log)
require.NoError(t, err, "unable to create ChannelArbitrator")
// Add a dummy payment hash to the preimage lookup.
rHash := [lntypes.PreimageSize]byte{1, 2, 3}
mockPreimageDB := newMockWitnessBeacon()
mockPreimageDB.lookupPreimage[rHash] = rHash
// Attack a mock PreimageDB and Registry to channel arbitrator.
chanArb := chanArbCtx.chanArb
chanArb.cfg.PreimageDB = mockPreimageDB
chanArb.cfg.Registry = &mockRegistry{}
htlcIndexBase := uint64(99)
heightHint := uint32(1000)
htlcExpiryBase := heightHint + uint32(10)
// Create four testing HTLCs.
htlcDust := channeldb.HTLC{
HtlcIndex: htlcIndexBase + 1,
RefundTimeout: htlcExpiryBase + 1,
OutputIndex: -1,
}
htlcSmallExipry := channeldb.HTLC{
HtlcIndex: htlcIndexBase + 2,
RefundTimeout: htlcExpiryBase + 2,
}
htlcPreimage := channeldb.HTLC{
HtlcIndex: htlcIndexBase + 3,
RefundTimeout: htlcExpiryBase + 3,
RHash: rHash,
}
htlcLargeExpiry := channeldb.HTLC{
HtlcIndex: htlcIndexBase + 4,
RefundTimeout: htlcExpiryBase + 100,
}
htlcExpired := channeldb.HTLC{
HtlcIndex: htlcIndexBase + 5,
RefundTimeout: heightHint,
}
makeHTLCSet := func(incoming, outgoing channeldb.HTLC) htlcSet {
return htlcSet{
incomingHTLCs: map[uint64]channeldb.HTLC{
incoming.HtlcIndex: incoming,
},
outgoingHTLCs: map[uint64]channeldb.HTLC{
outgoing.HtlcIndex: outgoing,
},
}
}
testCases := []struct {
name string
htlcs htlcSet
err error
deadline uint32
}{
{
// When we have no HTLCs, the default value should be
// used.
name: "use default conf target",
htlcs: htlcSet{},
err: nil,
deadline: anchorSweepConfTarget,
},
{
// When we have a preimage available in the local HTLC
// set, its CLTV should be used.
name: "use htlc with preimage available",
htlcs: makeHTLCSet(htlcPreimage, htlcLargeExpiry),
err: nil,
deadline: htlcPreimage.RefundTimeout - heightHint,
},
{
// When the HTLC in the local set is not preimage
// available, we should not use its CLTV even its value
// is smaller.
name: "use htlc with no preimage available",
htlcs: makeHTLCSet(htlcSmallExipry, htlcLargeExpiry),
err: nil,
deadline: htlcLargeExpiry.RefundTimeout - heightHint,
},
{
// When we have dust HTLCs, their CLTVs should NOT be
// used even the values are smaller.
name: "ignore dust HTLCs",
htlcs: makeHTLCSet(htlcPreimage, htlcDust),
err: nil,
deadline: htlcPreimage.RefundTimeout - heightHint,
},
{
// When we've reached our deadline, use conf target of
// 1 as our deadline.
name: "use conf target 1",
htlcs: makeHTLCSet(htlcPreimage, htlcExpired),
err: nil,
deadline: 1,
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
deadline, err := chanArb.findCommitmentDeadline(
heightHint, tc.htlcs,
)
require.Equal(t, tc.err, err)
require.Equal(t, tc.deadline, deadline)
})
}
} | explode_data.jsonl/74587 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1479
} | [
2830,
3393,
9885,
33441,
478,
83593,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
264,
7497,
5496,
57957,
850,
624,
6725,
1669,
609,
16712,
6953,
4489,
81,
850,
2201,
515,
197,
24291,
25,
257,
3234,
3675,
345,
197,
8638,
23256,
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 TestReadUnmodifiedFileSucceeds(t *testing.T) {
for _, alg := range hashAlgs {
vfsObj, root, ctx, err := newVerityRoot(t, alg)
if err != nil {
t.Fatalf("newVerityRoot: %v", err)
}
filename := "verity-test-file"
fd, size, err := newFileFD(ctx, t, vfsObj, root, filename, 0644)
if err != nil {
t.Fatalf("newFileFD: %v", err)
}
// Enable verity on the file and confirm a normal read succeeds.
enableVerity(ctx, t, fd)
buf := make([]byte, size)
n, err := fd.Read(ctx, usermem.BytesIOSequence(buf), vfs.ReadOptions{})
if err != nil && err != io.EOF {
t.Fatalf("fd.Read: %v", err)
}
if n != int64(size) {
t.Errorf("fd.PRead got read length %d, want %d", n, size)
}
}
} | explode_data.jsonl/56757 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
4418,
1806,
27162,
1703,
50,
29264,
82,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17345,
1669,
2088,
5175,
2101,
5857,
341,
197,
5195,
3848,
5261,
11,
3704,
11,
5635,
11,
1848,
1669,
501,
10141,
487,
8439,
1155,
11,
17345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClock_DelJobs(t *testing.T) {
//思路:
//新增一定数量的任务,延时1秒开始执行
//在一秒内,删除所有的任务。
//如果执行次数!=0,说明一秒内无法满足对应条数的增删
var (
myClock = NewClock().Reset()
jobsNum = 20000
randscope = 1 * 1000 * 1000 * 1000
jobs = make([]Job, jobsNum)
wantdeljobs = make([]Job, jobsNum)
fn = func() {
//do nothing
}
)
for i := 0; i < jobsNum; i++ {
delay := time.Second + time.Duration(r.Intn(randscope)) //增加一秒作为延迟,以避免删除的时候,已经存在任务被通知执行,导致后续判断失误
job, insert := myClock.AddJobWithInterval(delay, fn)
if !insert {
t.Errorf("添加任务失败!")
return
}
jobs[i] = job
wantdeljobs[i] = job
}
//myClock.DelJobs(wantdeljobs)
for _, job := range wantdeljobs {
job.Cancel()
}
if 0 != int(myClock.Count()) || myClock.WaitJobs() != 0 {
t.Errorf("应该执行%v次,实际执行%v次,此时任务队列中残余记录,myClock.actionindex.len=%v,\n", jobsNum-len(wantdeljobs), myClock.Count(), myClock.WaitJobs())
}
} | explode_data.jsonl/2025 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 640
} | [
2830,
3393,
26104,
1557,
301,
40667,
1155,
353,
8840,
836,
8,
341,
197,
322,
104337,
28311,
197,
322,
93620,
99623,
81800,
108530,
3837,
99771,
13343,
16,
45918,
55286,
75117,
198,
197,
322,
18493,
114825,
31843,
3837,
28606,
104152,
88802,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteBackupList_NoBackups(t *testing.T) {
expectedRes := "name modified wal_segment_backup_start start_time finish_time hostname data_dir pg_version start_lsn finish_lsn is_permanent\n"
backups := make([]postgres.BackupDetail, 0)
b := bytes.Buffer{}
postgres.WriteBackupListDetails(backups, &b)
assert.Equal(t, expectedRes, b.String())
} | explode_data.jsonl/23913 | {
"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,
7985,
56245,
852,
36989,
3707,
8602,
1155,
353,
8840,
836,
8,
341,
42400,
1061,
1669,
330,
606,
10807,
40826,
28061,
44710,
4906,
1191,
3009,
6248,
3009,
28115,
821,
4334,
17495,
9438,
1191,
907,
9613,
6248,
907,
9613,
374,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.