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 TestConfigMapReferenceReconciler_WrongConfigMapName(t *testing.T) {
ns := t.Name()
infraInstance := &v1beta1.KogitoInfra{
ObjectMeta: v1.ObjectMeta{
Name: "kogito-kafka",
Namespace: ns,
},
Spec: v1beta1.KogitoInfraSpec{
ConfigMapEnvFromReferences: []string{
"my-config-1",
},
},
}
cli := test.NewFakeClientBuilder().AddK8sObjects().Build()
infraContext := infraContext{
Context: operator.Context{
Client: cli,
Log: test.TestLogger,
Scheme: meta.GetRegisteredSchema(),
},
instance: infraInstance,
}
configMapReferenceReconciler := initConfigMapReferenceReconciler(infraContext)
err := configMapReferenceReconciler.Reconcile()
assert.Errorf(t, err, "Configmap resource(my-config-1) not found in namespace %s", ns)
} | explode_data.jsonl/70803 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
2648,
2227,
8856,
693,
40446,
5769,
2763,
14347,
2648,
2227,
675,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
259,
2967,
741,
197,
92317,
2523,
1669,
609,
85,
16,
19127,
16,
11352,
538,
6357,
19433,
956,
515,
197,
23816,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHMACKeyDerivOverAES256Key(t *testing.T) {
t.Parallel()
provider, _, cleanup := currentTestConfig.Provider(t)
defer cleanup()
k, err := provider.KeyGen(&bccsp.AESKeyGenOpts{Temporary: false})
if err != nil {
t.Fatalf("Failed generating AES_256 key [%s]", err)
}
hmcaedKey, err := provider.KeyDeriv(k, &bccsp.HMACDeriveKeyOpts{Temporary: false, Arg: []byte{1}})
if err != nil {
t.Fatalf("Failed HMACing AES_256 key [%s]", err)
}
if k == nil {
t.Fatal("Failed HMACing AES_256 key. HMACed Key must be different from nil")
}
if !hmcaedKey.Private() {
t.Fatal("Failed HMACing AES_256 key. HMACed Key should be private")
}
if !hmcaedKey.Symmetric() {
t.Fatal("Failed HMACing AES_256 key. HMACed Key should be asymmetric")
}
raw, err := hmcaedKey.Bytes()
if err != nil {
t.Fatalf("Failed marshalling to bytes [%s]", err)
}
if len(raw) == 0 {
t.Fatal("Failed marshalling to bytes. 0 bytes")
}
} | explode_data.jsonl/29275 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
39,
25788,
1592,
22171,
344,
1918,
69168,
17,
20,
21,
1592,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
19979,
11,
8358,
21290,
1669,
1482,
2271,
2648,
36208,
1155,
340,
16867,
21290,
2822,
16463,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestPodComputedMetric(t *testing.T) {
//given
pod := core.NewElement("kube-system/heapster", "kube-system/heapster", "Kubernetes Pod", "")
now := time.Now()
cpuUsageRate, _ := core.NewSample("cpu.usage_rate", now, 500.0)
cpuUsage, _ := core.NewSample("cpu.usage", now, 0.0)
cpuRequest, _ := core.NewSample("cpu.request", now, 0.0)
cpuLimit, _ := core.NewSample("cpu.limit", now, 1000.0)
pod.AddSample(cpuUsageRate)
pod.AddSample(cpuUsage)
pod.AddSample(cpuRequest)
pod.AddSample(cpuLimit)
//when
CreateComputedMetric(now.Unix()*1000, &pod)
//then
if len(pod.Samples()) != 5 {
t.Errorf("there should be 5 samples including a computed 'cpu.usage.percent', but actually has %d", len(pod.Samples()))
}
for _, s := range pod.Samples() {
if s.MetricId() == "cpu.usage.percent" {
if s.Val() != 50.0 {
t.Errorf("cpu usage percent should be 50.0 and the actual is %f", s.Val())
}
}
}
} | explode_data.jsonl/59937 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
23527,
56474,
54310,
1155,
353,
8840,
836,
8,
341,
197,
322,
41968,
198,
3223,
347,
1669,
6200,
7121,
1691,
445,
97717,
36648,
14,
15961,
3667,
497,
330,
97717,
36648,
14,
15961,
3667,
497,
330,
42,
29827,
16821,
497,
14676,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintJob(t *testing.T) {
now := time.Now()
completions := int32(2)
tests := []struct {
job batch.Job
options printers.GenerateOptions
expected []metav1.TableRow
}{
{
// Generate table rows for Job with no generate options.
job: batch.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "job1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Spec: batch.JobSpec{
Completions: &completions,
Template: api.PodTemplateSpec{
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "fake-job-container1",
Image: "fake-job-image1",
},
{
Name: "fake-job-container2",
Image: "fake-job-image2",
},
},
},
},
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"job-label": "job-lable-value"}},
},
Status: batch.JobStatus{
Succeeded: 1,
},
},
options: printers.GenerateOptions{},
// Columns: Name, Completions, Duration, Age
expected: []metav1.TableRow{{Cells: []interface{}{"job1", "1/2", "", "0s"}}},
},
// Generate table rows for Job with generate options "Wide".
{
job: batch.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "job1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Spec: batch.JobSpec{
Completions: &completions,
Template: api.PodTemplateSpec{
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "fake-job-container1",
Image: "fake-job-image1",
},
{
Name: "fake-job-container2",
Image: "fake-job-image2",
},
},
},
},
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"job-label": "job-label-value"}},
},
Status: batch.JobStatus{
Succeeded: 1,
},
},
options: printers.GenerateOptions{Wide: true},
// Columns: Name, Completions, Duration, Age, Containers, Images, Selectors
expected: []metav1.TableRow{
{
Cells: []interface{}{"job1", "1/2", "", "0s", "fake-job-container1,fake-job-container2", "fake-job-image1,fake-job-image2", "job-label=job-label-value"},
},
},
},
// Job with ten-year age.
{
job: batch.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "job2",
CreationTimestamp: metav1.Time{Time: time.Now().AddDate(-10, 0, 0)},
},
Spec: batch.JobSpec{
Completions: nil,
},
Status: batch.JobStatus{
Succeeded: 0,
},
},
options: printers.GenerateOptions{},
// Columns: Name, Completions, Duration, Age
expected: []metav1.TableRow{{Cells: []interface{}{"job2", "0/1", "", "10y"}}},
},
// Job with duration.
{
job: batch.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "job3",
CreationTimestamp: metav1.Time{Time: time.Now().AddDate(-10, 0, 0)},
},
Spec: batch.JobSpec{
Completions: nil,
},
Status: batch.JobStatus{
Succeeded: 0,
StartTime: &metav1.Time{Time: now.Add(time.Minute)},
CompletionTime: &metav1.Time{Time: now.Add(31 * time.Minute)},
},
},
options: printers.GenerateOptions{},
// Columns: Name, Completions, Duration, Age
expected: []metav1.TableRow{{Cells: []interface{}{"job3", "0/1", "30m", "10y"}}},
},
{
job: batch.Job{
ObjectMeta: metav1.ObjectMeta{
Name: "job4",
CreationTimestamp: metav1.Time{Time: time.Now().AddDate(-10, 0, 0)},
},
Spec: batch.JobSpec{
Completions: nil,
},
Status: batch.JobStatus{
Succeeded: 0,
StartTime: &metav1.Time{Time: time.Now().Add(-20 * time.Minute)},
},
},
options: printers.GenerateOptions{},
// Columns: Name, Completions, Duration, Age
expected: []metav1.TableRow{{Cells: []interface{}{"job4", "0/1", "20m", "10y"}}},
},
}
for i, test := range tests {
rows, err := printJob(&test.job, test.options)
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21609 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2061
} | [
2830,
3393,
8994,
12245,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
882,
13244,
741,
32810,
10819,
908,
1669,
526,
18,
17,
7,
17,
340,
78216,
1669,
3056,
1235,
341,
197,
68577,
414,
7162,
45293,
198,
197,
35500,
220,
55953,
57582,
379... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_Arguments_Diff_WithAnythingArgument(t *testing.T) {
var args = Arguments([]interface{}{"string", 123, true})
var count int
_, count = args.Diff([]interface{}{"string", Anything, true})
assert.Equal(t, 0, count)
} | explode_data.jsonl/8616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
87581,
2831,
1557,
3092,
62,
2354,
77303,
9171,
1155,
353,
8840,
836,
8,
8022,
2405,
2827,
284,
27702,
10556,
4970,
6257,
4913,
917,
497,
220,
16,
17,
18,
11,
830,
35099,
2405,
1760,
526,
319,
197,
6878,
1760,
284,
2827,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCollection_FindOneAndReplace(t *testing.T) {
mgoClient := Ins()
findResult := mgoClient.C("test").FindOneAndReplace(bson.M{"name": "lily"}, bson.M{"name": "lily", "age": 18})
if findResult.Err() != nil {
t.Errorf("FindOneAndReplace error: %s", findResult.Err())
t.FailNow()
}
result := bson.D{}
if err := findResult.Decode(&result); err != nil {
t.Errorf("FindOneAndReplace decode error: %s", err)
t.FailNow()
}
t.Log("FindOneAndReplace ok: ", result)
} | explode_data.jsonl/30104 | {
"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,
6482,
95245,
3966,
3036,
23107,
1155,
353,
8840,
836,
8,
341,
2109,
3346,
2959,
1669,
9726,
2822,
80603,
2077,
1669,
296,
3346,
2959,
727,
445,
1944,
1827,
9885,
3966,
3036,
23107,
1883,
930,
1321,
4913,
606,
788,
330,
75,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEds(t *testing.T) {
s := xds.NewFakeDiscoveryServer(t, xds.FakeOptions{
ConfigString: mustReadFile(t, "tests/testdata/config/destination-rule-locality.yaml"),
DiscoveryServerModifier: func(s *xds.DiscoveryServer) {
addUdsEndpoint(s)
// enable locality load balancing and add relevant endpoints in order to test
addLocalityEndpoints(s, "locality.cluster.local")
addLocalityEndpoints(s, "locality-no-outlier-detection.cluster.local")
// Add the test ads clients to list of service instances in order to test the context dependent locality coloring.
addTestClientEndpoints(s)
s.MemRegistry.AddHTTPService(edsIncSvc, edsIncVip, 8080)
s.MemRegistry.SetEndpoints(edsIncSvc, "",
newEndpointWithAccount("127.0.0.1", "hello-sa", "v1"))
},
})
adscConn := s.Connect(&model.Proxy{IPAddresses: []string{"10.10.10.10"}}, nil, watchAll)
adscConn2 := s.Connect(&model.Proxy{IPAddresses: []string{"10.10.10.11"}}, nil, watchAll)
t.Run("TCPEndpoints", func(t *testing.T) {
testTCPEndpoints("127.0.0.1", adscConn, t)
})
t.Run("edsz", func(t *testing.T) {
testEdsz(t, s, "test-1.default")
})
t.Run("LocalityPrioritizedEndpoints", func(t *testing.T) {
testLocalityPrioritizedEndpoints(adscConn, adscConn2, t)
})
t.Run("UDSEndpoints", func(t *testing.T) {
testUdsEndpoints(adscConn, t)
})
t.Run("PushIncremental", func(t *testing.T) {
edsUpdateInc(s, adscConn, t)
})
t.Run("Push", func(t *testing.T) {
edsUpdates(s, adscConn, t)
})
t.Run("MultipleRequest", func(t *testing.T) {
multipleRequest(s, false, 20, 5, 25*time.Second, nil, t)
})
// 5 pushes for 100 clients, using EDS incremental only.
t.Run("MultipleRequestIncremental", func(t *testing.T) {
multipleRequest(s, true, 20, 5, 25*time.Second, nil, t)
})
t.Run("CDSSave", func(t *testing.T) {
// Moved from cds_test, using new client
clusters := adscConn.GetClusters()
if len(clusters) == 0 {
t.Error("No clusters in ADS response")
}
strResponse, _ := json.MarshalIndent(clusters, " ", " ")
_ = os.WriteFile(env.IstioOut+"/cdsv2_sidecar.json", strResponse, 0o644)
})
} | explode_data.jsonl/7946 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 851
} | [
2830,
3393,
2715,
82,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
856,
5356,
7121,
52317,
67400,
5475,
1155,
11,
856,
5356,
991,
726,
3798,
515,
197,
66156,
703,
25,
1969,
4418,
1703,
1155,
11,
330,
23841,
12697,
691,
14730,
14,
17997,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidate(t *testing.T) {
data := []struct {
in *Node
out bool
}{
{
NewNode("first", "mongo", adaptor.Config{}),
false,
},
{
NewNode("second", "mongo", adaptor.Config{}).Add(NewNode("name", "mongo", adaptor.Config{})),
true,
},
{
NewNode("third", "mongo", adaptor.Config{}).Add(NewNode("name", "transformer", adaptor.Config{})),
false,
},
{
NewNode("fourth", "mongo", adaptor.Config{}).Add(NewNode("name", "transformer", adaptor.Config{}).Add(NewNode("name", "mongo", adaptor.Config{}))),
true,
},
}
for _, v := range data {
if v.in.Validate() != v.out {
t.Errorf("%s: expected: %t got: %t", v.in.Name, v.out, v.in.Validate())
}
}
} | explode_data.jsonl/60759 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 319
} | [
2830,
3393,
17926,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
1235,
341,
197,
17430,
220,
353,
1955,
198,
197,
13967,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
3564,
1955,
445,
3896,
497,
330,
53070,
497,
91941,
10753,
6257... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRedis_SetGetDelHashField(t *testing.T) {
runOnRedis(t, func(client *Redis) {
err := client.Hset("key", "field", "value")
assert.Nil(t, err)
_, err = NewRedis(client.Addr, "").Hget("key", "field")
assert.NotNil(t, err)
val, err := client.Hget("key", "field")
assert.Nil(t, err)
assert.Equal(t, "value", val)
_, err = NewRedis(client.Addr, "").Hexists("key", "field")
assert.NotNil(t, err)
ok, err := client.Hexists("key", "field")
assert.Nil(t, err)
assert.True(t, ok)
_, err = NewRedis(client.Addr, "").Hdel("key", "field")
assert.NotNil(t, err)
ret, err := client.Hdel("key", "field")
assert.Nil(t, err)
assert.True(t, ret)
ok, err = client.Hexists("key", "field")
assert.Nil(t, err)
assert.False(t, ok)
})
} | explode_data.jsonl/39186 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
48137,
14812,
1949,
16532,
6370,
1877,
1155,
353,
8840,
836,
8,
341,
56742,
1925,
48137,
1155,
11,
2915,
12805,
353,
48137,
8,
341,
197,
9859,
1669,
2943,
3839,
746,
445,
792,
497,
330,
2566,
497,
330,
957,
1138,
197,
6948... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSpanSlice(t *testing.T) {
es := NewSpanSlice()
assert.EqualValues(t, 0, es.Len())
es = newSpanSlice(&[]*otlptrace.Span{})
assert.EqualValues(t, 0, es.Len())
es.EnsureCapacity(7)
emptyVal := newSpan(&otlptrace.Span{})
testVal := generateTestSpan()
assert.EqualValues(t, 7, cap(*es.orig))
for i := 0; i < es.Len(); i++ {
el := es.AppendEmpty()
assert.EqualValues(t, emptyVal, el)
fillTestSpan(el)
assert.EqualValues(t, testVal, el)
}
} | explode_data.jsonl/63256 | {
"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,
12485,
33236,
1155,
353,
8840,
836,
8,
341,
78966,
1669,
1532,
12485,
33236,
741,
6948,
12808,
6227,
1155,
11,
220,
15,
11,
1531,
65819,
2398,
78966,
284,
501,
12485,
33236,
2099,
1294,
9,
354,
75,
3505,
578,
85309,
37790,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSpanProcessor_ToAttributes(t *testing.T) {
testCases := []struct {
rules []string
breakAfterMatch bool
testCase
}{
{
rules: []string{`^\/api\/v1\/document\/(?P<documentId>.*)\/update\/1$`},
testCase: testCase{
inputName: "/api/v1/document/321083210/update/1",
inputAttributes: map[string]interface{}{},
outputName: "/api/v1/document/{documentId}/update/1",
outputAttributes: map[string]interface{}{
"documentId": "321083210",
},
},
},
{
rules: []string{`^\/api\/(?P<version>.*)\/document\/(?P<documentId>.*)\/update\/2$`},
testCase: testCase{
inputName: "/api/v1/document/321083210/update/2",
outputName: "/api/{version}/document/{documentId}/update/2",
outputAttributes: map[string]interface{}{
"documentId": "321083210",
"version": "v1",
},
},
},
{
rules: []string{`^\/api\/.*\/document\/(?P<documentId>.*)\/update\/3$`,
`^\/api\/(?P<version>.*)\/document\/.*\/update\/3$`},
testCase: testCase{
inputName: "/api/v1/document/321083210/update/3",
outputName: "/api/{version}/document/{documentId}/update/3",
outputAttributes: map[string]interface{}{
"documentId": "321083210",
"version": "v1",
},
},
breakAfterMatch: false,
},
{
rules: []string{`^\/api\/v1\/document\/(?P<documentId>.*)\/update\/4$`,
`^\/api\/(?P<version>.*)\/document\/(?P<documentId>.*)\/update\/4$`},
testCase: testCase{
inputName: "/api/v1/document/321083210/update/4",
outputName: "/api/v1/document/{documentId}/update/4",
outputAttributes: map[string]interface{}{
"documentId": "321083210",
},
},
breakAfterMatch: true,
},
{
rules: []string{"rule"},
testCase: testCase{
inputName: "",
outputName: "",
outputAttributes: nil,
},
},
}
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
oCfg := cfg.(*Config)
oCfg.Rename.ToAttributes = &ToAttributes{}
for _, tc := range testCases {
oCfg.Rename.ToAttributes.Rules = tc.rules
oCfg.Rename.ToAttributes.BreakAfterMatch = tc.breakAfterMatch
tp, err := factory.CreateTracesProcessor(context.Background(), componenttest.NewNopProcessorCreateSettings(), oCfg, consumertest.NewNop())
require.Nil(t, err)
require.NotNil(t, tp)
runIndividualTestCase(t, tc.testCase, tp)
}
} | explode_data.jsonl/51043 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1060
} | [
2830,
3393,
12485,
22946,
38346,
10516,
1155,
353,
8840,
836,
8,
1476,
18185,
37302,
1669,
3056,
1235,
341,
197,
7000,
2425,
1843,
3056,
917,
198,
197,
3388,
6025,
8331,
1807,
198,
197,
18185,
4207,
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... | 2 |
func TestValidateErrorLog(t *testing.T) {
tests := map[string]apm.ErrorLogRecord{
"empty_message": {
Message: "",
},
"long_message": {
Message: strings.Repeat("x", 1025),
},
"level": {
Message: "x",
Level: strings.Repeat("x", 1025),
},
"logger_name": {
Message: "x",
LoggerName: strings.Repeat("x", 1025),
},
"message_format": {
Message: "x",
MessageFormat: strings.Repeat("x", 1025),
},
}
for name, record := range tests {
t.Run(name, func(t *testing.T) {
validatePayloads(t, func(tracer *apm.Tracer) {
tracer.NewErrorLog(record).Send()
})
})
}
} | explode_data.jsonl/796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
17926,
1454,
2201,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
391,
76,
6141,
2201,
6471,
515,
197,
197,
1,
3194,
6462,
788,
341,
298,
46733,
25,
8324,
197,
197,
1583,
197,
197,
1,
4825,
6462,
788,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRouterResponseHeaders(t *testing.T) {
r := NewTestRouter(t)
r.Resource("/test",
ResponseHeader("Etag", "Identifies a specific version of this resource"),
ResponseHeader("X-Test", "Custom test header"),
ResponseHeader("X-Missing", "Won't get sent"),
ResponseText(http.StatusOK, "Successful test", Headers("Etag", "X-Test", "X-Missing")),
ResponseError(http.StatusBadRequest, "Error example", Headers("X-Test")),
).Get("Test operation", func() (etag string, xTest *string, xMissing string, success string, fail string) {
test := "test"
return "\"abc123\"", &test, "", "hello", ""
})
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, "/test", nil)
r.ServeHTTP(w, req)
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "hello", w.Body.String())
assert.Equal(t, "\"abc123\"", w.Header().Get("Etag"))
assert.Equal(t, "test", w.Header().Get("X-Test"))
assert.Equal(t, "", w.Header().Get("X-Missing"))
} | explode_data.jsonl/66540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
9523,
2582,
10574,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
2271,
9523,
1155,
692,
7000,
20766,
4283,
1944,
756,
197,
69604,
4047,
445,
36,
4578,
497,
330,
28301,
9606,
264,
3151,
2319,
315,
419,
5101,
4461,
197,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_MemoryStore_Close(t *testing.T) {
m := NewMemoryStore()
m.Open()
if !m.opened {
t.Fatalf("MemoryStore was not set open")
}
m.Close()
if m.opened {
t.Fatalf("MemoryStore was still open after unopen")
}
} | explode_data.jsonl/37293 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
1245,
4731,
6093,
68185,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
10642,
6093,
741,
2109,
12953,
741,
743,
753,
76,
5826,
291,
341,
197,
3244,
30762,
445,
10642,
6093,
572,
537,
738,
1787,
1138,
197,
630,
2109,
1042... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunTasksQuery(t *testing.T) {
bg := context.Background()
expected := mustExpandTick(`
SELECT
TRS.bot.bot_id,
BUILDS.id AS bbid,
JSON_EXTRACT_SCALAR(BUILDS.output.properties, r"$.compressed_result") AS bb_output_properties,
TRS.task_id,
UNIX_SECONDS(TRS.end_time) AS end_time,
(SELECT ARRAY_TO_STRING(values, ",") FROM TRS.bot.dimensions WHERE key = "label-model" LIMIT 1)
AS model,
FROM {{$tick}}chromeos-swarming.swarming.task_results_summary{{$tick}} AS TRS
LEFT OUTER JOIN
{{$tick}}cr-buildbucket.chromeos.builds{{$tick}} AS BUILDS
ON TRS.task_id = BUILDS.infra.swarming.task_id
WHERE
REGEXP_CONTAINS(TRS.bot.bot_id, r'^(?i)crossk[-]')
AND 1 <= UNIX_SECONDS(TRS.end_time)
AND 2 > UNIX_SECONDS(TRS.end_time)
AND 1 <= UNIX_SECONDS(BUILDS.end_time) + 15000
AND 2 > UNIX_SECONDS(BUILDS.end_time) - 15000
AND (
("" = '') OR
(
SELECT SUM(IF("" IN UNNEST(values), 1, 0))
FROM TRS.bot.dimensions
WHERE key = 'label-model'
LIMIT 1
) > 0
)
LIMIT 10000
`)
actual, err := instantiateSQLQuery(
bg,
taskQueryTemplate,
&TaskQueryParams{
StartTime: 1,
EndTime: 2,
Model: "",
Limit: 10000,
BuildBucketSafetyMargin: 15000,
},
)
if err != nil {
t.Error(err)
}
if diff := cmp.Diff(expected, actual); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
}
} | explode_data.jsonl/28494 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 688
} | [
2830,
3393,
6727,
25449,
2859,
1155,
353,
8840,
836,
8,
341,
76131,
1669,
2266,
19047,
741,
42400,
1669,
1969,
38946,
22213,
61528,
4858,
198,
220,
4984,
50,
34709,
34709,
842,
345,
220,
425,
9776,
5936,
1764,
5752,
16520,
307,
345,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestIrisAuth(t *testing.T) {
e := irisTester(t)
e.GET("/auth").
Expect().
Status(http.StatusUnauthorized)
e.GET("/auth").WithBasicAuth("ford", "<bad password>").
Expect().
Status(http.StatusUnauthorized)
e.GET("/auth").WithBasicAuth("ford", "betelgeuse7").
Expect().
Status(http.StatusOK).Body().Equal("authenticated!")
} | explode_data.jsonl/66291 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
40,
5963,
5087,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
63942,
58699,
1155,
692,
7727,
17410,
4283,
3242,
38609,
197,
35911,
25829,
197,
58321,
19886,
10538,
51181,
692,
7727,
17410,
4283,
3242,
1827,
2354,
15944,
5087,
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 TestApps(t *testing.T) {
tests := []struct {
inConfigString string
inComment string
outError bool
}{
{
inConfigString: `
app_service:
enabled: true
apps:
-
name: foo
public_addr: "foo.example.com"
uri: "http://127.0.0.1:8080"
resources:
- labels:
'*': '*'
`,
inComment: "config is valid",
outError: false,
},
{
inConfigString: `
app_service:
enabled: true
apps:
-
public_addr: "foo.example.com"
uri: "http://127.0.0.1:8080"
`,
inComment: "config is missing name",
outError: true,
},
{
inConfigString: `
app_service:
enabled: true
apps:
-
name: foo
uri: "http://127.0.0.1:8080"
`,
inComment: "config is valid",
outError: false,
},
{
inConfigString: `
app_service:
enabled: true
apps:
-
name: foo
public_addr: "foo.example.com"
`,
inComment: "config is missing internal address",
outError: true,
},
}
for _, tt := range tests {
clf := CommandLineFlags{
ConfigString: base64.StdEncoding.EncodeToString([]byte(tt.inConfigString)),
}
cfg := service.MakeDefaultConfig()
err := Configure(&clf, cfg)
require.Equal(t, err != nil, tt.outError, tt.inComment)
}
} | explode_data.jsonl/47177 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 575
} | [
2830,
3393,
53602,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
2648,
703,
914,
198,
197,
17430,
10677,
414,
914,
198,
197,
13967,
1454,
981,
1807,
198,
197,
59403,
197,
197,
515,
298,
17430,
2648,
703,
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 TestCodeBytes(t *testing.T) {
var buf = make([]byte, 64)
var v []byte = []byte{1}
var n uint64
n = EncodeBytes(buf, v)
var d = make([]byte, 2)
n = DecodeBytes(buf[:n], &d)
if v[0] != d[0] {
t.Errorf("error %d != %d", v[0], d[0])
}
if n != SizeofBytes(v) {
t.Errorf("error %d != %d", n, len(buf[:n]))
}
} | explode_data.jsonl/58555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
2078,
7078,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
284,
1281,
10556,
3782,
11,
220,
21,
19,
340,
2405,
348,
3056,
3782,
284,
3056,
3782,
90,
16,
532,
2405,
308,
2622,
21,
19,
198,
9038,
284,
56562,
7078,
10731,
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 TestPathCleanMallocs(t *testing.T) {
if testing.Short() {
t.Skip("skipping malloc count in short mode")
}
if runtime.GOMAXPROCS(0) > 1 {
t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
return
}
for _, test := range cleanTests {
allocs := testing.AllocsPerRun(100, func() { CleanPath(test.result) })
if allocs > 0 {
t.Errorf("CleanPath(%q): %v allocs, want zero", test.result, allocs)
}
}
} | explode_data.jsonl/73831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
1820,
27529,
53681,
82,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
15731,
1760,
304,
2805,
3856,
1138,
197,
532,
743,
15592,
1224,
1898,
2954,
9117,
6412,
7,
15,
8,
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... | 1 |
func TestUnwrapType(t *testing.T) {
t.Run("nil", func(t *testing.T) {
assert.Nil(t, goutils.UnwrapType(nil))
})
t.Run("struct", func(t *testing.T) {
assert.Equal(t, reflect.Struct, goutils.UnwrapType(reflect.TypeOf(struct{}{})).Kind())
})
t.Run("pointer", func(t *testing.T) {
assert.Equal(t, reflect.Struct, goutils.UnwrapType(reflect.TypeOf(&struct{}{})).Kind())
})
} | explode_data.jsonl/78828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
1806,
10097,
929,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
8385,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
59678,
1155,
11,
342,
411,
8669,
10616,
10097,
929,
27907,
1171,
197,
3518,
3244,
16708,
445,
1235... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestProducerStartStop(t *testing.T) {
// this test checks that Start() followed by Stop() doesn't cause any race conditions.
mock := newMockAsyncProducer()
toDB := make(chan proto.Message)
topic := "occlient"
systemID := "Foobar"
p := &producer{
notifsChan: toDB,
kafkaProducer: mock,
encoder: openconfig.NewEncoder(topic, sarama.StringEncoder(systemID), ""),
done: make(chan struct{}),
}
msg := &pb.SubscribeResponse{
Response: &pb.SubscribeResponse_Update{
Update: &pb.Notification{
Timestamp: 0,
Prefix: newPath("/foo/bar"),
Update: []*pb.Update{},
},
},
}
done := make(chan struct{})
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-mock.input:
case <-done:
return
}
}
}()
wg.Add(1)
go func() {
defer wg.Done()
for {
select {
case <-done:
return
default:
}
p.Write(msg)
}
}()
p.Start()
p.Write(msg)
p.Stop()
close(done)
wg.Wait()
} | explode_data.jsonl/4803 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 466
} | [
2830,
3393,
45008,
3479,
10674,
1155,
353,
8840,
836,
8,
341,
197,
322,
419,
1273,
12341,
429,
5145,
368,
8110,
553,
14215,
368,
3171,
944,
5240,
894,
6957,
4682,
382,
77333,
1669,
501,
11571,
6525,
45008,
741,
31709,
3506,
1669,
1281,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddTCMallocStats(t *testing.T) {
d := NewMongodbData(
&StatLine{
TCMallocCurrentAllocatedBytes: 5877253096,
TCMallocHeapSize: 8067108864,
TCMallocPageheapFreeBytes: 1054994432,
TCMallocPageheapUnmappedBytes: 677859328,
TCMallocMaxTotalThreadCacheBytes: 1073741824,
TCMallocCurrentTotalThreadCacheBytes: 80405312,
TCMallocTotalFreeBytes: 457002008,
TCMallocCentralCacheFreeBytes: 375131800,
TCMallocTransferCacheFreeBytes: 1464896,
TCMallocThreadCacheFreeBytes: 80405312,
TCMallocPageheapComittedBytes: 7389249536,
TCMallocPageheapScavengeCount: 396394,
TCMallocPageheapCommitCount: 641765,
TCMallocPageheapTotalCommitBytes: 102248751104,
TCMallocPageheapDecommitCount: 396394,
TCMallocPageheapTotalDecommitBytes: 94859501568,
TCMallocPageheapReserveCount: 6179,
TCMallocPageheapTotalReserveBytes: 8067108864,
TCMallocSpinLockTotalDelayNanos: 2344453860,
},
tags,
)
var acc testutil.Accumulator
d.AddDefaultStats()
d.flush(&acc)
for key := range defaultTCMallocStats {
require.True(t, acc.HasInt64Field("mongodb", key))
}
} | explode_data.jsonl/35780 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 597
} | [
2830,
3393,
2212,
7749,
53681,
16635,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
1532,
44,
21225,
1043,
1006,
197,
197,
5,
15878,
2460,
515,
298,
197,
7749,
53681,
5405,
25154,
657,
7078,
25,
286,
220,
20,
23,
22,
22,
17,
20,
18,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMetricLists(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
opts := testOptions(ctrl)
lists := newMetricLists(testShard, opts)
require.False(t, lists.closed)
// Create a new standard metric list.
listID := standardMetricListID{resolution: time.Second}.toMetricListID()
sl, err := lists.FindOrCreate(listID)
require.NoError(t, err)
require.NotNil(t, sl)
require.Equal(t, 1, lists.Len())
// Find the same standard metric list.
sl2, err := lists.FindOrCreate(listID)
require.NoError(t, err)
require.True(t, sl == sl2)
require.Equal(t, 1, lists.Len())
// Create a new forwarded metric list.
listID = forwardedMetricListID{
resolution: 10 * time.Second,
numForwardedTimes: testNumForwardedTimes,
}.toMetricListID()
fl, err := lists.FindOrCreate(listID)
require.NoError(t, err)
require.NotNil(t, fl)
require.Equal(t, 2, lists.Len())
// Find the same forwarded metric list.
fl2, err := lists.FindOrCreate(listID)
require.NoError(t, err)
require.True(t, fl == fl2)
require.Equal(t, 2, lists.Len())
// Create a new timed metric list.
listID = timedMetricListID{
resolution: time.Minute,
}.toMetricListID()
tl, err := lists.FindOrCreate(listID)
require.NoError(t, err)
require.NotNil(t, tl)
require.Equal(t, 3, lists.Len())
// Find the same timed metric list.
tl2, err := lists.FindOrCreate(listID)
require.NoError(t, err)
require.True(t, tl == tl2)
require.Equal(t, 3, lists.Len())
// Perform a tick.
tickRes := lists.Tick()
expectedRes := listsTickResult{
standard: map[time.Duration]int{
time.Second: 0,
},
forwarded: map[time.Duration]int{
10 * time.Second: 0,
},
timed: map[time.Duration]int{
time.Minute: 0,
},
}
require.Equal(t, expectedRes, tickRes)
// Finding or creating in a closed list should result in an error.
lists.Close()
_, err = lists.FindOrCreate(listID)
require.Equal(t, errListsClosed, err)
require.True(t, lists.closed)
// Closing a second time should have no impact.
lists.Close()
require.True(t, lists.closed)
} | explode_data.jsonl/43599 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 796
} | [
2830,
3393,
54310,
37848,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
64734,
1669,
1273,
3798,
62100,
340,
14440,
82,
1669,
501,
54310,
37848,
8623,
2016,
567,
11,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceImpl_GetCountries(t *testing.T) {
var (
firstCountry = dto.Country{
LegacyID: 2,
Name: "Poland",
ImagePath: "https://cdn.sportmonks.com/images/countries/png/short/pl.png",
Continent: "Europe",
Region: "EMEA",
SubRegion: "Eastern Europe",
FIFA: "POL",
ISO: "POL",
ISO2: "PL",
Longitude: "19.37775993347168",
Latitude: "52.147850036621094",
}
secondCountry = dto.Country{
LegacyID: 5,
Name: "Brazil",
ImagePath: "https://cdn.sportmonks.com/images/countries/png/short/br.png",
Continent: "Americas",
Region: "AMER",
SubRegion: "South America",
FIFA: "BRA",
ISO: "BRA",
ISO2: "BR",
Longitude: "-52.97311782836914",
Latitude: "-10.81045150756836",
}
)
sportmonksService := New(nil, nil)
countries, hasNextPage, err := sportmonksService.GetCountries(context.TODO(), 1)
assert.Nil(t, err)
assert.NotNil(t, countries)
assert.Equal(t, firstCountry, countries[0])
assert.Equal(t, secondCountry, countries[1])
assert.Equal(t, true, hasNextPage)
} | explode_data.jsonl/28414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 515
} | [
2830,
3393,
50603,
13614,
71728,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
42190,
16408,
284,
28335,
62413,
515,
298,
15070,
791,
2757,
915,
25,
220,
220,
17,
345,
298,
21297,
25,
414,
330,
14658,
437,
756,
298,
53397,
1820,
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 TestUpdatePostEditAt(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
post := th.BasicPost.Clone()
post.IsPinned = true
saved, err := th.App.UpdatePost(th.Context, post, true)
require.Nil(t, err)
assert.Equal(t, saved.EditAt, post.EditAt, "shouldn't have updated post.EditAt when pinning post")
post = saved.Clone()
time.Sleep(time.Millisecond * 100)
post.Message = model.NewId()
saved, err = th.App.UpdatePost(th.Context, post, true)
require.Nil(t, err)
assert.NotEqual(t, saved.EditAt, post.EditAt, "should have updated post.EditAt when updating post message")
time.Sleep(time.Millisecond * 200)
} | explode_data.jsonl/26425 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 239
} | [
2830,
3393,
4289,
4133,
4036,
1655,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
51172,
1669,
270,
48868,
4133,
64463,
2822,
51172,
4506,
47,
20561,
284,
830,
198,
1903... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenModel_Issue910(t *testing.T) {
specDoc, err := loads.Spec("../fixtures/bugs/910/fixture-910.yaml")
require.NoError(t, err)
p, ok := specDoc.Spec().Paths.Paths["/mytest"]
require.True(t, ok)
op := p.Get
responses := op.Responses.StatusCodeResponses
for k, r := range responses {
t.Logf("Response: %d", k)
schema := *r.Schema
opts := opts()
genModel, err := makeGenDefinition("GetMyTestOKBody", "models", schema, specDoc, opts)
require.NoError(t, err)
buf := bytes.NewBuffer(nil)
require.NoError(t, opts.templates.MustGet("model").Execute(buf, genModel))
ct, err := opts.LanguageOpts.FormatContent("foo.go", buf.Bytes())
require.NoError(t, err)
res := string(ct)
assertInCode(t, "// bar\n // Required: true\n Bar *int64 `json:\"bar\"`", res)
assertInCode(t, "// foo\n // Required: true\n Foo interface{} `json:\"foo\"`", res)
assertInCode(t, "// baz\n Baz int64 `json:\"baz,omitempty\"`", res)
assertInCode(t, "// quux\n Quux []string `json:\"quux\"`", res)
assertInCode(t, `if err := validate.Required("bar", "body", m.Bar); err != nil {`, res)
assertInCode(t, `if m.Foo == nil {`, res) // interface{} now checked against nil (validate.Required fails on any zero value)
assertNotInCode(t, `if err := validate.Required("baz", "body", m.Baz); err != nil {`, res)
assertNotInCode(t, `if err := validate.Required("quux", "body", m.Quux); err != nil {`, res)
// NOTE(fredbi); fixed Required in slices. This property has actually no validation
}
} | explode_data.jsonl/2568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 589
} | [
2830,
3393,
9967,
1712,
7959,
83890,
24,
16,
15,
1155,
353,
8840,
836,
8,
341,
98100,
9550,
11,
1848,
1669,
20907,
36473,
17409,
45247,
14,
56176,
14,
24,
16,
15,
14,
59612,
12,
24,
16,
15,
33406,
1138,
17957,
35699,
1155,
11,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestJSONOutput(t *testing.T) {
sql := "select 1 from user where id = 1"
explains, err := Run(sql)
require.NoError(t, err, "vtexplain error")
require.NotNil(t, explains, "vtexplain error running %s: no explain", string(sql))
explainJSON := ExplainsAsJSON(explains)
var data interface{}
err = json.Unmarshal([]byte(explainJSON), &data)
require.NoError(t, err, "error unmarshaling json")
array, ok := data.([]interface{})
if !ok || len(array) != 1 {
t.Errorf("expected single-element top-level array, got:\n%s", explainJSON)
}
explain, ok := array[0].(map[string]interface{})
if !ok {
t.Errorf("expected explain map, got:\n%s", explainJSON)
}
if explain["SQL"] != sql {
t.Errorf("expected SQL, got:\n%s", explainJSON)
}
plans, ok := explain["Plans"].([]interface{})
if !ok || len(plans) != 1 {
t.Errorf("expected single-element plans array, got:\n%s", explainJSON)
}
actions, ok := explain["TabletActions"].(map[string]interface{})
if !ok {
t.Errorf("expected TabletActions map, got:\n%s", explainJSON)
}
actionsJSON, err := json.MarshalIndent(actions, "", " ")
require.NoError(t, err, "error in json marshal")
wantJSON := `{
"ks_sharded/-40": {
"MysqlQueries": [
{
"SQL": "select 1 from ` + "`user`" + ` where id = 1 limit 10001",
"Time": 1
}
],
"TabletQueries": [
{
"BindVars": {
"#maxLimit": "10001",
"vtg1": "1"
},
"SQL": "select :vtg1 from ` + "`user`" + ` where id = :vtg1",
"Time": 1
}
]
}
}`
diff := cmp.Diff(wantJSON, string(actionsJSON))
if diff != "" {
t.Errorf(diff)
}
} | explode_data.jsonl/12770 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 819
} | [
2830,
3393,
5370,
5097,
1155,
353,
8840,
836,
8,
341,
30633,
1669,
330,
1742,
220,
16,
504,
1196,
1380,
877,
284,
220,
16,
698,
8122,
500,
1735,
11,
1848,
1669,
6452,
13148,
340,
17957,
35699,
1155,
11,
1848,
11,
330,
9708,
94344,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreate(t *testing.T) {
oldGetUpdatedTime := getUpdatedTime
getUpdatedTime = func() time.Time { return time.Date(2022, 3, 16, 16, 55, 45, 0, time.UTC) }
defer func() { getUpdatedTime = oldGetUpdatedTime }()
tableName = "table-for-create"
tests := []struct {
client func(t *testing.T) PutItemAPI
input CreateInput
expected *CreateResult
expectedErr error
}{
{
client: func(t *testing.T) PutItemAPI {
return mockPutItemAPI(func(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error) {
t.Helper()
assert.Equal(t, tableName, *params.TableName)
messageID := params.Item["MessageID"].(*types.AttributeValueMemberS).Value
assert.Len(t, messageID, 6+32)
assert.True(t, strings.HasPrefix(messageID, "draft-"))
return &dynamodb.PutItemOutput{}, nil
})
},
input: CreateInput{
EmailInput: EmailInput{
Subject: "subject",
From: []string{"example@example.com"},
To: []string{"example@example.com"},
Cc: []string{"example@example.com"},
Bcc: []string{"example@example.com"},
ReplyTo: []string{"example@example.com"},
Text: "text",
HTML: "<p>html</p>",
},
},
expected: &CreateResult{
TimeIndex: TimeIndex{
Type: EmailTypeDraft,
TimeUpdated: "2022-03-16T16:55:45Z",
},
Subject: "subject",
From: []string{"example@example.com"},
To: []string{"example@example.com"},
Cc: []string{"example@example.com"},
Bcc: []string{"example@example.com"},
ReplyTo: []string{"example@example.com"},
Text: "text",
HTML: "<p>html</p>",
},
},
{
client: func(t *testing.T) PutItemAPI {
return mockPutItemAPI(func(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error) {
return &dynamodb.PutItemOutput{}, ErrInvalidInput
})
},
expectedErr: ErrInvalidInput,
},
}
for i, test := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
ctx := context.TODO()
actual, err := Create(ctx, test.client(t), test.input)
if actual != nil && test.expected != nil {
assert.True(t, strings.HasPrefix(actual.MessageID, "draft-"))
test.expected.MessageID = actual.MessageID // messageID is randomly generated
}
assert.Equal(t, test.expected, actual)
assert.Equal(t, test.expectedErr, err)
})
}
} | explode_data.jsonl/48130 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1064
} | [
2830,
3393,
4021,
1155,
353,
8840,
836,
8,
341,
61828,
1949,
16196,
1462,
1669,
633,
16196,
1462,
198,
10366,
16196,
1462,
284,
2915,
368,
882,
16299,
314,
470,
882,
8518,
7,
17,
15,
17,
17,
11,
220,
18,
11,
220,
16,
21,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMin(t *testing.T) {
cases := []struct {
x, y, min int
}{
{1, 2, 1},
{2, 1, 1},
{1, 1, 1},
{0, 0, 0},
{-2, 1, -2},
{1, -2, -2},
}
for _, c := range cases {
assert.Equal(t, c.min, Min(c.x, c.y), "Failed to compute Min(%d, %d)", c.x, c.y)
}
} | explode_data.jsonl/20990 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
6217,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
10225,
11,
379,
11,
1308,
526,
198,
197,
59403,
197,
197,
90,
16,
11,
220,
17,
11,
220,
16,
1583,
197,
197,
90,
17,
11,
220,
16,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGenerateStatisticsInputParams(t *testing.T) {
d := &cloudwatch.Dimension{
Name: aws.String("LoadBalancerName"),
Value: aws.String("p-example"),
}
m := &cloudwatch.Metric{
MetricName: aws.String("Latency"),
Dimensions: []*cloudwatch.Dimension{d},
}
duration, _ := time.ParseDuration("1m")
internalDuration := config.Duration(duration)
c := &CloudWatch{
Namespace: "AWS/ELB",
Delay: internalDuration,
Period: internalDuration,
}
c.initializeCloudWatch()
now := time.Now()
c.updateWindow(now)
statFilter, _ := filter.NewIncludeExcludeFilter(nil, nil)
queries, _ := c.getDataQueries([]filteredMetric{{metrics: []*cloudwatch.Metric{m}, statFilter: statFilter}})
params := c.getDataInputs(queries)
assert.EqualValues(t, *params.EndTime, now.Add(-time.Duration(c.Delay)))
assert.EqualValues(t, *params.StartTime, now.Add(-time.Duration(c.Period)).Add(-time.Duration(c.Delay)))
require.Len(t, params.MetricDataQueries, 5)
assert.Len(t, params.MetricDataQueries[0].MetricStat.Metric.Dimensions, 1)
assert.EqualValues(t, *params.MetricDataQueries[0].MetricStat.Period, 60)
} | explode_data.jsonl/56718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 429
} | [
2830,
3393,
31115,
38599,
2505,
4870,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
609,
12361,
14321,
53234,
515,
197,
21297,
25,
220,
31521,
6431,
445,
5879,
93825,
675,
4461,
197,
47399,
25,
31521,
6431,
445,
79,
43430,
4461,
197,
630,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMatAddWeighted(t *testing.T) {
mat1 := NewMatWithSize(101, 102, MatTypeCV8U)
mat2 := NewMatWithSize(101, 102, MatTypeCV8U)
mat3 := NewMat()
AddWeighted(mat1, 2.0, mat2, 3.0, 4.0, &mat3)
if mat3.Empty() {
t.Error("TestMatAddWeighted dest mat3 should not be empty.")
}
} | explode_data.jsonl/81706 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
11575,
2212,
8295,
291,
1155,
353,
8840,
836,
8,
341,
59874,
16,
1669,
1532,
11575,
2354,
1695,
7,
16,
15,
16,
11,
220,
16,
15,
17,
11,
6867,
929,
19589,
23,
52,
340,
59874,
17,
1669,
1532,
11575,
2354,
1695,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEncodeAsForm(t *testing.T) {
tests := []struct {
params map[string]string
body string
}{
{map[string]string{"a": "b"}, "a=b"},
{map[string]string{"a": "b", "c": "d"}, "a=b&c=d"},
{nil, ""},
}
for _, test := range tests {
u, err := url.Parse("http://localhost")
if err != nil {
t.Fatalf("url parse failed: %v", err)
}
q := u.Query()
for k, v := range test.params {
q.Set(k, v)
}
u.RawQuery = q.Encode()
trReq := transformable{}
trReq.setURL(*u)
res, err := encodeAsForm(trReq)
assert.NoError(t, err)
assert.Equal(t, test.body, string(res))
assert.Equal(t, "application/x-www-form-urlencoded", trReq.header().Get("Content-Type"))
}
} | explode_data.jsonl/20809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
32535,
2121,
1838,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
25856,
2415,
14032,
30953,
198,
197,
35402,
256,
914,
198,
197,
59403,
197,
197,
90,
2186,
14032,
30953,
4913,
64,
788,
330,
65,
14345,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFloorSum(t *testing.T) {
s := newSummary(100)
var total uint32
for i := 0; i < 100; i++ {
count := uint32(rand.Intn(10) + 1)
_ = s.Add(rand.Float64(), count)
total += count
}
idx, _ := s.FloorSum(-1)
if idx != -1 {
t.Errorf("Expected no centroid to satisfy -1 but got index=%d", idx)
}
for i := float64(0); i < float64(total)+10; i++ {
node, _ := s.FloorSum(i)
if s.HeadSum(node) > i {
t.Errorf("headSum(%d)=%.0f (>%.0f)", node, s.HeadSum(node), i)
}
if node+1 < s.Len() && s.HeadSum(node+1) <= i {
t.Errorf("headSum(%d)=%.0f (>%.0f)", node+1, s.HeadSum(node+1), i)
}
}
} | explode_data.jsonl/77562 | {
"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,
51444,
9190,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
19237,
7,
16,
15,
15,
340,
2405,
2790,
2622,
18,
17,
198,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
15,
26,
600,
1027,
341,
197,
18032,
1669,
262... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFmtNumber(t *testing.T) {
tests := []struct {
num float64
v uint64
expected string
}{
// {
// num: 1123456.5643,
// v: 2,
// expected: "1,123,456.56",
// },
// {
// num: 1123456.5643,
// v: 1,
// expected: "1,123,456.6",
// },
// {
// num: 221123456.5643,
// v: 3,
// expected: "221,123,456.564",
// },
// {
// num: -221123456.5643,
// v: 3,
// expected: "-221,123,456.564",
// },
// {
// num: -221123456.5643,
// v: 3,
// expected: "-221,123,456.564",
// },
// {
// num: 0,
// v: 2,
// expected: "0.00",
// },
// {
// num: -0,
// v: 2,
// expected: "0.00",
// },
// {
// num: -0,
// v: 2,
// expected: "0.00",
// },
}
trans := New()
for _, tt := range tests {
s := trans.FmtNumber(tt.num, tt.v)
if s != tt.expected {
t.Errorf("Expected '%s' Got '%s'", tt.expected, s)
}
}
} | explode_data.jsonl/1297 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 632
} | [
2830,
3393,
93322,
2833,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
22431,
414,
2224,
21,
19,
198,
197,
5195,
286,
2622,
21,
19,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
322,
341,
197,
197,
322,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestWebsocketListen(t *testing.T) {
zero, err := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/0/ws")
if err != nil {
t.Fatal(err)
}
tpt := &WebsocketTransport{}
l, err := tpt.Listen(zero)
if err != nil {
t.Fatal(err)
}
defer l.Close()
msg := []byte("HELLO WORLD")
go func() {
d, _ := tpt.Dialer(nil)
c, err := d.Dial(l.Multiaddr())
if err != nil {
t.Error(err)
return
}
c.Write(msg)
c.Close()
}()
c, err := l.Accept()
if err != nil {
t.Fatal(err)
}
defer c.Close()
obr := iotest.OneByteReader(c)
out, err := ioutil.ReadAll(obr)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(out, msg) {
t.Fatal("got wrong message", out, msg)
}
} | explode_data.jsonl/40772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 339
} | [
2830,
3393,
5981,
9556,
38714,
1155,
353,
8840,
836,
8,
341,
197,
14154,
11,
1848,
1669,
7491,
7121,
20358,
6214,
4283,
573,
19,
14,
16,
17,
22,
13,
15,
13,
15,
13,
16,
95958,
14,
15,
91021,
1138,
743,
1848,
961,
2092,
341,
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 TestGetLeaseConditional(t *testing.T) {
svc := &mockDynamoDB{tableExist: true, item: map[string]*dynamodb.AttributeValue{}}
kclConfig := cfg.NewKinesisClientLibConfig("appName", "test", "us-west-2", "abc").
WithInitialPositionInStream(cfg.LATEST).
WithMaxRecords(10).
WithMaxLeasesForWorker(1).
WithShardSyncIntervalMillis(5000).
WithFailoverTimeMillis(300000).
WithLeaseStealing(true)
checkpoint := NewDynamoCheckpoint(kclConfig).WithDynamoDB(svc)
checkpoint.Init()
marshalledCheckpoint := map[string]*dynamodb.AttributeValue{
LeaseKeyKey: {
S: aws.String("0001"),
},
LeaseOwnerKey: {
S: aws.String("abcd-efgh"),
},
LeaseTimeoutKey: {
S: aws.String(time.Now().Add(-1 * time.Second).UTC().Format(time.RFC3339)),
},
SequenceNumberKey: {
S: aws.String("deadbeef"),
},
ClaimRequestKey: {
S: aws.String("ijkl-mnop"),
},
}
input := &dynamodb.PutItemInput{
TableName: aws.String("TableName"),
Item: marshalledCheckpoint,
}
checkpoint.svc.PutItem(input)
shard := &par.ShardStatus{
ID: "0001",
Checkpoint: "deadbeef",
ClaimRequest: "ijkl-mnop",
Mux: &sync.RWMutex{},
}
err := checkpoint.FetchCheckpoint(shard)
if err != nil {
t.Errorf("Could not fetch checkpoint %s", err)
}
err = checkpoint.GetLease(shard, "ijkl-mnop")
if err != nil {
t.Errorf("Lease not aquired after timeout %s", err)
}
assert.Equal(t, *svc.expressionAttributeValues[":claim_request"].S, "ijkl-mnop")
assert.Contains(t, svc.conditionalExpression, " AND ClaimRequest = :claim_request")
} | explode_data.jsonl/9844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 668
} | [
2830,
3393,
1949,
2304,
519,
79233,
1155,
353,
8840,
836,
8,
341,
1903,
7362,
1669,
609,
16712,
35,
85608,
3506,
90,
2005,
25613,
25,
830,
11,
1509,
25,
2415,
14032,
8465,
67,
83348,
33775,
1130,
6257,
532,
16463,
564,
2648,
1669,
132... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetDefaultMACSettings(t *testing.T) {
for _, tc := range []struct {
name string
assertion func(err error) bool
req *ttnpb.GetDefaultMACSettingsRequest
}{
{
name: "NoFrequencyPlanID",
assertion: errors.IsNotFound,
req: &ttnpb.GetDefaultMACSettingsRequest{},
},
{
name: "NoLoRaWANVersion",
assertion: errors.IsInvalidArgument,
req: &ttnpb.GetDefaultMACSettingsRequest{
FrequencyPlanId: "EU_863_870",
},
},
{
name: "OK",
assertion: func(err error) bool { return err == nil },
req: &ttnpb.GetDefaultMACSettingsRequest{
FrequencyPlanId: "EU_863_870",
LorawanPhyVersion: ttnpb.RP001_V1_0_2_REV_B,
},
},
} {
tc := tc
test.RunSubtest(t, test.SubtestConfig{
Name: tc.name,
Parallel: true,
Func: func(ctx context.Context, t *testing.T, a *assertions.Assertion) {
ns, _, _, stop := StartTest(ctx, TestConfig{})
defer stop()
settings, err := ttnpb.NewNsClient(ns.LoopbackConn()).GetDefaultMACSettings(test.Context(), tc.req)
if tc.assertion != nil {
a.So(tc.assertion(err), should.BeTrue)
} else {
a.So(settings, should.NotBeNil)
}
},
})
}
} | explode_data.jsonl/76737 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 557
} | [
2830,
3393,
1949,
3675,
25788,
6086,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
6948,
290,
2915,
3964,
1465,
8,
1807,
198,
197,
24395,
981,
353,
83,
1517,
16650,
2234,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_strToContents(t *testing.T) {
type args struct {
line string
tabWidth int
}
tests := []struct {
name string
args args
want lineContents
}{
{
name: "test1",
args: args{line: "1", tabWidth: 4},
want: lineContents{
{width: 1, style: tcell.StyleDefault, mainc: rune('1'), combc: nil},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := strToContents(tt.args.line, tt.args.tabWidth); !reflect.DeepEqual(got, tt.want) {
t.Errorf("strToContent() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/15652 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
2895,
1249,
14803,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
27109,
257,
914,
198,
197,
58149,
3327,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
5078... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckEnforceHttps(t *testing.T) {
tests := []struct {
name string
input storage.Storage
expected bool
}{
{
name: "Storage account HTTPS enforcement disabled",
input: storage.Storage{
Metadata: types.NewTestMetadata(),
Accounts: []storage.Account{
{
Metadata: types.NewTestMetadata(),
EnforceHTTPS: types.Bool(false, types.NewTestMetadata()),
},
},
},
expected: true,
},
{
name: "Storage account HTTPS enforcement enabled",
input: storage.Storage{
Metadata: types.NewTestMetadata(),
Accounts: []storage.Account{
{
Metadata: types.NewTestMetadata(),
EnforceHTTPS: types.Bool(true, types.NewTestMetadata()),
},
},
},
expected: false,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var testState state.State
testState.Azure.Storage = test.input
results := CheckEnforceHttps.Evaluate(&testState)
var found bool
for _, result := range results {
if result.Status() != rules.StatusPassed && result.Rule().LongID() == CheckEnforceHttps.Rule().LongID() {
found = true
}
}
if test.expected {
assert.True(t, found, "Rule should have been found")
} else {
assert.False(t, found, "Rule should not have been found")
}
})
}
} | explode_data.jsonl/47717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 556
} | [
2830,
3393,
3973,
1702,
8833,
92869,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
5819,
43771,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
5793... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSigWaitTimeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond)
defer cancel()
go ensureCancel(t, ctx.Done())
cli.SigWait(ctx, cancel)
} | explode_data.jsonl/52971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
47246,
14190,
7636,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
220,
20,
77053,
71482,
340,
16867,
9121,
2822,
30680,
5978,
9269,
1155,
11,
5635,
60422,
12367,
86448,
808,
343,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIPv4Proxier(t *testing.T) {
tcpProtocol := v1.ProtocolTCP
tests := []struct {
name string
services []*v1.Service
endpoints []*discovery.EndpointSlice
expectedIPVS *ipvstest.FakeIPVS
}{
{
name: "2 services with Cluster IP, each with endpoints",
services: []*v1.Service{
makeTestService("ns1", "svc1", func(svc *v1.Service) {
svc.Spec.ClusterIP = "10.20.30.41"
svc.Spec.Ports = []v1.ServicePort{{
Name: "p80",
Port: int32(80),
Protocol: v1.ProtocolTCP,
}}
}),
makeTestService("ns2", "svc2", func(svc *v1.Service) {
svc.Spec.ClusterIP = "1002:ab8::2:1"
svc.Spec.Ports = []v1.ServicePort{{
Name: "p8080",
Port: int32(8080),
Protocol: v1.ProtocolTCP,
}}
}),
},
endpoints: []*discovery.EndpointSlice{
makeTestEndpointSlice("ns1", "svc1", 1, func(eps *discovery.EndpointSlice) {
eps.AddressType = discovery.AddressTypeIPv4
eps.Endpoints = []discovery.Endpoint{{
Addresses: []string{"10.180.0.1"},
}}
eps.Ports = []discovery.EndpointPort{{
Name: utilpointer.StringPtr("p80"),
Port: utilpointer.Int32(80),
Protocol: &tcpProtocol,
}}
}),
makeTestEndpointSlice("ns2", "svc2", 1, func(eps *discovery.EndpointSlice) {
eps.AddressType = discovery.AddressTypeIPv6
eps.Endpoints = []discovery.Endpoint{{
Addresses: []string{"1009:ab8::5:6"},
}}
eps.Ports = []discovery.EndpointPort{{
Name: utilpointer.StringPtr("p8080"),
Port: utilpointer.Int32(8080),
Protocol: &tcpProtocol,
}}
}),
},
expectedIPVS: &ipvstest.FakeIPVS{
Services: map[ipvstest.ServiceKey]*utilipvs.VirtualServer{
{
IP: "10.20.30.41",
Port: 80,
Protocol: "TCP",
}: {
Address: netutils.ParseIPSloppy("10.20.30.41"),
Protocol: "TCP",
Port: uint16(80),
Scheduler: "rr",
},
},
Destinations: map[ipvstest.ServiceKey][]*utilipvs.RealServer{
{
IP: "10.20.30.41",
Port: 80,
Protocol: "TCP",
}: {
{
Address: netutils.ParseIPSloppy("10.180.0.1"),
Port: uint16(80),
Weight: 1,
},
},
},
},
},
{
name: "cluster IP service with no endpoints",
services: []*v1.Service{
makeTestService("ns1", "svc1", func(svc *v1.Service) {
svc.Spec.ClusterIP = "10.20.30.41"
svc.Spec.Ports = []v1.ServicePort{{
Name: "p80",
Port: int32(80),
Protocol: v1.ProtocolTCP,
}}
}),
},
endpoints: []*discovery.EndpointSlice{},
expectedIPVS: &ipvstest.FakeIPVS{
Services: map[ipvstest.ServiceKey]*utilipvs.VirtualServer{
{
IP: "10.20.30.41",
Port: 80,
Protocol: "TCP",
}: {
Address: netutils.ParseIPSloppy("10.20.30.41"),
Protocol: "TCP",
Port: uint16(80),
Scheduler: "rr",
},
},
Destinations: map[ipvstest.ServiceKey][]*utilipvs.RealServer{
{
IP: "10.20.30.41",
Port: 80,
Protocol: "TCP",
}: {},
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ipt := iptablestest.NewFake()
ipvs := ipvstest.NewFake()
ipset := ipsettest.NewFake(testIPSetVersion)
fp := NewFakeProxier(ipt, ipvs, ipset, nil, nil, v1.IPv4Protocol)
makeServiceMap(fp, test.services...)
populateEndpointSlices(fp, test.endpoints...)
fp.syncProxyRules()
if !reflect.DeepEqual(ipvs, test.expectedIPVS) {
t.Logf("actual ipvs state: %v", ipvs)
t.Logf("expected ipvs state: %v", test.expectedIPVS)
t.Errorf("unexpected IPVS state")
}
})
}
} | explode_data.jsonl/44351 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1986
} | [
2830,
3393,
58056,
19,
1336,
87,
1268,
1155,
353,
8840,
836,
8,
341,
3244,
4672,
20689,
1669,
348,
16,
54096,
49896,
198,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
1903,
2161,
257,
29838,
85,
16,
13860,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStatusListFromJson(t *testing.T) {
const jsonStream = `
[{"user_id":"k39fowpzhfffjxeaw8ecyrygme","status":"online","manual":true,"last_activity_at":0},{"user_id":"e9f1bbg8wfno7b3k7yk79bbwfy","status":"offline","manual":true,"last_activity_at":0}]
`
var dat []map[string]interface{}
if err := json.Unmarshal([]byte(jsonStream), &dat); err != nil {
panic(err)
}
toDec := strings.NewReader(jsonStream)
statusesFromJson := StatusListFromJson(toDec)
assert.Equal(t, statusesFromJson[0].UserId, dat[0]["user_id"], "UserId should be equal")
assert.Equal(t, statusesFromJson[1].UserId, dat[1]["user_id"], "UserId should be equal")
} | explode_data.jsonl/67570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 271
} | [
2830,
3393,
2522,
852,
3830,
5014,
1155,
353,
8840,
836,
8,
341,
4777,
2951,
3027,
284,
22074,
15287,
61753,
872,
842,
3252,
74,
18,
24,
69,
363,
79,
23815,
14092,
73,
8371,
672,
23,
757,
88,
884,
70,
2660,
2198,
2829,
3252,
25649,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue29565(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
orgEnable := core.PreparedPlanCacheEnabled()
defer core.SetPreparedPlanCache(orgEnable)
core.SetPreparedPlanCache(true)
tk := testkit.NewTestKit(t, store)
tk.MustExec(`use test`)
tk.MustExec(`drop table if exists PK_SIGNED_10094`)
tk.MustExec(`CREATE TABLE PK_SIGNED_10094 (COL1 decimal(55,0) NOT NULL, PRIMARY KEY (COL1))`)
tk.MustExec(`insert into PK_SIGNED_10094 values(-9999999999999999999999999999999999999999999999999999999)`)
tk.MustExec(`prepare stmt from 'select * from PK_SIGNED_10094 where col1 != ? and col1 + 10 <=> ? + 10'`)
tk.MustExec(`set @a=7309027171262036496, @b=-9798213896406520625`)
tk.MustQuery(`execute stmt using @a,@b`).Check(testkit.Rows())
tk.MustExec(`set @a=5408499810319315618, @b=-9999999999999999999999999999999999999999999999999999999`)
tk.MustQuery(`execute stmt using @a,@b`).Check(testkit.Rows("-9999999999999999999999999999999999999999999999999999999"))
tk.MustQuery(`select @@last_plan_from_cache`).Check(testkit.Rows("1"))
} | explode_data.jsonl/5520 | {
"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,
42006,
17,
24,
20,
21,
20,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
87625,
11084,
1669,
6200,
28770,
7212,
20485,
8233,
5462,
741,
16867,
6200,
4202,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMigrate_upApplyAll(t *testing.T) {
db := dbtest.OpenWithoutMigrations(t)
session, err := dbpkg.Open(db.DSN)
require.NoError(t, err)
n, err := Migrate(session, migrate.Up, 0)
require.NoError(t, err)
require.Greater(t, n, 1)
ids := []string{}
err = session.Select(&ids, `SELECT id FROM gorp_migrations`)
require.NoError(t, err)
wantIDs := []string{
"20200309000000-initial-1.sql",
"20200309000001-initial-2.sql",
"20200311000000-create-accounts.sql",
"20200311000001-create-identities.sql",
"20200311000002-create-auth-methods.sql",
"20200320000000-create-accounts-audit.sql",
"20200320000001-create-identities-audit.sql",
"20200320000002-create-auth-methods-audit.sql",
}
assert.Equal(t, wantIDs, ids)
} | explode_data.jsonl/39324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
44,
34479,
8237,
28497,
2403,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
2927,
1944,
12953,
26040,
44,
17824,
1155,
340,
25054,
11,
1848,
1669,
2927,
30069,
12953,
9791,
909,
18966,
340,
17957,
35699,
1155,
11,
1848,
692,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAnalyzeHostHTTP(t *testing.T) {
tests := []struct {
name string
httpResult *httpResult
hostAnalyzer *troubleshootv1beta2.HTTPAnalyze
result []*AnalyzeResult
expectErr bool
}{
{
name: "error",
httpResult: &httpResult{
Error: &collect.HTTPError{
Message: "i/o timeout",
},
},
hostAnalyzer: &troubleshootv1beta2.HTTPAnalyze{
CollectorName: "registry",
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "error",
Message: "Failed to reach replicated.registry.com",
},
},
},
},
result: []*AnalyzeResult{
{
Title: "HTTP Request",
IsFail: true,
Message: "Failed to reach replicated.registry.com",
},
},
},
{
name: "200",
httpResult: &httpResult{
Response: &collect.HTTPResponse{
Status: 200,
},
},
hostAnalyzer: &troubleshootv1beta2.HTTPAnalyze{
CollectorName: "registry",
Outcomes: []*troubleshootv1beta2.Outcome{
{
Fail: &troubleshootv1beta2.SingleOutcome{
When: "error",
Message: "Failed to reach replicated.registry.com",
},
},
{
Warn: &troubleshootv1beta2.SingleOutcome{
When: "statusCode == 204",
Message: "No content",
},
},
{
Pass: &troubleshootv1beta2.SingleOutcome{
When: "statusCode == 200",
Message: "Successfully reached registry",
},
},
},
},
result: []*AnalyzeResult{
{
Title: "HTTP Request",
IsPass: true,
Message: "Successfully reached registry",
},
},
},
{
name: "skip default on pass",
httpResult: &httpResult{
Response: &collect.HTTPResponse{
Status: 200,
},
},
hostAnalyzer: &troubleshootv1beta2.HTTPAnalyze{
CollectorName: "collector",
Outcomes: []*troubleshootv1beta2.Outcome{
{
Pass: &troubleshootv1beta2.SingleOutcome{
When: "statusCode == 200",
Message: "passed",
},
},
{
Warn: &troubleshootv1beta2.SingleOutcome{
Message: "default",
},
},
},
},
result: []*AnalyzeResult{
{
Title: "HTTP Request",
IsPass: true,
Message: "passed",
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
req := require.New(t)
b, err := json.Marshal(test.httpResult)
if err != nil {
t.Fatal(err)
}
getCollectedFileContents := func(filename string) ([]byte, error) {
return b, nil
}
result, err := (&AnalyzeHostHTTP{test.hostAnalyzer}).Analyze(getCollectedFileContents)
if test.expectErr {
req.Error(err)
} else {
req.NoError(err)
}
assert.Equal(t, test.result, result)
})
}
} | explode_data.jsonl/13185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1409
} | [
2830,
3393,
2082,
55856,
9296,
9230,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
28080,
2077,
256,
353,
1254,
2077,
198,
197,
63104,
54911,
353,
376,
5482,
96408,
85,
16,
19127,
17,
2735... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgAppFlowControlRecvHeartbeat(t *testing.T) {
r := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
r.becomeCandidate()
r.becomeLeader()
pr2 := r.prs.prs[2]
// force the progress to be in replicate state
pr2.becomeReplicate()
// fill in the inflights window
for i := 0; i < r.prs.maxInflight; i++ {
r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
r.readMessages()
}
for tt := 1; tt < 5; tt++ {
if !pr2.ins.full() {
t.Fatalf("#%d: inflights.full = %t, want %t", tt, pr2.ins.full(), true)
}
// recv tt msgHeartbeatResp and expect one free slot
for i := 0; i < tt; i++ {
r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeatResp})
r.readMessages()
if pr2.ins.full() {
t.Fatalf("#%d.%d: inflights.full = %t, want %t", tt, i, pr2.ins.full(), false)
}
}
// one slot
r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
ms := r.readMessages()
if len(ms) != 1 {
t.Fatalf("#%d: free slot = 0, want 1", tt)
}
// and just one slot
for i := 0; i < 10; i++ {
r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: []pb.Entry{{Data: []byte("somedata")}}})
ms1 := r.readMessages()
if len(ms1) != 0 {
t.Fatalf("#%d.%d: len(ms) = %d, want 0", tt, i, len(ms1))
}
}
// clear all pending messages.
r.Step(pb.Message{From: 2, To: 1, Type: pb.MsgHeartbeatResp})
r.readMessages()
}
} | explode_data.jsonl/81200 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 692
} | [
2830,
3393,
6611,
2164,
18878,
3273,
63483,
45384,
22227,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
501,
2271,
55535,
723,
7,
16,
11,
3056,
2496,
21,
19,
90,
16,
11,
220,
17,
2137,
220,
20,
11,
220,
16,
11,
1532,
10642,
5793,
2398... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUGetNotionalLeverage(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("skipping test: api keys not set")
}
_, err := b.FuturesNotionalBracket(context.Background(), "BTCUSD")
if err != nil {
t.Error(err)
}
_, err = b.FuturesNotionalBracket(context.Background(), "")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76637 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
52,
1949,
2623,
3914,
43,
2054,
424,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
25,
6330,
6894,
537,
738,
1138,
197,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestOoklaMeasurement(t *testing.T) {
d, u, err := Measure()
if err != nil {
t.Fatal("error:", err)
}
t.Logf("download: %f Mbps, upload: %f Mbps", d, u)
} | explode_data.jsonl/35290 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
46,
562,
4260,
76548,
1155,
353,
8840,
836,
8,
341,
2698,
11,
575,
11,
1848,
1669,
34104,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
841,
12147,
1848,
340,
197,
532,
3244,
98954,
445,
12885,
25,
1018,
69,
794... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewMappingRuleSnapshotFromProtoTombstoned(t *testing.T) {
filterOpts := testTagsFilterOptions()
input := &rulepb.MappingRuleSnapshot{
Name: "foo",
Tombstoned: true,
CutoverNanos: 12345000000,
Filter: "tag1:value1 tag2:value2",
LastUpdatedAtNanos: 12345000000,
LastUpdatedBy: "someone",
Tags: []*metricpb.Tag{},
}
res, err := newMappingRuleSnapshotFromProto(input, filterOpts)
require.NoError(t, err)
expected := &mappingRuleSnapshot{
name: "foo",
tombstoned: true,
cutoverNanos: 12345000000,
rawFilter: "tag1:value1 tag2:value2",
aggregationID: aggregation.DefaultID,
lastUpdatedAtNanos: 12345000000,
lastUpdatedBy: "someone",
tags: []models.Tag{},
}
require.True(t, cmp.Equal(expected, res, testMappingRuleSnapshotCmpOpts...))
require.NotNil(t, res.filter)
} | explode_data.jsonl/64565 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 442
} | [
2830,
3393,
3564,
6807,
11337,
15009,
3830,
31549,
51,
2855,
7720,
291,
1155,
353,
8840,
836,
8,
341,
50108,
43451,
1669,
1273,
15930,
5632,
3798,
741,
22427,
1669,
609,
12937,
16650,
76455,
11337,
15009,
515,
197,
21297,
25,
2290,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResumeChangefeed(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
mo := mock_owner.NewMockOwner(ctrl)
cp := capture.NewCapture4Test(mo)
router := newRouter(cp, newStatusProvider())
// test resume changefeed succeeded
mo.EXPECT().
EnqueueJob(gomock.Any(), gomock.Any()).
Do(func(adminJob model.AdminJob, done chan<- error) {
require.EqualValues(t, changeFeedID, adminJob.CfID)
require.EqualValues(t, model.AdminResume, adminJob.Type)
close(done)
})
api := testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/resume", changeFeedID), method: "POST"}
w := httptest.NewRecorder()
req, _ := http.NewRequestWithContext(context.Background(), api.method, api.url, nil)
router.ServeHTTP(w, req)
require.Equal(t, 202, w.Code)
// test resume changefeed failed from owner side.
mo.EXPECT().
EnqueueJob(gomock.Any(), gomock.Any()).
Do(func(adminJob model.AdminJob, done chan<- error) {
done <- cerror.ErrChangeFeedNotExists.FastGenByArgs(adminJob.CfID)
close(done)
})
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/resume", changeFeedID), method: "POST"}
w = httptest.NewRecorder()
req, _ = http.NewRequestWithContext(context.Background(), api.method, api.url, nil)
router.ServeHTTP(w, req)
require.Equal(t, 400, w.Code)
respErr := model.HTTPError{}
err := json.NewDecoder(w.Body).Decode(&respErr)
require.Nil(t, err)
require.Contains(t, respErr.Error, "changefeed not exists")
// test resume changefeed failed
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/resume", nonExistChangefeedID),
method: "POST",
}
w = httptest.NewRecorder()
req, _ = http.NewRequestWithContext(context.Background(), api.method, api.url, nil)
router.ServeHTTP(w, req)
require.Equal(t, 400, w.Code)
respErr = model.HTTPError{}
err = json.NewDecoder(w.Body).Decode(&respErr)
require.Nil(t, err)
require.Contains(t, respErr.Error, "changefeed not exists")
} | explode_data.jsonl/75114 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 765
} | [
2830,
3393,
28563,
1143,
524,
823,
12051,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
2109,
78,
1669,
7860,
29027,
7121,
11571,
13801,
62100,
340,
52018,
1669,
12322,
7121,
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 TestTokenOutput(t *testing.T) {
testCases := []struct {
name string
id string
secret string
description string
usages []string
extraGroups []string
outputFormat string
expectedBytes []byte
}{
{
name: "JSON output",
id: "abcdef",
secret: "1234567890123456",
description: "valid bootstrap tooken",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:kubeadm:default-node-token"},
outputFormat: "json",
expectedBytes: []byte(`{
"kind": "BootstrapToken",
"apiVersion": "output.kubeadm.k8s.io/v1alpha1",
"creationTimestamp": null,
"token": "abcdef.1234567890123456",
"description": "valid bootstrap tooken",
"usages": [
"signing",
"authentication"
],
"groups": [
"system:bootstrappers:kubeadm:default-node-token"
]
}
`),
},
{
name: "YAML output",
id: "abcdef",
secret: "1234567890123456",
description: "valid bootstrap tooken",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:kubeadm:default-node-token"},
outputFormat: "yaml",
expectedBytes: []byte(`apiVersion: output.kubeadm.k8s.io/v1alpha1
creationTimestamp: null
description: valid bootstrap tooken
groups:
- system:bootstrappers:kubeadm:default-node-token
kind: BootstrapToken
token: abcdef.1234567890123456
usages:
- signing
- authentication
`),
},
{
name: "Go template output",
id: "abcdef",
secret: "1234567890123456",
description: "valid bootstrap tooken",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:kubeadm:default-node-token"},
outputFormat: "go-template={{println .token .description .usages .groups}}",
expectedBytes: []byte(`abcdef.1234567890123456 valid bootstrap tooken [signing authentication] [system:bootstrappers:kubeadm:default-node-token]
`),
},
{
name: "text output",
id: "abcdef",
secret: "1234567890123456",
description: "valid bootstrap tooken",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:kubeadm:default-node-token"},
outputFormat: "text",
expectedBytes: []byte(`TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS
abcdef.1234567890123456 <forever> <never> signing,authentication valid bootstrap tooken system:bootstrappers:kubeadm:default-node-token
`),
},
{
name: "jsonpath output",
id: "abcdef",
secret: "1234567890123456",
description: "valid bootstrap tooken",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:kubeadm:default-node-token"},
outputFormat: "jsonpath={.token} {.groups}",
expectedBytes: []byte(`abcdef.1234567890123456 [system:bootstrappers:kubeadm:default-node-token]`),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
token := outputapiv1alpha1.BootstrapToken{
BootstrapToken: kubeadmapiv1beta2.BootstrapToken{
Token: &kubeadmapiv1beta2.BootstrapTokenString{ID: tc.id, Secret: tc.secret},
Description: tc.description,
Usages: tc.usages,
Groups: tc.extraGroups,
},
}
buf := bytes.NewBufferString("")
outputFlags := output.NewOutputFlags(&tokenTextPrintFlags{}).WithTypeSetter(outputapischeme.Scheme).WithDefaultOutput(tc.outputFormat)
printer, err := outputFlags.ToPrinter()
if err != nil {
t.Errorf("can't create printer for output format %s: %+v", tc.outputFormat, err)
}
if err := printer.PrintObj(&token, buf); err != nil {
t.Errorf("unable to print token %s: %+v", token.Token, err)
}
actualBytes := buf.Bytes()
if !bytes.Equal(actualBytes, tc.expectedBytes) {
t.Errorf(
"failed TestTokenOutput:\n\nexpected:\n%s\n\nactual:\n%s",
string(tc.expectedBytes),
string(actualBytes),
)
}
})
}
} | explode_data.jsonl/41074 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1902
} | [
2830,
3393,
3323,
5097,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
15710,
310,
914,
198,
197,
197,
20474,
286,
914,
198,
197,
42407,
256,
914,
198,
197,
70175,
1134,
286,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestClient_context(t *testing.T) {
ctx := context.Background()
tracer := mocktracer.New()
span1, ctx := opentracing.StartSpanFromContextWithTracer(ctx, tracer, "span1")
span1.SetBaggageItem("foo", "bar")
span1.Finish()
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "https://example.com/", nil)
client := NewClient(tracer)
resp, _ := client.Do(req)
defer resp.Body.Close()
assert.Len(t, tracer.FinishedSpans(), 2)
assert.Equal(t, "bar", tracer.FinishedSpans()[1].BaggageItem("foo"))
} | explode_data.jsonl/29966 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
2959,
8467,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
25583,
9584,
1669,
7860,
94941,
7121,
741,
197,
1480,
16,
11,
5635,
1669,
1179,
23745,
4527,
12101,
12485,
3830,
1972,
2354,
1282,
9584,
7502,
11,
6430... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGet(t *testing.T) {
app := New()
app.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello"))
})
s := httptest.NewServer(app)
NewRequest(s.URL).
Get("/").
Expect(200, "hello")
} | explode_data.jsonl/48212 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
1949,
1155,
353,
8840,
836,
8,
341,
28236,
1669,
1532,
2822,
28236,
2234,
35460,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
4073,
10556,
3782,
445,
14990,
5455,
197,
8824,
1903,
1669,
54320,
70334,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStart_ContextIsCancelled_ReturnsAndMeetingPointIsCleared(t *testing.T) {
unittest.SmallTest(t)
switchboardMock := &mocks.Switchboard{}
switchboardMock.On("ReserveMeetingPoint", testutils.AnyContext, hostname, username).Return(meetingPoint, nil)
var clearMeetingPointCalledWG sync.WaitGroup
clearMeetingPointCalledWG.Add(1)
switchboardMock.On("ClearMeetingPoint", testutils.AnyContext, meetingPoint).Run(func(mock.Arguments) {
clearMeetingPointCalledWG.Done()
}).Return(nil)
c := New(switchboardMock, mockRevPortForwardCancellable{}, hostname, username)
ctx, cancel := context.WithCancel(context.Background())
cancel()
err := c.Start(ctx)
require.Error(t, err)
clearMeetingPointCalledWG.Wait()
require.Equal(t, int64(1), c.stepsCounter.Get())
c.stepsCounter.Reset()
switchboardMock.AssertExpectations(t)
} | explode_data.jsonl/82348 | {
"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,
3479,
71994,
3872,
39473,
53316,
82,
3036,
64576,
2609,
3872,
34,
92333,
1155,
353,
8840,
836,
8,
341,
20479,
14267,
90183,
2271,
1155,
340,
8961,
2482,
11571,
1669,
609,
16712,
82,
808,
5539,
2482,
16094,
8961,
2482,
11571,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeamsService_RemoveTeamRepoByID(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/organizations/1/team/1/repos/owner/repo", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
w.WriteHeader(http.StatusNoContent)
})
ctx := context.Background()
_, err := client.Teams.RemoveTeamRepoByID(ctx, 1, 1, "owner", "repo")
if err != nil {
t.Errorf("Teams.RemoveTeamRepoByID returned error: %v", err)
}
const methodName = "RemoveTeamRepoByID"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Teams.RemoveTeamRepoByID(ctx, -1, -1, "\n", "\n")
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Teams.RemoveTeamRepoByID(ctx, 1, 1, "owner", "repo")
})
} | explode_data.jsonl/4540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 322
} | [
2830,
3393,
60669,
1860,
66843,
14597,
25243,
60572,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
69253,
14,
16,
78015,
14,
16,
49505,
14,
8118,
10758,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_bot_removeBotMention(t *testing.T) {
cfg := fakeCfg{}
prc := &fakeProcessor{}
discord := &FakeDiscordClientSpy{}
discord.failOnClose = true
b := &bot{
cfg: cfg,
discord: discord,
prc: prc,
}
botUser := &discordgo.User{ID: "123"}
t.Run("we should remove the mention", func(t *testing.T) {
m := &discordgo.MessageCreate{
Message: &discordgo.Message{
Author: &discordgo.User{ID: "456"},
Content: "<@123> this is a message",
},
}
got := b.removeBotMention(m, botUser)
want := "this is a message"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("we should not remove the mention", func(t *testing.T) {
m := &discordgo.MessageCreate{
Message: &discordgo.Message{
Author: &discordgo.User{ID: "456"},
Content: "<@456> this is a another",
},
}
got := b.removeBotMention(m, botUser)
want := "<@456> this is a another"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
t.Run("there is not mention", func(t *testing.T) {
m := &discordgo.MessageCreate{
Message: &discordgo.Message{
Author: &discordgo.User{ID: "456"},
Content: "there is no mention",
},
}
got := b.removeBotMention(m, botUser)
want := "there is no mention"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
} | explode_data.jsonl/2141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 592
} | [
2830,
3393,
38883,
18193,
23502,
44,
2939,
1155,
353,
8840,
836,
8,
1476,
50286,
1669,
12418,
42467,
16094,
25653,
66,
1669,
609,
30570,
22946,
31483,
2698,
3427,
539,
1669,
609,
52317,
23477,
539,
2959,
44027,
16094,
2698,
3427,
539,
267... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestActiveEndpoint_Reserve_ReadyTimeoutWithError(t *testing.T) {
k8s, kna := fakeClients()
kna.ServingV1alpha1().Revisions(testNamespace).Create(
newRevisionBuilder(defaultRevisionLabels).
withReady(false).
build())
k8s.CoreV1().Services(testNamespace).Create(newServiceBuilder().build())
a := NewRevisionActivator(k8s, kna, TestLogger(t))
a.(*revisionActivator).readyTimout = 200 * time.Millisecond
ch := make(chan ActivationResult)
go func() {
ch <- a.ActiveEndpoint(testNamespace, testRevision)
}()
select {
case <-ch:
t.Error("Unexpected result before revision is ready.")
case <-time.After(100 * time.Millisecond):
break
}
select {
case ar := <-ch:
if got, want := ar.Endpoint, (Endpoint{}); got != want {
t.Errorf("Unexpected endpoint = %+v, want: %+v.", got, want)
}
if got, want := ar.Status, http.StatusInternalServerError; got != want {
t.Errorf("Unexpected error state = %v, want: %v.", got, want)
}
if ar.ServiceName != "" {
t.Errorf("ServiceName = %s, expected empty.", ar.ServiceName)
}
if ar.ConfigurationName != "" {
t.Errorf("ConfigurationName = %s, expected empty.", ar.ConfigurationName)
}
if ar.Error == nil {
t.Error("Expected error.")
}
case <-time.After(3 * time.Second):
t.Error("Expected result after timeout.")
}
} | explode_data.jsonl/27259 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
5728,
27380,
92815,
5852,
62,
19202,
7636,
66102,
1155,
353,
8840,
836,
8,
341,
16463,
23,
82,
11,
1148,
64,
1669,
12418,
47174,
741,
16463,
3376,
808,
19505,
53,
16,
7141,
16,
1005,
693,
40015,
8623,
22699,
568,
4021,
100... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetAccessModes(t *testing.T) {
tmpDir, plug := getPersistentPlugin(t)
defer os.RemoveAll(tmpDir)
modes := plug.GetAccessModes()
if !volumetest.ContainsAccessMode(modes, v1.ReadWriteOnce) {
t.Errorf("Expected AccessModeType %q", v1.ReadWriteOnce)
}
if volumetest.ContainsAccessMode(modes, v1.ReadWriteMany) {
t.Errorf("Found AccessModeType %q, expected not", v1.ReadWriteMany)
}
if volumetest.ContainsAccessMode(modes, v1.ReadOnlyMany) {
t.Errorf("Found AccessModeType %q, expected not", v1.ReadOnlyMany)
}
} | explode_data.jsonl/14252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
1949,
6054,
70035,
1155,
353,
8840,
836,
8,
341,
20082,
6184,
11,
19633,
1669,
633,
53194,
11546,
1155,
340,
16867,
2643,
84427,
10368,
6184,
692,
2109,
2539,
1669,
19633,
2234,
6054,
70035,
741,
743,
753,
85,
1132,
57824,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSortedArray_PopLefts(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []interface{}{"a", "d", "c", "b", "e", "f"}
func1 := func(v1, v2 interface{}) int {
return strings.Compare(gconv.String(v1), gconv.String(v2))
}
array1 := garray.NewSortedArrayFrom(a1, func1)
i1 := array1.PopLefts(2)
t.Assert(len(i1), 2)
t.AssertIN(i1, []interface{}{"a", "d", "c", "b", "e", "f"})
t.Assert(array1.Len(), 4)
i2 := array1.PopLefts(5)
t.Assert(len(i2), 4)
t.AssertIN(i1, []interface{}{"a", "d", "c", "b", "e", "f"})
t.Assert(array1.Len(), 0)
})
} | explode_data.jsonl/67015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
51051,
1857,
1088,
453,
5415,
82,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
4970,
6257,
4913,
64,
497,
330,
67,
497,
330,
66,
497,
330,
65... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetImageUser(t *testing.T) {
_, i, m, err := createTestRuntimeManager()
assert.NoError(t, err)
type image struct {
name string
uid *runtimeapi.Int64Value
username string
}
type imageUserValues struct {
// getImageUser can return (*int64)(nil) so comparing with *uid will break
// type cannot be *int64 as Golang does not allow to take the address of a numeric constant"
uid interface{}
username string
err error
}
tests := []struct {
description string
originalImage image
expectedImageUserValues imageUserValues
}{
{
"image without username and uid should return (new(int64), \"\", nil)",
image{
name: "test-image-ref1",
uid: (*runtimeapi.Int64Value)(nil),
username: "",
},
imageUserValues{
uid: int64(0),
username: "",
err: nil,
},
},
{
"image with username and no uid should return ((*int64)nil, imageStatus.Username, nil)",
image{
name: "test-image-ref2",
uid: (*runtimeapi.Int64Value)(nil),
username: "testUser",
},
imageUserValues{
uid: (*int64)(nil),
username: "testUser",
err: nil,
},
},
{
"image with uid should return (*int64, \"\", nil)",
image{
name: "test-image-ref3",
uid: &runtimeapi.Int64Value{
Value: 2,
},
username: "whatever",
},
imageUserValues{
uid: int64(2),
username: "",
err: nil,
},
},
}
i.SetFakeImages([]string{"test-image-ref1", "test-image-ref2", "test-image-ref3"})
for j, test := range tests {
i.Images[test.originalImage.name].Username = test.originalImage.username
i.Images[test.originalImage.name].Uid = test.originalImage.uid
uid, username, err := m.getImageUser(test.originalImage.name)
assert.NoError(t, err, "TestCase[%d]", j)
if test.expectedImageUserValues.uid == (*int64)(nil) {
assert.Equal(t, test.expectedImageUserValues.uid, uid, "TestCase[%d]", j)
} else {
assert.Equal(t, test.expectedImageUserValues.uid, *uid, "TestCase[%d]", j)
}
assert.Equal(t, test.expectedImageUserValues.username, username, "TestCase[%d]", j)
}
} | explode_data.jsonl/22802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 934
} | [
2830,
3393,
1949,
1906,
1474,
1155,
353,
8840,
836,
8,
341,
197,
6878,
600,
11,
296,
11,
1848,
1669,
1855,
2271,
15123,
2043,
741,
6948,
35699,
1155,
11,
1848,
692,
13158,
2168,
2036,
341,
197,
11609,
257,
914,
198,
197,
197,
2423,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEcdsaPrivateKey(t *testing.T) {
t.Parallel()
lowLevelKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
assert.NoError(t, err)
k := &ecdsaPrivateKey{lowLevelKey}
assert.False(t, k.Symmetric())
assert.True(t, k.Private())
_, err = k.Bytes()
assert.Error(t, err)
assert.Contains(t, err.Error(), "Not supported.")
k.privKey = nil
ski := k.SKI()
assert.Nil(t, ski)
k.privKey = lowLevelKey
ski = k.SKI()
raw := elliptic.Marshal(k.privKey.Curve, k.privKey.PublicKey.X, k.privKey.PublicKey.Y)
hash := sha256.New()
hash.Write(raw)
ski2 := hash.Sum(nil)
assert.Equal(t, ski2, ski, "SKI is not computed in the right way.")
pk, err := k.PublicKey()
assert.NoError(t, err)
assert.NotNil(t, pk)
ecdsaPK, ok := pk.(*ecdsaPublicKey)
assert.True(t, ok)
assert.Equal(t, &lowLevelKey.PublicKey, ecdsaPK.pubKey)
} | explode_data.jsonl/29814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 369
} | [
2830,
3393,
36,
4385,
9081,
75981,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
8810,
363,
4449,
1592,
11,
1848,
1669,
384,
4385,
9081,
57582,
1592,
7,
613,
11442,
292,
1069,
17,
20,
21,
1507,
10382,
47431,
340,
6948,
35699,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCatalog_Register_ConnectProxy_ACLProxyDestination(t *testing.T) {
t.Parallel()
assert := assert.New(t)
dir1, s1 := testServerWithConfig(t, func(c *Config) {
c.ACLDatacenter = "dc1"
c.ACLMasterToken = "root"
c.ACLDefaultPolicy = "deny"
})
defer os.RemoveAll(dir1)
defer s1.Shutdown()
codec := rpcClient(t, s1)
defer codec.Close()
testrpc.WaitForLeader(t, s1.RPC, "dc1")
// Create the ACL.
arg := structs.ACLRequest{
Datacenter: "dc1",
Op: structs.ACLSet,
ACL: structs.ACL{
Name: "User token",
Type: structs.ACLTypeClient,
Rules: `
service "foo" {
policy = "write"
}
`,
},
WriteRequest: structs.WriteRequest{Token: "root"},
}
var token string
assert.Nil(msgpackrpc.CallWithCodec(codec, "ACL.Apply", &arg, &token))
// Register should fail because we don't have permission on the destination
args := structs.TestRegisterRequestProxy(t)
args.Service.Service = "foo"
args.Service.Proxy.DestinationServiceName = "bar"
args.WriteRequest.Token = token
var out struct{}
err := msgpackrpc.CallWithCodec(codec, "Catalog.Register", &args, &out)
assert.True(acl.IsErrPermissionDenied(err))
// Register should fail with the right destination but wrong name
args = structs.TestRegisterRequestProxy(t)
args.Service.Service = "bar"
args.Service.Proxy.DestinationServiceName = "foo"
args.WriteRequest.Token = token
err = msgpackrpc.CallWithCodec(codec, "Catalog.Register", &args, &out)
assert.True(acl.IsErrPermissionDenied(err))
// Register should work with the right destination
args = structs.TestRegisterRequestProxy(t)
args.Service.Service = "foo"
args.Service.Proxy.DestinationServiceName = "foo"
args.WriteRequest.Token = token
assert.Nil(msgpackrpc.CallWithCodec(codec, "Catalog.Register", &args, &out))
} | explode_data.jsonl/49215 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 665
} | [
2830,
3393,
41606,
73124,
15100,
2321,
16219,
97627,
16219,
33605,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
6948,
1669,
2060,
7121,
1155,
340,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
2354,
2648,
1155,
11,
2915,
1337,
353... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBodyLimit(t *testing.T) {
e := echo.New()
hw := []byte("Hello, World!")
req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)
h := func(c echo.Context) error {
body, err := ioutil.ReadAll(c.Request().Body)
if err != nil {
return err
}
return c.String(http.StatusOK, string(body))
}
assert := assert.New(t)
// Based on content length (within limit)
if assert.NoError(BodyLimit("2M")(h)(c)) {
assert.Equal(http.StatusOK, rec.Code)
assert.Equal(hw, rec.Body.Bytes())
}
// Based on content read (overlimit)
he := BodyLimit("2B")(h)(c).(*echo.HTTPError)
assert.Equal(http.StatusRequestEntityTooLarge, he.Code)
// Based on content read (within limit)
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
rec = httptest.NewRecorder()
c = e.NewContext(req, rec)
if assert.NoError(BodyLimit("2M")(h)(c)) {
assert.Equal(http.StatusOK, rec.Code)
assert.Equal("Hello, World!", rec.Body.String())
}
// Based on content read (overlimit)
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
rec = httptest.NewRecorder()
c = e.NewContext(req, rec)
he = BodyLimit("2B")(h)(c).(*echo.HTTPError)
assert.Equal(http.StatusRequestEntityTooLarge, he.Code)
} | explode_data.jsonl/37301 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 503
} | [
2830,
3393,
5444,
16527,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
1687,
7121,
741,
9598,
86,
1669,
3056,
3782,
445,
9707,
11,
4337,
22988,
24395,
1669,
54320,
70334,
75274,
19886,
20798,
4133,
11,
64657,
5820,
68587,
73751,
1171,
67904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransportAltProto(t *testing.T) {
defer afterTest(t)
tr := &Transport{}
c := &Client{Transport: tr}
tr.RegisterProtocol("foo", fooProto{})
res, err := c.Get("foo://bar.com/path")
if err != nil {
t.Fatal(err)
}
bodyb, err := ioutil.ReadAll(res.Body)
if err != nil {
t.Fatal(err)
}
body := string(bodyb)
if e := "You wanted foo://bar.com/path"; body != e {
t.Errorf("got response %q, want %q", body, e)
}
} | explode_data.jsonl/4906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
27560,
26017,
31549,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
25583,
1669,
609,
27560,
16094,
1444,
1669,
609,
2959,
90,
27560,
25,
489,
532,
25583,
19983,
20689,
445,
7975,
497,
15229,
31549,
37790,
10202,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddressList(t *testing.T) {
fields := make([]interface{}, len(addrTests))
addrs := make([]*Address, len(addrTests))
for i, test := range addrTests {
fields[i] = test.fields
addrs[i] = test.addr
}
gotAddrs := ParseAddressList(fields)
if !reflect.DeepEqual(gotAddrs, addrs) {
t.Error("Invalid address list: got", gotAddrs, "but expected", addrs)
}
gotFields := FormatAddressList(addrs)
if !reflect.DeepEqual(gotFields, fields) {
t.Error("Invalid address list fields: got", gotFields, "but expected", fields)
}
} | explode_data.jsonl/43051 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
4286,
852,
1155,
353,
8840,
836,
8,
341,
55276,
1669,
1281,
10556,
4970,
22655,
2422,
24497,
18200,
1171,
12718,
5428,
1669,
1281,
85288,
4286,
11,
2422,
24497,
18200,
1171,
2023,
600,
11,
1273,
1669,
2088,
10789,
18200,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDeepEqualComplexStruct(t *testing.T) {
m := make(map[float64]float64)
stra, strb := "hello", "hello"
a, b := new(_Complex), new(_Complex)
*a = _Complex{5, [3]*_Complex{a, b, a}, &stra, m}
*b = _Complex{5, [3]*_Complex{b, a, a}, &strb, m}
if !DeepEqual(a, b) {
t.Error("DeepEqual(complex same) = false, want true")
}
} | explode_data.jsonl/29540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
33464,
2993,
31137,
9422,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1281,
9147,
95381,
21,
19,
60,
3649,
21,
19,
340,
11355,
64,
11,
607,
65,
1669,
330,
14990,
497,
330,
14990,
698,
11323,
11,
293,
1669,
501,
2490,
31137... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNetworkString(t *testing.T) {
for _, tt := range []struct {
name string
input Network
want string
}{
{
name: "simple net",
input: Network{
Nets: []string{"$HOME_NET"},
Ports: []string{"$HTTP_PORTS"},
},
want: "$HOME_NET $HTTP_PORTS",
},
{
name: "complex net",
input: Network{
Nets: []string{"$HOME_NET", "!$FOO_NET", "192.168.0.0/16"},
Ports: []string{"$HTTP_PORTS", "!53", "$BAR_NET"},
},
want: "[$HOME_NET,!$FOO_NET,192.168.0.0/16] [$HTTP_PORTS,!53,$BAR_NET]",
},
{
name: "grouped ports",
input: Network{
Nets: []string{"$HOME_NET", "!$FOO_NET", "192.168.0.0/16"},
Ports: []string{"1:80", "![2,4]", "[6,7,8]"},
},
want: "[$HOME_NET,!$FOO_NET,192.168.0.0/16] [1:80,![2,4],[6,7,8]]",
},
{
name: "grouped networks",
input: Network{
Nets: []string{"192.168.0.0/16", "![192.168.86.0/24,192.168.87.0/24]"},
Ports: []string{"$HTTP_PORTS", "!53", "$BAR_NET"},
},
want: "[192.168.0.0/16,![192.168.86.0/24,192.168.87.0/24]] [$HTTP_PORTS,!53,$BAR_NET]",
},
} {
got := tt.input.String()
if got != tt.want {
t.Fatalf("%s: got %v -- expected %v", tt.name, got, tt.want)
}
}
} | explode_data.jsonl/59682 | {
"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,
12320,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
8141,
198,
197,
50780,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
22944,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNasTypeLocalTimeZoneGetSetIei(t *testing.T) {
a := nasType.NewLocalTimeZone(nasMessage.ConfigurationUpdateCommandLocalTimeZoneType)
for _, table := range nasTypeConfigurationUpdateCommandLocalTimeZoneTable {
a.SetIei(table.in)
assert.Equal(t, table.out, a.GetIei())
}
} | explode_data.jsonl/63594 | {
"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,
45,
300,
929,
7319,
77786,
1949,
1649,
40,
19972,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
17141,
929,
7121,
7319,
77786,
1445,
300,
2052,
17334,
4289,
4062,
7319,
77786,
929,
340,
2023,
8358,
1965,
1669,
2088,
17141,
929,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSHA3FromString(t *testing.T) {
tests := []struct {
name string
arg string
want []byte
}{
{"SHA3-256 From String", "foo", []byte{118, 211, 188, 65, 201, 245, 136, 247, 252, 208, 213, 191, 71, 24, 248, 248, 75, 28, 65, 178, 8, 130, 112, 49, 0, 185, 235, 148, 19, 128, 124, 1}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := crypto.SHA3FromString(tt.arg); !reflect.DeepEqual(got, tt.want) {
t.Errorf("SHA3FromString() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/6957 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
33145,
18,
44491,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
47903,
220,
914,
198,
197,
50780,
3056,
3782,
198,
197,
59403,
197,
197,
4913,
33145,
18,
12,
17,
20,
21,
5542,
923... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_DatabaseAccountsSqlDatabasesThroughputSettings_Spec_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip from DatabaseAccountsSqlDatabasesThroughputSettings_Spec to DatabaseAccountsSqlDatabasesThroughputSettings_Spec via AssignPropertiesToDatabaseAccountsSqlDatabasesThroughputSettingsSpec & AssignPropertiesFromDatabaseAccountsSqlDatabasesThroughputSettingsSpec returns original",
prop.ForAll(RunPropertyAssignmentTestForDatabaseAccountsSqlDatabasesThroughputSettingsSpec, DatabaseAccountsSqlDatabasesThroughputSettingsSpecGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
} | explode_data.jsonl/21816 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
1557,
2211,
41369,
8269,
35,
23822,
23857,
628,
6086,
1098,
992,
62,
4498,
7903,
61941,
2568,
795,
21884,
1690,
26040,
39838,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateProject(t *testing.T) {
project := &models.Project{
Name: "example-project",
OwnerID: 1,
}
_, err := CreateProject(project)
require.Nil(t, err)
} | explode_data.jsonl/36144 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
4021,
7849,
1155,
353,
8840,
836,
8,
341,
72470,
1669,
609,
6507,
30944,
515,
197,
21297,
25,
262,
330,
8687,
33696,
756,
197,
197,
13801,
915,
25,
220,
16,
345,
197,
532,
197,
6878,
1848,
1669,
4230,
7849,
21168,
340,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestState_UpdateRplMode(t *testing.T) {
t.Parallel()
st := setupNewState()
ev := &irc.Event{
Name: irc.RPL_CHANNELMODEIS,
Sender: network,
Args: []string{st.selfUser.Nick(), channels[0], "+ntzl", "10"},
}
st.addChannel(channels[0])
ch, _ := st.Channel(channels[0])
if got, exp := ch.Modes.IsSet("ntzl 10"), false; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
st.Update(ev)
ch, _ = st.Channel(channels[0])
if got, exp := ch.Modes.IsSet("ntzl 10"), true; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
} | explode_data.jsonl/32112 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
1397,
47393,
49,
500,
3636,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18388,
1669,
6505,
3564,
1397,
2822,
74837,
1669,
609,
2437,
6904,
515,
197,
21297,
25,
256,
79923,
2013,
2916,
23688,
22808,
1637,
345,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestValueAtQuantile_CopyTo(t *testing.T) {
ms := NewValueAtQuantile()
generateTestValueAtQuantile().CopyTo(ms)
assert.EqualValues(t, generateTestValueAtQuantile(), ms)
} | explode_data.jsonl/32759 | {
"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,
1130,
1655,
44220,
457,
77637,
1249,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
1130,
1655,
44220,
457,
741,
3174,
13220,
2271,
1130,
1655,
44220,
457,
1005,
12106,
1249,
35680,
340,
6948,
12808,
6227,
1155,
11,
6923,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVaultChangePassword(t *testing.T) {
v := New()
assert.NotNil(t, v)
v.SetPassword("foobar")
assert.Equal(t, "foobar", v.password)
v.SetPassword("secret")
assert.Equal(t, "secret", v.password)
} | explode_data.jsonl/50664 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
79177,
4072,
4876,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
1532,
741,
6948,
93882,
1155,
11,
348,
692,
5195,
4202,
4876,
445,
50267,
1138,
6948,
12808,
1155,
11,
330,
50267,
497,
348,
11630,
692,
5195,
4202,
4876,
445,
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 |
func TestContextReset(t *testing.T) {
router := New()
c := router.allocateContext()
assert.Equal(t, c.engine, router)
c.index = 2
c.Writer = &responseWriter{ResponseWriter: httptest.NewRecorder()}
c.Params = Params{Param{}}
c.Error(errors.New("test")) // nolint: errcheck
c.Set("foo", "bar")
c.reset()
assert.False(t, c.IsAborted())
assert.Nil(t, c.Keys)
assert.Nil(t, c.Accepted)
assert.Len(t, c.Errors, 0)
assert.Empty(t, c.Errors.Errors())
assert.Empty(t, c.Errors.ByType(ErrorTypeAny))
assert.Len(t, c.Params, 0)
assert.EqualValues(t, c.index, -1)
assert.Equal(t, c.Writer.(*responseWriter), &c.writermem)
} | explode_data.jsonl/26742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
1972,
14828,
1155,
353,
8840,
836,
8,
341,
67009,
1669,
1532,
741,
1444,
1669,
9273,
68726,
1972,
741,
6948,
12808,
1155,
11,
272,
24417,
11,
9273,
692,
1444,
5154,
284,
220,
17,
198,
1444,
47838,
284,
609,
2322,
6492,
90,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseSecret(t *testing.T) {
in := &MountParams{
Attributes: `
{
"secrets": "- resourceName: \"projects/project/secrets/test/versions/latest\"\n fileName: \"good1.txt\"\n",
"csi.storage.k8s.io/pod.namespace": "default",
"csi.storage.k8s.io/pod.name": "mypod",
"csi.storage.k8s.io/pod.uid": "123",
"csi.storage.k8s.io/serviceAccount.name": "mysa"
}
`,
KubeSecrets: `{"key.json":"{\"private_key_id\": \"123\",\"private_key\": \"a-secret\",\"token_uri\": \"https://example.com/token\",\"type\": \"service_account\"}"}`,
TargetPath: "/tmp/foo",
Permissions: 777,
}
got, err := Parse(in)
if err != nil {
t.Errorf("Parse() failed: %v", err)
}
if got == nil || got.TokenSource == nil {
t.Errorf("TokenSource missing.")
}
} | explode_data.jsonl/30921 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
14463,
19773,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
609,
16284,
4870,
515,
197,
197,
10516,
25,
22074,
197,
197,
515,
298,
197,
1,
325,
52710,
788,
6523,
98485,
25,
7245,
17161,
40118,
59587,
52710,
12697,
14,
28290,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRegistrar(t *testing.T) {
connection := &testConnection{
errHeartbeat: errTest,
}
registrar1 := NewRegistrar(connection, instanceTest1, loggerTest)
registrar2 := NewRegistrar(connection, instanceTest2, loggerTest)
// Not registered.
registrar1.Deregister()
if want, have := 0, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
// Register.
registrar1.Register()
if want, have := 1, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
registrar2.Register()
if want, have := 2, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
// Deregister.
registrar1.Deregister()
if want, have := 1, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
// Already registered.
registrar1.Register()
if want, have := 2, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
registrar1.Register()
if want, have := 2, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
// Wait for a heartbeat failure.
time.Sleep(1010 * time.Millisecond)
if want, have := 2, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
registrar1.Deregister()
if want, have := 1, len(connection.instances); want != have {
t.Errorf("want %d, have %d", want, have)
}
} | explode_data.jsonl/53331 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 543
} | [
2830,
3393,
70252,
1155,
353,
8840,
836,
8,
341,
54590,
1669,
609,
1944,
4526,
515,
197,
9859,
45384,
22227,
25,
1848,
2271,
345,
197,
630,
37013,
34765,
16,
1669,
1532,
70252,
24147,
11,
2867,
2271,
16,
11,
5925,
2271,
340,
37013,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestNewRawExporter(t *testing.T) {
exporter, err := NewRawExporter(validConfig)
if err != nil {
t.Fatalf("Failed to create exporter with error %v", err)
}
if !cmp.Equal(validConfig, exporter.config) {
t.Fatalf("Got configuration %v, wanted %v", exporter.config, validConfig)
}
} | explode_data.jsonl/8037 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
3564,
20015,
88025,
1155,
353,
8840,
836,
8,
341,
59440,
261,
11,
1848,
1669,
1532,
20015,
88025,
41529,
2648,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
9408,
311,
1855,
57378,
448,
1465,
1018,
85,
497,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUnexportedUnmarshal(t *testing.T) {
result := unexportedMarshalTestStruct{}
err := Unmarshal(unexportedTestToml, &result)
expected := unexportedTestData
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(result, expected) {
t.Errorf("Bad unexported unmarshal: expected %v, got %v", expected, result)
}
} | explode_data.jsonl/46314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
1806,
1533,
291,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
650,
1533,
291,
55438,
2271,
9422,
16094,
9859,
1669,
1230,
27121,
18364,
1533,
291,
2271,
24732,
75,
11,
609,
1382,
340,
42400,
1669,
650,
1533,
291,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNewUserDicIndex01(t *testing.T) {
udic, e := NewUserDic(testFile)
if e != nil {
t.Fatalf("unexpected error: %v\n", e)
}
type tuple struct {
inp string
id int
ok bool
}
callAndRespose := []tuple{
{inp: "日本経済新聞", id: 0, ok: true},
{inp: "朝青龍", id: 1, ok: true},
{inp: "関西国際空港", id: 2, ok: true},
{inp: "成田国際空港", id: 9, ok: false},
}
for _, cr := range callAndRespose {
if ids := udic.dic.Index.Search(cr.inp); (len(ids) != 0) != cr.ok {
t.Errorf("got %v, expected %v", ids, cr.ok)
}
}
} | explode_data.jsonl/44232 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 299
} | [
2830,
3393,
3564,
1474,
44545,
1552,
15,
16,
1155,
353,
8840,
836,
8,
341,
197,
661,
292,
11,
384,
1669,
1532,
1474,
44545,
8623,
1703,
340,
743,
384,
961,
2092,
341,
197,
3244,
30762,
445,
53859,
1465,
25,
1018,
85,
1699,
497,
384,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateState(t *testing.T) {
thelmaBuilder := builder.NewBuilder().WithTestDefaults(t)
app, err := thelmaBuilder.Build()
require.NoError(t, err)
state, err := app.State()
require.NoError(t, err)
template, err := state.Environments().Get("sam-ci")
require.NoError(t, err)
missingEnv, err := state.Environments().Get("sam-ci-003")
require.NoError(t, err)
assert.Nil(t, missingEnv)
err = state.Environments().CreateFromTemplate("sam-ci-003", template)
require.NoError(t, err)
state, err = app.State() // reload state
require.NoError(t, err)
newEnv, err := state.Environments().Get("sam-ci-003")
require.NoError(t, err)
assert.Equal(t, "sam-ci-003", newEnv.Name())
assert.Equal(t, 2, len(newEnv.Releases())) // opendj & sam
} | explode_data.jsonl/79308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
4289,
1397,
1155,
353,
8840,
836,
8,
341,
70479,
301,
1728,
3297,
1669,
7363,
7121,
3297,
1005,
2354,
2271,
16273,
1155,
340,
28236,
11,
1848,
1669,
279,
75,
1728,
3297,
25212,
741,
17957,
35699,
1155,
11,
1848,
692,
24291,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeJsonWithInvalidNumberStringTime(t *testing.T) {
dec := json.NewDecoder(strings.NewReader("{\"time\":\"0xdeadbeef\",\"event\":\"hello\"}"))
dec.More()
var msg Event
err := dec.Decode(&msg)
assert.Error(t, err)
} | explode_data.jsonl/5177 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
32564,
5014,
2354,
7928,
2833,
703,
1462,
1155,
353,
8840,
836,
8,
341,
197,
8169,
1669,
2951,
7121,
20732,
51442,
68587,
99141,
1678,
23488,
15,
87,
33754,
1371,
823,
34333,
3087,
23488,
14990,
2105,
92,
28075,
197,
8169,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestLinesAfterRead(t *testing.T) {
l := NewReaderSize(bytes.NewReader([]byte("foo")), minReadBufferSize)
_, err := ioutil.ReadAll(l)
if err != nil {
t.Error(err)
return
}
line, isPrefix, err := l.ReadLine()
if err != io.EOF {
t.Errorf("expected EOF from ReadLine, got '%s' %t %s", line, isPrefix, err)
}
} | explode_data.jsonl/2888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
16794,
6025,
4418,
1155,
353,
8840,
836,
8,
341,
8810,
1669,
1532,
5062,
1695,
23158,
68587,
10556,
3782,
445,
7975,
35674,
1308,
4418,
52661,
340,
197,
6878,
1848,
1669,
43144,
41851,
2333,
340,
743,
1848,
961,
2092,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestChatSrvDeleteConversationUnconfirmed(t *testing.T) {
gc := libkb.NewGlobalContext()
gc.Init()
var is fakeInboxSource
cc := globals.ChatContext{
InboxSource: is,
}
g := globals.NewContext(gc, &cc)
chatUI := fakeChatUI{confirmChannelDelete: false}
ui := fakeUISource{
chatUI: chatUI,
}
h := NewServer(g, nil, &ui)
var ri fakeRemoteInterface
h.setTestRemoteClient(&ri)
ctx := context.Background()
var arg chat1.DeleteConversationLocalArg
_, err := h.deleteConversationLocal(ctx, arg)
require.Equal(t, errors.New("channel delete unconfirmed"), err)
require.False(t, ri.deleteConversationCalled)
ui.chatUI = fakeChatUI{confirmChannelDelete: true}
_, err = h.deleteConversationLocal(ctx, arg)
require.NoError(t, err)
require.True(t, ri.deleteConversationCalled)
} | explode_data.jsonl/63718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
15672,
50,
10553,
6435,
60313,
1806,
41028,
1155,
353,
8840,
836,
8,
341,
3174,
66,
1669,
3051,
21310,
7121,
11646,
1972,
741,
3174,
66,
26849,
741,
2405,
374,
12418,
641,
2011,
3608,
198,
63517,
1669,
37785,
58844,
1972,
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... | 1 |
func TestMenuParamsEmptyYaml(t *testing.T) {
b := newTestSitesBuilder(t).WithConfigFile("yaml", `
`)
b.WithTemplates("index.html", `{{ site.Menus }}`)
b.WithContent("p1.md", `---
menus:
main:
identity: journal
weight: 2
params:
---
`)
b.Build(BuildCfg{})
} | explode_data.jsonl/51845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
3514,
4870,
3522,
56,
9467,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
501,
2271,
93690,
3297,
1155,
568,
2354,
2648,
1703,
445,
41466,
497,
1565,
271,
63,
692,
2233,
26124,
51195,
445,
1252,
2564,
497,
1565,
2979,
2747,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAsOptions(t *testing.T) {
r, _ := Prepare(mocks.NewRequest(), AsOptions())
if r.Method != "OPTIONS" {
t.Fatal("autorest: AsOptions failed to set HTTP method header to OPTIONS")
}
} | explode_data.jsonl/20956 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
2121,
3798,
1155,
353,
8840,
836,
8,
972,
7000,
11,
716,
1669,
31166,
1255,
25183,
75274,
1507,
1634,
3798,
13116,
743,
435,
20798,
961,
330,
56929,
1,
972,
197,
3244,
26133,
445,
2717,
41419,
25,
1634,
3798,
4641,
311,
73... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUsageWithDefaults(t *testing.T) {
expectedUsage := "Usage: example [--label LABEL] [--content CONTENT]"
expectedHelp := `
Usage: example [--label LABEL] [--content CONTENT]
Options:
--label LABEL [default: cat]
--content CONTENT [default: dog]
--help, -h display this help and exit
`
var args struct {
Label string
Content string `default:"dog"`
}
args.Label = "cat"
p, err := NewParser(Config{Program: "example"}, &args)
require.NoError(t, err)
args.Label = "should_ignore_this"
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/20489 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
14783,
2354,
16273,
1155,
353,
8840,
836,
8,
341,
42400,
14783,
1669,
330,
14783,
25,
3110,
73817,
1502,
56874,
60,
73817,
1796,
35768,
60,
1837,
42400,
12689,
1669,
22074,
14783,
25,
3110,
73817,
1502,
56874,
60,
73817,
1796,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHealthCheckTimeout(t *testing.T) {
ts := memorytopo.NewServer("cell")
hc := createTestHc(ts)
hc.healthCheckTimeout = 500 * time.Millisecond
defer hc.Close()
tablet := topo.NewTablet(0, "cell", "a")
tablet.PortMap["vt"] = 1
input := make(chan *querypb.StreamHealthResponse)
fc := createFakeConn(tablet, input)
resultChan := hc.Subscribe()
hc.AddTablet(tablet)
// Immediately after AddTablet() there will be the first notification.
want := &TabletHealth{
Tablet: tablet,
Target: &querypb.Target{},
Serving: false,
MasterTermStartTime: 0,
}
result := <-resultChan
mustMatch(t, want, result, "Wrong TabletHealth data")
// one tablet after receiving a StreamHealthResponse
shr := &querypb.StreamHealthResponse{
TabletAlias: tablet.Alias,
Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_REPLICA},
Serving: true,
TabletExternallyReparentedTimestamp: 0,
RealtimeStats: &querypb.RealtimeStats{SecondsBehindMaster: 1, CpuUsage: 0.2},
}
want = &TabletHealth{
Tablet: tablet,
Target: &querypb.Target{Keyspace: "k", Shard: "s", TabletType: topodatapb.TabletType_REPLICA},
Serving: true,
Stats: &querypb.RealtimeStats{SecondsBehindMaster: 1, CpuUsage: 0.2},
MasterTermStartTime: 0,
}
input <- shr
result = <-resultChan
mustMatch(t, want, result, "Wrong TabletHealth data")
assert.Nil(t, checkErrorCounter("k", "s", topodatapb.TabletType_REPLICA, 0))
// wait for timeout period
time.Sleep(hc.healthCheckTimeout + 100*time.Millisecond)
t.Logf(`Sleep(1.1 * timeout)`)
result = <-resultChan
assert.False(t, result.Serving, "tabletHealthCheck: %+v; want not serving", result)
assert.Nil(t, checkErrorCounter("k", "s", topodatapb.TabletType_REPLICA, 1))
assert.True(t, fc.isCanceled(), "StreamHealth should be canceled after timeout, but is not")
// repeat the wait. It will timeout one more time trying to get the connection.
fc.resetCanceledFlag()
time.Sleep(hc.healthCheckTimeout)
result = <-resultChan
assert.False(t, result.Serving, "tabletHealthCheck: %+v; want not serving", result)
assert.Nil(t, checkErrorCounter("k", "s", topodatapb.TabletType_REPLICA, 2))
assert.True(t, fc.isCanceled(), "StreamHealth should be canceled again after timeout, but is not")
// send a healthcheck response, it should be serving again
fc.resetCanceledFlag()
input <- shr
// wait for the exponential backoff to wear off and health monitoring to resume.
result = <-resultChan
mustMatch(t, want, result, "Wrong TabletHealth data")
} | explode_data.jsonl/47688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1088
} | [
2830,
3393,
14542,
3973,
7636,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
4938,
3481,
78,
7121,
5475,
445,
5873,
1138,
9598,
66,
1669,
1855,
2271,
39,
66,
35864,
340,
9598,
66,
38107,
3973,
7636,
284,
220,
20,
15,
15,
353,
882,
7148... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSanitize(t *testing.T) {
assert.Equal(t, helper.sanitize(" "), "")
assert.Equal(t, helper.sanitize("a.y.c, b.y.c"), "a.y.c,b.y.c")
assert.Equal(t, helper.sanitize(" 80, 4080 "), "80,4080")
assert.Equal(t, helper.sanitize("aA.y.c, Bb.y.c"), "aa.y.c,bb.y.c")
} | explode_data.jsonl/15643 | {
"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,
23729,
26310,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
13137,
514,
58652,
445,
256,
59312,
14676,
6948,
12808,
1155,
11,
13137,
514,
58652,
445,
64,
2384,
520,
11,
293,
2384,
520,
3975,
330,
64,
2384,
520,
8402... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExcelizeChart(t *testing.T) {
f := excelize.NewFile()
categories := map[string]string{"A2": "Small", "A3": "Normal", "A4": "Large", "B1": "Apple", "C1": "Orange", "D1": "Pear"}
values := map[string]int{"B2": 2, "C2": 3, "D2": 3, "B3": 5, "C3": 2, "D3": 4, "B4": 6, "C4": 7, "D4": 8}
for k, v := range categories {
f.SetCellValue("Sheet1", k, v)
}
for k, v := range values {
f.SetCellValue("Sheet1", k, v)
}
if err := f.AddChart("Sheet1", "E1", `{
"type": "col3DClustered",
"series": [
{
"name": "Sheet1!$A$2",
"categories": "Sheet1!$B$1:$D$1",
"values": "Sheet1!$B$2:$D$2"
},
{
"name": "Sheet1!$A$3",
"categories": "Sheet1!$B$1:$D$1",
"values": "Sheet1!$B$3:$D$3"
},
{
"name": "Sheet1!$A$4",
"categories": "Sheet1!$B$1:$D$1",
"values": "Sheet1!$B$4:$D$4"
}],
"title":
{
"name": "Fruit 3D Clustered Column Chart"
}
}`); err != nil {
fmt.Println(err)
return
}
// 根据指定路径保存文件
if err := f.SaveAs(pathPrefix + "BookChart_out.xlsx"); err != nil {
fmt.Println(err)
}
} | explode_data.jsonl/474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 718
} | [
2830,
3393,
20055,
551,
14488,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
3438,
19412,
7121,
1703,
741,
1444,
5268,
1669,
2415,
14032,
30953,
4913,
32,
17,
788,
330,
25307,
497,
330,
32,
18,
788,
330,
12206,
497,
330,
32,
19,
788,
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... | 5 |
func TestAttributeMapWithNilValues(t *testing.T) {
origWithNil := []*otlpcommon.KeyValue{
nil,
{
Key: "test_key",
Value: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "test_value"}},
},
nil,
{
Key: "test_key2",
Value: nil,
},
nil,
{
Key: "test_key3",
Value: &otlpcommon.AnyValue{Value: nil},
},
}
sm := AttributeMap{
orig: &origWithNil,
}
val, exist := sm.Get("test_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "test_value", val.StringVal())
val, exist = sm.Get("test_key2")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueNULL, val.Type())
assert.EqualValues(t, "", val.StringVal())
val, exist = sm.Get("test_key3")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueNULL, val.Type())
assert.EqualValues(t, "", val.StringVal())
sm.Insert("other_key", NewAttributeValueString("other_value"))
val, exist = sm.Get("other_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "other_value", val.StringVal())
sm.InsertString("other_key_string", "other_value")
val, exist = sm.Get("other_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "other_value", val.StringVal())
sm.InsertInt("other_key_int", 123)
val, exist = sm.Get("other_key_int")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueINT, val.Type())
assert.EqualValues(t, 123, val.IntVal())
sm.InsertDouble("other_key_double", 1.23)
val, exist = sm.Get("other_key_double")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueDOUBLE, val.Type())
assert.EqualValues(t, 1.23, val.DoubleVal())
sm.InsertBool("other_key_bool", true)
val, exist = sm.Get("other_key_bool")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueBOOL, val.Type())
assert.EqualValues(t, true, val.BoolVal())
sm.Update("other_key", NewAttributeValueString("yet_another_value"))
val, exist = sm.Get("other_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "yet_another_value", val.StringVal())
sm.UpdateString("other_key_string", "yet_another_value")
val, exist = sm.Get("other_key_string")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "yet_another_value", val.StringVal())
sm.UpdateInt("other_key_int", 456)
val, exist = sm.Get("other_key_int")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueINT, val.Type())
assert.EqualValues(t, 456, val.IntVal())
sm.UpdateDouble("other_key_double", 4.56)
val, exist = sm.Get("other_key_double")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueDOUBLE, val.Type())
assert.EqualValues(t, 4.56, val.DoubleVal())
sm.UpdateBool("other_key_bool", false)
val, exist = sm.Get("other_key_bool")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueBOOL, val.Type())
assert.EqualValues(t, false, val.BoolVal())
sm.Upsert("other_key", NewAttributeValueString("other_value"))
val, exist = sm.Get("other_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "other_value", val.StringVal())
sm.UpsertString("other_key_string", "other_value")
val, exist = sm.Get("other_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "other_value", val.StringVal())
sm.UpsertInt("other_key_int", 123)
val, exist = sm.Get("other_key_int")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueINT, val.Type())
assert.EqualValues(t, 123, val.IntVal())
sm.UpsertDouble("other_key_double", 1.23)
val, exist = sm.Get("other_key_double")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueDOUBLE, val.Type())
assert.EqualValues(t, 1.23, val.DoubleVal())
sm.UpsertBool("other_key_bool", true)
val, exist = sm.Get("other_key_bool")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueBOOL, val.Type())
assert.EqualValues(t, true, val.BoolVal())
sm.Upsert("yet_another_key", NewAttributeValueString("yet_another_value"))
val, exist = sm.Get("yet_another_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "yet_another_value", val.StringVal())
sm.UpsertString("yet_another_key_string", "yet_another_value")
val, exist = sm.Get("yet_another_key_string")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "yet_another_value", val.StringVal())
sm.UpsertInt("yet_another_key_int", 456)
val, exist = sm.Get("yet_another_key_int")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueINT, val.Type())
assert.EqualValues(t, 456, val.IntVal())
sm.UpsertDouble("yet_another_key_double", 4.56)
val, exist = sm.Get("yet_another_key_double")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueDOUBLE, val.Type())
assert.EqualValues(t, 4.56, val.DoubleVal())
sm.UpsertBool("yet_another_key_bool", false)
val, exist = sm.Get("yet_another_key_bool")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueBOOL, val.Type())
assert.EqualValues(t, false, val.BoolVal())
assert.True(t, sm.Delete("other_key"))
assert.True(t, sm.Delete("other_key_string"))
assert.True(t, sm.Delete("other_key_int"))
assert.True(t, sm.Delete("other_key_double"))
assert.True(t, sm.Delete("other_key_bool"))
assert.True(t, sm.Delete("yet_another_key"))
assert.True(t, sm.Delete("yet_another_key_string"))
assert.True(t, sm.Delete("yet_another_key_int"))
assert.True(t, sm.Delete("yet_another_key_double"))
assert.True(t, sm.Delete("yet_another_key_bool"))
assert.False(t, sm.Delete("other_key"))
assert.False(t, sm.Delete("yet_another_key"))
// Test that the initial key is still there.
val, exist = sm.Get("test_key")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueSTRING, val.Type())
assert.EqualValues(t, "test_value", val.StringVal())
val, exist = sm.Get("test_key2")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueNULL, val.Type())
assert.EqualValues(t, "", val.StringVal())
val, exist = sm.Get("test_key3")
assert.True(t, exist)
assert.EqualValues(t, AttributeValueNULL, val.Type())
assert.EqualValues(t, "", val.StringVal())
// Test Sort
assert.EqualValues(t, AttributeMap{orig: &origWithNil}, sm.Sort())
} | explode_data.jsonl/38197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2520
} | [
2830,
3393,
3907,
2227,
2354,
19064,
6227,
1155,
353,
8840,
836,
8,
341,
197,
4670,
2354,
19064,
1669,
29838,
354,
13545,
5464,
9610,
1130,
515,
197,
84131,
345,
197,
197,
515,
298,
55242,
25,
256,
330,
1944,
3097,
756,
298,
47399,
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 TestTSVConvert(t *testing.T) {
testtype.SkipUnlessTestType(t, testtype.UnitTestType)
Convey("With a TSV input reader", t, func() {
Convey("calling convert on a TSVConverter should return the expected BSON document", func() {
tsvConverter := TSVConverter{
colSpecs: []ColumnSpec{
{"field1", new(FieldAutoParser), pgAutoCast, "auto"},
{"field2", new(FieldAutoParser), pgAutoCast, "auto"},
{"field3", new(FieldAutoParser), pgAutoCast, "auto"},
},
data: "a\tb\tc",
index: uint64(0),
}
expectedDocument := bson.D{
{"field1", "a"},
{"field2", "b"},
{"field3", "c"},
}
document, err := tsvConverter.Convert()
So(err, ShouldBeNil)
So(document, ShouldResemble, expectedDocument)
})
})
} | explode_data.jsonl/69023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 321
} | [
2830,
3393,
9951,
53,
12012,
1155,
353,
8840,
836,
8,
341,
18185,
1313,
57776,
35587,
2271,
929,
1155,
11,
1273,
1313,
25159,
2271,
929,
340,
93070,
5617,
445,
2354,
264,
350,
17803,
1946,
6604,
497,
259,
11,
2915,
368,
341,
197,
9307... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetOpenTriggerOrders(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip()
}
// optional params
_, err := f.GetOpenTriggerOrders(context.Background(), "", "")
if err != nil {
t.Error(err)
}
_, err = f.GetOpenTriggerOrders(context.Background(), spotPair, "")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15186 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
1949,
5002,
17939,
24898,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
741,
197,
532,
197,
322,
10101,
3628,
198,
197,
6878,
1848,
1669,
282,
2234... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test0003KCP(t *testing.T) {
c, err := NewConn("kcp")
if err != nil {
fmt.Println(err)
return
}
cc, err := c.Listen("127.0.0.1:58380")
if err != nil {
fmt.Println(err)
return
}
go func() {
cc.Accept()
fmt.Println("accept done")
}()
ccc, err := c.Dial("127.0.0.1:58380")
if err != nil {
fmt.Println(err)
return
}
go func() {
buf := make([]byte, 100)
_, err := ccc.Read(buf)
if err != nil {
fmt.Println(err)
return
}
}()
time.Sleep(time.Second)
cc.Close()
ccc.Close()
time.Sleep(time.Second)
} | explode_data.jsonl/19979 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
15,
15,
15,
18,
42,
7123,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
9701,
445,
74,
4672,
1138,
743,
1848,
961,
2092,
341,
197,
11009,
12419,
3964,
340,
197,
853,
198,
197,
630,
63517,
11,
1848,
1669,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestByteOwnership(t *testing.T) {
db := newTestDB(t, "people")
defer closeDB(t, db)
rows, err := db.Query("SELECT|people|name,photo|")
if err != nil {
t.Fatalf("Query: %v", err)
}
type row struct {
name []byte
photo RawBytes
}
got := []row{}
for rows.Next() {
var r row
err = rows.Scan(&r.name, &r.photo)
if err != nil {
t.Fatalf("Scan: %v", err)
}
got = append(got, r)
}
corruptMemory := []byte("\xffPHOTO")
want := []row{
{name: []byte("Alice"), photo: corruptMemory},
{name: []byte("Bob"), photo: corruptMemory},
{name: []byte("Chris"), photo: corruptMemory},
}
if !reflect.DeepEqual(got, want) {
t.Errorf("mismatch.\n got: %#v\nwant: %#v", got, want)
}
var photo RawBytes
err = db.QueryRow("SELECT|people|photo|name=?", "Alice").Scan(&photo)
if err == nil {
t.Error("want error scanning into RawBytes from QueryRow")
}
} | explode_data.jsonl/26173 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
7153,
77166,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
501,
2271,
3506,
1155,
11,
330,
16069,
1138,
16867,
3265,
3506,
1155,
11,
2927,
340,
68438,
11,
1848,
1669,
2927,
15685,
445,
4858,
91,
16069,
91,
606,
11,
11556,
91,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestCitizenStatus(t *testing.T) {
template := "citizenship-status.xml"
xpath := "Citizenship/USCitizen/ProofOfUSCitizenship/USPassport"
// Born in US with passport
form := newForm(t,
"citizenship/citizenship-status.json",
"foreign/foreign-passport.json",
)
snippet := applyForm(t, template, form)
assertHas1(t, template, xpath, snippet)
// Born in US without passport
form = newForm(t,
"citizenship/citizenship-status.json",
"no-passport.json",
)
snippet = applyForm(t, template, form)
assertHasNone(t, template, xpath, snippet)
// Foreign-born, but naturalized, with passport
form = newForm(t,
"naturalized.json",
"foreign/foreign-passport.json",
)
snippet = applyForm(t, template, form)
assertHas1(t, template, xpath, snippet)
} | explode_data.jsonl/23952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 281
} | [
2830,
3393,
64561,
23678,
2522,
1155,
353,
8840,
836,
8,
341,
22832,
1669,
330,
53861,
28960,
2151,
34998,
9028,
698,
10225,
2343,
1669,
330,
64561,
28960,
2151,
14,
2034,
64561,
23678,
14,
31076,
2124,
2034,
64561,
28960,
2151,
14,
2034,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_indexAllRoots(t *testing.T) {
tests := []struct {
name string
root string
mock indexerMock
expectedRoots []string
}{
{
name: "no additional roots",
root: "a/place",
mock: indexerMock{
additionalRoots: make(map[string][]string),
},
expectedRoots: []string{
"a/place",
},
},
{
name: "additional roots from a single call",
root: "a/place",
mock: indexerMock{
additionalRoots: map[string][]string{
"a/place": {
"another/place",
"yet-another/place",
},
},
},
expectedRoots: []string{
"a/place",
"another/place",
"yet-another/place",
},
},
{
name: "additional roots from a multiple calls",
root: "a/place",
mock: indexerMock{
additionalRoots: map[string][]string{
"a/place": {
"another/place",
"yet-another/place",
},
"yet-another/place": {
"a-quiet-place-2",
"a-final/place",
},
},
},
expectedRoots: []string{
"a/place",
"another/place",
"yet-another/place",
"a-quiet-place-2",
"a-final/place",
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.NoError(t, indexAllRoots(test.root, test.mock.indexer))
})
}
} | explode_data.jsonl/50122 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 652
} | [
2830,
3393,
3560,
2403,
8439,
82,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
33698,
688,
914,
198,
197,
77333,
688,
87216,
11571,
198,
197,
42400,
8439,
82,
3056,
917,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnescape(t *testing.T) {
tests := []struct {
input string
err error
output string
}{
{"hello", nil, "hello"},
{"file%20one%26two", nil, "file one&two"},
{"one/two%2fthree", nil, "one/two/three"},
{"this%20is%0not%valid", url.EscapeError("%0n"), ""},
}
for _, test := range tests {
if actual, err := unescape(test.input); err != test.err {
t.Errorf("unescape(%q) had err %v, expected: %q", test.input, err, test.err)
} else if actual != test.output {
t.Errorf("unescape(%q) = %q, expected: %q)", test.input, actual, test.output)
}
}
} | explode_data.jsonl/66568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
1806,
12998,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
220,
914,
198,
197,
9859,
262,
1465,
198,
197,
21170,
914,
198,
197,
59403,
197,
197,
4913,
14990,
497,
2092,
11,
330,
14990,
7115,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStackVal_UnmarshalJSON_GotTrue(t *testing.T) {
var sampleOut struct {
Val BoolString `json:"val"`
}
var sampleIn = []byte(`{"val":true}`)
json.Unmarshal(sampleIn, &sampleOut)
if !sampleOut.Val.Flag {
t.Errorf("should be true but got false")
}
if sampleOut.Val.Value != "" {
t.Error("string value should be empty")
}
} | explode_data.jsonl/31034 | {
"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,
4336,
2208,
40687,
27121,
5370,
2646,
354,
2514,
1155,
353,
8840,
836,
8,
341,
2405,
6077,
2662,
2036,
341,
197,
197,
2208,
12608,
703,
1565,
2236,
2974,
831,
8805,
197,
532,
2405,
6077,
641,
284,
3056,
3782,
5809,
4913,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestIssue29511(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
orgEnable := core.PreparedPlanCacheEnabled()
defer core.SetPreparedPlanCache(orgEnable)
core.SetPreparedPlanCache(true)
se, err := session.CreateSession4TestWithOpt(store, &session.Opt{
PreparedPlanCache: kvcache.NewSimpleLRUCache(100, 0.1, math.MaxUint64),
})
require.NoError(t, err)
tk := testkit.NewTestKitWithSession(t, store, se)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("CREATE TABLE `t` (`COL1` bigint(20) DEFAULT NULL COMMENT 'WITH DEFAULT', UNIQUE KEY `UK_COL1` (`COL1`))")
tk.MustExec("insert into t values(-3865356285544170443),(9223372036854775807);")
tk.MustExec("prepare stmt from 'select/*+ hash_agg() */ max(col1) from t where col1 = ? and col1 > ?;';")
tk.MustExec("set @a=-3865356285544170443, @b=-4055949188488870713;")
tk.MustQuery("execute stmt using @a,@b;").Check(testkit.Rows("-3865356285544170443"))
} | explode_data.jsonl/5530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
42006,
17,
24,
20,
16,
16,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
87625,
11084,
1669,
6200,
28770,
7212,
20485,
8233,
5462,
741,
16867,
6200,
4202,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.