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 TestCopyApplicationSource(t *testing.T) {
config := configuration.NewRepositoryWithDefaults()
i18n.T = i18n.Init(config)
RegisterFailHandler(Fail)
RunSpecs(t, "CopyApplicationSource Suite")
} | explode_data.jsonl/7154 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
12106,
4988,
3608,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
6546,
7121,
4624,
2354,
16273,
741,
8230,
16,
23,
77,
836,
284,
600,
16,
23,
77,
26849,
8754,
692,
79096,
19524,
3050,
7832,
604,
340,
85952,
8327,
82,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestChaincodeInvokeChaincode(t *testing.T) {
chainID := util.GetTestChainID()
lis, err := initPeer(chainID)
if err != nil {
t.Fail()
t.Logf("Error creating peer: %s", err)
}
defer finitPeer(lis, chainID)
err = chaincodeInvokeChaincode(t, chainID, "")
if err != nil {
t.Fail()
t.Logf("Failed chaincode invoke chaincode : %s", err)
closeListenerAndSleep(lis)
return
}
closeListenerAndSleep(lis)
} | explode_data.jsonl/52836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
18837,
1851,
17604,
18837,
1851,
1155,
353,
8840,
836,
8,
341,
197,
8819,
915,
1669,
4094,
2234,
2271,
18837,
915,
2822,
8810,
285,
11,
1848,
1669,
2930,
30888,
62591,
915,
340,
743,
1848,
961,
2092,
341,
197,
3244,
57243,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTicker_S3(t *testing.T) {
product := "btc_" + common.NativeToken
timeMap := GetTimes()
kline15s := []interface{}{}
kline1s := []interface{}{}
matches := prepareMatches(product, []float64{100.0}, []float64{2.0}, timeMap["now"])
fakeLatestTickers := &map[string]*types.Ticker{}
err := simpleCaseRunner(t, product, nil, timeMap["-24h"], timeMap["now"]+1, kline15s, kline1s, matches,
aTicker(product, 100.0, 100.0, 100.0, 100.0, 100.0, 2.0), fakeLatestTickers)
assert.True(t, err == nil)
} | explode_data.jsonl/37809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
87278,
1098,
18,
1155,
353,
8840,
836,
8,
1476,
69288,
1669,
330,
92634,
18771,
488,
4185,
68624,
3323,
198,
21957,
2227,
1669,
2126,
18889,
741,
16463,
1056,
16,
20,
82,
1669,
3056,
4970,
6257,
16094,
16463,
1056,
16,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImageManifest(t *testing.T) {
payload := []byte(``)
url := fmt.Sprintf("/images/%d/manifest", imageID)
req, _ := http.NewRequest("GET", url, bytes.NewBuffer(payload))
response := executeRequest(req)
checkResponseCode(t, http.StatusOK, response.Code)
m := objects.Seed{}
json.Unmarshal(response.Body.Bytes(), &m)
testManifest := objects.SeedFromManifestFile("../seed.manifest.json")
mStr := fmt.Sprintf("%v", m)
testStr := fmt.Sprintf("%v", testManifest)
if mStr != testStr {
t.Errorf("Expected manifest to be %v. Got '%v'", testManifest, m)
}
} | explode_data.jsonl/19328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
1906,
38495,
1155,
353,
8840,
836,
8,
341,
76272,
1669,
3056,
3782,
5809,
24183,
19320,
1669,
8879,
17305,
4283,
3642,
12627,
67,
14,
42315,
497,
2168,
915,
340,
24395,
11,
716,
1669,
1758,
75274,
445,
3806,
497,
2515,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRunner__Processor_Timer_Expired(t *testing.T) {
t.Parallel()
repo := &RepositoryMock{}
r := New(repo, WithRetryDuration(20*time.Millisecond))
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
repo.GetLastEventsFunc = func(ctx context.Context, limit uint64) ([]Event, error) {
return nil, nil
}
repo.GetUnprocessedEventsFunc = func(ctx context.Context, limit uint64) ([]Event, error) {
return nil, nil
}
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
r.Run(ctx)
}()
time.Sleep(30 * time.Millisecond)
cancel()
wg.Wait()
assert.Equal(t, 1, len(repo.GetLastEventsCalls()))
assert.Equal(t, 1, len(repo.GetUnprocessedEventsCalls()))
} | explode_data.jsonl/21367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
19486,
563,
22946,
64026,
62,
54349,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
17200,
5368,
1669,
609,
4624,
11571,
16094,
7000,
1669,
1532,
50608,
11,
3085,
51560,
12945,
7,
17,
15,
77053,
71482,
4390,
20985,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPodSpec(t *testing.T) {
volSize := resource.NewQuantity(100000.0, resource.BinarySI)
c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "rook/rook:myversion", "", "", *volSize, rookalpha.Annotations{}, rookalpha.Placement{},
edgefsv1beta1.NetworkSpec{}, edgefsv1beta1.DashboardSpec{}, v1.ResourceRequirements{
Limits: v1.ResourceList{
v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI),
},
Requests: v1.ResourceList{
v1.ResourceMemory: *resource.NewQuantity(1337.0, resource.BinarySI),
},
}, "", metav1.OwnerReference{}, false)
d := c.makeDeployment("mgr-a", "rook-edgefs", "edgefs", 1)
assert.NotNil(t, d)
assert.Equal(t, "mgr-a", d.Name)
assert.Equal(t, v1.RestartPolicyAlways, d.Spec.Template.Spec.RestartPolicy)
assert.Equal(t, 1, len(d.Spec.Template.Spec.Volumes))
//check ports
assert.Equal(t, 3, len(d.Spec.Template.Spec.Containers[0].Ports))
assert.Equal(t, int32(8881), d.Spec.Template.Spec.Containers[0].Ports[0].ContainerPort)
assert.Equal(t, int32(8080), d.Spec.Template.Spec.Containers[0].Ports[1].ContainerPort)
assert.Equal(t, int32(4443), d.Spec.Template.Spec.Containers[0].Ports[2].ContainerPort)
assert.Equal(t, "edgefs-datadir", d.Spec.Template.Spec.Volumes[0].Name)
assert.Equal(t, "mgr-a", d.ObjectMeta.Name)
assert.Equal(t, appName, d.Spec.Template.ObjectMeta.Labels["app"])
assert.Equal(t, c.Namespace, d.Spec.Template.ObjectMeta.Labels["rook_cluster"])
assert.Equal(t, 0, len(d.ObjectMeta.Annotations))
assert.Equal(t, 2, len(d.Spec.Template.ObjectMeta.Annotations))
assert.Equal(t, "true", d.Spec.Template.ObjectMeta.Annotations["prometheus.io/scrape"])
assert.Equal(t, strconv.Itoa(defaultMetricsPort), d.Spec.Template.ObjectMeta.Annotations["prometheus.io/port"])
cont := d.Spec.Template.Spec.Containers[0]
assert.Equal(t, 2, len(cont.VolumeMounts))
assert.Equal(t, "mgmt", cont.Args[0])
assert.Equal(t, "100", cont.Resources.Limits.Cpu().String())
assert.Equal(t, "1337", cont.Resources.Requests.Memory().String())
} | explode_data.jsonl/4576 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 823
} | [
2830,
3393,
23527,
8327,
1155,
353,
8840,
836,
8,
341,
5195,
337,
1695,
1669,
5101,
7121,
17342,
7,
16,
15,
15,
15,
15,
15,
13,
15,
11,
5101,
49983,
13817,
340,
1444,
1669,
1532,
2099,
18855,
67,
9328,
90,
2959,
746,
25,
1273,
453... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEntry_Notify(t *testing.T) {
entry := widget.NewEntry()
changed := false
entry.OnChanged = func(string) {
changed = true
}
entry.SetText("Test")
assert.True(t, changed)
} | explode_data.jsonl/12330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
5874,
1604,
37253,
1155,
353,
8840,
836,
8,
341,
48344,
1669,
9086,
7121,
5874,
741,
197,
17353,
1669,
895,
271,
48344,
8071,
5389,
284,
2915,
3609,
8,
341,
197,
197,
17353,
284,
830,
198,
197,
532,
48344,
92259,
445,
2271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestControllerDeleteEventWithGoodController(t *testing.T) {
c, tc := makeController("apps/v1", "ReplicaSet")
c.Delete(simpleOwnedPod("unit", "test"))
validateSent(t, tc, sourcesv1beta1.ApiServerSourceDeleteRefEventType)
} | explode_data.jsonl/39271 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
2051,
6435,
1556,
2354,
15216,
2051,
1155,
353,
8840,
836,
8,
341,
1444,
11,
17130,
1669,
1281,
2051,
445,
27635,
5457,
16,
497,
330,
18327,
15317,
1649,
1138,
1444,
18872,
1141,
6456,
57641,
23527,
445,
3843,
497,
330,
1944... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestAcceptGoodConfig(t *testing.T) {
mcm := &mockconfigtx.Manager{}
cf := NewFilter(mcm)
configGroup := cb.NewConfigGroup()
configGroup.Values["Foo"] = &cb.ConfigValue{}
configUpdateEnv := &cb.ConfigUpdateEnvelope{
ConfigUpdate: utils.MarshalOrPanic(configGroup),
}
configEnv := &cb.ConfigEnvelope{
LastUpdate: &cb.Envelope{
Payload: utils.MarshalOrPanic(&cb.Payload{
Header: &cb.Header{
ChannelHeader: utils.MarshalOrPanic(&cb.ChannelHeader{
Type: int32(cb.HeaderType_CONFIG_UPDATE),
}),
},
Data: utils.MarshalOrPanic(configUpdateEnv),
}),
},
}
configEnvBytes := utils.MarshalOrPanic(configEnv)
configBytes := utils.MarshalOrPanic(&cb.Payload{Header: &cb.Header{ChannelHeader: utils.MarshalOrPanic(&cb.ChannelHeader{Type: int32(cb.HeaderType_CONFIG)})}, Data: configEnvBytes})
configEnvelope := &cb.Envelope{
Payload: configBytes,
}
result, committer := cf.Apply(configEnvelope)
if result != filter.Accept {
t.Fatal("Should have indicated a good config message causes a reconfig")
}
if !committer.Isolated() {
t.Fatal("Config transactions should be isolated to their own block")
}
committer.Commit()
if !reflect.DeepEqual(mcm.AppliedConfigUpdateEnvelope, configEnv) {
t.Fatalf("Should have applied new config on commit got %+v and %+v", mcm.AppliedConfigUpdateEnvelope, configEnv.LastUpdate)
}
} | explode_data.jsonl/18641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 529
} | [
2830,
3393,
16646,
15216,
2648,
1155,
353,
8840,
836,
8,
341,
2109,
6226,
1669,
609,
16712,
1676,
3998,
58298,
16094,
96989,
1669,
1532,
5632,
1255,
6226,
340,
25873,
2808,
1669,
9858,
7121,
2648,
2808,
741,
25873,
2808,
35145,
1183,
4092... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCacheBinary(t *testing.T) {
oldMinikubeHome := os.Getenv("MINIKUBE_HOME")
defer os.Setenv("MINIKUBE_HOME", oldMinikubeHome)
minikubeHome, err := ioutil.TempDir("/tmp", "")
if err != nil {
t.Fatalf("error during creating tmp dir: %v", err)
}
defer os.RemoveAll(minikubeHome)
noWritePermDir, err := ioutil.TempDir("/tmp", "")
if err != nil {
t.Fatalf("error during creating tmp dir: %v", err)
}
defer os.RemoveAll(noWritePermDir)
err = os.Chmod(noWritePermDir, 0000)
if err != nil {
t.Fatalf("error (%v) during changing permissions of dir %v", err, noWritePermDir)
}
var tc = []struct {
desc, version, osName, archName string
minikubeHome, binary, description string
err bool
}{
{
desc: "ok kubeadm",
version: "v1.16.0",
osName: "linux",
archName: runtime.GOARCH,
binary: "kubeadm",
err: false,
minikubeHome: minikubeHome,
},
{
desc: "minikube home in dir without perms and arm runtime",
version: "v1.16.0",
osName: runtime.GOOS,
archName: "arm",
binary: "kubectl",
err: true,
minikubeHome: noWritePermDir,
},
{
desc: "minikube home in dir without perms",
version: "v1.16.0",
osName: runtime.GOOS,
archName: runtime.GOARCH,
binary: "kubectl",
err: true,
minikubeHome: noWritePermDir,
},
{
desc: "binary foo",
version: "v1.16.0",
osName: runtime.GOOS,
archName: runtime.GOARCH,
binary: "foo",
err: true,
minikubeHome: minikubeHome,
},
{
desc: "version 9000",
version: "v9000",
osName: runtime.GOOS,
archName: runtime.GOARCH,
binary: "foo",
err: true,
minikubeHome: minikubeHome,
},
{
desc: "bad os",
version: "v1.16.0",
osName: "no-such-os",
archName: runtime.GOARCH,
binary: "kubectl",
err: true,
minikubeHome: minikubeHome,
},
}
for _, test := range tc {
t.Run(test.desc, func(t *testing.T) {
os.Setenv("MINIKUBE_HOME", test.minikubeHome)
_, err := Binary(test.binary, test.version, test.osName, test.archName)
if err != nil && !test.err {
t.Fatalf("Got unexpected error %v", err)
}
if err == nil && test.err {
t.Fatalf("Expected error but got %v", err)
}
})
}
} | explode_data.jsonl/64224 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1260
} | [
2830,
3393,
8233,
21338,
1155,
353,
8840,
836,
8,
341,
61828,
6217,
1579,
3760,
7623,
1669,
2643,
64883,
445,
16413,
28561,
42389,
28466,
1138,
16867,
2643,
4202,
3160,
445,
16413,
28561,
42389,
28466,
497,
2310,
6217,
1579,
3760,
7623,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParseTopCodeBlock(t *testing.T) {
const markup = `
<table cellpadding="0" cellspacing="0"><tbody><tr>
<td colspan="1" rowspan="1">
<p><span class="code">start func() {<br>}</span><span class="code"></span></p>
<p><span class="code"></span></p>
<p><span class="code">func2() {<br>}</span><span class="code"> // comment</span></p>
</td>
</tr></tbody></table>
<table cellpadding="0" cellspacing="0"><tbody><tr>
<td colspan="1" rowspan="1">
<p><span class="term">adb shell am start -a VIEW \</span></p>
<p><span class="term">-d "http://host" app</span></p>
</td>
</tr></tbody></table>
`
code := "start func() {\n}\n\nfunc2() {\n} // comment"
term := "adb shell am start -a VIEW \\\n-d \"http://host\" app"
content := types.NewListNode()
content.Append(types.NewCodeNode(code, false))
content.Append(types.NewCodeNode(term, true))
doc, err := html.Parse(markupReader(markup))
if err != nil {
t.Fatal(err)
}
ds := &docState{
step: &types.Step{Content: types.NewListNode()},
css: cssStyle{
".code": {"font-family": fontCode},
".term": {"font-family": fontConsole},
},
cur: doc.FirstChild,
}
parseTop(ds)
html1, _ := render.HTML("", ds.step.Content)
html2, _ := render.HTML("", content)
s1 := strings.TrimSpace(string(html1))
s2 := strings.TrimSpace(string(html2))
if s1 != s2 {
t.Errorf("step.Content:\n\n%s\nwant:\n\n%s", s1, s2)
}
} | explode_data.jsonl/41568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 593
} | [
2830,
3393,
14463,
5366,
2078,
4713,
1155,
353,
8840,
836,
8,
341,
4777,
40751,
284,
22074,
197,
20993,
29104,
428,
15,
1,
27081,
428,
15,
3088,
10095,
1784,
376,
397,
197,
6868,
16848,
428,
16,
1,
51288,
428,
16,
881,
197,
197,
792... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProvider_FetchUserPerms(t *testing.T) {
t.Run("nil account", func(t *testing.T) {
p := NewProvider("", mustURL(t, "https://github.com"), "admin_token", nil, 3*time.Hour, nil)
_, err := p.FetchUserPerms(context.Background(), nil)
want := "no account provided"
got := fmt.Sprintf("%v", err)
if got != want {
t.Fatalf("err: want %q but got %q", want, got)
}
})
t.Run("not the code host of the account", func(t *testing.T) {
p := NewProvider("", mustURL(t, "https://github.com"), "admin_token", nil, 3*time.Hour, nil)
_, err := p.FetchUserPerms(context.Background(),
&extsvc.Account{
AccountSpec: extsvc.AccountSpec{
ServiceType: "gitlab",
ServiceID: "https://gitlab.com/",
},
},
)
want := `not a code host of the account: want "https://gitlab.com/" but have "https://github.com/"`
got := fmt.Sprintf("%v", err)
if got != want {
t.Fatalf("err: want %q but got %q", want, got)
}
})
t.Run("no token found in account data", func(t *testing.T) {
p := NewProvider("", mustURL(t, "https://github.com"), "admin_token", nil, 3*time.Hour, nil)
_, err := p.FetchUserPerms(context.Background(),
&extsvc.Account{
AccountSpec: extsvc.AccountSpec{
ServiceType: "github",
ServiceID: "https://github.com/",
},
AccountData: extsvc.AccountData{},
},
)
want := `no token found in the external account data`
got := fmt.Sprintf("%v", err)
if got != want {
t.Fatalf("err: want %q but got %q", want, got)
}
})
mockClient := &mockClient{
MockListAffiliatedRepositories: func(ctx context.Context, visibility github.Visibility, page int) ([]*github.Repository, bool, int, error) {
switch page {
case 1:
return []*github.Repository{
{ID: "MDEwOlJlcG9zaXRvcnkyNTI0MjU2NzE="},
{ID: "MDEwOlJlcG9zaXRvcnkyNDQ1MTc1MzY="},
}, true, 1, nil
case 2:
return []*github.Repository{
{ID: "MDEwOlJlcG9zaXRvcnkyNDI2NTEwMDA="},
}, false, 1, nil
}
return []*github.Repository{}, false, 1, nil
},
}
calledWithToken := false
mockClient.MockWithToken = func(token string) client {
calledWithToken = true
return mockClient
}
p := NewProvider("", mustURL(t, "https://github.com"), "admin_token", nil, 3*time.Hour, nil)
p.client = mockClient
authData := json.RawMessage(`{"access_token": "my_access_token"}`)
repoIDs, err := p.FetchUserPerms(context.Background(),
&extsvc.Account{
AccountSpec: extsvc.AccountSpec{
ServiceType: "github",
ServiceID: "https://github.com/",
},
AccountData: extsvc.AccountData{
AuthData: &authData,
},
},
)
if err != nil {
t.Fatal(err)
}
if !calledWithToken {
t.Fatal("!calledWithToken")
}
wantRepoIDs := []extsvc.RepoID{
"MDEwOlJlcG9zaXRvcnkyNTI0MjU2NzE=",
"MDEwOlJlcG9zaXRvcnkyNDQ1MTc1MzY=",
"MDEwOlJlcG9zaXRvcnkyNDI2NTEwMDA=",
}
if diff := cmp.Diff(wantRepoIDs, repoIDs); diff != "" {
t.Fatalf("RpoeIDs mismatch (-want +got):\n%s", diff)
}
} | explode_data.jsonl/7241 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1311
} | [
2830,
3393,
5179,
1400,
2995,
1474,
3889,
1011,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
8385,
2692,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3223,
1669,
1532,
5179,
19814,
1969,
3144,
1155,
11,
330,
2428,
1110,
5204,
905,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSplitTrim(t *testing.T) {
for i, test := range []struct {
input string
output []string
sep string
}{
{"os,arch,cpu,caddy_version", []string{"os", "arch", "cpu", "caddy_version"}, ","},
{"os,arch,cpu,caddy_version,", []string{"os", "arch", "cpu", "caddy_version"}, ","},
{"os,,, arch, cpu, caddy_version,", []string{"os", "arch", "cpu", "caddy_version"}, ","},
{", , os, arch, cpu , caddy_version,, ,", []string{"os", "arch", "cpu", "caddy_version"}, ","},
{"os, ,, arch, cpu , caddy_version,, ,", []string{"os", "arch", "cpu", "caddy_version"}, ","},
} {
got := splitTrim(test.input, test.sep)
if len(got) != len(test.output) {
t.Errorf("Test %d: spliteTrim() = %v, want %v", i, got, test.output)
continue
}
for j, item := range test.output {
if item != got[j] {
t.Errorf("Test %d: spliteTrim() = %v, want %v", i, got, test.output)
break
}
}
}
} | explode_data.jsonl/16478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 395
} | [
2830,
3393,
20193,
25656,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
22427,
220,
914,
198,
197,
21170,
3056,
917,
198,
197,
197,
28036,
262,
914,
198,
197,
59403,
197,
197,
4913,
436,
11,
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... | 5 |
func TestAllPathsSourceTarget(t *testing.T) {
tests := []struct {
name string
graph [][]int
want [][]int
}{
{
"test 1",
[][]int{{4, 3, 1}, {3, 2, 4}, {3}, {4}, {}},
[][]int{{0, 4}, {0, 3, 4}, {0, 1, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 4}},
},
{
"test 2",
[][]int{{1}, {}},
[][]int{{0, 1}},
},
{
"test 3",
[][]int{{1, 2, 3}, {2}, {3}, {}},
[][]int{{0, 1, 2, 3}, {0, 2, 3}, {0, 3}},
},
{
"test 4",
[][]int{{1, 3}, {2}, {3}, {}},
[][]int{{0, 1, 2, 3}, {0, 3}},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got := allPathsSourceTarget(tt.graph)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("allPathsSourceTarget() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/57948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
2403,
26901,
3608,
6397,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
66616,
52931,
396,
198,
197,
50780,
220,
52931,
396,
198,
197,
59403,
197,
197,
515,
298,
197,
1,
1944,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_UnsafeSetIsSuperset(t *testing.T) {
a := NewThreadUnsafeSet()
a.Add(9)
a.Add(5)
a.Add(2)
a.Add(1)
a.Add(11)
b := NewThreadUnsafeSet()
b.Add(5)
b.Add(2)
b.Add(11)
if !a.IsSuperset(b) {
t.Error("set a should be a superset of set b")
}
b.Add(42)
if a.IsSuperset(b) {
t.Error("set a should not be a superset of set b because set a has a 42")
}
} | explode_data.jsonl/188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
40687,
18675,
1649,
3872,
10048,
44146,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
6855,
78770,
1649,
741,
11323,
1904,
7,
24,
340,
11323,
1904,
7,
20,
340,
11323,
1904,
7,
17,
340,
11323,
1904,
7,
16,
340,
11323,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServer_Issue1746(t *testing.T) {
log.SetOutput(ioutil.Discard)
targetdir, err := ioutil.TempDir(".", "swagger_server")
if err != nil {
t.Fatalf("failed to create a test target directory: %v", err)
}
err = os.Chdir(targetdir)
if err != nil {
t.Fatalf("failed to create a test target directory: %v", err)
}
defer func() {
if err = os.Chdir(".."); err != nil {
t.Log("failed test exist: ", err)
}
log.SetOutput(os.Stdout)
if err = os.RemoveAll(targetdir); err != nil {
t.Log("failed test exist: ", err)
}
}()
opts := testGenOpts()
// NOTE: test fails when target != "."
opts.Target = "."
opts.Spec = "../../fixtures/bugs/1746/fixture-1746.yaml"
err = GenerateServer("", nil, nil, &opts)
assert.NoError(t, err)
gulp, err := ioutil.ReadFile(filepath.Join("restapi", "configure_example_swagger_server.go"))
assert.NoError(t, err)
assertInCode(t, `//go:generate swagger generate server --target .. --name ExampleSwaggerServer`, string(gulp))
} | explode_data.jsonl/3793 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 389
} | [
2830,
3393,
5475,
7959,
83890,
16,
22,
19,
21,
1155,
353,
8840,
836,
8,
341,
6725,
4202,
5097,
1956,
30158,
909,
47560,
340,
28861,
3741,
11,
1848,
1669,
43144,
65009,
6184,
64217,
330,
74755,
12015,
1138,
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 TestParseCommandLine1(t *testing.T) {
t.Run("simple", func(t *testing.T) {
g := NewWithT(t)
g.Expect(utils.ParseCommandLine("a b c")).To(Equal([]string{"a", "b", "c"}))
})
t.Run("spaces", func(t *testing.T) {
g := NewWithT(t)
g.Expect(utils.ParseCommandLine("a\\ b c")).To(Equal([]string{"a b", "c"}))
})
t.Run("strings", func(t *testing.T) {
g := NewWithT(t)
g.Expect(utils.ParseCommandLine("a \"b \" c")).To(Equal([]string{"a", "b ", "c"}))
})
t.Run("empty_arg", func(t *testing.T) {
g := NewWithT(t)
g.Expect(utils.ParseCommandLine("a -N \"\"")).To(Equal([]string{"a", "-N", ""}))
})
} | explode_data.jsonl/59869 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
14463,
71885,
16,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
22944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3174,
1669,
1532,
2354,
51,
1155,
340,
197,
3174,
81893,
64166,
8937,
71885,
445,
64,
293,
272,
15197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconstructQuery(t *testing.T) {
type io struct {
Input transaction
Full bool
Output string
}
tests := []io{
{
Input: transaction{
resource: "test.col",
method: "find",
event: map[string]interface{}{
"numberToSkip": 3,
"numberToReturn": 2,
},
params: map[string]interface{}{
"me": "you",
},
},
Full: true,
Output: `test.col.find({"me":"you"}).skip(3).limit(2)`,
},
{
Input: transaction{
resource: "test.col",
method: "insert",
params: map[string]interface{}{
"documents": "you",
},
},
Full: true,
Output: `test.col.insert({"documents":"you"})`,
},
{
Input: transaction{
resource: "test.col",
method: "insert",
params: map[string]interface{}{
"documents": "you",
},
},
Full: false,
Output: `test.col.insert({})`,
},
}
for _, test := range tests {
assert.Equal(t, test.Output,
reconstructQuery(&test.Input, test.Full))
}
} | explode_data.jsonl/35543 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 471
} | [
2830,
3393,
693,
7596,
2859,
1155,
353,
8840,
836,
8,
341,
13158,
6399,
2036,
341,
197,
66588,
220,
7745,
198,
197,
197,
9432,
256,
1807,
198,
197,
80487,
914,
198,
197,
532,
78216,
1669,
3056,
815,
515,
197,
197,
515,
298,
66588,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestContextExec(t *testing.T) {
t.Parallel()
ctx, _ := v8go.NewContext(nil)
_, _ = ctx.RunScript(`const add = (a, b) => a + b`, "add.js")
val, _ := ctx.RunScript(`add(3, 4)`, "main.js")
rtn := val.String()
if rtn != "7" {
t.Errorf("script returned an unexpected value: expected %q, got %q", "7", rtn)
}
_, err := ctx.RunScript(`add`, "func.js")
if err != nil {
t.Errorf("error not expected: %v", err)
}
iso, _ := ctx.Isolate()
ctx2, _ := v8go.NewContext(iso)
_, err = ctx2.RunScript(`add`, "ctx2.js")
if err == nil {
t.Error("error expected but was <nil>")
}
} | explode_data.jsonl/73930 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
1972,
10216,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
11,
716,
1669,
348,
23,
3346,
7121,
1972,
27907,
340,
197,
6878,
716,
284,
5635,
16708,
5910,
5809,
1024,
912,
284,
320,
64,
11,
293,
8,
589,
264,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRootParseExecutableFail(t *testing.T) {
for _, src := range []string{
"{ title }",
"\xef\xbb\xbf{ title }",
"{artists{name, ...sung}} fragment sung on Artist {songs}",
"query Qq ( $a : Int! = 3 ) { title }",
`query Qq ($a: String = "x") { artist (name: $id ) }`,
`{ arty: artists (name: "x") { name }}`,
} {
for i := 0; i < len(src); i++ {
failExeRead(t, src, i)
}
}
} | explode_data.jsonl/48191 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
8439,
14463,
94772,
19524,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
2286,
1669,
2088,
3056,
917,
515,
197,
197,
14129,
2265,
335,
756,
197,
197,
11934,
47510,
3462,
6066,
3462,
13233,
90,
2265,
335,
756,
197,
197,
14129,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDispatchCheck_Failure(t *testing.T) {
h := &mockHandler{err: errors.New("you shall not pass")}
_, err := executeDispatchCheck(t, h)
if err == nil {
t.Fatal("expected error not found")
}
} | explode_data.jsonl/64994 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
11283,
3973,
1400,
9373,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
609,
16712,
3050,
90,
615,
25,
5975,
7121,
445,
9330,
4880,
537,
1494,
899,
630,
197,
6878,
1848,
1669,
9026,
11283,
3973,
1155,
11,
305,
340,
743,
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
] | 2 |
func TestCollectorIncr(t *testing.T) {
_ = redisMetric.Incr("1", "300")
_ = redisNoLabelsMetric.Incr()
_ = Get("/metrics", nil)
} | explode_data.jsonl/52687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 60
} | [
2830,
3393,
53694,
641,
5082,
1155,
353,
8840,
836,
8,
341,
197,
62,
284,
20870,
54310,
5337,
5082,
445,
16,
497,
330,
18,
15,
15,
1138,
197,
62,
284,
20870,
2753,
23674,
54310,
5337,
5082,
741,
197,
62,
284,
2126,
4283,
43262,
497,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestTimeout(t *testing.T) {
ctx := context.Background()
lastID.Set(0)
count.Set(0)
p := NewResourcePool(PoolFactory, 1, 1, time.Second)
defer p.Close()
r, err := p.Get(ctx)
if err != nil {
t.Fatal(err)
}
newctx, cancel := context.WithTimeout(ctx, 1*time.Millisecond)
_, err = p.Get(newctx)
cancel()
want := "resource pool timed out"
if err == nil || err.Error() != want {
t.Errorf("got %v, want %s", err, want)
}
p.Put(r)
} | explode_data.jsonl/664 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 192
} | [
2830,
3393,
7636,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
33096,
915,
4202,
7,
15,
340,
18032,
4202,
7,
15,
340,
3223,
1669,
1532,
4783,
10551,
5304,
1749,
4153,
11,
220,
16,
11,
220,
16,
11,
882,
32435,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestReExportDefaultNoBundle(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
export {default as foo} from './foo'
export {default as bar} from './bar'
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38552 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
693,
16894,
3675,
2753,
8409,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
59440,
314,
2258,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImageAnnotatorSmoke(t *testing.T) {
if testing.Short() {
t.Skip("skipping smoke test in short mode")
}
ctx := context.Background()
ts := testutil.TokenSource(ctx, DefaultAuthScopes()...)
if ts == nil {
t.Skip("Integration tests skipped. See CONTRIBUTING.md for details")
}
projectId := testutil.ProjID()
_ = projectId
c, err := NewImageAnnotatorClient(ctx, option.WithTokenSource(ts))
if err != nil {
t.Fatal(err)
}
var gcsImageUri string = "gs://gapic-toolkit/President_Barack_Obama.jpg"
var source = &visionpb.ImageSource{
GcsImageUri: gcsImageUri,
}
var image = &visionpb.Image{
Source: source,
}
var type_ visionpb.Feature_Type = visionpb.Feature_FACE_DETECTION
var featuresElement = &visionpb.Feature{
Type: type_,
}
var features = []*visionpb.Feature{featuresElement}
var requestsElement = &visionpb.AnnotateImageRequest{
Image: image,
Features: features,
}
var requests = []*visionpb.AnnotateImageRequest{requestsElement}
var request = &visionpb.BatchAnnotateImagesRequest{
Requests: requests,
}
if _, err := c.BatchAnnotateImages(ctx, request); err != nil {
t.Error(err)
}
} | explode_data.jsonl/69076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 422
} | [
2830,
3393,
1906,
2082,
1921,
850,
76880,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
16205,
1273,
304,
2805,
3856,
1138,
197,
532,
20985,
1669,
2266,
19047,
741,
57441,
1669,
1273,
1314,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInferFields(t *testing.T) {
type Thing struct {
Foo int `json:"foo"`
Bar bool
Poo time.Duration `json:"what,"`
Yes string
Buz time.Time
Float float64
}
fields := InferFields(reflect.TypeOf(&Thing{}))
assert.DeepEqual(t, fields, map[string]Type{
"foo": NumberType,
"Bar": BoolType,
"what": DurationType,
"Yes": StringType,
"Buz": TimeType,
"Float": NumberType,
})
} | explode_data.jsonl/9196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
641,
802,
8941,
1155,
353,
8840,
836,
8,
341,
13158,
37200,
2036,
341,
197,
12727,
2624,
256,
526,
1565,
2236,
2974,
7975,
8805,
197,
197,
3428,
256,
1807,
198,
197,
10025,
2624,
256,
882,
33795,
1565,
2236,
2974,
12555,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateLedgerFactory(t *testing.T) {
cleanup := configtest.SetDevFabricConfigPath(t)
defer cleanup()
testCases := []struct {
name string
ledgerType string
ledgerDir string
ledgerDirPrefix string
expectPanic bool
}{
{"RAM", "ram", "", "", false},
{"FilewithPathSet", "file", filepath.Join(os.TempDir(), "test-dir"), "", false},
{"FilewithPathUnset", "file", "", "test-prefix", false},
}
conf, err := config.Load()
if err != nil {
t.Fatal("failed to load config")
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
defer func() {
r := recover()
if tc.expectPanic && r == nil {
t.Fatal("Should have panicked")
}
if !tc.expectPanic && r != nil {
t.Fatal("Should not have panicked")
}
}()
conf.General.LedgerType = tc.ledgerType
conf.FileLedger.Location = tc.ledgerDir
conf.FileLedger.Prefix = tc.ledgerDirPrefix
lf, ld := createLedgerFactory(conf)
defer func() {
if ld != "" {
os.RemoveAll(ld)
t.Log("Removed temp dir:", ld)
}
}()
lf.ChainIDs()
})
}
} | explode_data.jsonl/23315 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 500
} | [
2830,
3393,
4021,
60850,
1389,
4153,
1155,
353,
8840,
836,
8,
341,
1444,
60639,
1669,
2193,
1944,
4202,
14592,
81731,
2648,
1820,
1155,
340,
16867,
21290,
741,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
197,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestFindAndAddNewPods_WithRescontructedVolume(t *testing.T) {
// create dswp
dswp, fakePodManager := prepareDswpWithVolume(t)
// create pod
fakeOuterVolumeName := "dswp-test-volume-name"
containers := []v1.Container{
{
VolumeMounts: []v1.VolumeMount{
{
Name: fakeOuterVolumeName,
MountPath: "/mnt",
},
},
},
}
pod := createPodWithVolume("dswp-test-pod", fakeOuterVolumeName, "file-bound", containers)
fakePodManager.AddPod(pod)
podName := util.GetUniquePodName(pod)
mode := v1.PersistentVolumeFilesystem
pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: fakeOuterVolumeName,
},
Spec: v1.PersistentVolumeSpec{
ClaimRef: &v1.ObjectReference{Namespace: "ns", Name: "file-bound"},
VolumeMode: &mode,
},
}
generatedVolumeName := "fake-plugin/" + pod.Spec.Volumes[0].Name
uniqueVolumeName := v1.UniqueVolumeName(generatedVolumeName)
expectedOuterVolumeName := "dswp-test-volume-name"
opts := operationexecutor.MarkVolumeOpts{
PodName: podName,
PodUID: pod.UID,
VolumeName: uniqueVolumeName,
OuterVolumeSpecName: generatedVolumeName, // fake reconstructed volume
VolumeGidVolume: "",
VolumeSpec: volume.NewSpecFromPersistentVolume(pv, false),
VolumeMountState: operationexecutor.VolumeMounted,
}
dswp.actualStateOfWorld.MarkVolumeAsAttached(opts.VolumeName, opts.VolumeSpec, "fake-node", "")
dswp.actualStateOfWorld.MarkVolumeAsMounted(opts)
dswp.findAndAddNewPods()
mountedVolumes := dswp.actualStateOfWorld.GetMountedVolumesForPod(podName)
found := false
for _, volume := range mountedVolumes {
if volume.OuterVolumeSpecName == expectedOuterVolumeName {
found = true
break
}
}
if !found {
t.Fatalf(
"Could not found pod volume %v in the list of actual state of world volumes to mount.",
expectedOuterVolumeName)
}
} | explode_data.jsonl/45744 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 746
} | [
2830,
3393,
9885,
3036,
2212,
3564,
23527,
82,
62,
2354,
1061,
8222,
667,
291,
18902,
1155,
353,
8840,
836,
8,
341,
197,
322,
1855,
294,
2280,
79,
198,
2698,
2280,
79,
11,
12418,
23527,
2043,
1669,
10549,
35,
2280,
79,
2354,
18902,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRob(t *testing.T) {
tests := [...]caseType{
{
input: []int{1, 2, 3, 1},
expected: 4,
},
{
input: []int{2, 7, 9, 3, 1},
expected: 12,
},
}
for _, tc := range tests {
output := rob(tc.input)
if output != tc.expected {
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
}
}
} | explode_data.jsonl/29680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
14465,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
48179,
5638,
929,
515,
197,
197,
515,
298,
22427,
25,
262,
3056,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
16,
1583,
298,
42400,
25,
220,
19,
345,
197,
197,
158... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAccessRequest(t *testing.T) {
ar := NewAccessRequest(nil)
ar.GrantTypes = Arguments{"foobar"}
ar.Client = &DefaultClient{}
ar.GrantScope("foo")
ar.SetRequestedAudience(Arguments{"foo", "foo", "bar"})
ar.SetRequestedScopes(Arguments{"foo", "foo", "bar"})
assert.True(t, ar.GetGrantedScopes().Has("foo"))
assert.NotNil(t, ar.GetRequestedAt())
assert.Equal(t, ar.GrantTypes, ar.GetGrantTypes())
assert.Equal(t, Arguments{"foo", "bar"}, ar.RequestedAudience)
assert.Equal(t, Arguments{"foo", "bar"}, ar.RequestedScope)
assert.Equal(t, ar.Client, ar.GetClient())
} | explode_data.jsonl/4227 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
6054,
1900,
1155,
353,
8840,
836,
8,
341,
69340,
1669,
1532,
6054,
1900,
27907,
340,
69340,
1224,
34434,
4173,
284,
27702,
4913,
50267,
16707,
69340,
11716,
284,
609,
3675,
2959,
16094,
69340,
1224,
34434,
10803,
445,
7975,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReconcilePropagateLabelsPending(t *testing.T) {
names.TestingSeed()
ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline}
prs := []*v1beta1.PipelineRun{{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pipeline-run-with-labels",
Namespace: "foo",
Labels: map[string]string{
"PipelineRunLabel": "PipelineRunValue",
pipeline.PipelineLabelKey: "WillNotBeUsed",
},
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{Name: "test-pipeline"},
ServiceAccountName: "test-sa",
Status: v1beta1.PipelineRunSpecStatusPending,
},
}}
ts := []*v1beta1.Task{simpleHelloWorldTask}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
_, clients := prt.reconcileRun("foo", "test-pipeline-run-with-labels", []string{}, false)
reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(prt.TestAssets.Ctx, "test-pipeline-run-with-labels", metav1.GetOptions{})
if err != nil {
t.Fatalf("unexpected error when updating status: %v", err)
}
want := "test-pipeline"
got := reconciledRun.ObjectMeta.Labels["tekton.dev/pipeline"]
if d := cmp.Diff(want, got); d != "" {
t.Errorf("expected to see label %v created. Diff %s", want, diff.PrintWantGot(d))
}
} | explode_data.jsonl/27300 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 602
} | [
2830,
3393,
693,
40446,
457,
2008,
46836,
23674,
32027,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
2822,
35009,
1669,
29838,
85,
16,
19127,
16,
1069,
8790,
90,
22944,
9707,
10134,
34656,
532,
25653,
82,
1669,
29838,
85,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUserEntityGetUniqueNOTEXIST(t *testing.T) {
resp := sendGet("http://localhost:8080/Search/User&q=NOTEXIST")
response := responseToString(resp)
compareResults(t, response, HyperText.CustomResponses["not-found-entity"])
} | explode_data.jsonl/59346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
1474,
3030,
1949,
22811,
14065,
92827,
1155,
353,
8840,
836,
8,
341,
34653,
1669,
3624,
1949,
445,
1254,
1110,
8301,
25,
23,
15,
23,
15,
78893,
33511,
62735,
28,
14065,
92827,
1138,
21735,
1669,
2033,
5870,
20267,
340,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestDataPosString(t *testing.T) {
for _, tt := range []struct {
val DataPos
want string
}{
{
val: pktData,
want: "pkt_data",
},
{
val: base64Data,
want: "base64_data",
},
{
val: httpRequestLine,
want: "http_request_line",
},
} {
s := tt.val.String()
if s != tt.want {
t.Fatalf("String: got=%v; want=%v", s, tt.want)
}
}
} | explode_data.jsonl/59695 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
93200,
4859,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
19302,
220,
2885,
4859,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
19302,
25,
220,
34654,
1043,
345,
298,
50780... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServerReduceMemoryUsageSerial(t *testing.T) {
ln := fasthttputil.NewInmemoryListener()
s := &Server{
Handler: func(ctx *RequestCtx) {},
ReduceMemoryUsage: true,
}
ch := make(chan struct{})
go func() {
if err := s.Serve(ln); err != nil {
t.Fatalf("unexpected error: %s", err)
}
close(ch)
}()
testServerRequests(t, ln)
if err := ln.Close(); err != nil {
t.Fatalf("error when closing listener: %s", err)
}
select {
case <-ch:
case <-time.After(time.Second):
t.Fatalf("timeout when waiting for the server to stop")
}
} | explode_data.jsonl/73280 | {
"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,
5475,
50325,
10642,
14783,
5915,
1155,
353,
8840,
836,
8,
341,
197,
2261,
1669,
4937,
96336,
628,
321,
7121,
641,
17269,
2743,
2822,
1903,
1669,
609,
5475,
515,
197,
197,
3050,
25,
1843,
2915,
7502,
353,
1900,
23684,
8,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestServiceInGroup(t *testing.T) {
registry := newMockRegistry()
assert.True(t, ServiceInGroup(registry, "testGroup", "testService"))
assert.False(t, ServiceInGroup(registry, "testGroup", "testNoneExistService"))
discoverErrorRegistry := newDiscoverErrorRegistry()
assert.False(t, ServiceInGroup(discoverErrorRegistry, "testGroup", "testService"))
} | explode_data.jsonl/67631 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
1860,
641,
2808,
1155,
353,
8840,
836,
8,
341,
197,
29172,
1669,
501,
11571,
15603,
741,
6948,
32443,
1155,
11,
5362,
641,
2808,
18390,
4944,
11,
330,
1944,
2808,
497,
330,
1944,
1860,
5455,
6948,
50757,
1155,
11,
5362,
64... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCustomParserBasicType(t *testing.T) {
type ConstT int32
type config struct {
Const ConstT `env:"CONST_VAL"`
}
exp := ConstT(123)
os.Setenv("CONST_VAL", fmt.Sprintf("%d", exp))
customParserFunc := func(v string) (interface{}, error) {
i, err := strconv.Atoi(v)
if err != nil {
return nil, err
}
r := ConstT(i)
return r, nil
}
cfg := &config{}
err := env.ParseWithFuncs(cfg, map[reflect.Type]env.ParserFunc{
reflect.TypeOf(ConstT(0)): customParserFunc,
})
assert.NoError(t, err)
assert.Equal(t, exp, cfg.Const)
} | explode_data.jsonl/7499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
10268,
6570,
15944,
929,
1155,
353,
8840,
836,
8,
341,
13158,
24522,
51,
526,
18,
17,
271,
13158,
2193,
2036,
341,
197,
197,
19167,
24522,
51,
1565,
3160,
2974,
41795,
6096,
8805,
197,
630,
48558,
1669,
24522,
51,
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 TestPluginScalarSerialize(t *testing.T) {
grpcClientMock, teardown := setupPluginDriverTests(t)
defer teardown(t)
plug := plugin.NewPlugin(plugin.Config{
Cmd: "fake-plugin-command",
})
defer plug.Close()
data := []struct {
in driver.ScalarSerializeInput
out driver.ScalarSerializeOutput
outErr error
}{
{
in: driver.ScalarSerializeInput{},
out: driver.ScalarSerializeOutput{},
},
{
in: driver.ScalarSerializeInput{},
out: driver.ScalarSerializeOutput{
Error: &driver.Error{
Message: "",
},
},
outErr: errors.New(""),
},
}
for _, tt := range data {
grpcClientMock.On("ScalarSerialize", tt.in).Return(tt.out, tt.outErr).Once()
out := plug.ScalarSerialize(tt.in)
assert.Equal(t, tt.out, out)
}
grpcClientMock.AssertNumberOfCalls(t, "ScalarSerialize", len(data))
} | explode_data.jsonl/37055 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 374
} | [
2830,
3393,
11546,
20639,
15680,
1155,
353,
8840,
836,
8,
341,
197,
56585,
2959,
11571,
11,
49304,
1669,
6505,
11546,
11349,
18200,
1155,
340,
16867,
49304,
1155,
340,
197,
47474,
1669,
9006,
7121,
11546,
46801,
10753,
515,
197,
6258,
227... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKafkaClient_decodeGroupMetadata_Errors(t *testing.T) {
module := fixtureModule()
module.Configure("test", "consumer.test")
for _, values := range decodeGroupMetadataErrors {
// Should not timeout
module.decodeGroupMetadata(bytes.NewBuffer(values.KeyBytes), values.ValueBytes, zap.NewNop())
}
} | explode_data.jsonl/34276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
42,
21883,
2959,
15227,
2808,
14610,
93623,
1087,
1155,
353,
8840,
836,
8,
341,
54020,
1669,
12507,
3332,
741,
54020,
78281,
445,
1944,
497,
330,
46764,
5958,
5130,
2023,
8358,
2750,
1669,
2088,
16895,
2808,
14610,
13877,
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... | 2 |
func TestLex(t *testing.T) {
files, err := filepath.Glob("tests/lex/*.in")
if err != nil {
t.Errorf("unable to find test files: %s", err)
return
}
for _, fname := range files {
runLexTest(t, "tests/lex/", fname, strings.Replace(fname, "in", "out", -1))
}
} | explode_data.jsonl/25849 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
47778,
1155,
353,
8840,
836,
8,
341,
74075,
11,
1848,
1669,
26054,
1224,
1684,
445,
23841,
14,
2571,
23540,
258,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
45928,
311,
1477,
1273,
3542,
25,
1018,
82,
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 TestApplyArgs(t *testing.T) {
cmd := []string{"echo", "something", "$3", "else", "$1", "$3"}
args := []string{"a1", "a2"}
eres := []string{"echo", "something", "$3", "else", "a1", "$3"}
res, total := ApplyArguments(cmd, args)
assert.Equal(t, eres, res)
assert.Equal(t, total, 1)
args = []string{"a1", "a2", "a3"}
eres = []string{"echo", "something", "a3", "else", "a1", "a3"}
res, total = ApplyArguments(cmd, args)
assert.Equal(t, eres, res)
assert.Equal(t, total, 3)
} | explode_data.jsonl/80380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
28497,
4117,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
3056,
917,
4913,
3047,
497,
330,
33331,
497,
5201,
18,
497,
330,
1503,
497,
5201,
16,
497,
5201,
18,
16707,
31215,
1669,
3056,
917,
4913,
64,
16,
497,
330,
64,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRegisterTestStepDoesNotValidate(t *testing.T) {
pr := NewPluginRegistry()
err := pr.RegisterTestStep("AStep", NewAStep, []event.Name{event.Name("Event which does not validate")})
require.Error(t, err)
} | explode_data.jsonl/80904 | {
"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,
8690,
2271,
8304,
21468,
2623,
17926,
1155,
353,
8840,
836,
8,
341,
25653,
1669,
1532,
11546,
15603,
741,
9859,
1669,
548,
19983,
2271,
8304,
445,
32,
8304,
497,
1532,
32,
8304,
11,
3056,
3087,
2967,
90,
3087,
2967,
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 |
func TestUpper(t *testing.T) {
cases := []struct {
s interface{}
want string
isErr bool
}{
{"test", "TEST", false},
{template.HTML("UpPeR"), "UPPER", false},
{[]byte("bytes"), "BYTES", false},
}
for i, c := range cases {
res, err := upper(c.s)
if (err != nil) != c.isErr {
t.Fatalf("[%d] unexpected isErr state: want %v, got %v, err = %v", i, c.want, (err != nil), err)
}
if res != c.want {
t.Errorf("[%d] upper failed: want %v, got %v", i, c.want, res)
}
}
} | explode_data.jsonl/9237 | {
"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,
14251,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
1903,
257,
3749,
16094,
197,
50780,
220,
914,
198,
197,
19907,
7747,
1807,
198,
197,
59403,
197,
197,
4913,
1944,
497,
330,
10033,
497,
895,
1583... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFeeBumpUpgradesV0Transaction(t *testing.T) {
kp0 := newKeypair0()
sourceAccount := NewSimpleAccount(kp0.Address(), 1)
tx, err := NewTransaction(
TransactionParams{
SourceAccount: &sourceAccount,
IncrementSequenceNum: false,
Operations: []Operation{&Inflation{}},
BaseFee: 2 * MinBaseFee,
Memo: MemoText("test-memo"),
Timebounds: NewInfiniteTimeout(),
},
)
assert.NoError(t, err)
tx, err = tx.Sign(network.TestNetworkPassphrase, kp0)
assert.NoError(t, err)
convertToV0(tx)
feeBump, err := NewFeeBumpTransaction(
FeeBumpTransactionParams{
FeeAccount: newKeypair1().Address(),
BaseFee: 3 * MinBaseFee,
Inner: tx,
},
)
assert.NoError(t, err)
assert.Equal(t, xdr.EnvelopeTypeEnvelopeTypeTx, feeBump.InnerTransaction().envelope.Type)
assert.Equal(t, xdr.EnvelopeTypeEnvelopeTypeTxV0, tx.envelope.Type)
innerHash, err := feeBump.InnerTransaction().HashHex(network.TestNetworkPassphrase)
assert.NoError(t, err)
originalHash, err := tx.HashHex(network.TestNetworkPassphrase)
assert.NoError(t, err)
assert.Equal(t, originalHash, innerHash)
assert.Equal(t, tx.Signatures(), feeBump.InnerTransaction().Signatures())
assert.Equal(t, tx.Operations(), feeBump.InnerTransaction().Operations())
assert.Equal(t, tx.MaxFee(), feeBump.InnerTransaction().MaxFee())
assert.Equal(t, tx.BaseFee(), feeBump.InnerTransaction().BaseFee())
assert.Equal(t, tx.SourceAccount(), feeBump.InnerTransaction().SourceAccount())
assert.Equal(t, tx.Memo(), feeBump.InnerTransaction().Memo())
assert.Equal(t, tx.Timebounds(), feeBump.InnerTransaction().Timebounds())
innerBase64, err := feeBump.InnerTransaction().Base64()
assert.NoError(t, err)
originalBase64, err := tx.Base64()
assert.NoError(t, err)
assert.NotEqual(t, innerBase64, originalBase64)
} | explode_data.jsonl/67674 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 759
} | [
2830,
3393,
41941,
33,
1510,
2324,
22340,
53,
15,
8070,
1155,
353,
8840,
836,
8,
341,
16463,
79,
15,
1669,
501,
6608,
1082,
1310,
15,
741,
47418,
7365,
1669,
1532,
16374,
7365,
5969,
79,
15,
26979,
1507,
220,
16,
692,
46237,
11,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_observability_PreStart(t *testing.T) {
type args struct {
ctx context.Context
}
type fields struct {
eg errgroup.Group
collector collector.Collector
tracer trace.Tracer
exporters []exporter.Exporter
profilers []profiler.Profiler
}
type want struct {
err error
}
type test struct {
name string
args args
fields fields
want want
checkFunc func(want, error) error
beforeFunc func(args)
afterFunc func(args)
}
defaultCheckFunc := func(w want, err error) error {
if !errors.Is(err, w.err) {
return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err)
}
return nil
}
tests := []test{
// TODO test cases
/*
{
name: "test_case_1",
args: args {
ctx: nil,
},
fields: fields {
eg: nil,
collector: nil,
tracer: nil,
exporters: nil,
profilers: nil,
},
want: want{},
checkFunc: defaultCheckFunc,
},
*/
// TODO test cases
/*
func() test {
return test {
name: "test_case_2",
args: args {
ctx: nil,
},
fields: fields {
eg: nil,
collector: nil,
tracer: nil,
exporters: nil,
profilers: nil,
},
want: want{},
checkFunc: defaultCheckFunc,
}
}(),
*/
}
for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(tt)
if test.beforeFunc != nil {
test.beforeFunc(test.args)
}
if test.afterFunc != nil {
defer test.afterFunc(test.args)
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
o := &observability{
eg: test.fields.eg,
collector: test.fields.collector,
tracer: test.fields.tracer,
exporters: test.fields.exporters,
profilers: test.fields.profilers,
}
err := o.PreStart(test.args.ctx)
if err := test.checkFunc(test.want, err); err != nil {
tt.Errorf("error = %v", err)
}
})
}
} | explode_data.jsonl/32268 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1132
} | [
2830,
3393,
62,
22764,
2897,
79561,
3479,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
20985,
2266,
9328,
198,
197,
532,
13158,
5043,
2036,
341,
197,
197,
791,
286,
1848,
4074,
5407,
198,
197,
1444,
24605,
269,
31953,
72... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoSuchFileP8File(t *testing.T) {
token, err := token.AuthKeyFromFile("")
assert.Equal(t, errors.New("open : no such file or directory").Error(), err.Error())
assert.Nil(t, token)
} | explode_data.jsonl/74818 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
65531,
1703,
47,
23,
1703,
1155,
353,
8840,
836,
8,
341,
43947,
11,
1848,
1669,
3950,
25233,
1592,
43633,
31764,
6948,
12808,
1155,
11,
5975,
7121,
445,
2508,
549,
902,
1741,
1034,
476,
6220,
1827,
1454,
1507,
1848,
6141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVMDetailsToSurvey(t *testing.T) {
vms := []vmDetails{
vmDetails{Zone: "us-central-1", Name: "app-central-as72"},
vmDetails{Zone: "us-west-1", Name: "db-west-09as"},
vmDetails{Zone: "eu-west-1", Name: "something-central-a7m2"},
}
response := vmDetailsToSurvey(vms)
expected := []string{
"(us-central-1) app-central-as72",
"(us-west-1) db-west-09as",
"(eu-west-1) something-central-a7m2",
}
assert.Equal(t, expected, response)
} | explode_data.jsonl/13299 | {
"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,
53,
6076,
2237,
1249,
68015,
1155,
353,
8840,
836,
8,
341,
5195,
1011,
1669,
3056,
7338,
7799,
515,
197,
54879,
7799,
90,
15363,
25,
330,
355,
84081,
12,
16,
497,
3988,
25,
330,
676,
84081,
32434,
22,
17,
7115,
197,
5487... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerHasGVK(t *testing.T) {
okClient := fakeDiscoveryClient{
results: map[string]metav1.APIResourceList{
"vegetables.k8s.io/v1": {APIResources: []metav1.APIResource{
{Kind: "Potato"},
{Kind: "Carrot"},
{Kind: "Lettuce"},
}},
"fruits.k8s.io/v1": {APIResources: []metav1.APIResource{
{Kind: "Apple"},
{Kind: "Banana"},
{Kind: "Pear"},
}},
},
}
errClient := fakeDiscoveryClient{
err: errors.New("some fake error"),
}
for _, tt := range []struct {
name string
client discovery.ServerResourcesInterface
groupVersion, kind string
wantResult bool
wantErr bool
}{
{
name: "positive case",
client: &okClient,
groupVersion: "vegetables.k8s.io/v1",
kind: "Carrot",
wantResult: true,
},
{
name: "error",
client: &errClient,
groupVersion: "vegetables.k8s.io/v1",
kind: "Carrot",
wantErr: true,
},
{
name: "gv has no such kind",
client: &okClient,
groupVersion: "vegetables.k8s.io/v1",
kind: "Australia",
wantResult: false,
},
{
name: "has kind in another gv",
client: &okClient,
groupVersion: "fruits.k8s.io/v1",
kind: "Potato",
wantResult: false,
},
{
name: "no such gv",
client: &okClient,
groupVersion: "grains.k8s.io",
kind: "Wheat",
wantResult: false,
},
} {
t.Run(tt.name, func(t *testing.T) {
gotResult, gotErr := ServerHasGVK(tt.client, tt.groupVersion, tt.kind)
if gotResult != tt.wantResult {
t.Errorf("ServerHasGVK result: got %t, want %t", gotResult, tt.wantResult)
}
if (gotErr != nil) != tt.wantErr {
t.Errorf("ServerHasGVK: got error: %v, wanted error? %t", gotErr, tt.wantErr)
}
})
}
} | explode_data.jsonl/52104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 928
} | [
2830,
3393,
5475,
10281,
39718,
42,
1155,
353,
8840,
836,
8,
341,
59268,
2959,
1669,
12418,
67400,
2959,
515,
197,
55497,
25,
2415,
14032,
60,
4059,
402,
16,
24922,
4783,
852,
515,
298,
197,
1,
82471,
4788,
5202,
23,
82,
4245,
5457,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRedisMetricsOnly(t *testing.T) {
for _, inc := range []bool{false, true} {
r := prometheus.NewRegistry()
ts := httptest.NewServer(promhttp.HandlerFor(r, promhttp.HandlerOpts{}))
_, err := NewRedisExporter(os.Getenv("TEST_REDIS_URI"), Options{Namespace: "test", Registry: r, RedisMetricsOnly: inc})
if err != nil {
t.Fatalf(`error when creating exporter with registry: %s`, err)
}
body := downloadURL(t, ts.URL+"/metrics")
if inc && strings.Contains(body, "exporter_build_info") {
t.Errorf("want metrics to include exporter_build_info, have:\n%s", body)
} else if !inc && !strings.Contains(body, "exporter_build_info") {
t.Errorf("did NOT want metrics to include exporter_build_info, have:\n%s", body)
}
ts.Close()
}
} | explode_data.jsonl/47008 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
48137,
27328,
7308,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
3625,
1669,
2088,
3056,
2641,
90,
3849,
11,
830,
92,
341,
197,
7000,
1669,
2706,
39705,
7121,
15603,
741,
197,
57441,
1669,
54320,
70334,
7121,
5475,
83332,
1254,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPodLabelsAnnotations(t *testing.T) {
annotations := map[string]string{
"testannotation": "testvalue",
}
labels := map[string]string{
"testlabel": "testvalue",
}
sset, err := makeStatefulSet(&monitoringv1.Alertmanager{
ObjectMeta: metav1.ObjectMeta{},
Spec: monitoringv1.AlertmanagerSpec{
PodMetadata: &metav1.ObjectMeta{
Annotations: annotations,
Labels: labels,
},
},
}, nil, defaultTestConfig)
require.NoError(t, err)
if _, ok := sset.Spec.Template.ObjectMeta.Labels["testlabel"]; !ok {
t.Fatal("Pod labes are not properly propagated")
}
if !reflect.DeepEqual(annotations, sset.Spec.Template.ObjectMeta.Annotations) {
t.Fatal("Pod annotaitons are not properly propagated")
}
} | explode_data.jsonl/37678 | {
"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,
23527,
23674,
21418,
1155,
353,
8840,
836,
8,
341,
197,
39626,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
1944,
24674,
788,
330,
1944,
957,
756,
197,
532,
95143,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
1944,
1502,
788... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTsValue(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderTappx, config.Adapter{
Endpoint: "http://{{.Host}}"})
if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}
bidderTappx := bidder.(*TappxAdapter)
var test int
test = 0
var tappxExt openrtb_ext.ExtImpTappx
tappxExt.Endpoint = "DUMMYENDPOINT"
tappxExt.TappxKey = "dummy-tappx-key"
url, err := bidderTappx.buildEndpointURL(&tappxExt, test)
match, err := regexp.MatchString(`http://ssp\.api\.tappx\.com/rtb/v2/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.4`, url)
if err != nil {
t.Errorf("Error while running regex validation: %s", err.Error())
return
}
assert.True(t, match)
} | explode_data.jsonl/51705 | {
"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,
52793,
1130,
1155,
353,
8840,
836,
8,
341,
2233,
307,
1107,
11,
1936,
7747,
1669,
20626,
30981,
3342,
65,
9927,
1785,
307,
1107,
51,
676,
87,
11,
2193,
34190,
515,
197,
197,
27380,
25,
330,
1254,
1110,
2979,
13,
9296,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSend(t *testing.T) {
webhookUrl := "https://hooks.slack.com/services/xxxx"
err := SendSlack(webhookUrl,
Payload{Text: "``` xiaohei```", Markdown: true})
fmt.Println(err)
} | explode_data.jsonl/76219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
11505,
1155,
353,
8840,
836,
8,
341,
97250,
20873,
2864,
1669,
330,
2428,
1110,
38560,
25101,
473,
905,
22258,
14,
18516,
698,
9859,
1669,
11000,
7442,
473,
39769,
20873,
2864,
345,
197,
10025,
6989,
90,
1178,
25,
330,
73594... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCertificate_nilPrompt(t *testing.T) {
man := &Manager{}
defer man.stopRenew()
url, finish := startACMEServerStub(t, getCertificateFromManager(man, true), "example.org")
defer finish()
man.Client = &acme.Client{DirectoryURL: url}
hello := clientHelloInfo("example.org", true)
if _, err := man.GetCertificate(hello); err == nil {
t.Error("got certificate for example.org; wanted error")
}
} | explode_data.jsonl/65047 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
1949,
33202,
36175,
54615,
1155,
353,
8840,
836,
8,
341,
197,
1515,
1669,
609,
2043,
16094,
16867,
883,
13227,
34625,
365,
741,
19320,
11,
6248,
1669,
1191,
1706,
87711,
2836,
33838,
1155,
11,
633,
33202,
3830,
2043,
60671,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPeerConnection_SetConfiguration(t *testing.T) {
// Note: These tests don't include ICEServer.Credential,
// ICEServer.CredentialType, or Certificates because those are not supported
// in the WASM bindings.
for _, test := range []struct {
name string
init func() (*PeerConnection, error)
config Configuration
wantErr error
}{
{
name: "valid",
init: func() (*PeerConnection, error) {
pc, err := NewPeerConnection(Configuration{
ICECandidatePoolSize: 5,
})
if err != nil {
return pc, err
}
err = pc.SetConfiguration(Configuration{
ICEServers: []ICEServer{
{
URLs: []string{
"stun:stun.l.google.com:19302",
},
Username: "unittest",
},
},
ICETransportPolicy: ICETransportPolicyAll,
BundlePolicy: BundlePolicyBalanced,
RTCPMuxPolicy: RTCPMuxPolicyRequire,
ICECandidatePoolSize: 5,
})
if err != nil {
return pc, err
}
return pc, nil
},
config: Configuration{},
wantErr: nil,
},
{
name: "closed connection",
init: func() (*PeerConnection, error) {
pc, err := NewPeerConnection(Configuration{})
assert.Nil(t, err)
err = pc.Close()
assert.Nil(t, err)
return pc, err
},
config: Configuration{},
wantErr: &rtcerr.InvalidStateError{Err: ErrConnectionClosed},
},
{
name: "update PeerIdentity",
init: func() (*PeerConnection, error) {
return NewPeerConnection(Configuration{})
},
config: Configuration{
PeerIdentity: "unittest",
},
wantErr: &rtcerr.InvalidModificationError{Err: ErrModifyingPeerIdentity},
},
{
name: "update BundlePolicy",
init: func() (*PeerConnection, error) {
return NewPeerConnection(Configuration{})
},
config: Configuration{
BundlePolicy: BundlePolicyMaxCompat,
},
wantErr: &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy},
},
{
name: "update RTCPMuxPolicy",
init: func() (*PeerConnection, error) {
return NewPeerConnection(Configuration{})
},
config: Configuration{
RTCPMuxPolicy: RTCPMuxPolicyNegotiate,
},
wantErr: &rtcerr.InvalidModificationError{Err: ErrModifyingRTCPMuxPolicy},
},
{
name: "update ICECandidatePoolSize",
init: func() (*PeerConnection, error) {
pc, err := NewPeerConnection(Configuration{
ICECandidatePoolSize: 0,
})
if err != nil {
return pc, err
}
offer, err := pc.CreateOffer(nil)
if err != nil {
return pc, err
}
err = pc.SetLocalDescription(offer)
if err != nil {
return pc, err
}
return pc, nil
},
config: Configuration{
ICECandidatePoolSize: 1,
},
wantErr: &rtcerr.InvalidModificationError{Err: ErrModifyingICECandidatePoolSize},
},
} {
pc, err := test.init()
if err != nil {
t.Errorf("SetConfiguration %q: init failed: %v", test.name, err)
}
err = pc.SetConfiguration(test.config)
if got, want := err, test.wantErr; !reflect.DeepEqual(got, want) {
t.Errorf("SetConfiguration %q: err = %v, want %v", test.name, got, want)
}
assert.NoError(t, pc.Close())
}
} | explode_data.jsonl/8644 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1365
} | [
2830,
3393,
30888,
4526,
14812,
7688,
1155,
353,
8840,
836,
8,
341,
197,
322,
7036,
25,
4220,
7032,
1513,
944,
2924,
19288,
1570,
2836,
727,
30320,
345,
197,
322,
19288,
1570,
2836,
727,
30320,
929,
11,
476,
15304,
24405,
1576,
1846,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRootRouteExists(t *testing.T) {
in := `
receivers:
- name: 'team-X-mails'
`
_, err := Load(in)
expected := "no routes provided"
if err == nil {
t.Fatalf("no error returned, expected:\n%q", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%q\ngot:\n%q", expected, err.Error())
}
} | explode_data.jsonl/72901 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
8439,
4899,
15575,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
22074,
53387,
1945,
510,
12,
829,
25,
364,
9196,
30550,
60220,
1248,
3989,
197,
6878,
1848,
1669,
8893,
5900,
692,
42400,
1669,
330,
2152,
11291,
3897,
1837,
743,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClock_AddOnceJob(t *testing.T) {
var (
randscope = 50 * 1000 * 1000 //随机范围
interval = time.Millisecond*100 + time.Duration(r.Intn(randscope))
myClock = Default().Reset()
jobFunc = func() {
//fmt.Println("任务事件")
}
)
//插入时间间隔≤0,应该不允许添加
if _, inserted := myClock.AddJobWithInterval(0, jobFunc); inserted {
t.Error("任务添加失败,加入了间隔时间≤0的任务。")
}
if _, inserted := myClock.AddJobWithInterval(interval, jobFunc); !inserted {
t.Error("任务添加失败,未加入任务。")
}
time.Sleep(time.Second)
if myClock.Count() != 1 {
t.Errorf("任务执行存在问题,应该执行%d次,实际执行%d次", 1, myClock.Count())
}
} | explode_data.jsonl/2016 | {
"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,
26104,
21346,
12522,
12245,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
7000,
2844,
2417,
284,
220,
20,
15,
353,
220,
16,
15,
15,
15,
353,
220,
16,
15,
15,
15,
442,
107898,
101121,
198,
197,
2084,
6152,
220,
284,
88... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseProgression_Storex(t *testing.T) {
par := MustParseProgression("A (E F) =")
if got, want := par.Storex(), "progression('A (E F) =')"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
} | explode_data.jsonl/60940 | {
"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,
14463,
9496,
290,
92684,
87,
1155,
353,
8840,
836,
8,
341,
197,
1732,
1669,
15465,
14463,
9496,
290,
445,
32,
320,
36,
434,
8,
284,
1138,
743,
2684,
11,
1366,
1669,
1346,
38047,
87,
1507,
330,
14366,
290,
492,
32,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestString(t *testing.T) {
expectPrinted(t, "a:after { content: 'a\\\rb' }", "a:after {\n content: \"ab\";\n}\n")
expectPrinted(t, "a:after { content: 'a\\\nb' }", "a:after {\n content: \"ab\";\n}\n")
expectPrinted(t, "a:after { content: 'a\\\fb' }", "a:after {\n content: \"ab\";\n}\n")
expectPrinted(t, "a:after { content: 'a\\\r\nb' }", "a:after {\n content: \"ab\";\n}\n")
expectPrinted(t, "a:after { content: 'a\\62 c' }", "a:after {\n content: \"abc\";\n}\n")
expectParseError(t, "a:after { content: '\r' }",
`<stdin>: error: Unterminated string token
<stdin>: error: Unterminated string token
<stdin>: warning: Expected "}" but found end of file
`)
expectParseError(t, "a:after { content: '\n' }",
`<stdin>: error: Unterminated string token
<stdin>: error: Unterminated string token
<stdin>: warning: Expected "}" but found end of file
`)
expectParseError(t, "a:after { content: '\f' }",
`<stdin>: error: Unterminated string token
<stdin>: error: Unterminated string token
<stdin>: warning: Expected "}" but found end of file
`)
expectParseError(t, "a:after { content: '\r\n' }",
`<stdin>: error: Unterminated string token
<stdin>: error: Unterminated string token
<stdin>: warning: Expected "}" but found end of file
`)
expectPrinted(t, "a:after { content: '\\1010101' }", "a:after {\n content: \"\U001010101\";\n}\n")
expectPrinted(t, "a:after { content: '\\invalid' }", "a:after {\n content: \"invalid\";\n}\n")
} | explode_data.jsonl/32614 | {
"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,
703,
1155,
353,
8840,
836,
8,
341,
24952,
8994,
291,
1155,
11,
330,
64,
25,
10694,
314,
2213,
25,
364,
64,
81351,
10681,
6,
335,
497,
330,
64,
25,
10694,
28152,
77,
220,
2213,
25,
7245,
370,
2105,
17882,
77,
11035,
77,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateCertificateFilesMethods(t *testing.T) {
var tests = []struct {
setupFunc func(cfg *kubeadmapi.InitConfiguration) error
createFunc func(cfg *kubeadmapi.InitConfiguration) error
expectedFiles []string
externalEtcd bool
}{
{
createFunc: CreatePKIAssets,
expectedFiles: []string{
kubeadmconstants.CACertName, kubeadmconstants.CAKeyName,
kubeadmconstants.APIServerCertName, kubeadmconstants.APIServerKeyName,
kubeadmconstants.APIServerKubeletClientCertName, kubeadmconstants.APIServerKubeletClientKeyName,
kubeadmconstants.EtcdCACertName, kubeadmconstants.EtcdCAKeyName,
kubeadmconstants.EtcdServerCertName, kubeadmconstants.EtcdServerKeyName,
kubeadmconstants.EtcdPeerCertName, kubeadmconstants.EtcdPeerKeyName,
kubeadmconstants.EtcdHealthcheckClientCertName, kubeadmconstants.EtcdHealthcheckClientKeyName,
kubeadmconstants.APIServerEtcdClientCertName, kubeadmconstants.APIServerEtcdClientKeyName,
kubeadmconstants.ServiceAccountPrivateKeyName, kubeadmconstants.ServiceAccountPublicKeyName,
kubeadmconstants.FrontProxyCACertName, kubeadmconstants.FrontProxyCAKeyName,
kubeadmconstants.FrontProxyClientCertName, kubeadmconstants.FrontProxyClientKeyName,
},
},
{
createFunc: CreatePKIAssets,
externalEtcd: true,
expectedFiles: []string{
kubeadmconstants.CACertName, kubeadmconstants.CAKeyName,
kubeadmconstants.APIServerCertName, kubeadmconstants.APIServerKeyName,
kubeadmconstants.APIServerKubeletClientCertName, kubeadmconstants.APIServerKubeletClientKeyName,
kubeadmconstants.ServiceAccountPrivateKeyName, kubeadmconstants.ServiceAccountPublicKeyName,
kubeadmconstants.FrontProxyCACertName, kubeadmconstants.FrontProxyCAKeyName,
kubeadmconstants.FrontProxyClientCertName, kubeadmconstants.FrontProxyClientKeyName,
},
},
}
for _, test := range tests {
// Create temp folder for the test case
tmpdir := testutil.SetupTempDir(t)
defer os.RemoveAll(tmpdir)
cfg := &kubeadmapi.InitConfiguration{
APIEndpoint: kubeadmapi.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
ClusterConfiguration: kubeadmapi.ClusterConfiguration{
Etcd: kubeadmapi.Etcd{Local: &kubeadmapi.LocalEtcd{}},
Networking: kubeadmapi.Networking{ServiceSubnet: "10.96.0.0/12", DNSDomain: "cluster.local"},
CertificatesDir: tmpdir,
},
NodeRegistration: kubeadmapi.NodeRegistrationOptions{Name: "valid-hostname"},
}
if test.externalEtcd {
if cfg.Etcd.External == nil {
cfg.Etcd.External = &kubeadmapi.ExternalEtcd{}
}
cfg.Etcd.Local = nil
cfg.Etcd.External.Endpoints = []string{"192.168.1.1:2379"}
}
// executes create func
if err := test.createFunc(cfg); err != nil {
t.Errorf("error executing createFunc: %v", err)
continue
}
// asserts expected files are there
testutil.AssertFileExists(t, tmpdir, test.expectedFiles...)
}
} | explode_data.jsonl/58628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1190
} | [
2830,
3393,
4021,
33202,
10809,
17856,
1155,
353,
8840,
836,
8,
1476,
2405,
7032,
284,
3056,
1235,
341,
197,
84571,
9626,
257,
2915,
28272,
353,
74,
392,
3149,
76,
2068,
26849,
7688,
8,
1465,
198,
197,
39263,
9626,
262,
2915,
28272,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRecursive(test *testing.T) {
_, err := parseRDLString(`
type Node Struct {
Node left;
String value;
Node right (optional);
}
`)
if err == nil {
test.Errorf("recursive field must be optional")
}
_, err = parseRDLString(`
type Node Struct {
Node left (optional);
String value;
Node right (optional);
}
`)
if err != nil {
test.Errorf("cannot parse valid RDL: %v", err)
}
} | explode_data.jsonl/74348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
78542,
8623,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
4715,
49,
16524,
703,
61528,
1313,
6018,
16139,
341,
220,
6018,
2115,
280,
220,
923,
897,
280,
220,
6018,
1290,
320,
12807,
317,
532,
24183,
743,
1848,
621,
2092,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestEventAggregatorByReasonMessageFunc(t *testing.T) {
expectedPrefix := "(combined from similar events): "
event1 := makeEvent("end-of-world", "it was fun", makeObjectReference("Pod", "pod1", "other"))
actual := EventAggregatorByReasonMessageFunc(&event1)
if !strings.HasPrefix(actual, expectedPrefix) {
t.Errorf("Expected %v to begin with prefix %v", actual, expectedPrefix)
}
} | explode_data.jsonl/59127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
1556,
9042,
58131,
1359,
25139,
2052,
9626,
1155,
353,
8840,
836,
8,
341,
42400,
14335,
1669,
11993,
66307,
504,
4428,
4357,
1648,
6228,
28302,
16,
1669,
1281,
1556,
445,
408,
8668,
30084,
497,
330,
275,
572,
2464,
497,
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... | 2 |
func TestYesFilter_Type(t *testing.T) {
expected := YesInternalFilter.String()
var f YesFilter
actual := f.Type().String()
if actual != expected {
t.Errorf("Type() = %v, want %v", actual, expected)
}
} | explode_data.jsonl/25903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
9454,
5632,
13729,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
7414,
11569,
5632,
6431,
741,
2405,
282,
7414,
5632,
198,
88814,
1669,
282,
10184,
1005,
703,
741,
743,
5042,
961,
3601,
341,
197,
3244,
13080,
445,
929,
368,
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
] | 2 |
func TestNextConcurrent(t *testing.T) {
skipOn(t, "broken", "freebsd")
testcases := []nextTest{
{8, 9},
{9, 10},
{10, 11},
}
protest.AllowRecording(t)
withTestProcess("parallel_next", t, func(p *proc.Target, fixture protest.Fixture) {
bp := setFunctionBreakpoint(p, t, "main.sayhi")
assertNoError(p.Continue(), t, "Continue")
f, ln := currentLineNumber(p, t)
initV := evalVariable(p, t, "n")
initVval, _ := constant.Int64Val(initV.Value)
err := p.ClearBreakpoint(bp.Addr)
assertNoError(err, t, "ClearBreakpoint()")
for _, tc := range testcases {
g, err := proc.GetG(p.CurrentThread())
assertNoError(err, t, "GetG()")
if p.SelectedGoroutine().ID != g.ID {
t.Fatalf("SelectedGoroutine not CurrentThread's goroutine: %d %d", g.ID, p.SelectedGoroutine().ID)
}
if ln != tc.begin {
t.Fatalf("Program not stopped at correct spot expected %d was %s:%d", tc.begin, filepath.Base(f), ln)
}
assertNoError(p.Next(), t, "Next() returned an error")
f, ln = assertLineNumber(p, t, tc.end, "Program did not continue to the expected location")
v := evalVariable(p, t, "n")
vval, _ := constant.Int64Val(v.Value)
if vval != initVval {
t.Fatal("Did not end up on same goroutine")
}
}
})
} | explode_data.jsonl/56206 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 525
} | [
2830,
3393,
5847,
1109,
3231,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
1925,
1155,
11,
330,
48909,
497,
330,
10593,
51835,
1138,
18185,
23910,
1669,
3056,
3600,
2271,
515,
197,
197,
90,
23,
11,
220,
24,
1583,
197,
197,
90,
24,
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... | 5 |
func TestStartAcquisitionTail(t *testing.T) {
sources := []DataSource{
&MockTail{},
}
out := make(chan types.Event)
acquisTomb := tomb.Tomb{}
go func() {
if err := StartAcquisition(sources, out, &acquisTomb); err != nil {
t.Fatalf("unexpected error")
}
}()
count := 0
READLOOP:
for {
select {
case <-out:
count++
case <-time.After(1 * time.Second):
break READLOOP
}
}
if count != 10 {
t.Fatalf("expected 10 results, got %d", count)
}
acquisTomb.Kill(nil)
time.Sleep(1 * time.Second)
if acquisTomb.Err() != nil {
t.Fatalf("unexpected tomb error %s (should be dead)", acquisTomb.Err())
}
} | explode_data.jsonl/29482 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
3479,
11654,
17204,
44795,
1155,
353,
8840,
836,
8,
341,
1903,
2360,
1669,
3056,
17173,
515,
197,
197,
5,
11571,
44795,
38837,
197,
532,
13967,
1669,
1281,
35190,
4494,
6904,
340,
81200,
9202,
51,
2855,
1669,
43080,
836,
285... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigFindDefaultVersionError(t *testing.T) {
confFile := configfile(`{"firefox":{"default":""}}`)
defer os.Remove(confFile)
conf := config.NewConfig()
conf.Load(confFile, logConfPath)
_, _, ok := conf.Find("firefox", "")
AssertThat(t, ok, Is{false})
} | explode_data.jsonl/37921 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
2648,
9885,
3675,
5637,
1454,
1155,
353,
8840,
836,
8,
341,
67850,
1703,
1669,
2193,
1192,
5809,
4913,
97912,
22317,
2258,
62366,
3417,
24183,
16867,
2643,
13270,
29879,
1703,
340,
67850,
1669,
2193,
7121,
2648,
741,
67850,
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 TestPackagerOnlyAdds(t *testing.T) {
t.Parallel()
db := makeFwdPkgDB(t, "")
shortChanID := lnwire.NewShortChanIDFromInt(1)
packager := channeldb.NewChannelPackager(shortChanID)
// To begin, there should be no forwarding packages on disk.
fwdPkgs := loadFwdPkgs(t, db, packager)
if len(fwdPkgs) != 0 {
t.Fatalf("no forwarding packages should exist, found %d", len(fwdPkgs))
}
// Next, create and write a new forwarding package that only has add
// htlcs.
fwdPkg := channeldb.NewFwdPkg(shortChanID, 0, adds, nil)
nAdds := len(adds)
if err := kvdb.Update(db, func(tx kvdb.RwTx) error {
return packager.AddFwdPkg(tx, fwdPkg)
}); err != nil {
t.Fatalf("unable to add fwd pkg: %v", err)
}
// There should now be one fwdpkg on disk. Since no forwarding decision
// has been written, we expect it to be FwdStateLockedIn. The package
// has unacked add HTLCs, so the ack filter should not be full.
fwdPkgs = loadFwdPkgs(t, db, packager)
if len(fwdPkgs) != 1 {
t.Fatalf("expected 1 fwdpkg, instead found %d", len(fwdPkgs))
}
assertFwdPkgState(t, fwdPkgs[0], channeldb.FwdStateLockedIn)
assertFwdPkgNumAddsSettleFails(t, fwdPkgs[0], nAdds, 0)
assertAckFilterIsFull(t, fwdPkgs[0], false)
// Now, write the forwarding decision. Since we have not explicitly
// added any adds to the fwdfilter, this would indicate that all of the
// adds were 1) settled locally by this link (exit hop), or 2) the htlc
// was failed locally.
if err := kvdb.Update(db, func(tx kvdb.RwTx) error {
return packager.SetFwdFilter(tx, fwdPkg.Height, fwdPkg.FwdFilter)
}); err != nil {
t.Fatalf("unable to set fwdfiter: %v", err)
}
for i := range adds {
// We should still have one package on disk. Since the forwarding
// decision has been written, it will minimally be in FwdStateProcessed.
// However not allf of the HTLCs have been acked, so should not
// have advanced further.
fwdPkgs = loadFwdPkgs(t, db, packager)
if len(fwdPkgs) != 1 {
t.Fatalf("expected 1 fwdpkg, instead found %d", len(fwdPkgs))
}
assertFwdPkgState(t, fwdPkgs[0], channeldb.FwdStateProcessed)
assertFwdPkgNumAddsSettleFails(t, fwdPkgs[0], nAdds, 0)
assertAckFilterIsFull(t, fwdPkgs[0], false)
addRef := channeldb.AddRef{
Height: fwdPkg.Height,
Index: uint16(i),
}
if err := kvdb.Update(db, func(tx kvdb.RwTx) error {
return packager.AckAddHtlcs(tx, addRef)
}); err != nil {
t.Fatalf("unable to ack add htlc: %v", err)
}
}
// We should still have one package on disk. Now that all adds have been
// acked, the ack filter should return true and the package should be
// FwdStateCompleted since there are no other settle/fail packets.
fwdPkgs = loadFwdPkgs(t, db, packager)
if len(fwdPkgs) != 1 {
t.Fatalf("expected 1 fwdpkg, instead found %d", len(fwdPkgs))
}
assertFwdPkgState(t, fwdPkgs[0], channeldb.FwdStateCompleted)
assertFwdPkgNumAddsSettleFails(t, fwdPkgs[0], nAdds, 0)
assertAckFilterIsFull(t, fwdPkgs[0], true)
// Lastly, remove the completed forwarding package from disk.
if err := kvdb.Update(db, func(tx kvdb.RwTx) error {
return packager.RemovePkg(tx, fwdPkg.Height)
}); err != nil {
t.Fatalf("unable to remove fwdpkg: %v", err)
}
// Check that the fwd package was actually removed.
fwdPkgs = loadFwdPkgs(t, db, packager)
if len(fwdPkgs) != 0 {
t.Fatalf("no forwarding packages should exist, found %d", len(fwdPkgs))
}
} | explode_data.jsonl/75198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1380
} | [
2830,
3393,
30684,
1409,
7308,
72111,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20939,
1669,
1281,
37,
6377,
47,
7351,
3506,
1155,
11,
85617,
47981,
46019,
915,
1669,
29390,
35531,
7121,
12472,
46019,
915,
3830,
1072,
7,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestShouldMountUFS(t *testing.T) {
type fields struct {
runtime *datav1alpha1.GooseFSRuntime
dataset *datav1alpha1.Dataset
name string
namespace string
Log logr.Logger
Client client.Client
}
tests := []struct {
name string
fields fields
wantShould bool
wantErr bool
}{
{
name: "test",
fields: fields{
runtime: &datav1alpha1.GooseFSRuntime{
ObjectMeta: v1.ObjectMeta{
Name: "spark",
Namespace: "default",
},
},
dataset: &datav1alpha1.Dataset{
ObjectMeta: v1.ObjectMeta{
Name: "spark",
Namespace: "default",
},
},
name: "spark",
namespace: "default",
Log: fake.NullLogger(),
},
wantShould: false,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
testObjs := []runtime.Object{}
testObjs = append(testObjs, tt.fields.runtime, tt.fields.dataset)
client := fake.NewFakeClientWithScheme(testScheme, testObjs...)
e := &GooseFSEngine{
runtime: tt.fields.runtime,
name: tt.fields.name,
namespace: tt.fields.namespace,
Log: tt.fields.Log,
Client: client,
}
patch1 := ApplyFunc(kubeclient.ExecCommandInContainer, func(podName string, containerName string, namespace string, cmd []string) (string, string, error) {
summary := mockGooseFSReportSummary()
return summary, "", nil
})
defer patch1.Reset()
gotShould, err := e.shouldMountUFS()
if (err != nil) != tt.wantErr {
t.Errorf("GooseFSEngine.shouldMountUFS() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotShould != tt.wantShould {
t.Errorf("GooseFSEngine.shouldMountUFS() = %v, want %v", gotShould, tt.wantShould)
}
})
}
} | explode_data.jsonl/70298 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 844
} | [
2830,
3393,
14996,
16284,
52,
8485,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
7000,
4466,
256,
353,
5911,
402,
16,
7141,
16,
1224,
13752,
8485,
15123,
198,
197,
2698,
8369,
256,
353,
5911,
402,
16,
7141,
16,
79356,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGameServerGetDevAddress(t *testing.T) {
devGs := &GameServer{
ObjectMeta: metav1.ObjectMeta{
Name: "dev-game",
Namespace: "default",
Annotations: map[string]string{DevAddressAnnotation: ipFixture},
},
Spec: GameServerSpec{
Ports: []GameServerPort{{HostPort: 7777, PortPolicy: Static}},
Template: corev1.PodTemplateSpec{Spec: corev1.PodSpec{
Containers: []corev1.Container{{Name: "container", Image: "container/image"}},
},
},
},
}
devAddress, isDev := devGs.GetDevAddress()
assert.True(t, isDev, "dev-game should had a dev-address")
assert.Equal(t, ipFixture, devAddress, "dev-address IP address should be 127.1.1.1")
regularGs := devGs.DeepCopy()
regularGs.ObjectMeta.Annotations = map[string]string{}
devAddress, isDev = regularGs.GetDevAddress()
assert.False(t, isDev, "dev-game should NOT have a dev-address")
assert.Equal(t, "", devAddress, "dev-address IP address should be 127.1.1.1")
} | explode_data.jsonl/19638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 362
} | [
2830,
3393,
4868,
5475,
1949,
14592,
4286,
1155,
353,
8840,
836,
8,
341,
27302,
81152,
1669,
609,
4868,
5475,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
286,
330,
3583,
19395,
756,
298,
90823,
25,
256,
330,
225... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadInvalidTemplate(t *testing.T) {
// Invalid Template
template := map[string]interface{}{
"json": "invalid",
}
// Setup ES
client := estest.GetTestingElasticsearch(t)
if err := client.Connect(); err != nil {
t.Fatal(err)
}
templateName := "invalidtemplate"
loader := &Loader{
client: client,
}
// Try to load invalid template
err := loader.LoadTemplate(templateName, template)
assert.Error(t, err)
// Make sure template was not loaded
assert.False(t, loader.CheckTemplate(templateName))
} | explode_data.jsonl/63862 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
5879,
7928,
7275,
1155,
353,
8840,
836,
8,
341,
197,
322,
13882,
14355,
198,
22832,
1669,
2415,
14032,
31344,
67066,
197,
197,
1,
2236,
788,
330,
11808,
756,
197,
630,
197,
322,
18626,
19287,
198,
25291,
1669,
1788,
477,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGlobalMemoryStatusEx(t *testing.T) {
ms, err := globalMemoryStatusEx()
if err != nil {
t.Fatal(err)
}
t.Logf("memory used %%: %d%%", ms.dwMemoryLoad)
t.Logf("total physical memory: %d", ms.ullTotalPhys)
t.Logf("avail physical memory: %d", ms.ullAvailPhys)
t.Logf("total virtual memory: %d", ms.ullTotalVirtual)
t.Logf("avail virtual memory: %d", ms.ullAvailVirtual)
t.Logf("total page file: %d", ms.ullTotalPageFile)
t.Logf("avail page file: %d", ms.ullAvailPageFile)
} | explode_data.jsonl/67704 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
11646,
10642,
2522,
840,
1155,
353,
8840,
836,
8,
341,
47691,
11,
1848,
1669,
3644,
10642,
2522,
840,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
3244,
98954,
445,
17269,
1483,
23277,
25,
1018,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAgent_RegisterService_ACLDeny(t *testing.T) {
t.Parallel()
a := NewTestAgent(t.Name(), TestACLConfig())
defer a.Shutdown()
args := &structs.ServiceDefinition{
Name: "test",
Tags: []string{"master"},
Port: 8000,
Check: structs.CheckType{
TTL: 15 * time.Second,
},
Checks: []*structs.CheckType{
&structs.CheckType{
TTL: 20 * time.Second,
},
&structs.CheckType{
TTL: 30 * time.Second,
},
},
}
t.Run("no token", func(t *testing.T) {
req, _ := http.NewRequest("PUT", "/v1/agent/service/register", jsonReader(args))
if _, err := a.srv.AgentRegisterService(nil, req); !acl.IsErrPermissionDenied(err) {
t.Fatalf("err: %v", err)
}
})
t.Run("root token", func(t *testing.T) {
req, _ := http.NewRequest("PUT", "/v1/agent/service/register?token=root", jsonReader(args))
if _, err := a.srv.AgentRegisterService(nil, req); err != nil {
t.Fatalf("err: %v", err)
}
})
} | explode_data.jsonl/33627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
16810,
73124,
1860,
97627,
23619,
88,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
3393,
55393,
2648,
2398,
16867,
264,
10849,
18452,
2822,
31215,
1669,
609,
1235,
82,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEspData_Measurement(t *testing.T) {
ts := api.UnixTime(time.Now())
temp := float32(25)
humidity := float32(33.5)
pressure := float32(1015.1)
pm25 := float32(1.8)
pm10 := float32(14.5)
m := api.Measurement{
Timestamp: &ts,
Temperature: &temp,
Humidity: &humidity,
Pressure: &pressure,
Pm25: &pm25,
Pm10: &pm10,
Aqi: nil,
}
tests := []struct {
name string
file string
want api.Measurement
}{
{name: "esp-mega-20190301", file: "esp-mega-20190301.json", want: m},
{name: "esp-mega-20190903", file: "esp-mega-20190903.json", want: m},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ed, err := testReadEspData(tt.file)
require.NoError(t, err)
got := ed.Measurement(ts)
require.Equal(t, tt.want, *got)
})
}
} | explode_data.jsonl/43005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
76954,
1043,
1245,
68,
24359,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
6330,
10616,
941,
1462,
9730,
13244,
2398,
16280,
1669,
2224,
18,
17,
7,
17,
20,
340,
9598,
73926,
1669,
2224,
18,
17,
7,
18,
18,
13,
20,
340,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseTime(t *testing.T) {
testCases := []struct {
value string
success bool
}{
// Parses 1 day successfully.
{
value: "1d",
success: true,
},
// Parses 1 week successfully.
{
value: "1w",
success: true,
},
// Parses 1 year successfully.
{
value: "1y",
success: true,
},
// Parses 2 months successfully.
{
value: "2m",
success: true,
},
// Failure to parse "xd".
{
value: "xd",
success: false,
},
// Failure to parse empty string.
{
value: "",
success: false,
},
}
for i, testCase := range testCases {
pt, err := parseTime(testCase.value)
if err != nil && testCase.success {
t.Errorf("Test: %d, Expected to be successful, but found error %s, for time value %s", i+1, err, testCase.value)
}
if pt.IsZero() && testCase.success {
t.Errorf("Test: %d, Expected time to be non zero, but found zero time for time value %s", i+1, testCase.value)
}
if err == nil && !testCase.success {
t.Errorf("Test: %d, Expected error but found to be successful for time value %s", i+1, testCase.value)
}
}
} | explode_data.jsonl/76928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 473
} | [
2830,
3393,
14463,
1462,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
16309,
256,
914,
198,
197,
30553,
1807,
198,
197,
59403,
197,
197,
322,
73430,
220,
16,
1899,
7790,
624,
197,
197,
515,
298,
16309,
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... | 8 |
func TestSwarmLeaveErrors(t *testing.T) {
testCases := []struct {
name string
args []string
swarmLeaveFunc func() error
expectedError string
}{
{
name: "too-many-args",
args: []string{"foo"},
expectedError: "accepts no argument(s)",
},
{
name: "leave-failed",
swarmLeaveFunc: func() error {
return errors.Errorf("error leaving the swarm")
},
expectedError: "error leaving the swarm",
},
}
for _, tc := range testCases {
buf := new(bytes.Buffer)
cmd := newLeaveCommand(
test.NewFakeCli(&fakeClient{
swarmLeaveFunc: tc.swarmLeaveFunc,
}, buf))
cmd.SetArgs(tc.args)
cmd.SetOutput(ioutil.Discard)
testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
} | explode_data.jsonl/74066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 337
} | [
2830,
3393,
13218,
2178,
21833,
13877,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
31215,
1843,
3056,
917,
198,
197,
77295,
2178,
21833,
9626,
2915,
368,
1465,
198,
197,
42400,
145... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatterObjectNil(test *testing.T) {
var object *struct {
Foo int
}
formatted, err := formatter.New().Format("Message {p} {p} {p2}", 3, object, "object")
assert.Nil(test, object)
assert.NoError(test, err)
assert.Equal(test, "Message 3 <nil> object", formatted)
} | explode_data.jsonl/39742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
14183,
1190,
19064,
8623,
353,
8840,
836,
8,
341,
2405,
1633,
353,
1235,
341,
197,
12727,
2624,
526,
198,
197,
630,
37410,
12127,
11,
1848,
1669,
24814,
7121,
1005,
4061,
445,
2052,
314,
79,
92,
314,
79,
92,
314,
79,
17,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDecodersReusable(t *testing.T) {
assert := assert.New(t)
testCases := []struct {
firstPayload io.Reader
secondPayload io.Reader
decoder ClientDecoder
}{
{firstPayload: getJSONPayload(), secondPayload: getJSONPayload(), decoder: newJSONDecoder()},
{firstPayload: getMsgpackPayload(), secondPayload: getMsgpackPayload(), decoder: newMsgpackDecoder()},
}
for _, tc := range testCases {
// first decoding
var firstTraces Traces
l, err := tc.decoder.Decode(tc.firstPayload, &firstTraces)
assert.Nil(err)
assert.NotEqual(0, l)
// second decoding
var secondTraces Traces
l, err = tc.decoder.Decode(tc.secondPayload, &secondTraces)
assert.Nil(err)
assert.NotEqual(0, l)
assert.Len(secondTraces, 1)
trace := secondTraces[0]
assert.Len(trace, 1)
span := trace[0]
assert.Equal(uint64(math.MaxUint64), span.TraceID)
assert.Equal(uint64(math.MaxUint64), span.SpanID)
assert.Equal(int64(math.MaxInt64), span.Duration)
assert.Equal("fennel_IS amazing!", span.Service)
assert.Equal("something &&<@# that should be a metric!", span.Name)
assert.Equal("NOT touched because it is going to be hashed", span.Resource)
assert.Equal("192.168.0.1", span.Meta["http.host"])
assert.Equal(math.MaxFloat64, span.Metrics["http.monitor"])
// the two data structures should be different because of the timestamps
assert.False(reflect.DeepEqual(firstTraces, secondTraces))
}
} | explode_data.jsonl/35761 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 547
} | [
2830,
3393,
4900,
52498,
35576,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
18185,
37302,
1669,
3056,
1235,
341,
197,
42190,
29683,
220,
6399,
47431,
198,
197,
197,
5569,
29683,
6399,
47431,
198,
197,
197,
48110,
98... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncodeInt(t *testing.T) {
for _, v := range []int{-1, 0, 1024 * 1024} {
s := strconv.Itoa(v)
resp := NewInt([]byte(s))
testEncodeAndCheck(t, resp, []byte(":"+s+"\r\n"))
}
} | explode_data.jsonl/48347 | {
"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,
32535,
1072,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
348,
1669,
2088,
3056,
396,
19999,
16,
11,
220,
15,
11,
220,
16,
15,
17,
19,
353,
220,
16,
15,
17,
19,
92,
341,
197,
1903,
1669,
33317,
64109,
3747,
340,
197,
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... | 2 |
func TestSocketWriter_unix(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "telegraf")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
sock := filepath.Join(tmpdir, "sw.TestSocketWriter_unix.sock")
listener, err := net.Listen("unix", sock)
require.NoError(t, err)
sw := newSocketWriter()
sw.Address = "unix://" + sock
err = sw.Connect()
require.NoError(t, err)
lconn, err := listener.Accept()
require.NoError(t, err)
testSocketWriter_stream(t, sw, lconn)
} | explode_data.jsonl/34019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
10286,
6492,
80572,
1155,
353,
8840,
836,
8,
341,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
15410,
76039,
1138,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
84427,
10368,
3741,
340,
85809,
1669,
26054,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInsertionSort(t *testing.T) {
var a0 = goutil.RandIntArray(10, 1000000)
// fmt.Println(a0)
InsertionSort(a0)
// fmt.Println(a0)
} | explode_data.jsonl/20289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
13780,
290,
10231,
1155,
353,
8840,
836,
8,
341,
2405,
264,
15,
284,
342,
30158,
2013,
437,
95338,
7,
16,
15,
11,
220,
16,
15,
15,
15,
15,
15,
15,
692,
197,
322,
8879,
12419,
2877,
15,
340,
197,
13780,
290,
10231,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_TableBorder_GetBorder(t *testing.T) {
config := ReadConfiguration(t)
client, ctx := PrepareTest(t, config)
remoteDataFolder := remoteBaseTestDataFolder + "/DocumentElements/Tables"
localFile := "DocumentElements/Tables/TablesGet.docx"
remoteFileName := "TestGetBorder.docx"
UploadNextFileToStorage(t, ctx, client, GetLocalFile(localFile), remoteDataFolder + "/" + remoteFileName)
options := map[string]interface{}{
"nodePath": "tables/1/rows/0/cells/0",
"folder": remoteDataFolder,
}
request := &models.GetBorderRequest{
Name: ToStringPointer(remoteFileName),
BorderType: ToStringPointer("left"),
Optionals: options,
}
actual, _, err := client.WordsApi.GetBorder(ctx, request)
if err != nil {
t.Error(err)
}
assert.NotNil(t, actual.Border, "Validate GetBorder response.");
assert.NotNil(t, actual.Border.Color, "Validate GetBorder response.");
assert.Equal(t, "#000000", actual.Border.Color.Web, "Validate GetBorder response.");
} | explode_data.jsonl/16254 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
42544,
10691,
13614,
10691,
1155,
353,
8840,
836,
8,
341,
262,
2193,
1669,
4457,
7688,
1155,
340,
262,
2943,
11,
5635,
1669,
31166,
2271,
1155,
11,
2193,
340,
262,
8699,
1043,
13682,
1669,
8699,
3978,
83920,
13682,
488,
3521... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPEXReactorRunning(t *testing.T) {
N := 3
switches := make([]*p2p.Switch, N)
// directory to store address books
dir, err := ioutil.TempDir("", "pex_reactor")
require.Nil(t, err)
defer os.RemoveAll(dir) // nolint: errcheck
books := make([]*addrBook, N)
logger := log.TestingLogger()
// create switches
for i := 0; i < N; i++ {
switches[i] = p2p.MakeSwitch(config, i, "127.0.0.1", "123.123.123", func(i int, sw *p2p.Switch) *p2p.Switch {
books[i] = NewAddrBook(filepath.Join(dir, fmt.Sprintf("addrbook%d.json", i)), false)
books[i].SetLogger(logger.With("pex", i))
sw.SetAddrBook(books[i])
sw.SetLogger(logger.With("pex", i))
r := NewPEXReactor(books[i], &PEXReactorConfig{})
r.SetLogger(logger.With("pex", i))
r.SetEnsurePeersPeriod(250 * time.Millisecond)
sw.AddReactor("pex", r)
return sw
})
}
addOtherNodeAddrToAddrBook := func(switchIndex, otherSwitchIndex int) {
addr := switches[otherSwitchIndex].NodeInfo().NetAddress()
books[switchIndex].AddAddress(addr, addr)
}
addOtherNodeAddrToAddrBook(0, 1)
addOtherNodeAddrToAddrBook(1, 0)
addOtherNodeAddrToAddrBook(2, 1)
for i, sw := range switches {
sw.AddListener(p2p.NewDefaultListener("tcp", sw.NodeInfo().ListenAddr, true, logger.With("pex", i)))
err := sw.Start() // start switch and reactors
require.Nil(t, err)
}
assertPeersWithTimeout(t, switches, 10*time.Millisecond, 10*time.Second, N-1)
// stop them
for _, s := range switches {
s.Stop()
}
} | explode_data.jsonl/6125 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 617
} | [
2830,
3393,
1740,
55,
693,
5621,
18990,
1155,
353,
8840,
836,
8,
341,
18317,
1669,
220,
18,
198,
8961,
288,
1669,
1281,
85288,
79,
17,
79,
808,
5539,
11,
451,
692,
197,
322,
6220,
311,
3553,
2621,
6467,
198,
48532,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAcquireRenewLease(t *testing.T) {
f := newFixture(t)
defer f.Close()
attrs := &subnet.LeaseAttrs{
PublicIP: mustParseIP4("1.1.1.1"),
}
l, err := f.sm.AcquireLease(f.ctx, "_", attrs)
if err != nil {
t.Fatalf("AcquireLease failed: %v", err)
}
if !mustParseIP4Net(expectedNetwork).Contains(l.Subnet.IP) {
t.Errorf("AcquireLease returned subnet not in network: %v (in %v)", l.Subnet, expectedNetwork)
}
if err = f.sm.RenewLease(f.ctx, "_", l); err != nil {
t.Errorf("RenewLease failed: %v", err)
}
} | explode_data.jsonl/69657 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
11654,
984,
34625,
365,
2304,
519,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
10421,
2822,
197,
20468,
1669,
609,
88636,
11824,
519,
53671,
515,
197,
73146,
3298,
25,
1969,
14463,
3298,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestAcme_Mux(t *testing.T) {
// uncomment to debug
logrus.SetLevel(logrus.DebugLevel)
a := New(nil)
a.challengesTokenToKey["token1"] = "auth1"
a.challengesHostToToken["domain1.example.com"] = "token1"
req, err := http.NewRequest(
"GET",
"http://domain1.example.com/.well-known/acme-challenge/token1",
nil,
)
assert.Nil(t, err, "no error during request")
w := httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 200, w.Code)
assert.Equal(t, "auth1", w.Body.String())
req, err = http.NewRequest(
"GET",
"http://domain1.example.com:8080/.well-known/acme-challenge/token1",
nil,
)
assert.Nil(t, err, "no error during request")
w = httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 200, w.Code)
assert.Equal(t, "auth1", w.Body.String())
req, err = http.NewRequest(
"GET",
"http://domain666.example.com/.well-known/acme-challenge/token1",
nil,
)
assert.Nil(t, err, "no error during request")
w = httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 404, w.Code)
req, err = http.NewRequest(
"GET",
"http://domain1.example.com/.well-known/acme-challenge/token666",
nil,
)
assert.Nil(t, err, "no error during request")
w = httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 404, w.Code)
req, err = http.NewRequest(
"GET",
"http://domain1.example.com/aasdasdas/acme-challenge/token1",
nil,
)
assert.Nil(t, err, "no error during request")
w = httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 404, w.Code)
req, err = http.NewRequest(
"GET",
"http://1.2.3.4/healthz",
nil,
)
assert.Nil(t, err, "no error during request")
w = httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 200, w.Code)
req, err = http.NewRequest(
"GET",
"http://1.2.3.4/",
nil,
)
assert.Nil(t, err, "no error during request")
w = httptest.NewRecorder()
a.Mux().ServeHTTP(w, req)
assert.Equal(t, "text/plain", w.Header().Get("Content-Type"))
assert.Equal(t, 200, w.Code)
} | explode_data.jsonl/70063 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1049
} | [
2830,
3393,
11654,
2660,
1245,
2200,
1155,
353,
8840,
836,
8,
341,
197,
322,
62073,
311,
7390,
198,
90822,
4202,
4449,
12531,
20341,
20345,
4449,
692,
11323,
1669,
1532,
27907,
340,
11323,
5329,
42370,
3323,
1249,
1592,
1183,
5839,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAccAWSDBInstance_iamAuth(t *testing.T) {
var v rds.DBInstance
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckAWSDBIAMAuth(acctest.RandInt()),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
testAccCheckAWSDBInstanceAttributes(&v),
resource.TestCheckResourceAttr(
"aws_db_instance.bar", "iam_database_authentication_enabled", "true"),
),
},
},
})
} | explode_data.jsonl/33921 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
14603,
36136,
3506,
2523,
62,
4932,
5087,
1155,
353,
8840,
836,
8,
341,
2405,
348,
435,
5356,
22537,
2523,
271,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,
2915,
368,
314,
1273,
14603,
4703,
397... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPushedMetricsToMetricsAndContext(t *testing.T) {
container := protos.PushedMetricsContainer{
NetworkId: "testNetwork",
Metrics: []*protos.PushedMetric{{
MetricName: "metricA",
Value: 10,
TimestampMS: 1234,
Labels: []*protos.LabelPair{{Name: "labelName", Value: "labelValue"}},
},
},
}
metricAndContext := pushedMetricsToMetricsAndContext(&container)
assert.Equal(t, 1, len(metricAndContext))
ctx := metricAndContext[0].Context
family := metricAndContext[0].Family
assert.NotNil(t, ctx.AdditionalContext)
assert.Equal(t, "testNetwork", ctx.AdditionalContext.(*exporters.PushedMetricContext).NetworkID)
labels := family.GetMetric()[0].Label
assert.Equal(t, 2, len(labels))
assert.True(t, tests.HasLabel(labels, metrics.NetworkLabelName, "testNetwork"))
assert.True(t, tests.HasLabel(labels, "labelName", "labelValue"))
} | explode_data.jsonl/82513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
16644,
291,
27328,
1249,
27328,
3036,
1972,
1155,
353,
8840,
836,
8,
341,
53290,
1669,
1724,
436,
34981,
291,
27328,
4502,
515,
197,
197,
12320,
764,
25,
330,
1944,
12320,
756,
197,
9209,
13468,
25,
29838,
4391,
436,
34981,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTopLevelReturnForbiddenImport(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
return
import 'foo'
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModePassThrough,
AbsOutputFile: "/out.js",
},
expectedScanLog: `entry.js: error: Top-level return cannot be used inside an ECMAScript module
entry.js: note: This file is considered an ECMAScript module because of the "import" keyword here
`,
})
} | explode_data.jsonl/38509 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
5366,
4449,
5598,
69115,
11511,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
853,
198,
571,
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 TestRejectUnknownFields_allowUnknownNonCriticals(t *testing.T) {
tests := []struct {
name string
in proto.Message
allowUnknownNonCriticals bool
wantErr error
}{
{
name: "Field that's in the reserved range, should fail by default",
in: &testdata.Customer2{
Id: 289,
Reserved: 99,
},
wantErr: &errUnknownField{
Type: "*testdata.Customer1",
TagNum: 1047,
WireType: 0,
},
},
{
name: "Field that's in the reserved range, toggle allowUnknownNonCriticals",
allowUnknownNonCriticals: true,
in: &testdata.Customer2{
Id: 289,
Reserved: 99,
},
wantErr: nil,
},
{
name: "Unknown fields that are critical, but with allowUnknownNonCriticals set",
allowUnknownNonCriticals: true,
in: &testdata.Customer2{
Id: 289,
City: testdata.Customer2_PaloAlto,
},
wantErr: &errUnknownField{
Type: "*testdata.Customer1",
TagNum: 6,
WireType: 0,
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
blob, err := proto.Marshal(tt.in)
if err != nil {
t.Fatalf("Failed to marshal input: %v", err)
}
c1 := new(testdata.Customer1)
_, gotErr := RejectUnknownFields(blob, c1, tt.allowUnknownNonCriticals)
if !reflect.DeepEqual(gotErr, tt.wantErr) {
t.Fatalf("Error mismatch\nGot:\n%s\n\nWant:\n%s", gotErr, tt.wantErr)
}
})
}
} | explode_data.jsonl/34605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 751
} | [
2830,
3393,
78413,
13790,
8941,
55731,
13790,
8121,
42008,
82,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
3824,
914,
198,
197,
17430,
5180,
18433,
8472,
198,
197,
197,
7183,
13790,
8121,
42008,
82,
1807,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPassNew(t *testing.T) {
PassNew(func(got interface{}) {
if newObj != got.(string) {
t.Errorf("PassNew() = %v, wanted %v", got, newObj)
}
})(oldObj, newObj)
} | explode_data.jsonl/45276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
12187,
3564,
1155,
353,
8840,
836,
8,
341,
10025,
395,
3564,
18552,
3268,
354,
3749,
28875,
341,
197,
743,
74259,
961,
2684,
12832,
917,
8,
341,
298,
3244,
13080,
445,
12187,
3564,
368,
284,
1018,
85,
11,
4829,
1018,
85,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParse_Errors(t *testing.T) {
for _, tt := range []struct {
tmpl string
good string
bad string
}{
// Second argument to derivative must be duration
{tmpl: `SELECT derivative(f, %s) FROM m`, good: "1h", bad: "true"},
} {
good := fmt.Sprintf(tt.tmpl, tt.good)
if _, err := influxql.ParseStatement(good); err != nil {
t.Fatalf("statement %q should have parsed correctly but returned error: %s", good, err)
}
bad := fmt.Sprintf(tt.tmpl, tt.bad)
if _, err := influxql.ParseStatement(bad); err == nil {
t.Fatalf("statement %q should have resulted in a parse error but did not", bad)
}
}
} | explode_data.jsonl/28586 | {
"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,
14463,
93623,
1087,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
3244,
54010,
914,
198,
197,
3174,
1386,
914,
198,
197,
2233,
329,
220,
914,
198,
197,
59403,
197,
197,
322,
10440,
5693... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPolicyDto_ApplicationJson(t *testing.T) {
var dto = serverguard.PolicyDto{RefuseResponse: `{\"success\": true, \"msg\": \"访问频繁\"}`}
if dto.RefuseResonseCanBeJson() {
t.Fatal("the refuseResponse can not be json")
}
dto.RefuseResponse = `{"success": true, "msg": "访问频繁"}`
if !dto.RefuseResonseCanBeJson() {
t.Fatal("the refuseResponse can be json")
}
} | explode_data.jsonl/1814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
13825,
14797,
96579,
5014,
1155,
353,
8840,
836,
8,
341,
2405,
28335,
284,
3538,
26098,
1069,
8018,
14797,
90,
3945,
810,
2582,
25,
53692,
2105,
5630,
11693,
830,
11,
7245,
3236,
11693,
7245,
104925,
106689,
2105,
44099,
743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseInt(t *testing.T) {
var tcs = []struct {
name string
input string
expected int
}{
{
name: tt.Name{
Given: "string",
When: "the value is valid",
Then: "return valid int",
}.Construct(),
input: "123",
expected: 123,
},
{
name: tt.Name{
Given: "string",
When: "the value is invalid",
Then: "return empty int",
}.Construct(),
input: "123x",
expected: 0,
},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
actual := ParseInt(tc.input)
tt.Equal(t, tc.expected, actual)
})
}
} | explode_data.jsonl/9689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
14463,
1072,
1155,
353,
8840,
836,
8,
341,
2405,
259,
4837,
284,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
914,
198,
197,
42400,
526,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
17853,
2967,
515,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStartWithdrawal(t *testing.T) {
tearDown, pool, store := vp.TstCreatePoolAndTxStore(t)
defer tearDown()
mgr := pool.Manager()
masters := []*hdkeychain.ExtendedKey{
vp.TstCreateMasterKey(t, bytes.Repeat([]byte{0x00, 0x01}, 16)),
vp.TstCreateMasterKey(t, bytes.Repeat([]byte{0x02, 0x01}, 16)),
vp.TstCreateMasterKey(t, bytes.Repeat([]byte{0x03, 0x01}, 16))}
def := vp.TstCreateSeriesDef(t, pool, 2, masters)
vp.TstCreateSeries(t, pool, []vp.TstSeriesDef{def})
// Create eligible inputs and the list of outputs we need to fulfil.
vp.TstCreateCreditsOnSeries(t, pool, def.SeriesID, []int64{5e6, 4e6}, store)
address1 := "34eVkREKgvvGASZW7hkgE2uNc1yycntMK6"
address2 := "3PbExiaztsSYgh6zeMswC49hLUwhTQ86XG"
requests := []vp.OutputRequest{
vp.TstNewOutputRequest(t, 1, address1, 4e6, mgr.ChainParams()),
vp.TstNewOutputRequest(t, 2, address2, 1e6, mgr.ChainParams()),
}
changeStart := vp.TstNewChangeAddress(t, pool, def.SeriesID, 0)
startAddr := vp.TstNewWithdrawalAddress(t, pool, def.SeriesID, 0, 0)
lastSeriesID := def.SeriesID
dustThreshold := btcutil.Amount(1e4)
currentBlock := int32(vp.TstInputsBlock + vp.TstEligibleInputMinConfirmations + 1)
var status *vp.WithdrawalStatus
var err error
vp.TstRunWithManagerUnlocked(t, mgr, func() {
status, err = pool.StartWithdrawal(0, requests, *startAddr, lastSeriesID, *changeStart,
store, currentBlock, dustThreshold)
})
if err != nil {
t.Fatal(err)
}
// Check that all outputs were successfully fulfilled.
checkWithdrawalOutputs(t, status, map[string]btcutil.Amount{address1: 4e6, address2: 1e6})
if status.Fees() != btcutil.Amount(1e3) {
t.Fatalf("Wrong amount for fees; got %v, want %v", status.Fees(), btcutil.Amount(1e3))
}
// This withdrawal generated a single transaction with just one change
// output, so the next change address will be on the same series with the
// index incremented by 1.
nextChangeAddr := status.NextChangeAddr()
if nextChangeAddr.SeriesID() != changeStart.SeriesID() {
t.Fatalf("Wrong nextChangeStart series; got %d, want %d", nextChangeAddr.SeriesID(),
changeStart.SeriesID())
}
if nextChangeAddr.Index() != changeStart.Index()+1 {
t.Fatalf("Wrong nextChangeStart index; got %d, want %d", nextChangeAddr.Index(),
changeStart.Index()+1)
}
// NOTE: The ntxid is deterministic so we hardcode it here, but if the test
// or the code is changed in a way that causes the generated transaction to
// change (e.g. different inputs/outputs), the ntxid will change too and
// this will have to be updated.
ntxid := vp.Ntxid("eb753083db55bd0ad2eb184bfd196a7ea8b90eaa000d9293e892999695af2519")
txSigs := status.Sigs()[ntxid]
// Finally we use SignTx() to construct the SignatureScripts (using the raw
// signatures). Must unlock the manager as signing involves looking up the
// redeem script, which is stored encrypted.
msgtx := status.TstGetMsgTx(ntxid)
vp.TstRunWithManagerUnlocked(t, mgr, func() {
if err = vp.SignTx(msgtx, txSigs, mgr, store); err != nil {
t.Fatal(err)
}
})
} | explode_data.jsonl/82311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1167
} | [
2830,
3393,
3479,
92261,
278,
1155,
353,
8840,
836,
8,
341,
197,
82892,
11,
7314,
11,
3553,
1669,
34823,
836,
267,
4021,
10551,
3036,
31584,
6093,
1155,
340,
16867,
32825,
741,
2109,
901,
1669,
7314,
58298,
2822,
2109,
14199,
1669,
2983... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEtcdUpdatePodNotScheduled(t *testing.T) {
ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true
key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"},
}), 1)
registry := NewTestEtcdRegistry(fakeClient)
podIn := api.Pod{
TypeMeta: api.TypeMeta{ID: "foo", ResourceVersion: "1"},
Labels: map[string]string{
"foo": "bar",
},
}
err := registry.UpdatePod(ctx, &podIn)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
response, err := fakeClient.Get(key, false, false)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
var podOut api.Pod
latest.Codec.DecodeInto([]byte(response.Node.Value), &podOut)
if !reflect.DeepEqual(podOut, podIn) {
t.Errorf("expected: %v, got: %v", podOut, podIn)
}
} | explode_data.jsonl/8147 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
31860,
4385,
4289,
23527,
2623,
88137,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6330,
7121,
3675,
1972,
741,
1166,
726,
2959,
1669,
7375,
7121,
52317,
31860,
4385,
2959,
1155,
340,
1166,
726,
2959,
8787,
1552,
284,
830,
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... | 4 |
func TestUnmarshalSignedAttribute(t *testing.T) {
cert, err := createTestCertificate(x509.SHA512WithRSA)
if err != nil {
t.Fatal(err)
}
content := []byte("Hello World")
toBeSigned, err := NewSignedData(content)
if err != nil {
t.Fatalf("Cannot initialize signed data: %s", err)
}
oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7}
testValue := "TestValue"
if err := toBeSigned.AddSigner(cert.Certificate, *cert.PrivateKey, SignerInfoConfig{
ExtraSignedAttributes: []Attribute{Attribute{Type: oidTest, Value: testValue}},
}); err != nil {
t.Fatalf("Cannot add signer: %s", err)
}
signed, err := toBeSigned.Finish()
if err != nil {
t.Fatalf("Cannot finish signing data: %s", err)
}
p7, err := Parse(signed)
if err != nil {
t.Fatalf("Cannot parse signed data: %v", err)
}
var actual string
err = p7.UnmarshalSignedAttribute(oidTest, &actual)
if err != nil {
t.Fatalf("Cannot unmarshal test value: %s", err)
}
if testValue != actual {
t.Errorf("Attribute does not match test value\n\tExpected: %s\n\tActual: %s", testValue, actual)
}
} | explode_data.jsonl/25098 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
1806,
27121,
49312,
3907,
1155,
353,
8840,
836,
8,
341,
1444,
529,
11,
1848,
1669,
1855,
2271,
33202,
2075,
20,
15,
24,
808,
17020,
20,
16,
17,
2354,
73564,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestRequest_DangerousContext(t *testing.T) {
tests := []struct {
name string
request *alice.Request
want bool
}{
{
name: "",
request: getReq(0),
want: false,
}, {
name: "",
request: getReq(1),
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req := tt.request
if got := req.DangerousContext(); got != tt.want {
t.Errorf("Request.DangerousContext() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/18226 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
1900,
1557,
4003,
782,
1972,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
23555,
353,
63195,
9659,
198,
197,
50780,
262,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
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 TestPostNotificationGetSenderName(t *testing.T) {
th := Setup(t)
defer th.TearDown()
defaultChannel := &model.Channel{Type: model.CHANNEL_OPEN}
defaultPost := &model.Post{Props: model.StringInterface{}}
sender := &model.User{Id: model.NewId(), Username: "sender", FirstName: "Sender", LastName: "Sender", Nickname: "Sender"}
overriddenPost := &model.Post{
Props: model.StringInterface{
"override_username": "Overridden",
"from_webhook": "true",
},
}
for name, testCase := range map[string]struct {
channel *model.Channel
post *model.Post
nameFormat string
allowOverrides bool
expected string
}{
"name format unspecified": {
expected: sender.Username,
},
"name format username": {
nameFormat: model.SHOW_USERNAME,
expected: sender.Username,
},
"name format full name": {
nameFormat: model.SHOW_FULLNAME,
expected: sender.FirstName + " " + sender.LastName,
},
"name format nickname": {
nameFormat: model.SHOW_NICKNAME_FULLNAME,
expected: sender.Nickname,
},
"system message": {
post: &model.Post{Type: model.POST_SYSTEM_MESSAGE_PREFIX + "custom"},
expected: utils.T("system.message.name"),
},
"overridden username": {
post: overriddenPost,
allowOverrides: true,
expected: overriddenPost.Props["override_username"].(string),
},
"overridden username, direct channel": {
channel: &model.Channel{Type: model.CHANNEL_DIRECT},
post: overriddenPost,
allowOverrides: true,
expected: sender.Username,
},
"overridden username, overrides disabled": {
post: overriddenPost,
allowOverrides: false,
expected: sender.Username,
},
} {
t.Run(name, func(t *testing.T) {
channel := defaultChannel
if testCase.channel != nil {
channel = testCase.channel
}
post := defaultPost
if testCase.post != nil {
post = testCase.post
}
notification := &postNotification{
channel: channel,
post: post,
sender: sender,
}
assert.Equal(t, testCase.expected, notification.GetSenderName(testCase.nameFormat, testCase.allowOverrides))
})
}
} | explode_data.jsonl/28311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 906
} | [
2830,
3393,
4133,
11196,
1949,
20381,
675,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
340,
16867,
270,
836,
682,
4454,
2822,
11940,
9629,
1669,
609,
2528,
38716,
90,
929,
25,
1614,
37465,
17901,
24070,
532,
11940,
4133,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetTargetsDirError(t *testing.T) {
testDir, err := initTestFiles(map[string]string{
"foo_benthos_test.yaml": `tests: [{}]`,
"bar.yaml": `foobar: {}`,
"bar_benthos_test.yaml": `tests: [{}]`,
})
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(testDir)
if _, err = test.GetTestTargets(testDir, "_benthos_test", false); err == nil {
t.Error("Expected error")
}
} | explode_data.jsonl/34065 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
1949,
49030,
6184,
1454,
1155,
353,
8840,
836,
8,
341,
18185,
6184,
11,
1848,
1669,
2930,
2271,
10809,
9147,
14032,
30953,
515,
197,
197,
1,
7975,
880,
20684,
436,
4452,
33406,
788,
1565,
23841,
25,
508,
78134,
12892,
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 TestServer_Request_Post_Body_ContentLength_TooSmall(t *testing.T) {
testBodyContentsFail(t, 4, "sender tried to send more than declared Content-Length of 4 bytes",
func(st *serverTester) {
st.writeHeaders(HeadersFrameParam{
StreamID: 1, // clients send odd numbers
BlockFragment: st.encodeHeader(
":method", "POST",
"content-length", "4",
),
EndStream: false, // to say DATA frames are coming
EndHeaders: true,
})
st.writeData(1, true, []byte("12345"))
})
} | explode_data.jsonl/71613 | {
"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,
5475,
44024,
66726,
1668,
1076,
78383,
4373,
1139,
2624,
25307,
1155,
353,
8840,
836,
8,
341,
18185,
5444,
14803,
19524,
1155,
11,
220,
19,
11,
330,
11644,
6679,
311,
3624,
803,
1091,
14275,
8883,
52493,
315,
220,
19,
5820,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRenderWithInvalidTemplate(t *testing.T) {
t.Parallel()
cfg, fs := newTestCfg()
writeSource(t, fs, filepath.Join("content", "foo.md"), "foo")
withTemplate := createWithTemplateFromNameValues("missing", templateMissingFunc)
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg, WithTemplate: withTemplate}, BuildCfg{})
errCount := s.Log.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError)
// TODO(bep) clean up the template error handling
// The template errors are stored in a slice etc. so we get 4 log entries
// When we should get only 1
if errCount == 0 {
t.Fatalf("Expecting the template to log 1 ERROR, got %d", errCount)
}
} | explode_data.jsonl/40663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
6750,
2354,
7928,
7275,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
11,
8619,
1669,
501,
2271,
42467,
2822,
24945,
3608,
1155,
11,
8619,
11,
26054,
22363,
445,
1796,
497,
330,
7975,
21324,
3975,
330,
7975,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetDeleteCASTemplate(t *testing.T) {
sc := &v1_storage.StorageClass{}
sc.Annotations = make(map[string]string)
tests := map[string]struct {
scDeleteCASAnnotation string
scCASTypeAnnotation string
envJivaCAST string
envCStorCAST string
expectedCAST string
}{
"CAST annotation is present": {
"cast-read-from-annotation",
"",
"",
"",
"cast-read-from-annotation",
},
"CAST annotation is absent/empty and cas type is cstor": {
"",
"cstor",
"",
"cast-cstor-read-from-env",
"cast-cstor-read-from-env",
},
"CAST annotation is absent/empty and cas type is jiva": {
"",
"jiva",
"cast-jiva-read-from-env",
"",
"cast-jiva-read-from-env",
},
"CAST annotation is absent/empty and cas type unknown": {
"",
"unknown",
"cast-jiva-read-from-env",
"cast-cstor-read-from-env",
"",
},
}
defer func() {
os.Unsetenv(string(menv.CASTemplateToDeleteCStorSnapshotENVK))
os.Unsetenv(string(menv.CASTemplateToDeleteJivaSnapshotENVK))
}()
for name, test := range tests {
t.Run(name, func(t *testing.T) {
sc.Annotations[string(v1alpha1.CASTemplateKeyForSnapshotDelete)] = test.scDeleteCASAnnotation
sc.Annotations[string(v1alpha1.CASTypeKey)] = test.scCASTypeAnnotation
os.Setenv(string(menv.CASTemplateToDeleteCStorSnapshotENVK), test.envCStorCAST)
os.Setenv(string(menv.CASTemplateToDeleteJivaSnapshotENVK), test.envJivaCAST)
castName := getDeleteCASTemplate(sc)
if castName != test.expectedCAST {
t.Fatalf("unexpected cast name, wanted %q got %q", test.expectedCAST, castName)
}
})
}
} | explode_data.jsonl/563 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 713
} | [
2830,
3393,
1949,
6435,
34163,
3708,
1155,
353,
8840,
836,
8,
341,
29928,
1669,
609,
85,
16,
23310,
43771,
1957,
16094,
29928,
91172,
284,
1281,
9147,
14032,
30953,
340,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
29928,
6435,
87516,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitializeSessionTimers(t *testing.T) {
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
defer s1.Shutdown()
testrpc.WaitForLeader(t, s1.RPC, "dc1")
state := s1.fsm.State()
if err := state.EnsureNode(1, &structs.Node{Node: "foo", Address: "127.0.0.1"}); err != nil {
t.Fatalf("err: %s", err)
}
session := &structs.Session{
ID: generateUUID(),
Node: "foo",
TTL: "10s",
}
if err := state.SessionCreate(100, session); err != nil {
t.Fatalf("err: %v", err)
}
// Reset the session timers
err := s1.initializeSessionTimers()
if err != nil {
t.Fatalf("err: %v", err)
}
// Check that we have a timer
_, ok := s1.sessionTimers[session.ID]
if !ok {
t.Fatalf("missing session timer")
}
} | explode_data.jsonl/35327 | {
"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,
9928,
5283,
20217,
388,
1155,
353,
8840,
836,
8,
341,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
1155,
340,
16867,
2643,
84427,
14161,
16,
340,
16867,
274,
16,
10849,
18452,
2822,
18185,
29414,
99153,
52621,
1155,
11,
274,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.