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 TestRemove(t *testing.T) {
t.Parallel()
hCopy := sample(t)
equals(t, len(hCopy.records[1].Hostnames), 2)
hCopy.Remove("bazbaz")
equals(t, len(hCopy.records[1].Hostnames), 1)
ok := hCopy.records[1].Hostnames["blahbar"]
assert(t, ok, "item \"blahbar\" not found in %v", hCopy.records[1].Hostnames)
hCopy.Remove("blahbar")
equals(t, len(hCopy.records), 1)
} | explode_data.jsonl/43701 | {
"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,
13021,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
9598,
12106,
1669,
6077,
1155,
340,
197,
7176,
1155,
11,
2422,
3203,
12106,
64516,
58,
16,
936,
9296,
11400,
701,
220,
17,
340,
9598,
12106,
13270,
445,
42573,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSend(t *testing.T) {
v := &validator{}
v.queue = "send-validator"
v.start()
b := NewBroker()
b.Start(func(m ezbus.Message) error {
return nil
})
h := make(map[string]string)
h[headers.MessageName] = "validation-message"
m := ezbus.NewMessage(h, []byte("message-body-sent"))
err := b.Send("send-validator", m)
if err != nil {
t.Errorf("Failed to send message: %s", err.Error())
}
v.waitOne()
assert.Equal(t, "message-body-sent", string(v.m.Body))
} | explode_data.jsonl/61032 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
11505,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
609,
16112,
16094,
5195,
29598,
284,
330,
6681,
78574,
698,
5195,
4962,
2822,
2233,
1669,
1532,
65545,
741,
2233,
12101,
18552,
1255,
43320,
10338,
8472,
8,
1465,
341,
197,
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,
1,
1,
1,
1,
1,
1... | 1 |
func TestPageTokenDecode(t *testing.T) {
tests := []struct {
input string
expect *PageToken
pass bool
}{
{"_wMAAA==", &PageToken{Limit: 1023}, true},
{"LQAJAA==", &PageToken{Limit: 45, Page: 9}, true},
// incorrectly base64-encoded data
{"basdfasdf", nil, false},
// empty string is valid base64, but fails binary decode
{"", nil, false},
}
for i, tt := range tests {
tok, err := decodePageToken(tt.input)
if (err == nil) != tt.pass {
t.Errorf("case %d: expected pass=%t, got err=%v", i, tt.pass, err)
continue
}
if !reflect.DeepEqual(tok, tt.expect) {
t.Errorf("case %d: expected %v, got %v", i, tt.expect, tok)
}
}
} | explode_data.jsonl/14974 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
2665,
3323,
32564,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
220,
914,
198,
197,
24952,
353,
2665,
3323,
198,
197,
41431,
256,
1807,
198,
197,
59403,
197,
197,
4913,
62,
86,
4835,
6029,
418,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_almaOSAnalyzer_Analyze(t *testing.T) {
tests := []struct {
name string
inputFile string
want *analyzer.AnalysisResult
wantErr string
}{
{
name: "happy path",
inputFile: "testdata/alma/almalinux-release",
want: &analyzer.AnalysisResult{
OS: &types.OS{Family: "alma", Name: "8.4"},
},
},
{
name: "sad path",
inputFile: "testdata/not_redhatbase/empty",
wantErr: "alma: unable to analyze OS information",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := almaOSAnalyzer{}
b, err := os.ReadFile(tt.inputFile)
require.NoError(t, err)
got, err := a.Analyze(analyzer.AnalysisTarget{
FilePath: "etc/almalinux-release",
Content: b,
})
if tt.wantErr != "" {
require.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
return
}
require.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/57170 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 450
} | [
2830,
3393,
8418,
1728,
3126,
54911,
32699,
55856,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
22427,
1703,
914,
198,
197,
50780,
414,
353,
276,
27165,
8624,
9092,
2077,
198,
197,
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... | 2 |
func TestReconcileWithTaskResultsInFinalTasks(t *testing.T) {
names.TestingSeed()
ps := []*v1beta1.Pipeline{parse.MustParsePipeline(t, `
metadata:
name: test-pipeline
namespace: foo
spec:
finally:
- name: final-task-1
params:
- name: finalParam
value: $(tasks.dag-task-1.results.aResult)
taskRef:
name: final-task
- name: final-task-2
params:
- name: finalParam
value: $(tasks.dag-task-2.results.aResult)
taskRef:
name: final-task
- name: final-task-3
params:
- name: finalParam
value: param
taskRef:
name: final-task
when:
- input: $(tasks.dag-task-1.results.aResult)
operator: notin
values:
- aResultValue
- name: final-task-4
params:
- name: finalParam
value: param
taskRef:
name: final-task
when:
- input: $(tasks.dag-task-1.results.aResult)
operator: in
values:
- aResultValue
- name: final-task-5
params:
- name: finalParam
value: param
taskRef:
name: final-task
when:
- input: $(tasks.dag-task-2.results.aResult)
operator: notin
values:
- aResultValue
- name: final-task-6
params:
- name: finalParam
value: $(tasks.dag-task-2.results.aResult)
taskRef:
name: final-task
when:
- input: $(tasks.dag-task-1.results.aResult)
operator: in
values:
- aResultValue
tasks:
- name: dag-task-1
taskRef:
name: dag-task
- name: dag-task-2
taskRef:
name: dag-task
`)}
prs := []*v1beta1.PipelineRun{parse.MustParsePipelineRun(t, `
metadata:
name: test-pipeline-run-final-task-results
namespace: foo
spec:
pipelineRef:
name: test-pipeline
serviceAccountName: test-sa-0
`)}
ts := []*v1beta1.Task{
parse.MustParseTask(t, `
metadata:
name: dag-task
namespace: foo
`),
parse.MustParseTask(t, `
metadata:
name: final-task
namespace: foo
spec:
params:
- name: finalParam
type: string
`),
}
trs := []*v1beta1.TaskRun{
mustParseTaskRunWithObjectMeta(t,
taskRunObjectMeta("test-pipeline-run-final-task-results-dag-task-1-xxyyy", "foo",
"test-pipeline-run-final-task-results", "test-pipeline", "dag-task-1", false),
`
spec:
serviceAccountName: test-sa
taskRef:
name: hello-world
status:
conditions:
- reason: Succeeded
status: "True"
type: Succeeded
taskResults:
- name: aResult
value: aResultValue
`),
mustParseTaskRunWithObjectMeta(t,
taskRunObjectMeta("test-pipeline-run-final-task-results-dag-task-2-xxyyy", "foo",
"test-pipeline-run-final-task-results", "test-pipeline", "dag-task-2", false),
`
spec:
serviceAccountName: test-sa
taskRef:
name: hello-world
status:
conditions:
- lastTransitionTime: null
status: "False"
type: Succeeded
`),
}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
TaskRuns: trs,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-final-task-results", []string{}, false)
expectedTaskRunName := "test-pipeline-run-final-task-results-final-task-1"
expectedTaskRunObjectMeta := taskRunObjectMeta("test-pipeline-run-final-task-results-final-task-1", "foo",
"test-pipeline-run-final-task-results", "test-pipeline", "final-task-1", true)
expectedTaskRunObjectMeta.Labels[pipeline.MemberOfLabelKey] = v1beta1.PipelineFinallyTasks
expectedTaskRun := mustParseTaskRunWithObjectMeta(t, expectedTaskRunObjectMeta, `
spec:
params:
- name: finalParam
value: aResultValue
resources: {}
serviceAccountName: test-sa-0
taskRef:
name: final-task
timeout: 1h0m0s
`)
// Check that the expected TaskRun was created
actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{
LabelSelector: "tekton.dev/pipelineTask=final-task-1,tekton.dev/pipelineRun=test-pipeline-run-final-task-results",
Limit: 1,
})
if err != nil {
t.Fatalf("Failure to list TaskRun's %s", err)
}
if len(actual.Items) != 1 {
t.Fatalf("Expected 1 TaskRuns got %d", len(actual.Items))
}
actualTaskRun := actual.Items[0]
if d := cmp.Diff(*expectedTaskRun, actualTaskRun, ignoreResourceVersion, ignoreTypeMeta); d != "" {
t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRunName, diff.PrintWantGot(d))
}
expectedSkippedTasks := []v1beta1.SkippedTask{{
Name: "final-task-2",
}, {
Name: "final-task-3",
WhenExpressions: v1beta1.WhenExpressions{{
Input: "aResultValue",
Operator: "notin",
Values: []string{"aResultValue"},
}},
}, {
Name: "final-task-5",
}, {
Name: "final-task-6",
}}
if d := cmp.Diff(expectedSkippedTasks, reconciledRun.Status.SkippedTasks); d != "" {
t.Fatalf("Didn't get the expected list of skipped tasks. Diff: %s", diff.PrintWantGot(d))
}
} | explode_data.jsonl/27330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2094
} | [
2830,
3393,
693,
40446,
457,
2354,
6262,
9801,
641,
19357,
25449,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
2822,
35009,
1669,
29838,
85,
16,
19127,
16,
1069,
8790,
90,
6400,
50463,
14463,
34656,
1155,
11,
22074,
17637,
510... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDomainRecord_String(t *testing.T) {
record := &DomainRecord{
ID: 1,
Type: "CNAME",
Name: "example",
Data: "@",
Priority: 10,
Port: 10,
TTL: 1800,
Weight: 10,
Flags: 1,
Tag: "test",
}
stringified := record.String()
expected := `godo.DomainRecord{ID:1, Type:"CNAME", Name:"example", Data:"@", Priority:10, Port:10, TTL:1800, Weight:10, Flags:1, Tag:"test"}`
if expected != stringified {
t.Errorf("DomainRecord.String returned %+v, expected %+v", stringified, expected)
}
} | explode_data.jsonl/22680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
13636,
6471,
31777,
1155,
353,
8840,
836,
8,
341,
71952,
1669,
609,
13636,
6471,
515,
197,
29580,
25,
981,
220,
16,
345,
197,
27725,
25,
257,
330,
34,
7535,
756,
197,
21297,
25,
257,
330,
8687,
756,
197,
40927,
25,
257,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPut(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(HandlePut))
defer srv.Close()
url := "http://" + srv.Listener.Addr().String()
res := structType{}
resp, err := Put(url, &fooStruct, &res, nil)
if err != nil {
t.Error(err)
}
assert.Equal(t, resp.Status(), 200)
// Server should return NO data
assert.Equal(t, resp.RawText(), "")
} | explode_data.jsonl/14815 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
19103,
1155,
353,
8840,
836,
8,
341,
1903,
10553,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
90832,
19103,
1171,
16867,
43578,
10421,
741,
19320,
1669,
330,
1254,
52136,
488,
43578,
64091,
93626,
1005,
703,
741,
10202,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDependencies(t *testing.T) {
tests := []struct {
description string
manifests []string
expected []string
}{
{
description: "no manifest",
manifests: []string(nil),
expected: []string(nil),
},
{
description: "missing manifest file",
manifests: []string{"missing.yaml"},
expected: []string(nil),
},
{
description: "ignore non-manifest",
manifests: []string{"*.ignored"},
expected: []string(nil),
},
{
description: "single manifest",
manifests: []string{"deployment.yaml"},
expected: []string{"deployment.yaml"},
},
{
description: "keep manifests order",
manifests: []string{"01_name.yaml", "00_service.yaml"},
expected: []string{"01_name.yaml", "00_service.yaml"},
},
{
description: "sort children",
manifests: []string{"01/*.yaml", "00/*.yaml"},
expected: []string{filepath.Join("01", "a.yaml"), filepath.Join("01", "b.yaml"), filepath.Join("00", "a.yaml"), filepath.Join("00", "b.yaml")},
},
{
description: "http manifest",
manifests: []string{"deployment.yaml", "http://remote.yaml"},
expected: []string{"deployment.yaml"},
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.NewTempDir().
Touch("deployment.yaml", "01_name.yaml", "00_service.yaml", "empty.ignored").
Touch("01/a.yaml", "01/b.yaml").
Touch("00/b.yaml", "00/a.yaml").
Chdir()
k, err := NewDeployer(&kubectlConfig{}, &label.DefaultLabeller{}, &latestV1.KubectlDeploy{Manifests: test.manifests})
t.RequireNoError(err)
dependencies, err := k.Dependencies()
t.CheckNoError(err)
t.CheckDeepEqual(test.expected, dependencies)
})
}
} | explode_data.jsonl/52880 | {
"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,
48303,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
197,
42315,
82,
256,
3056,
917,
198,
197,
42400,
262,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
42407,
25,
330,
2152,
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 TestDomainUsers(t *testing.T) {
var users []DomainUser
db, err := InitializeDb()
assert.Nil(t, err)
if err != nil {
log.Fatal(err)
}
sqlCommand := "SELECT id FROM users"
rows, err := db.Query(sqlCommand)
if err != nil {
fmt.Println("ERROR: ", err)
}
assert.Nil(t, err)
defer rows.Close()
for rows.Next() {
var user DomainUser
if err := rows.Scan(&user.Id); err != nil {
panic(err)
}
users = append(users, user)
}
assert.Equal(t, true, len(users) > 0)
} | explode_data.jsonl/74890 | {
"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,
13636,
7137,
1155,
353,
8840,
836,
8,
341,
2405,
3847,
3056,
13636,
1474,
198,
20939,
11,
1848,
1669,
9008,
7994,
741,
6948,
59678,
1155,
11,
1848,
340,
743,
1848,
961,
2092,
341,
197,
6725,
26133,
3964,
340,
197,
532,
306... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceDefaultsToNoSessionPersistence(t *testing.T) {
az := getTestCloud()
svc := getTestService("service-sa-omitted", v1.ProtocolTCP, 7170)
clusterResources := getClusterResources(az, 1, 1)
lb, err := az.reconcileLoadBalancer(testClusterName, &svc, clusterResources.nodes, true /* wantLb */)
if err != nil {
t.Errorf("Unexpected error reconciling svc1: %q", err)
}
validateLoadBalancer(t, lb, svc)
lbRule, err := findLBRuleForPort(*lb.LoadBalancingRules, 7170)
if err != nil {
t.Error(err)
}
if lbRule.LoadDistribution != network.Default {
t.Errorf("Expected LB rule to have default load distribution but was %s", lbRule.LoadDistribution)
}
} | explode_data.jsonl/50396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
1860,
16273,
1249,
2753,
5283,
71562,
1155,
353,
8840,
836,
8,
341,
197,
1370,
1669,
633,
2271,
16055,
741,
1903,
7362,
1669,
633,
2271,
1860,
445,
7936,
1331,
64,
12,
316,
3762,
497,
348,
16,
54096,
49896,
11,
220,
22,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestAuthorization_TCP(t *testing.T) {
framework.NewTest(t).
Run(func(ctx framework.TestContext) {
ns := namespace.NewOrFail(t, ctx, namespace.Config{
Prefix: "v1beta1-tcp-1",
Inject: true,
})
ns2 := namespace.NewOrFail(t, ctx, namespace.Config{
Prefix: "v1beta1-tcp-2",
Inject: true,
})
policy := tmpl.EvaluateAllOrFail(t, map[string]string{
"Namespace": ns.Name(),
"Namespace2": ns2.Name(),
}, file.AsStringOrFail(t, "testdata/authz/v1beta1-tcp.yaml.tmpl"))
ctx.Config().ApplyYAMLOrFail(t, "", policy...)
defer ctx.Config().DeleteYAMLOrFail(t, "", policy...)
var a, b, c, d, e, x echo.Instance
ports := []echo.Port{
{
Name: "http-8090",
Protocol: protocol.HTTP,
InstancePort: 8090,
},
{
Name: "http-8091",
Protocol: protocol.HTTP,
InstancePort: 8091,
},
{
Name: "tcp",
Protocol: protocol.TCP,
InstancePort: 8092,
},
}
echoboot.NewBuilder(ctx).
With(&x, util.EchoConfig("x", ns2, false, nil)).
With(&a, echo.Config{
Subsets: []echo.SubsetConfig{{}},
Namespace: ns,
Service: "a",
Ports: ports,
ServiceAccount: true,
}).
With(&b, echo.Config{
Namespace: ns,
Subsets: []echo.SubsetConfig{{}},
Service: "b",
Ports: ports,
ServiceAccount: true,
}).
With(&c, echo.Config{
Namespace: ns,
Subsets: []echo.SubsetConfig{{}},
Service: "c",
Ports: ports,
ServiceAccount: true,
}).
With(&d, echo.Config{
Namespace: ns,
Subsets: []echo.SubsetConfig{{}},
Service: "d",
Ports: ports,
ServiceAccount: true,
}).
With(&e, echo.Config{
Namespace: ns,
Service: "e",
Ports: ports,
ServiceAccount: true,
}).
BuildOrFail(t)
newTestCase := func(from, target echo.Instance, port string, expectAllowed bool, scheme scheme.Instance) rbacUtil.TestCase {
return rbacUtil.TestCase{
Request: connection.Checker{
From: from,
Options: echo.CallOptions{
Target: target,
PortName: port,
Scheme: scheme,
Path: "/data",
},
},
ExpectAllowed: expectAllowed,
}
}
cases := []rbacUtil.TestCase{
// The policy on workload b denies request with path "/data" to port 8090:
// - request to port http-8090 should be denied because both path and port are matched.
// - request to port http-8091 should be allowed because the port is not matched.
// - request to port tcp should be allowed because the port is not matched.
newTestCase(a, b, "http-8090", false, scheme.HTTP),
newTestCase(a, b, "http-8091", true, scheme.HTTP),
newTestCase(a, b, "tcp", true, scheme.TCP),
// The policy on workload c denies request to port 8090:
// - request to port http-8090 should be denied because the port is matched.
// - request to http port 8091 should be allowed because the port is not matched.
// - request to tcp port 8092 should be allowed because the port is not matched.
newTestCase(a, c, "http-8090", false, scheme.HTTP),
newTestCase(a, c, "http-8091", true, scheme.HTTP),
newTestCase(a, c, "tcp", true, scheme.TCP),
// The policy on workload d denies request from service account a and workloads in namespace 2:
// - request from a to d should be denied because it has service account a.
// - request from b to d should be allowed.
// - request from c to d should be allowed.
// - request from x to a should be allowed because there is no policy on a.
// - request from x to d should be denied because it's in namespace 2.
newTestCase(a, d, "tcp", false, scheme.TCP),
newTestCase(b, d, "tcp", true, scheme.TCP),
newTestCase(c, d, "tcp", true, scheme.TCP),
newTestCase(x, a, "tcp", true, scheme.TCP),
newTestCase(x, d, "tcp", false, scheme.TCP),
// The policy on workload e denies request with path "/other":
// - request to port http-8090 should be allowed because the path is not matched.
// - request to port http-8091 should be allowed because the path is not matched.
// - request to port tcp should be denied because policy uses HTTP fields.
newTestCase(a, e, "http-8090", true, scheme.HTTP),
newTestCase(a, e, "http-8091", true, scheme.HTTP),
newTestCase(a, e, "tcp", false, scheme.TCP),
}
rbacUtil.RunRBACTest(t, cases)
})
} | explode_data.jsonl/41498 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2050
} | [
2830,
3393,
18124,
50614,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
7121,
2271,
1155,
4292,
197,
85952,
18552,
7502,
12626,
8787,
1972,
8,
341,
298,
84041,
1669,
4473,
7121,
46059,
1155,
11,
5635,
11,
4473,
10753,
515,
571,
10025,
5060,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitCARESTfulVerbs(t *testing.T) {
ts := httptest.NewServer(NewHandler())
data := csrData(t)
// POST should work.
req, _ := http.NewRequest("POST", ts.URL, data)
resp, _ := http.DefaultClient.Do(req)
if resp.StatusCode != http.StatusOK {
t.Fatal(resp.Status)
}
// Test GET, PUT, DELETE and whatever, expect 400 errors.
req, _ = http.NewRequest("GET", ts.URL, data)
resp, _ = http.DefaultClient.Do(req)
if resp.StatusCode != http.StatusMethodNotAllowed {
t.Fatal(resp.Status)
}
req, _ = http.NewRequest("PUT", ts.URL, data)
resp, _ = http.DefaultClient.Do(req)
if resp.StatusCode != http.StatusMethodNotAllowed {
t.Fatal(resp.Status)
}
req, _ = http.NewRequest("DELETE", ts.URL, data)
resp, _ = http.DefaultClient.Do(req)
if resp.StatusCode != http.StatusMethodNotAllowed {
t.Fatal(resp.Status)
}
req, _ = http.NewRequest("WHATEVER", ts.URL, data)
resp, _ = http.DefaultClient.Do(req)
if resp.StatusCode != http.StatusMethodNotAllowed {
t.Fatal(resp.Status)
}
} | explode_data.jsonl/4728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 394
} | [
2830,
3393,
3803,
34,
74335,
1262,
10141,
1279,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
35063,
3050,
2398,
8924,
1669,
68932,
1043,
1155,
340,
197,
322,
12869,
1265,
975,
624,
24395,
11,
716,
1669,
1758,
752... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestValidateMissingReferencesConfig(t *testing.T) {
config := clientcmdapi.NewConfig()
config.CurrentContext = "anything"
config.Contexts["anything"] = &clientcmdapi.Context{Cluster: "missing", AuthInfo: "missing"}
test := configValidationTest{
config: config,
expectedErrorSubstring: []string{"user \"missing\" was not found for context \"anything\"", "cluster \"missing\" was not found for context \"anything\""},
}
test.testContext("anything", t)
test.testConfig(t)
} | explode_data.jsonl/13488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
17926,
25080,
31712,
2648,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2943,
8710,
2068,
7121,
2648,
741,
25873,
11517,
1972,
284,
330,
72154,
698,
25873,
9328,
82,
1183,
72154,
1341,
284,
609,
2972,
8710,
2068,
9328,
90,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeam_String(t *testing.T) {
v := Team{
ID: Int64(0),
NodeID: String(""),
Name: String(""),
Description: String(""),
URL: String(""),
Slug: String(""),
Permission: String(""),
Privacy: String(""),
MembersCount: Int(0),
ReposCount: Int(0),
Organization: &Organization{},
MembersURL: String(""),
RepositoriesURL: String(""),
Parent: &Team{},
LDAPDN: String(""),
}
want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}`
if got := v.String(); got != want {
t.Errorf("Team.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33291 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 386
} | [
2830,
3393,
14597,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
7909,
515,
197,
29580,
25,
1060,
1333,
21,
19,
7,
15,
1326,
197,
30217,
915,
25,
688,
923,
445,
4461,
197,
21297,
25,
310,
923,
445,
4461,
197,
47414,
25,
257,
92... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadUnmodifiedEmptyFileSucceeds(t *testing.T) {
for _, alg := range hashAlgs {
vfsObj, root, ctx, err := newVerityRoot(t, alg)
if err != nil {
t.Fatalf("newVerityRoot: %v", err)
}
filename := "verity-test-empty-file"
fd, err := newEmptyFileFD(ctx, t, vfsObj, root, filename, 0644)
if err != nil {
t.Fatalf("newEmptyFileFD: %v", err)
}
// Enable verity on the file and confirm a normal read succeeds.
enableVerity(ctx, t, fd)
var buf []byte
n, err := fd.Read(ctx, usermem.BytesIOSequence(buf), vfs.ReadOptions{})
if err != nil && err != io.EOF {
t.Fatalf("fd.Read: %v", err)
}
if n != 0 {
t.Errorf("fd.Read got read length %d, expected 0", n)
}
}
} | explode_data.jsonl/56758 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
4418,
1806,
27162,
3522,
1703,
50,
29264,
82,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17345,
1669,
2088,
5175,
2101,
5857,
341,
197,
5195,
3848,
5261,
11,
3704,
11,
5635,
11,
1848,
1669,
501,
10141,
487,
8439,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpanFinishWithOptionsLogs(t *testing.T) {
tracer, apmtracer, recorder := newTestTracer()
defer apmtracer.Close()
err0Time := time.Unix(42, 0).UTC()
spanStart := time.Unix(60, 0).UTC()
spanFinish := time.Unix(66, 0).UTC()
span := tracer.StartSpan("span", opentracing.StartTime(spanStart))
span.FinishWithOptions(opentracing.FinishOptions{
FinishTime: spanFinish,
LogRecords: []opentracing.LogRecord{{
// The docs for FinishOptions.LogRecords state that
// Timestamp must be set explicitly, and must be
// >= span start and <= span finish, or else the
// behaviour is undefined. Our behaviour is this:
// we do not check the timestamp bounds, and if it
// is unset we set it to the span finish time.
Timestamp: err0Time,
Fields: []log.Field{log.String("event", "error"), log.Error(errors.New("boom"))},
}, {
Fields: []log.Field{log.String("event", "error"), log.String("message", "C5H8NO4Na")},
}},
})
apmtracer.Flush(nil)
payloads := recorder.Payloads()
require.Len(t, payloads.Errors, 2)
errors := payloads.Errors
assert.Equal(t, "boom", errors[0].Log.Message)
assert.Equal(t, model.Time(err0Time), errors[0].Timestamp)
assert.Equal(t, "C5H8NO4Na", errors[1].Log.Message)
assert.Equal(t, model.Time(spanFinish), errors[1].Timestamp)
} | explode_data.jsonl/28600 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 490
} | [
2830,
3393,
12485,
25664,
74238,
51053,
1155,
353,
8840,
836,
8,
341,
25583,
9584,
11,
1443,
76,
94941,
11,
48835,
1669,
501,
2271,
1282,
9584,
741,
16867,
1443,
76,
94941,
10421,
2822,
9859,
15,
1462,
1669,
882,
10616,
941,
7,
19,
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 TestRecordSetsListAllIntegrationFilterForNonexistentName(t *testing.T) {
c := client()
zs, err := c.ZonesListAll(ListFilter{})
if err != nil {
t.Error(err)
}
records, err := c.RecordSetsListAll(zs[0].ID, ListFilter{
NameFilter: "thisdoesnotexist",
})
if err != nil {
t.Error(err)
}
if len(records) > 0 {
t.Error("Expected RecordSetsListAll for records named 'thisdoesnotexist' to yield no results")
}
} | explode_data.jsonl/12125 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
6471,
30175,
852,
2403,
52464,
5632,
2461,
8121,
64085,
675,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2943,
741,
20832,
82,
11,
1848,
1669,
272,
13476,
3154,
852,
2403,
10278,
5632,
37790,
743,
1848,
961,
2092,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestValidateRefs(t *testing.T) {
cases := []struct {
name string
extraRefs []prowapi.Refs
expected error
}{
{
name: "validation error for extra ref specifying the same repo for which the job is configured",
extraRefs: []prowapi.Refs{
{
Org: "org",
Repo: "repo",
},
},
expected: fmt.Errorf("Invalid job test on repo org/repo: the following refs specified more than once: %s",
"org/repo"),
},
{
name: "validation error lists all duplications",
extraRefs: []prowapi.Refs{
{
Org: "org",
Repo: "repo",
},
{
Org: "org",
Repo: "foo",
},
{
Org: "org",
Repo: "bar",
},
{
Org: "org",
Repo: "foo",
},
},
expected: fmt.Errorf("Invalid job test on repo org/repo: the following refs specified more than once: %s",
"org/foo,org/repo"),
},
{
name: "no errors if there are no duplications",
extraRefs: []prowapi.Refs{
{
Org: "org",
Repo: "foo",
},
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
job := JobBase{
Name: "test",
UtilityConfig: UtilityConfig{
ExtraRefs: tc.extraRefs,
},
}
if err := ValidateRefs("org/repo", job); !reflect.DeepEqual(err, tc.expected) {
t.Errorf("expected %#v\n!=\nactual %#v", tc.expected, err)
}
})
}
} | explode_data.jsonl/8077 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 674
} | [
2830,
3393,
17926,
82807,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
8122,
2172,
82807,
3056,
79,
651,
2068,
2817,
3848,
198,
197,
42400,
220,
1465,
198,
197,
59403,
197,
197,
515,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIndexNames(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
names, err := client.IndexNames()
if err != nil {
t.Fatal(err)
}
if len(names) == 0 {
t.Fatalf("expected some index names, got: %d", len(names))
}
var found bool
for _, name := range names {
if name == testIndexName {
found = true
break
}
}
if !found {
t.Fatalf("expected to find index %q; got: %v", testIndexName, found)
}
} | explode_data.jsonl/38016 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
1552,
7980,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
6505,
2271,
2959,
3036,
4021,
1552,
1155,
340,
93940,
11,
1848,
1669,
2943,
18338,
7980,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
743,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestHandler_getRepo(t *testing.T) {
loggerWriter := logrus.StandardLogger().Out
logrus.SetOutput(ioutil.Discard)
defer logrus.SetOutput(loggerWriter)
tcs := []struct {
svc *fakeService
repoName string
expectedStatus int
expectedRepo *model.RepositoryInfo
expectedErrCode sgerrors.ErrorCode
}{
{ // TC#1
repoName: "notFound",
svc: &fakeService{
err: sgerrors.ErrNotFound,
},
expectedStatus: http.StatusNotFound,
expectedErrCode: sgerrors.NotFound,
},
{ // TC#2
repoName: "getError",
svc: &fakeService{
err: errFake,
},
expectedStatus: http.StatusInternalServerError,
expectedErrCode: sgerrors.UnknownError,
},
{ // TC#3
repoName: "sgRepo",
svc: &fakeService{
repo: &model.RepositoryInfo{
Config: repo.Entry{
Name: "sgRepo",
},
},
},
expectedStatus: http.StatusOK,
expectedRepo: &model.RepositoryInfo{
Config: repo.Entry{
Name: "sgRepo",
},
},
},
}
for i, tc := range tcs {
// setup handler
h := &Handler{svc: tc.svc}
// prepare
req, err := http.NewRequest("", "/helm/"+tc.repoName, nil)
require.Equalf(t, nil, err, "TC#%d: create request: %v", i+1, err)
router := mux.NewRouter()
router.HandleFunc("/helm/{repoName}", h.getRepo)
w := httptest.NewRecorder()
// run
router.ServeHTTP(w, req)
// check
require.Equalf(t, tc.expectedStatus, w.Code, "TC#%d: check status code", i+1)
if w.Code == http.StatusOK {
hrepo := &model.RepositoryInfo{}
require.Nilf(t, json.NewDecoder(w.Body).Decode(hrepo), "TC#%d: decode repo", i+1)
require.Equalf(t, tc.expectedRepo, hrepo, "TC#%d: check repo", i+1)
} else {
apiErr := &message.Message{}
require.Nilf(t, json.NewDecoder(w.Body).Decode(apiErr), "TC#%d: decode message", i+1)
require.Equalf(t, tc.expectedErrCode, apiErr.ErrorCode, "TC#%d: check error code", i+1)
}
}
} | explode_data.jsonl/12098 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 869
} | [
2830,
3393,
3050,
3062,
25243,
1155,
353,
8840,
836,
8,
341,
17060,
6492,
1669,
1487,
20341,
53615,
7395,
1005,
2662,
198,
90822,
4202,
5097,
1956,
30158,
909,
47560,
340,
16867,
1487,
20341,
4202,
5097,
37833,
6492,
692,
3244,
4837,
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... | 3 |
func TestTooManySubs(t *testing.T) {
sOpts := GetDefaultOptions()
sOpts.ID = clusterName
sOpts.MaxSubscriptions = 1
s := runServerWithOpts(t, sOpts, nil)
defer s.Shutdown()
sc := NewDefaultConnection(t)
defer sc.Close()
// This should be ok
if _, err := sc.Subscribe("foo", func(_ *stan.Msg) {}); err != nil {
t.Fatalf("Unexpected error on subscribe: %v", err)
}
check := func() {
cs := channelsGet(t, s.channels, "foo")
ss := cs.ss
ss.RLock()
if ss.psubs == nil || len(ss.psubs) != 1 {
stackFatalf(t, "Expected only one subscription, got %v", len(ss.psubs))
}
ss.RUnlock()
subs := s.clients.getSubs(clientName)
if len(subs) != 1 {
stackFatalf(t, "Expected 1 subscription for client %q, got %+v", clientName, subs)
}
}
// We should get an error here
if _, err := sc.Subscribe("foo", func(_ *stan.Msg) {}); err == nil {
t.Fatal("Expected error on subscribe, go none")
}
check()
// Try with a durable
if _, err := sc.Subscribe("foo", func(_ *stan.Msg) {}, stan.DurableName("dur")); err == nil {
t.Fatal("Expected error on subscribe, go none")
}
check()
// And a queue sub
if _, err := sc.QueueSubscribe("foo", "queue", func(_ *stan.Msg) {}); err == nil {
t.Fatal("Expected error on subscribe, go none")
}
check()
// Finally a durable queue sub
if _, err := sc.QueueSubscribe("foo", "queue", func(_ *stan.Msg) {}, stan.DurableName("dur")); err == nil {
t.Fatal("Expected error on subscribe, go none")
}
check()
} | explode_data.jsonl/23091 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 579
} | [
2830,
3393,
31246,
8441,
3136,
82,
1155,
353,
8840,
836,
8,
341,
1903,
43451,
1669,
2126,
3675,
3798,
741,
1903,
43451,
9910,
284,
10652,
675,
198,
1903,
43451,
14535,
3136,
29966,
284,
220,
16,
198,
1903,
1669,
1598,
5475,
2354,
43451,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegrations(t *testing.T) {
suite := newSuite(t)
t.Run("AuditOff", suite.bind(testAuditOff))
t.Run("AuditOn", suite.bind(testAuditOn))
t.Run("BPFExec", suite.bind(testBPFExec))
t.Run("BPFInteractive", suite.bind(testBPFInteractive))
t.Run("BPFSessionDifferentiation", suite.bind(testBPFSessionDifferentiation))
t.Run("CmdLabels", suite.bind(testCmdLabels))
t.Run("ControlMaster", suite.bind(testControlMaster))
t.Run("CustomReverseTunnel", suite.bind(testCustomReverseTunnel))
t.Run("DataTransfer", suite.bind(testDataTransfer))
t.Run("Disconnection", suite.bind(testDisconnectScenarios))
t.Run("Discovery", suite.bind(testDiscovery))
t.Run("DiscoveryNode", suite.bind(testDiscoveryNode))
t.Run("DiscoveryRecovers", suite.bind(testDiscoveryRecovers))
t.Run("EnvironmentVars", suite.bind(testEnvironmentVariables))
t.Run("ExecEvents", suite.bind(testExecEvents))
t.Run("ExternalClient", suite.bind(testExternalClient))
t.Run("HA", suite.bind(testHA))
t.Run("Interactive (Regular)", suite.bind(testInteractiveRegular))
t.Run("Interactive (Reverse Tunnel)", suite.bind(testInteractiveReverseTunnel))
t.Run("Interoperability", suite.bind(testInteroperability))
t.Run("InvalidLogin", suite.bind(testInvalidLogins))
t.Run("JumpTrustedClusters", suite.bind(testJumpTrustedClusters))
t.Run("JumpTrustedClustersWithLabels", suite.bind(testJumpTrustedClustersWithLabels))
t.Run("List", suite.bind(testList))
t.Run("MapRoles", suite.bind(testMapRoles))
t.Run("MultiplexingTrustedClusters", suite.bind(testMultiplexingTrustedClusters))
t.Run("PAM", suite.bind(testPAM))
t.Run("PortForwarding", suite.bind(testPortForwarding))
t.Run("ProxyHostKeyCheck", suite.bind(testProxyHostKeyCheck))
t.Run("ReverseTunnelCollapse", suite.bind(testReverseTunnelCollapse))
t.Run("Readyz", suite.bind(testReadyz))
t.Run("RotateChangeSigningAlg", suite.bind(testRotateChangeSigningAlg))
t.Run("RotateRollback", suite.bind(testRotateRollback))
t.Run("RotateSuccess", suite.bind(testRotateSuccess))
t.Run("RotateTrustedClusters", suite.bind(testRotateTrustedClusters))
t.Run("SessionStartContainsAccessRequest", suite.bind(testSessionStartContainsAccessRequest))
t.Run("SessionStreaming", suite.bind(testSessionStreaming))
t.Run("SSHExitCode", suite.bind(testSSHExitCode))
t.Run("Shutdown", suite.bind(testShutdown))
t.Run("TrustedClusters", suite.bind(testTrustedClusters))
t.Run("TrustedClustersWithLabels", suite.bind(testTrustedClustersWithLabels))
t.Run("TrustedTunnelNode", suite.bind(testTrustedTunnelNode))
t.Run("TwoClustersProxy", suite.bind(testTwoClustersProxy))
t.Run("TwoClustersTunnel", suite.bind(testTwoClustersTunnel))
t.Run("UUIDBasedProxy", suite.bind(testUUIDBasedProxy))
t.Run("WindowChange", suite.bind(testWindowChange))
t.Run("SSHTracker", suite.bind(testSSHTracker))
t.Run("TestKubeAgentFiltering", suite.bind(testKubeAgentFiltering))
} | explode_data.jsonl/71196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1026
} | [
2830,
3393,
1072,
14412,
804,
1155,
353,
8840,
836,
8,
341,
96572,
1669,
501,
28000,
1155,
692,
3244,
16708,
445,
74516,
4596,
497,
16182,
6090,
8623,
74516,
4596,
1171,
3244,
16708,
445,
74516,
1925,
497,
16182,
6090,
8623,
74516,
1925,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStripURLParts(t *testing.T) {
//Test cases
cases := map[string]string{
"http://google.com": "google.com",
"http://google.com/ding?true": "google.com",
"google.com/?ding=false": "google.com",
"google.com?ding=false": "google.com",
"nonexist.***": "nonexist.***",
"google.com": "google.com",
"google.co.uk": "google.co.uk",
"gama.google.com": "gama.google.com",
"gama.google.co.uk": "gama.google.co.uk",
"beta.gama.google.co.uk": "beta.gama.google.co.uk",
"https://beta.gama.google.co.uk": "beta.gama.google.co.uk",
"xn--n3h.example": "☃.example",
"xn--äää": "",
"http://admin:adminpw@google.com": "google.com",
"admin:adminpw@gama.google.com": "gama.google.com",
"https://admin:adminpw@gama.google.com/path?key=value": "gama.google.com",
"http://medium.com/@example/example": "medium.com",
}
//Test each domain, some should fail (expected)
for url, expectedStripped := range cases {
stripped := stripURLParts(url)
if stripped != expectedStripped {
t.Errorf("Url (%q) returned %q for StripURLParts(), but %q was expected", url, stripped, expectedStripped)
}
}
} | explode_data.jsonl/30834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 669
} | [
2830,
3393,
5901,
3144,
28921,
1155,
353,
8840,
836,
8,
341,
197,
322,
2271,
5048,
198,
1444,
2264,
1669,
2415,
14032,
30953,
515,
197,
197,
76932,
1110,
17485,
905,
788,
2290,
330,
17485,
905,
756,
197,
197,
76932,
1110,
17485,
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... | 3 |
func TestApplicationEventGetApplicationID(t *testing.T) {
tests := []struct {
name string
appID, msg string
event events.ApplicationEventType
wantID string
}{
{TestAppIDName, "testAppId001", "testTask001", events.SubmitApplication, "testAppId001"},
}
for _, tt := range tests {
instance := NewApplicationEvent(tt.appID, tt.event, tt.msg)
id := instance.GetApplicationID()
t.Run(tt.name, func(t *testing.T) {
if id != tt.wantID {
t.Errorf("want %s, got %s", tt.wantID, id)
}
})
}
} | explode_data.jsonl/9776 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
4988,
1556,
1949,
4988,
915,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
28236,
915,
11,
3750,
914,
198,
197,
28302,
414,
4357,
17521,
47906,
198,
197,
50780,
915,
257,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBlockReject_InnerBlockIsNotRejected(t *testing.T) {
// setup
coreVM, _, _, _, proVM, coreGenBlk, _ := initTestProposerVM(t, time.Time{}, 0)
proVM.Set(coreGenBlk.Timestamp())
// create post fork oracle block ...
oracleCoreBlk := &TestOptionsBlock{
TestBlock: snowman.TestBlock{
TestDecidable: choices.TestDecidable{
IDV: ids.Empty.Prefix(1111),
StatusV: choices.Processing,
},
BytesV: []byte{1},
ParentV: coreGenBlk.ID(),
TimestampV: coreGenBlk.Timestamp(),
},
}
oracleCoreBlk.opts = [2]snowman.Block{
&snowman.TestBlock{
TestDecidable: choices.TestDecidable{
IDV: ids.Empty.Prefix(2222),
StatusV: choices.Processing,
},
BytesV: []byte{2},
ParentV: oracleCoreBlk.ID(),
TimestampV: oracleCoreBlk.Timestamp(),
},
&snowman.TestBlock{
TestDecidable: choices.TestDecidable{
IDV: ids.Empty.Prefix(3333),
StatusV: choices.Processing,
},
BytesV: []byte{3},
ParentV: oracleCoreBlk.ID(),
TimestampV: oracleCoreBlk.Timestamp(),
},
}
coreVM.BuildBlockF = func() (snowman.Block, error) { return oracleCoreBlk, nil }
coreVM.GetBlockF = func(blkID ids.ID) (snowman.Block, error) {
switch blkID {
case coreGenBlk.ID():
return coreGenBlk, nil
case oracleCoreBlk.ID():
return oracleCoreBlk, nil
case oracleCoreBlk.opts[0].ID():
return oracleCoreBlk.opts[0], nil
case oracleCoreBlk.opts[1].ID():
return oracleCoreBlk.opts[1], nil
default:
return nil, database.ErrNotFound
}
}
coreVM.ParseBlockF = func(b []byte) (snowman.Block, error) {
switch {
case bytes.Equal(b, coreGenBlk.Bytes()):
return coreGenBlk, nil
case bytes.Equal(b, oracleCoreBlk.Bytes()):
return oracleCoreBlk, nil
case bytes.Equal(b, oracleCoreBlk.opts[0].Bytes()):
return oracleCoreBlk.opts[0], nil
case bytes.Equal(b, oracleCoreBlk.opts[1].Bytes()):
return oracleCoreBlk.opts[1], nil
default:
return nil, errUnknownBlock
}
}
builtBlk, err := proVM.BuildBlock()
if err != nil {
t.Fatal("could not build post fork oracle block")
}
// reject oracle block
if err := builtBlk.Reject(); err != nil {
t.Fatal("could not reject block")
}
proBlk, ok := builtBlk.(*postForkBlock)
if !ok {
t.Fatal("built block has not expected type")
}
if proBlk.Status() != choices.Rejected {
t.Fatal("block rejection did not set state properly")
}
if proBlk.innerBlk.Status() == choices.Rejected {
t.Fatal("block rejection unduly changed inner block status")
}
// reject an option
postForkOracleBlk, ok := builtBlk.(*postForkBlock)
if !ok {
t.Fatal("expected post fork block")
}
opts, err := postForkOracleBlk.Options()
if err != nil {
t.Fatal("could not retrieve options from post fork oracle block")
}
if err := opts[0].Reject(); err != nil {
t.Fatal("could not accept option")
}
proOpt, ok := opts[0].(*postForkOption)
if !ok {
t.Fatal("built block has not expected type")
}
if proOpt.Status() != choices.Rejected {
t.Fatal("block rejection did not set state properly")
}
if proOpt.innerBlk.Status() == choices.Rejected {
t.Fatal("block rejection unduly changed inner block status")
}
} | explode_data.jsonl/19404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1327
} | [
2830,
3393,
4713,
78413,
25972,
1194,
4713,
3872,
2623,
77693,
1155,
353,
8840,
836,
8,
341,
197,
322,
6505,
198,
71882,
11187,
11,
8358,
8358,
8358,
462,
11187,
11,
6200,
9967,
4923,
74,
11,
716,
1669,
2930,
2271,
2008,
23438,
11187,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSpecificTicker(t *testing.T) {
e := CreateTestBot(t)
p, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
err = ticker.ProcessTicker(&ticker.Price{
Pair: p,
Last: 1000,
AssetType: asset.Spot,
ExchangeName: testExchange})
if err != nil {
t.Fatal("ProcessTicker error", err)
}
tick, err := e.GetSpecificTicker(p, testExchange, asset.Spot)
if err != nil {
t.Fatal(err)
}
if tick.Last != 1000 {
t.Fatal("Unexpected result")
}
ethltc, err := currency.NewPairFromStrings("ETH", "LTC")
if err != nil {
t.Fatal(err)
}
_, err = e.GetSpecificTicker(ethltc, testExchange, asset.Spot)
if err == nil {
t.Fatal("Unexpected result")
}
err = e.UnloadExchange(testExchange)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/59236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
1949,
47514,
87278,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
4230,
2271,
23502,
1155,
340,
3223,
11,
1848,
1669,
11413,
7121,
12443,
3830,
20859,
445,
59118,
497,
330,
26749,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
2613... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewSyncerMap(t *testing.T) {
syncConfig := config.Adapter{
UserSyncURL: "some-sync-url",
}
cfg := &config.Configuration{
Adapters: map[string]config.Adapter{
string(openrtb_ext.Bidder33Across): syncConfig,
string(openrtb_ext.BidderAcuityAds): syncConfig,
string(openrtb_ext.BidderAdf): syncConfig,
string(openrtb_ext.BidderAdform): syncConfig,
string(openrtb_ext.BidderAdkernel): syncConfig,
string(openrtb_ext.BidderAdkernelAdn): syncConfig,
string(openrtb_ext.BidderAdman): syncConfig,
string(openrtb_ext.BidderAdmixer): syncConfig,
string(openrtb_ext.BidderAdOcean): syncConfig,
string(openrtb_ext.BidderAdpone): syncConfig,
string(openrtb_ext.BidderAdtarget): syncConfig,
string(openrtb_ext.BidderAdtelligent): syncConfig,
string(openrtb_ext.BidderAdvangelists): syncConfig,
string(openrtb_ext.BidderAdxcg): syncConfig,
string(openrtb_ext.BidderAdyoulike): syncConfig,
string(openrtb_ext.BidderAJA): syncConfig,
string(openrtb_ext.BidderAMX): syncConfig,
string(openrtb_ext.BidderAppnexus): syncConfig,
string(openrtb_ext.BidderAudienceNetwork): syncConfig,
string(openrtb_ext.BidderAvocet): syncConfig,
string(openrtb_ext.BidderBeachfront): syncConfig,
string(openrtb_ext.BidderBeintoo): syncConfig,
string(openrtb_ext.BidderBetween): syncConfig,
string(openrtb_ext.BidderBrightroll): syncConfig,
string(openrtb_ext.BidderColossus): syncConfig,
string(openrtb_ext.BidderConnectAd): syncConfig,
string(openrtb_ext.BidderConsumable): syncConfig,
string(openrtb_ext.BidderConversant): syncConfig,
string(openrtb_ext.BidderCpmstar): syncConfig,
string(openrtb_ext.BidderCriteo): syncConfig,
string(openrtb_ext.BidderDatablocks): syncConfig,
string(openrtb_ext.BidderDmx): syncConfig,
string(openrtb_ext.BidderDeepintent): syncConfig,
string(openrtb_ext.BidderEmxDigital): syncConfig,
string(openrtb_ext.BidderEngageBDR): syncConfig,
string(openrtb_ext.BidderEPlanning): syncConfig,
string(openrtb_ext.BidderGamma): syncConfig,
string(openrtb_ext.BidderGamoshi): syncConfig,
string(openrtb_ext.BidderGrid): syncConfig,
string(openrtb_ext.BidderGumGum): syncConfig,
string(openrtb_ext.BidderImprovedigital): syncConfig,
string(openrtb_ext.BidderInvibes): syncConfig,
string(openrtb_ext.BidderIx): syncConfig,
string(openrtb_ext.BidderJixie): syncConfig,
string(openrtb_ext.BidderKrushmedia): syncConfig,
string(openrtb_ext.BidderLifestreet): syncConfig,
string(openrtb_ext.BidderLockerDome): syncConfig,
string(openrtb_ext.BidderLogicad): syncConfig,
string(openrtb_ext.BidderLunaMedia): syncConfig,
string(openrtb_ext.BidderMarsmedia): syncConfig,
string(openrtb_ext.BidderMediafuse): syncConfig,
string(openrtb_ext.BidderMgid): syncConfig,
string(openrtb_ext.BidderNanoInteractive): syncConfig,
string(openrtb_ext.BidderNinthDecimal): syncConfig,
string(openrtb_ext.BidderNoBid): syncConfig,
string(openrtb_ext.BidderOneTag): syncConfig,
string(openrtb_ext.BidderOpenx): syncConfig,
string(openrtb_ext.BidderOutbrain): syncConfig,
string(openrtb_ext.BidderPubmatic): syncConfig,
string(openrtb_ext.BidderPulsepoint): syncConfig,
string(openrtb_ext.BidderRhythmone): syncConfig,
string(openrtb_ext.BidderRTBHouse): syncConfig,
string(openrtb_ext.BidderRubicon): syncConfig,
string(openrtb_ext.BidderSharethrough): syncConfig,
string(openrtb_ext.BidderSmartAdserver): syncConfig,
string(openrtb_ext.BidderSmartRTB): syncConfig,
string(openrtb_ext.BidderSmartyAds): syncConfig,
string(openrtb_ext.BidderSomoaudience): syncConfig,
string(openrtb_ext.BidderSonobi): syncConfig,
string(openrtb_ext.BidderSovrn): syncConfig,
string(openrtb_ext.BidderSynacormedia): syncConfig,
string(openrtb_ext.BidderTappx): syncConfig,
string(openrtb_ext.BidderTelaria): syncConfig,
string(openrtb_ext.BidderTriplelift): syncConfig,
string(openrtb_ext.BidderTripleliftNative): syncConfig,
string(openrtb_ext.BidderTrustX): syncConfig,
string(openrtb_ext.BidderUcfunnel): syncConfig,
string(openrtb_ext.BidderUnruly): syncConfig,
string(openrtb_ext.BidderValueImpression): syncConfig,
string(openrtb_ext.BidderVerizonMedia): syncConfig,
string(openrtb_ext.BidderVisx): syncConfig,
string(openrtb_ext.BidderVrtcal): syncConfig,
string(openrtb_ext.BidderYieldlab): syncConfig,
string(openrtb_ext.BidderYieldmo): syncConfig,
string(openrtb_ext.BidderYieldone): syncConfig,
string(openrtb_ext.BidderZeroClickFraud): syncConfig,
},
}
adaptersWithoutSyncers := map[openrtb_ext.BidderName]bool{
openrtb_ext.BidderAdgeneration: true,
openrtb_ext.BidderAdhese: true,
openrtb_ext.BidderAdoppler: true,
openrtb_ext.BidderAdot: true,
openrtb_ext.BidderAdprime: true,
openrtb_ext.BidderApplogy: true,
openrtb_ext.BidderBidmachine: true,
openrtb_ext.BidderEpom: true,
openrtb_ext.BidderDecenterAds: true,
openrtb_ext.BidderInMobi: true,
openrtb_ext.BidderInteractiveoffers: true,
openrtb_ext.BidderKidoz: true,
openrtb_ext.BidderKubient: true,
openrtb_ext.BidderMobfoxpb: true,
openrtb_ext.BidderMobileFuse: true,
openrtb_ext.BidderOrbidder: true,
openrtb_ext.BidderPangle: true,
openrtb_ext.BidderPubnative: true,
openrtb_ext.BidderRevcontent: true,
openrtb_ext.BidderSilverMob: true,
openrtb_ext.BidderSmaato: true,
openrtb_ext.BidderUnicorn: true,
openrtb_ext.BidderYeahmobi: true,
}
for bidder, config := range cfg.Adapters {
delete(cfg.Adapters, bidder)
cfg.Adapters[strings.ToLower(string(bidder))] = config
}
syncers := NewSyncerMap(cfg)
for _, bidderName := range openrtb_ext.CoreBidderNames() {
_, adapterWithoutSyncer := adaptersWithoutSyncers[bidderName]
if _, ok := syncers[bidderName]; !ok && !adapterWithoutSyncer {
t.Errorf("No syncer exists for adapter: %s", bidderName)
}
}
} | explode_data.jsonl/63832 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3407
} | [
2830,
3393,
3564,
12154,
261,
2227,
1155,
353,
8840,
836,
8,
341,
1903,
1721,
2648,
1669,
2193,
34190,
515,
197,
31672,
12154,
3144,
25,
330,
14689,
65034,
25443,
756,
197,
532,
50286,
1669,
609,
1676,
17334,
515,
197,
197,
2589,
17425,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsReady(t *testing.T) {
cases := []struct {
name string
status PodAutoscalerStatus
isReady bool
}{{
name: "empty status should not be ready",
status: PodAutoscalerStatus{},
isReady: false,
}, {
name: "Different condition type should not be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionActive,
Status: corev1.ConditionTrue,
}},
},
isReady: false,
}, {
name: "False condition status should not be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionReady,
Status: corev1.ConditionFalse,
}},
},
isReady: false,
}, {
name: "Unknown condition status should not be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionReady,
Status: corev1.ConditionUnknown,
}},
},
isReady: false,
}, {
name: "Missing condition status should not be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionReady,
}},
},
isReady: false,
}, {
name: "True condition status should be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionReady,
Status: corev1.ConditionTrue,
}},
},
isReady: true,
}, {
name: "Multiple conditions with ready status should be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionActive,
Status: corev1.ConditionTrue,
}, {
Type: PodAutoscalerConditionReady,
Status: corev1.ConditionTrue,
}},
},
isReady: true,
}, {
name: "Multiple conditions with ready status false should not be ready",
status: PodAutoscalerStatus{
Conditions: duckv1beta1.Conditions{{
Type: PodAutoscalerConditionActive,
Status: corev1.ConditionTrue,
}, {
Type: PodAutoscalerConditionReady,
Status: corev1.ConditionFalse,
}},
},
isReady: false,
}}
for _, tc := range cases {
if e, a := tc.isReady, tc.status.IsReady(); e != a {
t.Errorf("%q expected: %v got: %v", tc.name, e, a)
}
}
} | explode_data.jsonl/32166 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 886
} | [
2830,
3393,
3872,
19202,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
23847,
220,
16821,
19602,
436,
63084,
2522,
198,
197,
19907,
19202,
1807,
198,
197,
15170,
515,
197,
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... | 3 |
func TestPriorityQueue_Pop(t *testing.T) {
objs := []runtime.Object{medPriorityPodInfo.Pod}
q := NewTestQueueWithObjects(context.Background(), newDefaultQueueSort(), objs)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
if p, err := q.Pop(); err != nil || p.Pod != medPriorityPodInfo.Pod {
t.Errorf("Expected: %v after Pop, but got: %v", medPriorityPodInfo.Pod.Name, p.Pod.Name)
}
if len(q.PodNominator.(*nominator).nominatedPods["node1"]) != 1 {
t.Errorf("Expected medPriorityPodInfo to be present in nomindatePods: %v", q.PodNominator.(*nominator).nominatedPods["node1"])
}
}()
q.Add(medPriorityPodInfo.Pod)
wg.Wait()
} | explode_data.jsonl/68186 | {
"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,
20555,
7554,
1088,
453,
1155,
353,
8840,
836,
8,
341,
22671,
82,
1669,
3056,
22255,
8348,
90,
2061,
20555,
23527,
1731,
88823,
532,
18534,
1669,
1532,
2271,
7554,
2354,
11543,
5378,
19047,
1507,
501,
3675,
7554,
10231,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInit(t *testing.T) {
type args struct {
db *SourceMap
}
tests := []struct {
name string
args args
wantErr bool
}{
//{
// name: "test1",
// args: args{
// &SourceMap{
// Db: []string{
// "test",
// },
// Driver: "Mysql",
// Host: "localhost",
// Password: "password",
// User: "root",
// Port: "3306",
// },
// },
// wantErr: false,
//},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := Init(tt.args.db); (err != nil) != tt.wantErr {
t.Errorf("Init() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
} | explode_data.jsonl/74249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 340
} | [
2830,
3393,
3803,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
20939,
353,
3608,
2227,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
198,
197,
50780,
7747,
1807,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAssociateSpaceDeveloperByUsername(t *testing.T) {
Convey("Associate developer by username", t, func() {
setup(MockRoute{"PUT", "/v2/spaces/bc7b4caf-f4b8-4d85-b126-0729b9351e56/developers", associateSpaceUserPayload, "", 201, "", nil}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
space := &Space{
Guid: "bc7b4caf-f4b8-4d85-b126-0729b9351e56",
c: client,
}
newSpace, err := space.AssociateDeveloperByUsername("user-name")
So(err, ShouldBeNil)
So(newSpace.Guid, ShouldEqual, "bc7b4caf-f4b8-4d85-b126-0729b9351e56")
})
} | explode_data.jsonl/59990 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 308
} | [
2830,
3393,
95540,
9914,
44911,
91519,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
95540,
15754,
553,
5934,
497,
259,
11,
2915,
368,
341,
197,
84571,
66436,
4899,
4913,
6221,
497,
3521,
85,
17,
26734,
2434,
3470,
66,
22,
65,
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 TestIn(t *testing.T) {
for i, this := range []struct {
v1 interface{}
v2 interface{}
expect bool
}{
{[]string{"a", "b", "c"}, "b", true},
{[]interface{}{"a", "b", "c"}, "b", true},
{[]interface{}{"a", "b", "c"}, "d", false},
{[]string{"a", "b", "c"}, "d", false},
{[]string{"a", "12", "c"}, 12, false},
{[]int{1, 2, 4}, 2, true},
{[]interface{}{1, 2, 4}, 2, true},
{[]interface{}{1, 2, 4}, nil, false},
{[]interface{}{nil}, nil, false},
{[]int{1, 2, 4}, 3, false},
{[]float64{1.23, 2.45, 4.67}, 1.23, true},
{[]float64{1.234567, 2.45, 4.67}, 1.234568, false},
{"this substring should be found", "substring", true},
{"this substring should not be found", "subseastring", false},
} {
result := in(this.v1, this.v2)
if result != this.expect {
t.Errorf("[%d] got %v but expected %v", i, result, this.expect)
}
}
} | explode_data.jsonl/9218 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 406
} | [
2830,
3393,
641,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
419,
1669,
2088,
3056,
1235,
341,
197,
5195,
16,
257,
3749,
16094,
197,
5195,
17,
257,
3749,
16094,
197,
24952,
1807,
198,
197,
59403,
197,
197,
90,
1294,
917,
4913,
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... | 3 |
func TestLogicRunner_OnPulse(t *testing.T) {
table := []struct {
name string
mocks func(ctx context.Context, t minimock.Tester) *LogicRunner
}{
{
name: "broker that stays and sends messages",
mocks: func(ctx context.Context, mc minimock.Tester) *LogicRunner {
lr, err := NewLogicRunner(&configuration.LogicRunner{}, nil, nil)
require.NoError(t, err)
lr.initHandlers()
lr.Sender = bus.NewSenderMock(t).SendRoleMock.Set(
func(ctx context.Context, msg *message2.Message, role insolar.DynamicRole, obj insolar.Reference) (ch1 <-chan *message2.Message, f1 func()) {
return nil, func() {}
})
lr.StateStorage = NewStateStorageMock(mc).
IsEmptyMock.Return(false).
OnPulseMock.Return(map[insolar.Reference][]payload.Payload{gen.Reference(): {&payload.ExecutorResults{}}})
lr.WriteController = writecontroller.NewWriteController()
_ = lr.WriteController.Open(ctx, pulse.MinTimePulse)
lr.ShutdownFlag = shutdown.NewFlagMock(mc).
DoneMock.Set(
func(ctx context.Context, isDone func() bool) {
isDone()
})
lr.ResultsMatcher = newResultsMatcher(lr.Sender, lr.PulseAccessor)
return lr
},
},
{
name: "broker that goes way",
mocks: func(ctx context.Context, mc minimock.Tester) *LogicRunner {
lr, err := NewLogicRunner(&configuration.LogicRunner{}, nil, nil)
require.NoError(t, err)
lr.initHandlers()
lr.StateStorage = NewStateStorageMock(mc).
IsEmptyMock.Return(true).
OnPulseMock.Return(map[insolar.Reference][]payload.Payload{})
lr.WriteController = writecontroller.NewWriteController()
_ = lr.WriteController.Open(ctx, pulse.MinTimePulse)
lr.ShutdownFlag = shutdown.NewFlagMock(mc).
DoneMock.Set(
func(ctx context.Context, isDone func() bool) {
isDone()
})
lr.ResultsMatcher = newResultsMatcher(lr.Sender, lr.PulseAccessor)
return lr
},
},
}
for _, test := range table {
t.Run(test.name, func(t *testing.T) {
ctx := inslogger.TestContext(t)
mc := minimock.NewController(t)
lr := test.mocks(ctx, mc)
err := lr.OnPulse(ctx, insolar.Pulse{PulseNumber: pulse.MinTimePulse}, insolar.Pulse{PulseNumber: pulse.MinTimePulse + 1})
require.NoError(t, err)
mc.Wait(3 * time.Minute)
mc.Finish()
})
}
} | explode_data.jsonl/67709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 965
} | [
2830,
3393,
26751,
19486,
35482,
47,
17217,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
2109,
25183,
2915,
7502,
2266,
9328,
11,
259,
21187,
1176,
836,
5191,
8,
353,
26751,
19486,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExpandResourceServiceAccountExternalPermission(t *testing.T) {
_default := kops.ServiceAccountExternalPermission{}
type args struct {
in map[string]interface{}
}
tests := []struct {
name string
args args
want kops.ServiceAccountExternalPermission
}{
{
name: "default",
args: args{
in: map[string]interface{}{
"name": "",
"namespace": "",
"aws": nil,
},
},
want: _default,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := ExpandResourceServiceAccountExternalPermission(tt.args.in)
if diff := cmp.Diff(tt.want, got); diff != "" {
t.Errorf("ExpandResourceServiceAccountExternalPermission() mismatch (-want +got):\n%s", diff)
}
})
}
} | explode_data.jsonl/22380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
38946,
4783,
1860,
7365,
25913,
14966,
1155,
353,
8840,
836,
8,
341,
197,
9993,
1669,
595,
3721,
13860,
7365,
25913,
14966,
16094,
13158,
2827,
2036,
341,
197,
17430,
2415,
14032,
31344,
16094,
197,
532,
78216,
1669,
3056,
123... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHttpParser_splitResponse_midBody(t *testing.T) {
data1 := "HTTP/1.1 200 OK\r\n" +
"Date: Tue, 14 Aug 2012 22:31:45 GMT\r\n" +
"Expires: -1\r\n" +
"Cache-Control: private, max-age=0\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
"Content-Encoding: gzip\r\n" +
"Server: gws\r\n" +
"Content-Length: 3"
data2 := "0\r\n" +
"X-XSS-Protection: 1; mode=block\r\n" +
"X-Frame-Options: SAMEORIGIN\r\n" +
"\r\n" +
"xxxxxxxxxx"
data3 := "xxxxxxxxxxxxxxxxxxxx"
tp := newTestParser(nil, data1, data2, data3)
_, ok, complete := tp.parse()
assert.True(t, ok)
assert.False(t, complete)
_, ok, complete = tp.parse()
assert.True(t, ok)
assert.False(t, complete)
message, ok, complete := tp.parse()
assert.True(t, ok)
assert.True(t, complete)
assert.Equal(t, 30, message.contentLength)
assert.Equal(t, []byte(""), tp.stream.data[tp.stream.parseOffset:])
} | explode_data.jsonl/16499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
2905,
6570,
17052,
2582,
43733,
5444,
1155,
353,
8840,
836,
8,
341,
8924,
16,
1669,
330,
9230,
14,
16,
13,
16,
220,
17,
15,
15,
10402,
12016,
1699,
1,
3610,
197,
197,
1,
1916,
25,
39167,
11,
220,
16,
19,
4928,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestArrayLookup(t *testing.T) {
testStr := `<?
echo $arr['one'][$two];
$var->arr[] = 2;
echo $arr[2 + 1];`
p := NewParser()
p.disableScoping = true
p.Debug = true
p.MaxErrors = 0
a, _ := p.Parse("test.php", testStr)
if len(a.Nodes) == 0 {
t.Fatalf("Array lookup did not correctly parse")
}
tree := []ast.Node{
ast.EchoStmt{
Expressions: []ast.Expr{&ast.ArrayLookupExpr{
Array: &ast.ArrayLookupExpr{
Array: ast.NewVariable("arr"),
Index: &ast.Literal{Type: ast.String, Value: `'one'`},
},
Index: ast.NewVariable("two"),
}},
},
ast.ExprStmt{
Expr: ast.AssignmentExpr{
Assignee: ast.ArrayAppendExpr{
Array: &ast.PropertyCallExpr{
Receiver: ast.NewVariable("var"),
Name: &ast.Identifier{Value: "arr"},
},
},
Operator: "=",
Value: &ast.Literal{Type: ast.Float, Value: "2"},
},
},
}
if !assertEquals(a.Nodes[0], tree[0]) {
t.Fatalf("Array lookup did not correctly parse")
}
if !assertEquals(a.Nodes[1], tree[1]) {
t.Fatalf("Array append expression did not correctly parse")
}
} | explode_data.jsonl/28446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 506
} | [
2830,
3393,
1857,
34247,
1155,
353,
8840,
836,
8,
341,
18185,
2580,
1669,
1565,
53075,
220,
1687,
400,
1118,
677,
603,
18159,
19789,
935,
220,
400,
947,
405,
1118,
1294,
284,
220,
17,
280,
220,
1687,
400,
1118,
58,
17,
488,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestClientInterface(t *testing.T) {
t.Run("Transport", func(t *testing.T) {
c, err := NewClient(Config{Transport: &mockTransp{}})
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if called != false { // megacheck ignore
t.Errorf("Unexpected call to transport by client")
}
c.Perform(&http.Request{URL: &url.URL{}, Header: make(http.Header)}) // errcheck ignore
if called != true { // megacheck ignore
t.Errorf("Expected client to call transport")
}
})
} | explode_data.jsonl/24030 | {
"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,
2959,
5051,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
27560,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1444,
11,
1848,
1669,
1532,
2959,
33687,
90,
27560,
25,
609,
16712,
3167,
79,
90,
3417,
692,
197,
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,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestNew(t *testing.T) {
c := Config{
APIKey: "apikey",
}
a, err := New(c)
assert.Implements(t, (*Apixu)(nil), a)
assert.NoError(t, err)
} | explode_data.jsonl/14936 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
5532,
515,
197,
197,
7082,
1592,
25,
330,
72174,
756,
197,
532,
11323,
11,
1848,
1669,
1532,
1337,
692,
6948,
26914,
4674,
1155,
11,
4609,
10611,
941,
84,
2376,
8385,
701,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccComputeRouterInterface_basic(t *testing.T) {
t.Parallel()
testId := acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeRouterInterfaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccComputeRouterInterfaceBasic(testId),
Check: testAccCheckComputeRouterInterfaceExists(
"google_compute_router_interface.foobar"),
},
{
ResourceName: "google_compute_router_interface.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeRouterInterfaceKeepRouter(testId),
Check: testAccCheckComputeRouterInterfaceDelete(
"google_compute_router_interface.foobar"),
},
},
})
} | explode_data.jsonl/73836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
14603,
46254,
9523,
5051,
34729,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
764,
1669,
1613,
67880,
2013,
437,
703,
7,
16,
15,
340,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_convertCustomAppsToForecastleApps(t *testing.T) {
type args struct {
customApps []config.CustomApp
}
tests := []struct {
name string
args args
wantApps []forecastle.App
}{
{
name: "TestConvertCustomAppsToForecastleAppsWithNoApps",
args: args{
customApps: []config.CustomApp{},
},
wantApps: nil,
},
{
name: "TestConvertCustomAppsToForecastleApps",
args: args{
customApps: []config.CustomApp{
config.CustomApp{
Name: "test",
Icon: "http://google.com/image.png",
Group: "New",
URL: "http://google.com",
},
},
},
wantApps: []forecastle.App{
forecastle.App{
Name: "test",
Icon: "http://google.com/image.png",
Group: "New",
URL: "http://google.com",
DiscoverySource: forecastle.Config,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotApps := convertCustomAppsToForecastleApps(tt.args.customApps); !reflect.DeepEqual(gotApps, tt.wantApps) {
t.Errorf("convertCustomAppsToForecastleApps() = %v, want %v", gotApps, tt.wantApps)
}
})
}
} | explode_data.jsonl/72060 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 553
} | [
2830,
3393,
34910,
10268,
53602,
1249,
11092,
35108,
53602,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1444,
1450,
53602,
3056,
1676,
27649,
2164,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMarshalCustomTag(t *testing.T) {
c := core.NewDefault()
assert.NoError(t, c.RegisterModels(&CustomTagModel{}))
hidden := &CustomTagModel{ID: 1, VisibleCustomName: "found", HiddenField: true, OmitEmptyField: "found", CustomOmitEmpty: "found"}
modelStruct := c.MustModelStruct(hidden)
attributes := modelStruct.Attributes()
payload := &codec.Payload{
ModelStruct: modelStruct,
Data: []mapping.Model{hidden},
FieldSets: []mapping.FieldSet{append([]*mapping.StructField{modelStruct.Primary()}, attributes...)},
}
cd := &Codec{c: c}
nodes, err := cd.visitPayloadModels(payload, &codec.MarshalOptions{})
require.NoError(t, err)
require.Len(t, nodes, 1)
attrs := nodes[0].Attributes
atr, ok := attrs["visible"]
if assert.True(t, ok, attrs) {
assert.Equal(t, "found", atr)
}
atr, ok = attrs["omit_empty_field"]
if assert.True(t, ok) {
assert.Equal(t, "found", atr)
}
atr, ok = attrs["custom"]
if assert.True(t, ok) {
assert.Equal(t, "found", atr)
}
_, ok = attrs["hidden_field"]
assert.False(t, ok)
} | explode_data.jsonl/47148 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 423
} | [
2830,
3393,
55438,
10268,
5668,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
6200,
7121,
3675,
741,
6948,
35699,
1155,
11,
272,
19983,
16969,
2099,
10268,
5668,
1712,
6257,
4390,
197,
6263,
1669,
609,
10268,
5668,
1712,
90,
915,
25,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestEndExecutionSpanWithNoError(t *testing.T) {
defer os.Unsetenv(functionNameEnvVar)
defer os.Unsetenv("DD_CAPTURE_LAMBDA_PAYLOAD")
os.Setenv(functionNameEnvVar, "TestFunction")
os.Setenv("DD_CAPTURE_LAMBDA_PAYLOAD", "true")
defer reset()
testString := `a5a{"resource":"/users/create","path":"/users/create","httpMethod":"GET","headers":{"Accept":"*/*","Accept-Encoding":"gzip","x-datadog-parent-id":"1480558859903409531","x-datadog-sampling-priority":"1","x-datadog-trace-id":"5736943178450432258"}}0`
startTime := time.Now()
startExecutionSpan(startTime, testString, LambdaInvokeEventHeaders{})
duration := 1 * time.Second
endTime := startTime.Add(duration)
isError := false
var tracePayload *api.Payload
mockProcessTrace := func(payload *api.Payload) {
tracePayload = payload
}
endExecutionSpan(mockProcessTrace, "test-request-id", endTime, isError, []byte(`{"response":"test response payload"}`))
executionSpan := tracePayload.TracerPayload.Chunks[0].Spans[0]
assert.Equal(t, "aws.lambda", executionSpan.Name)
assert.Equal(t, "aws.lambda", executionSpan.Service)
assert.Equal(t, "TestFunction", executionSpan.Resource)
assert.Equal(t, "serverless", executionSpan.Type)
assert.Equal(t, "test-request-id", executionSpan.Meta["request_id"])
assert.Equal(t, testString, executionSpan.Meta["function.request"])
assert.Equal(t, `{"response":"test response payload"}`, executionSpan.Meta["function.response"])
assert.Equal(t, currentExecutionInfo.traceID, executionSpan.TraceID)
assert.Equal(t, currentExecutionInfo.spanID, executionSpan.SpanID)
assert.Equal(t, startTime.UnixNano(), executionSpan.Start)
assert.Equal(t, duration.Nanoseconds(), executionSpan.Duration)
} | explode_data.jsonl/2348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 623
} | [
2830,
3393,
3727,
20294,
12485,
2354,
2753,
1454,
1155,
353,
8840,
836,
8,
341,
16867,
2643,
10616,
746,
3160,
2920,
675,
14359,
3962,
340,
16867,
2643,
10616,
746,
3160,
445,
4103,
61801,
2351,
69200,
6352,
79493,
1138,
25078,
4202,
3160... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConnectCluster(t *testing.T) {
nodeList := createMockNodes(allocatableMap, schedulableNodeMap)
ms := &MockClusterScrapper{
mockGetAllNodes: func() ([]*v1.Node, error) {
return nodeList, nil
},
mockGetKubernetesServiceID: func() (svcID string, err error) {
return testClusterName, nil
},
}
ns := &MockNodeScrapper{
mockGetSummary: func(ip, nodeName string) (*stats.Summary, error) {
summary := stats.Summary{}
return &summary, nil
},
}
clusterProcessor := &ClusterProcessor{
clusterInfoScraper: ms,
nodeScrapper: ns,
}
err := clusterProcessor.ConnectCluster()
//assert.NotNil(t, kubeCluster)
assert.True(t, clusterProcessor.isValidated)
assert.Nil(t, err)
} | explode_data.jsonl/62017 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
14611,
28678,
1155,
353,
8840,
836,
8,
341,
20831,
852,
1669,
1855,
11571,
12288,
7,
4742,
15086,
2227,
11,
5575,
360,
480,
1955,
2227,
340,
47691,
1669,
609,
11571,
28678,
3326,
5518,
515,
197,
77333,
1949,
2403,
12288,
25,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNoTTLStrategyFailedButTTLSecondsAfterFinished(t *testing.T) {
var err error
var un *unstructured.Unstructured
var ten int32 = 10
controller := newTTLController()
// Veirfy we do not enqueue if not completed
wf := test.LoadWorkflowFromBytes([]byte(failedWf))
wf.Spec.TTLSecondsAfterFinished = &ten
wf.Status.FinishedAt = metav1.Time{Time: controller.clock.Now().Add(-5 * time.Second)}
un, err = util.ToUnstructured(wf)
assert.NoError(t, err)
controller.enqueueWF(un)
assert.Equal(t, 0, controller.workqueue.Len())
wf1 := test.LoadWorkflowFromBytes([]byte(failedWf))
wf1.Spec.TTLSecondsAfterFinished = &ten
ttlstrategy := wfv1.TTLStrategy{SecondsAfterFailure: &ten}
wf1.Spec.TTLStrategy = &ttlstrategy
wf1.Status.FinishedAt = metav1.Time{Time: controller.clock.Now().Add(-11 * time.Second)}
un, err = util.ToUnstructured(wf1)
assert.NoError(t, err)
controller.enqueueWF(un)
assert.Equal(t, 1, controller.workqueue.Len())
} | explode_data.jsonl/48745 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 372
} | [
2830,
3393,
2753,
51,
13470,
19816,
9408,
3983,
51,
13470,
15343,
6025,
24890,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
2405,
650,
353,
359,
51143,
10616,
51143,
198,
2405,
5779,
526,
18,
17,
284,
220,
16,
15,
271,
61615,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestURIMapping(t *testing.T) {
t.Parallel()
r, err := buildRelabeling(config.RelabelConfig{
Split: 2,
Matches: []config.RelabelValueMatch{
{RegexpString: "^/users/[0-9]+", Replacement: "/users/:id"},
},
})
if err != nil {
t.Error(err)
}
assertMapping(t, r, "GET /users/12345 HTTP/1.1", "/users/:id")
assertMapping(t, r, "GET /users/12345/about HTTP/1.1", "/users/:id/about")
assertMapping(t, r, "GET /v1/users/12345 HTTP/1.1", "")
} | explode_data.jsonl/49265 | {
"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,
1900,
1511,
1791,
3629,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
7000,
11,
1848,
1669,
1936,
6740,
780,
287,
8754,
38939,
780,
2648,
515,
197,
7568,
2292,
25,
220,
17,
345,
197,
197,
42470,
25,
3056,
1676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPassthroughDuringDrain(t *testing.T) {
flag.Set("enable_buffer", "true")
flag.Set("buffer_keyspace_shards", topoproto.KeyspaceShardString(keyspace, shard))
defer resetFlagsForTesting()
b := New()
// Buffer one request.
markRetryDone := make(chan struct{})
stopped := issueRequestAndBlockRetry(context.Background(), t, b, failoverErr, markRetryDone)
if err := waitForRequestsInFlight(b, 1); err != nil {
t.Fatal(err)
}
// Stop buffering and trigger drain.
b.StatsUpdate(&discovery.TabletStats{
Tablet: newMaster,
Target: &querypb.Target{Keyspace: keyspace, Shard: shard, TabletType: topodatapb.TabletType_MASTER},
TabletExternallyReparentedTimestamp: 1, // Use any value > 0.
})
if got, want := b.getOrCreateBuffer(keyspace, shard).state, stateDraining; got != want {
t.Fatalf("wrong expected state. got = %v, want = %v", got, want)
}
// Requests during the drain will be passed through and not buffered.
if retryDone, err := b.WaitForFailoverEnd(context.Background(), keyspace, shard, nil); err != nil || retryDone != nil {
t.Fatalf("requests with no error must not be buffered during a drain. err: %v retryDone: %v", err, retryDone)
}
if retryDone, err := b.WaitForFailoverEnd(context.Background(), keyspace, shard, failoverErr); err != nil || retryDone != nil {
t.Fatalf("requests with failover errors must not be buffered during a drain. err: %v retryDone: %v", err, retryDone)
}
// Finish draining by telling the buffer that the retry is done.
close(markRetryDone)
<-stopped
// Wait for the drain to complete to avoid races with other tests.
if err := waitForState(b, stateIdle); err != nil {
t.Fatal(err)
}
if err := waitForPoolSlots(b, *size); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/55858 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 611
} | [
2830,
3393,
70911,
86901,
16014,
8847,
466,
1155,
353,
8840,
836,
8,
341,
30589,
4202,
445,
12552,
7776,
497,
330,
1866,
1138,
30589,
4202,
445,
7573,
3097,
8746,
3712,
2347,
497,
1909,
45926,
983,
37863,
1306,
2016,
567,
703,
4857,
874... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestLimitRestore(t *testing.T) {
testCases := []NodeRestoreTestCase{
{"limit 10", "LIMIT 10"},
{"limit 10,20", "LIMIT 10,20"},
{"limit 20 offset 10", "LIMIT 10,20"},
}
extractNodeFunc := func(node Node) Node {
return node.(*SelectStmt).Limit
}
runNodeRestoreTest(t, testCases, "SELECT 1 %s", extractNodeFunc)
} | explode_data.jsonl/27568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
16527,
56284,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1955,
56284,
16458,
515,
197,
197,
4913,
9506,
220,
16,
15,
497,
330,
57100,
220,
16,
15,
7115,
197,
197,
4913,
9506,
220,
16,
15,
11,
17,
15,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMempoolCloseWAL(t *testing.T) {
// 1. Create the temporary directory for mempool and WAL testing.
rootDir, err := ioutil.TempDir("", "mempool-test")
require.Nil(t, err, "expecting successful tmpdir creation")
// 2. Ensure that it doesn't contain any elements -- Sanity check
m1, err := filepath.Glob(filepath.Join(rootDir, "*"))
require.Nil(t, err, "successful globbing expected")
require.Equal(t, 0, len(m1), "no matches yet")
// 3. Create the mempool
wcfg := cfg.DefaultConfig()
wcfg.Mempool.RootDir = rootDir
app := kvstore.NewApplication()
cc := proxy.NewLocalClientCreator(app)
mempool, cleanup := newMempoolWithAppAndConfig(cc, wcfg)
defer cleanup()
mempool.height = 10
err = mempool.InitWAL()
require.NoError(t, err)
// 4. Ensure that the directory contains the WAL file
m2, err := filepath.Glob(filepath.Join(rootDir, "*"))
require.Nil(t, err, "successful globbing expected")
require.Equal(t, 1, len(m2), "expecting the wal match in")
// 5. Write some contents to the WAL
err = mempool.CheckTx(types.Tx([]byte("foo")), nil, TxInfo{})
require.NoError(t, err)
walFilepath := mempool.wal.Path
sum1 := checksumFile(walFilepath, t)
// 6. Sanity check to ensure that the written TX matches the expectation.
require.Equal(t, sum1, checksumIt([]byte("foo\n")), "foo with a newline should be written")
// 7. Invoke CloseWAL() and ensure it discards the
// WAL thus any other write won't go through.
mempool.CloseWAL()
err = mempool.CheckTx(types.Tx([]byte("bar")), nil, TxInfo{})
require.NoError(t, err)
sum2 := checksumFile(walFilepath, t)
require.Equal(t, sum1, sum2, "expected no change to the WAL after invoking CloseWAL() since it was discarded")
// 8. Sanity check to ensure that the WAL file still exists
m3, err := filepath.Glob(filepath.Join(rootDir, "*"))
require.Nil(t, err, "successful globbing expected")
require.Equal(t, 1, len(m3), "expecting the wal match in")
} | explode_data.jsonl/14614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 684
} | [
2830,
3393,
44,
3262,
1749,
7925,
54,
969,
1155,
353,
8840,
836,
8,
341,
197,
322,
220,
16,
13,
4230,
279,
13340,
6220,
369,
1833,
10285,
323,
73792,
7497,
624,
33698,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
76,
3262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseIncompleteSecurityRequirement(t *testing.T) {
swagger := openapi_options.Swagger{
Security: []*openapi_options.SecurityRequirement{
{
SecurityRequirement: map[string]*openapi_options.SecurityRequirement_SecurityRequirementValue{
"key": nil,
},
},
},
}
file := descriptor.File{
FileDescriptorProto: &descriptorpb.FileDescriptorProto{
SourceCodeInfo: &descriptorpb.SourceCodeInfo{},
Name: proto.String("example.proto"),
Package: proto.String("example"),
Options: &descriptorpb.FileOptions{
GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"),
},
},
}
proto.SetExtension(proto.Message(file.FileDescriptorProto.Options), openapi_options.E_Openapiv2Swagger, &swagger)
reg := descriptor.NewRegistry()
err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}})
if err != nil {
t.Errorf("failed to reg.Load(): %v", err)
return
}
_, err = applyTemplate(param{File: crossLinkFixture(&file), reg: reg})
if err == nil {
t.Errorf("applyTemplate(%#v) did not error as expected", file)
return
}
} | explode_data.jsonl/32809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
14463,
96698,
15352,
75802,
1155,
353,
8840,
836,
8,
341,
77295,
10114,
1669,
1787,
2068,
8743,
808,
86,
10114,
515,
197,
7568,
18429,
25,
29838,
2508,
2068,
8743,
21567,
75802,
515,
298,
197,
515,
571,
7568,
18429,
75802,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestImportFromDiskWrongJson(t *testing.T) {
RegisterTestingT(t)
unit := NewHoverflyWithConfiguration(&Configuration{})
err := unit.ImportFromDisk("examples/exports/README.md")
Expect(err).ToNot(BeNil())
} | explode_data.jsonl/75448 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
11511,
3830,
47583,
29185,
5014,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
692,
81189,
1669,
1532,
34379,
21642,
2354,
7688,
2099,
7688,
6257,
692,
9859,
1669,
4982,
67275,
3830,
47583,
445,
51668,
14,
4986,
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 |
func TestPublishFlags(t *testing.T) {
assert := assert.New(t)
var f PublishFlags
assert.False(f.Dup())
assert.Equal(QoS0, f.QoS())
assert.False(f.Retain())
f.SetDup(true)
f.SetQoS(QoS1)
f.SetRetain(true)
assert.True(f.Dup())
assert.Equal(QoS1, f.QoS())
assert.True(f.Retain())
f.SetDup(false)
f.SetQoS(QoS2)
f.SetRetain(false)
assert.False(f.Dup())
assert.Equal(QoS2, f.QoS())
assert.False(f.Retain())
} | explode_data.jsonl/59725 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
50145,
9195,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
2405,
282,
23499,
9195,
271,
6948,
50757,
955,
909,
454,
2398,
6948,
12808,
6253,
72743,
15,
11,
282,
10003,
72743,
2398,
6948,
50757,
955,
52846,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDirectlyWithinInlineFragment(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Pet {
... on Dog {
...fragA
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself.`, 4, 11),
})
} | explode_data.jsonl/30371 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
17926,
36989,
82440,
9488,
6406,
30358,
36989,
6406,
6154,
2132,
721,
16027,
398,
41961,
25324,
9488,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
81893,
37,
6209,
11337,
1155,
11,
48865,
16766,
9488,
34,
15805,
11337,
11,
22074... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMatches_Total(t *testing.T) {
type fields struct {
hits map[string]int
}
tests := []struct {
name string
fields fields
want int
}{
{
"no results",
fields{hits: map[string]int{}},
0,
},
{
"some results",
fields{hits: map[string]int{
"one": 1,
"two times": 2,
"many": 10,
}},
13,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
sh := &Matches{
termFrequency: tt.fields.hits,
}
if got := sh.Total(); got != tt.want {
t.Errorf("Matches.Total() = %v, want %v", got, tt.want)
}
if diff := cmp.Diff(sh.termFrequency, sh.TermFrequency(), cmp.AllowUnexported(Matches{})); diff != "" {
t.Errorf("Matches.Total() %s = mismatch (-want +got):\n%s", tt.name, diff)
}
})
}
} | explode_data.jsonl/22246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 403
} | [
2830,
3393,
42470,
85933,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
9598,
1199,
2415,
14032,
63025,
198,
197,
630,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
55276,
5043,
198,
197,
50780,
256,
526,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_CtlSvc_StoragePrepare(t *testing.T) {
for name, tc := range map[string]struct {
bmbc *bdev.MockBackendConfig
smbc *scm.MockBackendConfig
req StoragePrepareReq
expResp *StoragePrepareResp
}{
"success": {
smbc: &scm.MockBackendConfig{
DiscoverRes: storage.ScmModules{storage.MockScmModule()},
},
req: StoragePrepareReq{
Nvme: &PrepareNvmeReq{},
Scm: &PrepareScmReq{},
},
expResp: &StoragePrepareResp{
Nvme: &PrepareNvmeResp{State: new(ResponseState)},
Scm: &PrepareScmResp{State: new(ResponseState)},
},
},
"scm only": {
smbc: &scm.MockBackendConfig{
DiscoverRes: storage.ScmModules{storage.MockScmModule()},
},
req: StoragePrepareReq{
Nvme: nil,
Scm: &PrepareScmReq{},
},
expResp: &StoragePrepareResp{
Nvme: nil,
Scm: &PrepareScmResp{State: new(ResponseState)},
},
},
"nvme only": {
req: StoragePrepareReq{
Nvme: &PrepareNvmeReq{},
Scm: nil,
},
expResp: &StoragePrepareResp{
Nvme: &PrepareNvmeResp{State: new(ResponseState)},
Scm: nil,
},
},
"success with pmem devices": {
smbc: &scm.MockBackendConfig{
DiscoverRes: storage.ScmModules{storage.MockScmModule()},
PrepNamespaceRes: storage.ScmNamespaces{storage.MockScmNamespace()},
},
req: StoragePrepareReq{
Nvme: &PrepareNvmeReq{},
Scm: &PrepareScmReq{},
},
expResp: &StoragePrepareResp{
Nvme: &PrepareNvmeResp{State: new(ResponseState)},
Scm: &PrepareScmResp{
State: new(ResponseState),
Namespaces: []*ScmNamespace{proto.MockScmNamespace()},
},
},
},
"fail scm prep": {
smbc: &scm.MockBackendConfig{
DiscoverRes: storage.ScmModules{storage.MockScmModule()},
PrepErr: errors.New("scm prep error"),
},
req: StoragePrepareReq{
Nvme: &PrepareNvmeReq{},
Scm: &PrepareScmReq{},
},
expResp: &StoragePrepareResp{
Nvme: &PrepareNvmeResp{State: new(ResponseState)},
Scm: &PrepareScmResp{
State: &ResponseState{
Status: ResponseStatus_CTL_ERR_SCM,
Error: "scm prep error",
},
},
},
},
"fail nvme prep": {
bmbc: &bdev.MockBackendConfig{
PrepareErr: errors.New("nvme prep error"),
},
smbc: &scm.MockBackendConfig{
DiscoverRes: storage.ScmModules{storage.MockScmModule()},
},
req: StoragePrepareReq{
Nvme: &PrepareNvmeReq{},
Scm: &PrepareScmReq{},
},
expResp: &StoragePrepareResp{
Nvme: &PrepareNvmeResp{
State: &ResponseState{
Status: ResponseStatus_CTL_ERR_NVME,
Error: "nvme prep error",
},
},
Scm: &PrepareScmResp{
State: new(ResponseState),
},
},
},
} {
t.Run(name, func(t *testing.T) {
log, buf := logging.NewTestLogger(t.Name())
defer common.ShowBufferOnFailure(t, buf)
config := newDefaultConfiguration(nil)
cs := mockControlService(t, log, config, tc.bmbc, tc.smbc, nil)
_ = new(StoragePrepareResp)
// runs discovery for nvme & scm
if err := cs.Setup(); err != nil {
t.Fatal(err.Error() + name)
}
// StoragePrepare should never return an error
resp, err := cs.StoragePrepare(context.TODO(), &tc.req)
if err != nil {
t.Fatal(err)
}
if diff := cmp.Diff(tc.expResp, resp); diff != "" {
t.Fatalf("unexpected response (-want, +got):\n%s\n", diff)
}
})
}
} | explode_data.jsonl/64627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1644
} | [
2830,
3393,
5475,
920,
11544,
92766,
62,
5793,
50590,
1155,
353,
8840,
836,
8,
341,
2023,
829,
11,
17130,
1669,
2088,
2415,
14032,
60,
1235,
341,
197,
2233,
3096,
66,
262,
353,
65,
3583,
24664,
29699,
2648,
198,
197,
1903,
3096,
66,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetHelmCharts(t *testing.T) {
service := newService("../..")
res, err := service.GetHelmCharts(context.Background(), &apiclient.HelmChartsRequest{Repo: &argoappv1.Repository{}})
assert.NoError(t, err)
assert.Len(t, res.Items, 1)
item := res.Items[0]
assert.Equal(t, "my-chart", item.Name)
assert.EqualValues(t, []string{"1.0.0", "1.1.0"}, item.Versions)
} | explode_data.jsonl/5692 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
1949,
39,
23162,
64878,
1155,
353,
8840,
836,
8,
341,
52934,
1669,
501,
1860,
17409,
496,
1138,
10202,
11,
1848,
1669,
2473,
2234,
39,
23162,
64878,
5378,
19047,
1507,
609,
391,
292,
1451,
3839,
23162,
64878,
1900,
90,
25243... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddNotificationToMongo(t *testing.T) {
notificationAddResultErr := AddNotificationToMongo(mongoTestsHostURL, "", "", mongoCollectionForTests, year, ownerToUseForTests, numberToUseForCheck, prizeToUseForTests, originToUserForTests)
if notificationAddResultErr != nil {
log.Fatal(notificationAddResultErr)
}
defer testFindAndDeleteNotificationsFromMongo(mongoCollectionForTests, year, ownerToUseForTests, numberToUseForCheck, prizeToUseForTests, originToUserForTests)
} | explode_data.jsonl/71138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
2212,
11196,
1249,
54998,
1155,
353,
8840,
836,
8,
341,
197,
18553,
2212,
2077,
7747,
1669,
2691,
11196,
1249,
54998,
1255,
6363,
18200,
9296,
3144,
11,
7342,
7342,
33814,
6482,
2461,
18200,
11,
1042,
11,
6372,
1249,
10253,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCapacityGetError(t *testing.T) {
testServer(t, func(c *stdsdk.Client, p *structs.MockProvider) {
var c1 *structs.Capacity
p.On("CapacityGet").Return(nil, fmt.Errorf("err1"))
err := c.Get("/system/capacity", stdsdk.RequestOptions{}, c1)
require.Nil(t, c1)
require.EqualError(t, err, "err1")
})
} | explode_data.jsonl/23745 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 136
} | [
2830,
3393,
29392,
1949,
1454,
1155,
353,
8840,
836,
8,
341,
18185,
5475,
1155,
11,
2915,
1337,
353,
1834,
51295,
11716,
11,
281,
353,
1235,
82,
24664,
5179,
8,
341,
197,
2405,
272,
16,
353,
1235,
82,
78963,
4018,
198,
197,
3223,
80... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCorrectScopeError(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
variable.RegisterSysVar(&variable.SysVar{Scope: variable.ScopeNone, Name: "sv_none", Value: "acdc"})
variable.RegisterSysVar(&variable.SysVar{Scope: variable.ScopeGlobal, Name: "sv_global", Value: "acdc"})
variable.RegisterSysVar(&variable.SysVar{Scope: variable.ScopeSession, Name: "sv_session", Value: "acdc"})
variable.RegisterSysVar(&variable.SysVar{Scope: variable.ScopeGlobal | variable.ScopeSession, Name: "sv_both", Value: "acdc"})
// check set behavior
// none
_, err := tk.Exec("SET sv_none='acdc'")
require.Equal(t, "[variable:1238]Variable 'sv_none' is a read only variable", err.Error())
_, err = tk.Exec("SET GLOBAL sv_none='acdc'")
require.Equal(t, "[variable:1238]Variable 'sv_none' is a read only variable", err.Error())
// global
tk.MustExec("SET GLOBAL sv_global='acdc'")
_, err = tk.Exec("SET sv_global='acdc'")
require.Equal(t, "[variable:1229]Variable 'sv_global' is a GLOBAL variable and should be set with SET GLOBAL", err.Error())
// session
_, err = tk.Exec("SET GLOBAL sv_session='acdc'")
require.Equal(t, "[variable:1228]Variable 'sv_session' is a SESSION variable and can't be used with SET GLOBAL", err.Error())
tk.MustExec("SET sv_session='acdc'")
// both
tk.MustExec("SET GLOBAL sv_both='acdc'")
tk.MustExec("SET sv_both='acdc'")
// unregister
variable.UnregisterSysVar("sv_none")
variable.UnregisterSysVar("sv_global")
variable.UnregisterSysVar("sv_session")
variable.UnregisterSysVar("sv_both")
} | explode_data.jsonl/5747 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 587
} | [
2830,
3393,
33092,
10803,
1454,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
741,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetBundleIndex(t *testing.T) {
if index, err := getBundleIndex("ELASTICSEARCH", []Bundle{
{Bundle: "LOG_SHIPPER"},
{Bundle: "ELASTICSEARCH"},
}); err != nil || index != 1 {
t.Fatalf("Expect no error and 1, got %v and %v", err, index)
}
if index, err := getBundleIndex("ELASTICSEARCH", []Bundle{
{Bundle: "ELASTICSEARCH"},
}); err != nil || index != 0 {
t.Fatalf("Expect no error and 0, got %v and %v", err, index)
}
} | explode_data.jsonl/3829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
1949,
8409,
1552,
1155,
353,
8840,
836,
8,
341,
743,
1922,
11,
1848,
1669,
633,
8409,
1552,
445,
2749,
6349,
1317,
43545,
497,
3056,
8409,
515,
197,
197,
90,
8409,
25,
330,
7243,
6834,
3298,
9654,
7115,
197,
197,
90,
840... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCAuserHasAttribute(t *testing.T) {
testDirClean(t)
ca, err := newCA(configFile, &CAConfig{}, &srv, false)
if err != nil {
t.Fatal("newCA failed ", err)
}
_, err = ca.userHasAttribute(string(0), string(0))
t.Log("userHasAttribute err: ", err)
if err == nil {
t.Error("userHasAttribute should have failed: bad parameter")
}
CAclean(ca, t)
} | explode_data.jsonl/82699 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
5049,
872,
10281,
3907,
1155,
353,
8840,
836,
8,
341,
18185,
6184,
27529,
1155,
340,
197,
924,
11,
1848,
1669,
501,
5049,
8754,
1703,
11,
609,
5049,
2648,
22655,
609,
40020,
11,
895,
340,
743,
1848,
961,
2092,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTLDReplace(t *testing.T) {
out, err := strategy.TLDReplace.Generate("example", "com")
if err != nil {
t.Fail()
t.Fatal("Error should not occur !", err)
}
if len(out) == 0 {
t.FailNow()
}
if len(out) != 83 {
t.FailNow()
}
} | explode_data.jsonl/47665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
51,
12335,
23107,
1155,
353,
8840,
836,
8,
341,
13967,
11,
1848,
1669,
8282,
836,
12335,
23107,
57582,
445,
8687,
497,
330,
874,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
57243,
741,
197,
3244,
26133,
445,
1454,
1265,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestApplicationResolver_UpdateApplication(t *testing.T) {
// GIVEN
fixName := "fix-name"
appSvc := automock.NewApplicationSvc()
defer appSvc.AssertExpectations(t)
resolver := application.NewApplicationResolver(appSvc, nil)
for tn, tc := range map[string]struct {
givenDesc *string
givenLabels gqlschema.Labels
expectedDesc string
expectedLabels gqlschema.Labels
}{
"nothing provided": {},
"fully parametrized": {
givenDesc: ptrStr("desc"),
givenLabels: gqlschema.Labels{
"lol": "test",
},
expectedDesc: "desc",
expectedLabels: gqlschema.Labels{
"lol": "test",
},
},
"only desc provided": {
givenDesc: ptrStr("desc"),
expectedDesc: "desc",
},
"only labels provided": {
givenLabels: gqlschema.Labels{
"lol": "test",
},
expectedLabels: gqlschema.Labels{
"lol": "test",
},
},
} {
t.Run(tn, func(t *testing.T) {
appSvc.On("Update", fixName, tc.expectedDesc, tc.expectedLabels).Return(&v1alpha1.Application{
ObjectMeta: v1.ObjectMeta{
Name: fixName,
},
Spec: v1alpha1.ApplicationSpec{
Description: tc.expectedDesc,
Labels: tc.expectedLabels,
},
}, nil)
// WHEN
out, err := resolver.UpdateApplication(context.Background(), fixName, tc.givenDesc, tc.givenLabels)
// THEN
require.NoError(t, err)
assert.Equal(t, fixName, out.Name)
assert.Equal(t, tc.expectedDesc, out.Description)
assert.Equal(t, tc.expectedLabels, out.Labels)
})
}
} | explode_data.jsonl/28763 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 647
} | [
2830,
3393,
4988,
18190,
47393,
4988,
1155,
353,
8840,
836,
8,
341,
197,
322,
89836,
198,
1166,
941,
675,
1669,
330,
5743,
11494,
698,
28236,
92766,
1669,
5006,
1176,
7121,
4988,
92766,
741,
16867,
906,
92766,
11711,
17536,
804,
1155,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBrightness(t *testing.T) {
cases := []struct {
desc string
percent float64
value image.Image
expected *image.RGBA
}{
{
desc: "+100%",
percent: 1.0,
value: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
expected: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0xFF, 0xFF, 0xFF, 0x80, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
},
{
desc: "+0%",
percent: 0.0,
value: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
expected: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
},
{
desc: "+50%",
percent: 0.50,
value: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
expected: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0xC0, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
},
{
desc: "-100%",
percent: -1.0,
value: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
expected: &image.RGBA{
Rect: image.Rect(0, 0, 2, 2),
Stride: 8,
Pix: []uint8{
0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0xFF,
0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0xFF,
},
},
},
}
for _, c := range cases {
actual := Brightness(c.value, c.percent)
if !rgbaImageEqual(actual, c.expected) {
t.Error(testFailMessage("Brightness "+c.desc, c.expected, actual))
}
}
} | explode_data.jsonl/5950 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1405
} | [
2830,
3393,
93247,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
197,
24422,
220,
2224,
21,
19,
198,
197,
16309,
262,
2168,
7528,
198,
197,
42400,
353,
1805,
80114,
32,
198,
197,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetric_MetricDescriptor(t *testing.T) {
ms := NewMetric()
ms.InitEmpty()
assert.EqualValues(t, true, ms.MetricDescriptor().IsNil())
ms.MetricDescriptor().InitEmpty()
assert.EqualValues(t, false, ms.MetricDescriptor().IsNil())
fillTestMetricDescriptor(ms.MetricDescriptor())
assert.EqualValues(t, generateTestMetricDescriptor(), ms.MetricDescriptor())
} | explode_data.jsonl/19511 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
54310,
1245,
16340,
11709,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
54310,
741,
47691,
26849,
3522,
741,
6948,
12808,
6227,
1155,
11,
830,
11,
9829,
1321,
16340,
11709,
1005,
3872,
19064,
2398,
47691,
1321,
16340,
1170... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_getPlatformBenchmarkVersion(t *testing.T) {
type args struct {
platform Platform
}
tests := []struct {
name string
args args
want string
}{
{
name: "eks",
args: args{
platform: Platform{Name: "eks"},
},
want: "eks-1.0.1",
},
{
name: "gke 1.19",
args: args{
platform: Platform{Name: "gke", Version: "1.19"},
},
want: "gke-1.0",
},
{
name: "gke 1.20",
args: args{
platform: Platform{Name: "gke", Version: "1.20"},
},
want: "gke-1.2.0",
},
{
name: "gke 1.22",
args: args{
platform: Platform{Name: "gke", Version: "1.22"},
},
want: "gke-1.2.0",
},
{
name: "aliyun",
args: args{
platform: Platform{Name: "aliyun"},
},
want: "ack-1.0",
},
{
name: "unknown",
args: args{
platform: Platform{Name: "rh"},
},
want: "",
},
{
name: "empty",
args: args{
platform: Platform{},
},
want: "",
},
{
name: "openshift3",
args: args{
platform: Platform{Name: "ocp", Version: "3.10"},
},
want: "rh-0.7",
},
{
name: "openshift4",
args: args{
platform: Platform{Name: "ocp", Version: "4.1"},
},
want: "rh-1.0",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := getPlatformBenchmarkVersion(tt.args.platform); got != tt.want {
t.Errorf("getPlatformBenchmarkVersion() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/60207 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 728
} | [
2830,
3393,
3062,
17296,
84971,
5637,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
197,
15734,
17458,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
914,
198,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSnapshotShouldFail(t *testing.T) {
if test.UpdateGoldenGlobal {
t.Skip()
}
a := struct {
A string
B int
C bool
D *string
}{
A: "fo",
B: 1,
C: true,
D: swag.String("bar"),
}
b := "Hello World!"
tMock := new(mocks.TestingT)
tMock.On("Helper").Return()
tMock.On("Name").Return("TestSnapshotShouldFail")
tMock.On("Error", mock.Anything).Return()
test.Snapshoter.Save(tMock, a, b)
tMock.AssertNotCalled(t, "Fatal")
tMock.AssertNotCalled(t, "Fatalf")
tMock.AssertCalled(t, "Error", mock.Anything)
} | explode_data.jsonl/17627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
15009,
14996,
19524,
1155,
353,
8840,
836,
8,
341,
743,
1273,
16689,
59790,
11646,
341,
197,
3244,
57776,
741,
197,
532,
11323,
1669,
2036,
341,
197,
22985,
914,
198,
197,
12791,
526,
198,
197,
6258,
1807,
198,
197,
10957,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStub(t *testing.T) {
tests := []struct {
name string
want *routev1.Route
}{
{
name: "Test stubbing out route",
want: &routev1.Route{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: api.OpenShiftConsoleName,
GenerateName: "",
Namespace: api.OpenShiftConsoleNamespace,
SelfLink: "",
UID: "",
ResourceVersion: "",
Generation: 0,
CreationTimestamp: metav1.Time{},
DeletionTimestamp: nil,
DeletionGracePeriodSeconds: nil,
Labels: map[string]string{"app": api.OpenShiftConsoleName},
Annotations: map[string]string{},
OwnerReferences: nil,
Finalizers: nil,
ClusterName: "",
},
Spec: routev1.RouteSpec{},
Status: routev1.RouteStatus{},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if diff := deep.Equal(DefaultStub(), tt.want); diff != nil {
t.Error(diff)
}
})
}
} | explode_data.jsonl/62121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 658
} | [
2830,
3393,
33838,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
50780,
353,
8966,
85,
16,
58004,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
2271,
13633,
7132,
700,
6021,
756,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCachePath(t *testing.T) {
os.Unsetenv(xdg.CacheHomeEnvVar)
os.Setenv("TEMP", filepath.Join(homedir.HomeDir(), "foo"))
expected := filepath.Join(homedir.HomeDir(), "foo", appName, testFile)
if lazy.cachePath(testFile) != expected {
t.Errorf("expected '%s', got '%s'", expected, lazy.cachePath(testFile))
}
os.Setenv(xdg.CacheHomeEnvVar, filepath.Join(homedir.HomeDir(), "xdg"))
expected = filepath.Join(homedir.HomeDir(), "xdg", appName, testFile)
if lazy.cachePath(testFile) != expected {
t.Errorf("expected '%s', got '%s'", expected, lazy.cachePath(testFile))
}
} | explode_data.jsonl/5286 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
8233,
1820,
1155,
353,
8840,
836,
8,
341,
25078,
10616,
746,
3160,
2075,
35138,
46130,
7623,
14359,
3962,
340,
25078,
4202,
3160,
445,
48343,
497,
26054,
22363,
3203,
24139,
404,
59965,
6184,
1507,
330,
7975,
28075,
42400,
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 TestOpenConversation(t *testing.T) {
http.HandleFunc("/conversations.open", openConversationHandler)
once.Do(startServer)
api := New("testing-token", OptionAPIURL("http://"+serverAddr+"/"))
params := OpenConversationParameters{ChannelID: "CXXXXXXXX"}
_, _, _, err := api.OpenConversation(¶ms)
if err != nil {
t.Errorf("Unexpected error: %s", err)
return
}
} | explode_data.jsonl/78552 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
5002,
60313,
1155,
353,
8840,
836,
8,
341,
28080,
63623,
4283,
443,
72995,
5826,
497,
1787,
60313,
3050,
340,
197,
13184,
33596,
10639,
5475,
340,
54299,
1669,
1532,
445,
8840,
34841,
497,
6959,
7082,
3144,
445,
1254,
1110,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEvent_ID(t *testing.T) {
e := Message{}
require.Equal(t, EventID{}, e.ID(), "invalid default ID")
id := MustEventID("idk")
e.SetID(id)
require.Equal(t, id, e.ID(), "invalid received ID")
} | explode_data.jsonl/47329 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
1556,
3450,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
4856,
16094,
17957,
12808,
1155,
11,
3665,
915,
22655,
384,
9910,
1507,
330,
11808,
1638,
3034,
1138,
15710,
1669,
15465,
1556,
915,
445,
307,
74,
1138,
7727,
4202,
915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSetDNSSuffix(t *testing.T) {
d := setup()
dn := DNS{}
dn.Suffix = "home.gan"
dn, err := d.SetDNSSuffix(dn)
notErr(t, err)
assert(t, dn.Suffix, "home.gan")
} | explode_data.jsonl/21123 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
1649,
31264,
1220,
13554,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
6505,
741,
2698,
77,
1669,
27598,
16094,
2698,
77,
808,
13554,
284,
330,
5117,
1302,
276,
698,
2698,
77,
11,
1848,
1669,
294,
4202,
31264,
1220,
13554,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestUnexpectedArgValue_FirstArg(t *testing.T) {
reporter, ctrl := createFixtures(t)
defer reporter.recoverUnexpectedFatal()
subject := new(Subject)
expectedArg0 := TestStruct{Number: 123, Message: "hello"}
ctrl.RecordCall(subject, "ActOnTestStructMethod", expectedArg0, 15)
reporter.assertFatal(func() {
// the method argument (of TestStruct type) has 1 unexpected value (for the Message field)
ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 123, Message: "no message"}, 15)
}, "Unexpected call to", "doesn't match the argument at index 0",
"ifference:\nMessage: \"no message\" != \"hello\"")
reporter.assertFatal(func() {
// the method argument (of TestStruct type) has 2 unexpected values (for both fields)
ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 11, Message: "no message"}, 15)
}, "Unexpected call to", "doesn't match the argument at index 0",
"Difference:\nNumber: 11 != 123\nMessage: \"no message\" != \"hello\"")
reporter.assertFatal(func() {
// The expected call wasn't made.
ctrl.Finish()
})
} | explode_data.jsonl/17274 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 340
} | [
2830,
3393,
29430,
2735,
1130,
79790,
2735,
1155,
353,
8840,
836,
8,
341,
69931,
261,
11,
23743,
1669,
1855,
25958,
18513,
1155,
340,
16867,
18960,
1327,
3688,
29430,
62396,
741,
28624,
583,
1669,
501,
7,
13019,
692,
42400,
2735,
15,
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 TestGlobAnyMatch(t *testing.T) {
assert := assert.New(t)
assert.False(globAnyMatch("", "testo"))
assert.True(globAnyMatch("*", "testo"))
assert.True(globAnyMatch("x,testo", "testo"))
assert.False(globAnyMatch("x,y", "testo"))
} | explode_data.jsonl/60253 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
38,
1684,
8610,
8331,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
6948,
50757,
3268,
1684,
8610,
8331,
19814,
330,
1944,
78,
5455,
6948,
32443,
3268,
1684,
8610,
8331,
29592,
497,
330,
1944,
78,
5455,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAPIServerDefaults(t *testing.T) {
defaults := kubeapiservercmdoptions.NewServerRunOptions()
// This is a snapshot of the default config
// If the default changes (new fields are added, or default values change), we want to know
// Once we've reacted to the changes appropriately in BuildKubernetesMasterConfig(), update this expected default to match the new upstream defaults
expectedDefaults := &kubeapiservercmdoptions.ServerRunOptions{
ServiceClusterIPRange: net.IPNet{IP: net.ParseIP("10.0.0.0"), Mask: net.CIDRMask(24, 32)}, // overridden
ServiceNodePortRange: utilnet.PortRange{Base: 30000, Size: 2768}, // overridden
MasterCount: 1, // ignored
GenericServerRunOptions: &apiserveroptions.ServerRunOptions{
MaxRequestsInFlight: 400,
MaxMutatingRequestsInFlight: 200,
MinRequestTimeout: 1800,
RequestTimeout: time.Duration(60) * time.Second,
JSONPatchMaxCopyBytes: int64(3 * 1024 * 1024),
MaxRequestBodyBytes: int64(3 * 1024 * 1024),
},
Admission: &kubeapiserveroptions.AdmissionOptions{
PluginNames: nil, // ignored
GenericAdmission: &apiserveroptions.AdmissionOptions{
RecommendedPluginOrder: kubeapiserveroptions.AllOrderedPlugins, // ignored
DefaultOffPlugins: kubeapiserveroptions.DefaultOffAdmissionPlugins(), // ignored
},
},
Etcd: &apiserveroptions.EtcdOptions{
StorageConfig: storagebackend.Config{
ServerList: nil,
Prefix: "/registry",
DeserializationCacheSize: 0,
Quorum: true,
CompactionInterval: 300000000000, // five minutes
CountMetricPollPeriod: 60000000000, // one minute
},
DefaultStorageMediaType: "application/vnd.kubernetes.protobuf",
DeleteCollectionWorkers: 1,
EnableGarbageCollection: true,
EnableWatchCache: true,
DefaultWatchCacheSize: 100,
},
SecureServing: &apiserveroptions.SecureServingOptionsWithLoopback{
SecureServingOptions: &apiserveroptions.SecureServingOptions{
BindAddress: net.ParseIP("0.0.0.0"),
BindPort: 6443,
ServerCert: apiserveroptions.GeneratableKeyCert{
CertDirectory: "/var/run/kubernetes",
PairName: "apiserver",
},
},
},
InsecureServing: &kubeoptions.InsecureServingOptions{
BindAddress: net.ParseIP("127.0.0.1"),
BindPort: 8080,
},
EndpointReconcilerType: "lease", //ignored
EventTTL: 1 * time.Hour,
KubeletConfig: kubeletclient.KubeletClientConfig{
Port: 10250,
ReadOnlyPort: 10255,
PreferredAddressTypes: []string{
string(apiv1.NodeHostName),
string(apiv1.NodeInternalDNS),
string(apiv1.NodeInternalIP),
string(apiv1.NodeExternalDNS),
string(apiv1.NodeExternalIP),
},
EnableHttps: true,
HTTPTimeout: time.Duration(5) * time.Second,
},
// we currently overwrite this entire stanza, but we should be trying to collapse onto the upstream
// flag or config mechanism for kube.
Audit: &apiserveroptions.AuditOptions{
LogOptions: apiserveroptions.AuditLogOptions{
GroupVersionString: "audit.k8s.io/v1beta1",
Format: "json",
BatchOptions: apiserveroptions.AuditBatchOptions{
Mode: "blocking",
BatchConfig: pluginbuffered.BatchConfig{
BufferSize: 10000,
MaxBatchSize: 400,
MaxBatchWait: time.Duration(30000000000),
ThrottleQPS: 10,
ThrottleBurst: 15,
},
},
TruncateOptions: apiserveroptions.AuditTruncateOptions{
TruncateConfig: plugintruncate.Config{
MaxEventSize: 102400,
MaxBatchSize: 10485760,
},
},
},
WebhookOptions: apiserveroptions.AuditWebhookOptions{
GroupVersionString: "audit.k8s.io/v1beta1",
BatchOptions: apiserveroptions.AuditBatchOptions{
Mode: "batch",
BatchConfig: pluginbuffered.BatchConfig{
BufferSize: 10000,
MaxBatchSize: 400,
MaxBatchWait: time.Duration(30000000000),
ThrottleEnable: true,
ThrottleQPS: 10,
ThrottleBurst: 15,
},
},
TruncateOptions: apiserveroptions.AuditTruncateOptions{
TruncateConfig: plugintruncate.Config{
MaxEventSize: 102400,
MaxBatchSize: 10485760,
},
},
InitialBackoff: time.Duration(10000000000),
},
},
Features: &apiserveroptions.FeatureOptions{
EnableProfiling: true,
},
Authentication: &kubeoptions.BuiltInAuthenticationOptions{
Anonymous: &kubeoptions.AnonymousAuthenticationOptions{Allow: true},
BootstrapToken: &kubeoptions.BootstrapTokenAuthenticationOptions{},
ClientCert: &apiserveroptions.ClientCertAuthenticationOptions{},
OIDC: &kubeoptions.OIDCAuthenticationOptions{},
PasswordFile: &kubeoptions.PasswordFileAuthenticationOptions{},
RequestHeader: &apiserveroptions.RequestHeaderAuthenticationOptions{},
ServiceAccounts: &kubeoptions.ServiceAccountAuthenticationOptions{
Lookup: true,
},
TokenFile: &kubeoptions.TokenFileAuthenticationOptions{},
WebHook: &kubeoptions.WebHookAuthenticationOptions{CacheTTL: 2 * time.Minute},
TokenSuccessCacheTTL: 10 * time.Second,
TokenFailureCacheTTL: 0,
},
Authorization: &kubeoptions.BuiltInAuthorizationOptions{
Modes: []string{"AlwaysAllow"},
WebhookCacheAuthorizedTTL: 5 * time.Minute,
WebhookCacheUnauthorizedTTL: 30 * time.Second,
},
CloudProvider: &kubeoptions.CloudProviderOptions{},
StorageSerialization: &kubeoptions.StorageSerializationOptions{
StorageVersions: kubeapiserveroptions.ToPreferredVersionString(legacyscheme.Scheme.PreferredVersionAllGroups()),
DefaultStorageVersions: kubeapiserveroptions.ToPreferredVersionString(legacyscheme.Scheme.PreferredVersionAllGroups()),
},
APIEnablement: &apiserveroptions.APIEnablementOptions{
RuntimeConfig: utilconfig.ConfigurationMap{},
},
EnableLogsHandler: true, // we disable this
}
// clear the non-serializeable bit
defaults.Admission.GenericAdmission.Plugins = nil
if !reflect.DeepEqual(defaults, expectedDefaults) {
t.Logf("expected defaults, actual defaults: \n%s", diff.ObjectReflectDiff(expectedDefaults, defaults))
t.Errorf("Got different defaults than expected, adjust in BuildKubernetesMasterConfig and update expectedDefaults")
}
} | explode_data.jsonl/53173 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2554
} | [
2830,
3393,
2537,
1637,
2836,
16273,
1155,
353,
8840,
836,
8,
341,
11940,
82,
1669,
80958,
13725,
2836,
8710,
2875,
7121,
5475,
6727,
3798,
2822,
197,
322,
1096,
374,
264,
16295,
315,
279,
1638,
2193,
198,
197,
322,
1416,
279,
1638,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCalc2(t *testing.T) {
if _, err := Calc("5/0"); err == nil {
t.Error("Calc did not work as expected.")
} else {
t.Log("Calc test passed.", err)
}
} | explode_data.jsonl/49583 | {
"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,
47168,
17,
1155,
353,
8840,
836,
8,
341,
743,
8358,
1848,
1669,
34215,
445,
20,
14,
15,
5038,
1848,
621,
2092,
341,
197,
3244,
6141,
445,
47168,
1521,
537,
975,
438,
3601,
13053,
197,
92,
770,
341,
197,
3244,
5247,
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
] | 2 |
func Test_sub(t *testing.T) {
numA, numB, expectedResult := 3, 4, -1
result := sub(numA, numB)
if result != expectedResult {
t.Fatalf("Sub error: expected %d, but got %d", expectedResult, result)
}
} | explode_data.jsonl/22787 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
5228,
1155,
353,
8840,
836,
8,
341,
22431,
32,
11,
1629,
33,
11,
81441,
1669,
220,
18,
11,
220,
19,
11,
481,
16,
198,
9559,
1669,
1186,
8068,
32,
11,
1629,
33,
340,
743,
1102,
961,
81441,
341,
197,
3244,
30762,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestRequestRecovery(t *testing.T) {
time.Sleep(1*time.Second)
mockIpList(t)
server:=runNormalBackupConfigResponse()
newAppConfig:=getTestAppConfig()
newAppConfig.Ip=server.URL
appConfig:=GetAppConfig(newAppConfig)
urlSuffix:=getConfigUrlSuffix(appConfig,newAppConfig)
o,err:=requestRecovery(appConfig,&ConnectConfig{
Uri:urlSuffix,
},&CallBack{
SuccessCallBack:autoSyncConfigServicesSuccessCallBack,
})
test.Nil(t,err)
test.Nil(t,o)
} | explode_data.jsonl/5414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
1900,
693,
7449,
1155,
353,
8840,
836,
8,
341,
21957,
31586,
7,
16,
77053,
32435,
340,
77333,
23378,
852,
1155,
340,
41057,
14209,
6108,
12206,
56245,
2648,
2582,
741,
8638,
2164,
2648,
14209,
455,
2271,
2164,
2648,
741,
863... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestManifestGenerateTelemetry(t *testing.T) {
runTestGroup(t, testGroup{
{
desc: "all_off",
},
{
desc: "telemetry_default",
diffIgnore: "",
},
{
desc: "telemetry_k8s_settings",
diffSelect: "Deployment:*:istio-telemetry, HorizontalPodAutoscaler:*:istio-telemetry",
},
{
desc: "telemetry_override_values",
diffSelect: "handler:*:prometheus",
},
{
desc: "telemetry_override_kubernetes",
diffSelect: "Deployment:*:istio-telemetry, handler:*:prometheus",
},
})
} | explode_data.jsonl/48764 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
38495,
31115,
6639,
35958,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
2808,
1155,
11,
1273,
2808,
515,
197,
197,
515,
298,
41653,
25,
330,
541,
13651,
756,
197,
197,
1583,
197,
197,
515,
298,
41653,
25,
981,
330,
665,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAction_Validate_RequireSingleMixinData(t *testing.T) {
c := NewTestConfig(t)
c.SetupPorterHome()
c.TestContext.AddTestFile("testdata/simple.porter.yaml", Name)
err := c.LoadManifest()
require.NoError(t, err)
// Sabotage!
c.Manifest.Install[0].Data["rando-mixin"] = ""
err = c.Manifest.Install.Validate(c.Manifest)
assert.EqualError(t, err, "more than one mixin specified")
} | explode_data.jsonl/10948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
2512,
62,
17926,
62,
17959,
10888,
38456,
1043,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
2271,
2648,
1155,
340,
1444,
39820,
7084,
261,
7623,
2822,
1444,
8787,
1972,
1904,
2271,
1703,
445,
92425,
67195,
14598,
261,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBarDefaultValue(t *testing.T) {
bar := NewBar()
err := bar.Render(ioutil.Discard)
assert.NoError(t, err)
assert.Equal(t, "900px", bar.Initialization.Width)
assert.Equal(t, "500px", bar.Initialization.Height)
assert.Equal(t, "Awesome go-tachart", bar.PageTitle)
assert.Equal(t, host, bar.AssetsHost)
} | explode_data.jsonl/28524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
3428,
41533,
1155,
353,
8840,
836,
8,
341,
90709,
1669,
1532,
3428,
741,
9859,
1669,
3619,
27386,
1956,
30158,
909,
47560,
340,
6948,
35699,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
330,
24,
15,
15,
1767,
497,
3619,
329... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindBundleBundleNotCached(t *testing.T) {
cfg := config.NewTestConfig(t)
c := New(cfg.Config)
path, _, ok, err := c.FindBundle(kahnlatest)
assert.NoError(t, err, "the cache dir should exist, no error should have happened")
assert.False(t, ok, "the bundle should not exist")
assert.Empty(t, path, "should not have a path")
} | explode_data.jsonl/56183 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
9885,
8409,
8409,
2623,
70293,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
2193,
7121,
2271,
2648,
1155,
340,
1444,
1669,
1532,
28272,
10753,
340,
26781,
11,
8358,
5394,
11,
1848,
1669,
272,
9998,
8409,
5969,
29560,
19350,
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... | 1 |
func TestIstanbulConsensus_ValidateShutdown_Validator(t *testing.T) {
var tests = []struct {
name, istanbulIsValidatorResp, istanbulStatusResp string
wantErrMsg string
}{
{
name: "mintingNotStarted",
istanbulIsValidatorResp: `{"result": true}`,
istanbulStatusResp: `{"result": {"numBlocks":0, "sealerActivity": {"somesigner":1}}}`,
wantErrMsg: "istanbul consensus check failed - block minting not started at network",
},
{
name: "notEnoughPeers",
istanbulIsValidatorResp: `{"result": true}`,
istanbulStatusResp: `{"result": {"numBlocks":10, "sealerActivity": {"minterone":10, "mintertwo":10, "minterthree":10}}}`,
wantErrMsg: "istanbul consensus check - the number of nodes currently down has reached threshold, numOfNodesThatCanBeDown:0 numNodesDown:0",
},
{
name: "notEnoughActivePeers",
istanbulIsValidatorResp: `{"result": true}`,
istanbulStatusResp: `{"result": {"numBlocks":10, "sealerActivity": {"minterone":0, "mintertwo":10, "minterthree":10, "minterfour":10}}}`,
wantErrMsg: "istanbul consensus check - the number of nodes currently down has reached threshold, numOfNodesThatCanBeDown:1 numNodesDown:1",
},
{
name: "enoughActivePeers",
istanbulIsValidatorResp: `{"result": true}`,
istanbulStatusResp: `{"result": {"numBlocks":10, "sealerActivity": {"minterone":10, "mintertwo":10, "minterthree":10, "minterfour":10}}}`,
wantErrMsg: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mockServer := startMockIstanbulServer(t, tt.istanbulIsValidatorResp, tt.istanbulStatusResp)
defer mockServer.Close()
istanbul := NewIstanbulConsensus(&config.Node{
BasicConfig: &config.Basic{
BlockchainClient: &config.BlockchainClient{
BcClntRpcUrl: mockServer.URL,
},
},
}, nil)
isConsensusNode, err := istanbul.ValidateShutdown()
if tt.wantErrMsg == "" {
require.NoError(t, err)
} else {
require.EqualError(t, err, tt.wantErrMsg)
}
require.True(t, isConsensusNode)
})
}
} | explode_data.jsonl/59657 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 980
} | [
2830,
3393,
40,
45116,
15220,
13626,
62,
17926,
62004,
62,
14256,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
11609,
11,
5999,
276,
16110,
3872,
14256,
36555,
11,
5999,
276,
16110,
2522,
36555,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSchemaResolversErr(t *testing.T) {
expected := errors.New("mock")
resolver := func(*broker.Context) (specs.Schemas, error) {
return nil, expected
}
ctx := logger.WithLogger(broker.NewBackground())
resolvers := SchemaResolvers{resolver}
_, err := resolvers.Resolve(ctx)
if err == nil {
t.Fatal("unexpected pass")
}
if err != expected {
t.Fatalf("unexpected error %s, expected %s", err, expected)
}
} | explode_data.jsonl/2211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
8632,
1061,
39435,
7747,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
5975,
7121,
445,
16712,
1138,
10202,
7921,
1669,
2915,
4071,
69309,
9328,
8,
320,
94531,
808,
31126,
11,
1465,
8,
341,
197,
853,
2092,
11,
3601,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFormatterHide(test *testing.T) {
formatted, err := formatter.Format("{hide}text{hide | off}")
assert.NoError(test, err)
assert.Equal(test, "\x1b[8mtext\x1b[28m", formatted)
} | explode_data.jsonl/39775 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
14183,
21692,
8623,
353,
8840,
836,
8,
341,
37410,
12127,
11,
1848,
1669,
24814,
9978,
13976,
8559,
92,
1318,
90,
8559,
760,
1007,
55266,
6948,
35699,
8623,
11,
1848,
340,
6948,
12808,
8623,
11,
2917,
87,
16,
65,
58,
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 |
func TestEncodeHighLevel(t *testing.T) {
shape := SymbolShapeHint_FORCE_NONE
str := string(make([]byte, 1559))
_, e := EncodeHighLevel(str, shape, nil, nil)
if e == nil {
t.Fatalf("EncodeHighLevel must be error")
}
str = " 0A 0A 0A 0A000000"
expect := []byte{
230, 19, 111, 19, 111, 19, 111, 19, 111, 254, 130, 130, 130, 129, 87, 237, 133, 28,
}
min, _ := gozxing.NewDimension(16, 16)
b, e := EncodeHighLevel(str, shape, min, nil)
if e != nil {
t.Fatalf("EncodeHighLevel returns error: %v", e)
}
if !reflect.DeepEqual(b, expect) {
t.Fatalf("EncodeHighLevel = %v, expect %v", b, expect)
}
str = "[)>\u001E05\u001Daaaaaa\u001E\u0004"
b, e = EncodeHighLevel(str, shape, nil, nil)
expect = []byte{236, 239, 89, 191, 89, 191, 254, 129}
if e != nil {
t.Fatalf("EncodeHighLevel returns error: %v", e)
}
if !reflect.DeepEqual(b, expect) {
t.Fatalf("EncodeHighLevel = %v, expect %v", b, expect)
}
str = "[)>\u001E06\u001Daaaaaa\u001E\u0004"
b, e = EncodeHighLevel(str, shape, nil, nil)
expect = []byte{237, 239, 89, 191, 89, 191, 254, 129}
if e != nil {
t.Fatalf("EncodeHighLevel returns error: %v", e)
}
if !reflect.DeepEqual(b, expect) {
t.Fatalf("EncodeHighLevel = %v, expect %v", b, expect)
}
} | explode_data.jsonl/32233 | {
"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,
32535,
11976,
4449,
1155,
353,
8840,
836,
8,
341,
197,
12231,
1669,
19612,
12301,
26987,
50092,
14904,
271,
11355,
1669,
914,
36944,
10556,
3782,
11,
220,
16,
20,
20,
24,
1171,
197,
6878,
384,
1669,
56562,
11976,
4449,
4199,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func Test_RegistrySynchronizer_UpkeepRegisteredLog(t *testing.T) {
db, synchronizer, ethMock, lb, job := setupRegistrySync(t)
contractAddress := job.KeeperSpec.ContractAddress.Address()
fromAddress := job.KeeperSpec.FromAddress.Address()
registryMock := cltest.NewContractMockReceiver(t, ethMock, keeper.RegistryABI, contractAddress)
registryMock.MockResponse("getConfig", registryConfig).Once()
registryMock.MockResponse("getKeeperList", []common.Address{fromAddress}).Once()
registryMock.MockResponse("getCanceledUpkeepList", []*big.Int{}).Once()
registryMock.MockResponse("getUpkeepCount", big.NewInt(0)).Once()
require.NoError(t, synchronizer.Start())
defer synchronizer.Close()
cltest.WaitForCount(t, db, "keeper_registries", 1)
registryMock.MockResponse("getUpkeep", upkeepConfig).Once()
cfg := cltest.NewTestGeneralConfig(t)
head := cltest.MustInsertHead(t, db, cfg, 1)
rawLog := types.Log{BlockHash: head.Hash}
log := keeper_registry_wrapper.KeeperRegistryUpkeepRegistered{Id: big.NewInt(3)}
logBroadcast := new(logmocks.Broadcast)
logBroadcast.On("DecodedLog").Return(&log)
logBroadcast.On("RawLog").Return(rawLog)
logBroadcast.On("String").Maybe().Return("")
lb.On("MarkConsumed", mock.Anything, mock.Anything).Return(nil)
lb.On("WasAlreadyConsumed", mock.Anything, mock.Anything).Return(false, nil)
// Do the thing
synchronizer.HandleLog(logBroadcast)
cltest.WaitForCount(t, db, "upkeep_registrations", 1)
ethMock.AssertExpectations(t)
logBroadcast.AssertExpectations(t)
} | explode_data.jsonl/35262 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 531
} | [
2830,
3393,
62,
15603,
50,
14113,
3135,
88425,
13096,
41430,
2201,
1155,
353,
8840,
836,
8,
341,
20939,
11,
14121,
3135,
11,
8372,
11571,
11,
18866,
11,
2618,
1669,
6505,
15603,
12154,
1155,
692,
197,
20257,
4286,
1669,
2618,
11352,
430... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgTransferNFTGetSignersMethod(t *testing.T) {
newMsgTransferNFT := types.NewMsgTransferNFT(denomID, denom, id, tokenURI, uriHash, tokenData, address.String(), address2.String())
signers := newMsgTransferNFT.GetSigners()
require.Equal(t, 1, len(signers))
require.Equal(t, address.String(), signers[0].String())
} | explode_data.jsonl/28172 | {
"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,
6611,
21970,
45,
3994,
1949,
7264,
388,
3523,
1155,
353,
8840,
836,
8,
341,
8638,
6611,
21970,
45,
3994,
1669,
4494,
7121,
6611,
21970,
45,
3994,
1500,
268,
316,
915,
11,
49744,
11,
877,
11,
3950,
10301,
11,
13071,
6370,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_SshDail(t *testing.T){
h:=orm.HostsList{
IP:"10.21.21.179",
User:"root",
Password:"sunrunvas",
}
fmt.Println(SshDail(h))
} | explode_data.jsonl/20540 | {
"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,
1098,
927,
35,
604,
1155,
353,
8840,
836,
1264,
9598,
14209,
493,
29840,
82,
852,
515,
197,
197,
3298,
2974,
16,
15,
13,
17,
16,
13,
17,
16,
13,
16,
22,
24,
756,
197,
31672,
2974,
2888,
756,
197,
197,
4876,
2974,
395... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileHelper_IsPathString_03(t *testing.T) {
fh := FileHelper{}
pathFile := fh.AdjustPathSlash("../../filesfortest/levelfilesfortest/level_01_dir/" +
"level_02_dir/iDoNotExist")
expectedPathStr := fh.AdjustPathSlash("..\\..\\filesfortest\\levelfilesfortest\\level_01_dir\\" +
"level_02_dir\\iDoNotExist")
isPath, cannotDetermine, testPathStr, err := fh.IsPathString(pathFile)
if err != nil {
t.Errorf("Error returned from fh.IsPathString(pathFile). "+
"pathFile='%v' Error='%v' ", pathFile, err.Error())
}
if false != isPath {
t.Errorf("Expected isPath='%v'. Instead, isPath='%v' "+
"testPathStr='%v' ", false, isPath, testPathStr)
}
if expectedPathStr != testPathStr {
t.Errorf("Error: Expected 'expectedPathStr'='%v'. Instead, 'expectedPathStr='%v'.",
expectedPathStr, testPathStr)
}
if true != cannotDetermine {
t.Errorf("Error: Expected 'cannotDetermine'='%v'. Instead, 'cannotDetermine'='%v' ",
true, cannotDetermine)
}
} | explode_data.jsonl/14508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
1703,
5511,
31879,
1820,
703,
62,
15,
18,
1155,
353,
8840,
836,
8,
1476,
220,
36075,
1669,
2887,
5511,
31483,
220,
1815,
1703,
1669,
36075,
17865,
4250,
1820,
88004,
36800,
7198,
3969,
477,
14,
3449,
490,
3658,
3969,
477,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_AWSPublic(t *testing.T) {
expectedCode := "aws-rds-no-public-db-access"
var tests = []struct {
name string
source string
mustIncludeResultCode string
mustExcludeResultCode string
}{
{
name: "check aws_db_instance when publicly exposed",
source: `
resource "aws_db_instance" "my-resource" {
publicly_accessible = true
}`,
mustIncludeResultCode: expectedCode,
},
{
name: "check aws_rds_cluster_instance when publicly exposed",
source: `
resource "aws_rds_cluster" "cluster1" {
}
resource "aws_rds_cluster_instance" "my-resource" {
cluster_identifier = aws_rds_cluster.cluster1.id
publicly_accessible = true
}`,
mustIncludeResultCode: expectedCode,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
results := testutil.ScanHCL(test.source, t)
testutil.AssertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results)
})
}
} | explode_data.jsonl/52873 | {
"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,
1566,
54,
4592,
475,
1155,
353,
8840,
836,
8,
341,
42400,
2078,
1669,
330,
8635,
3795,
5356,
28366,
56471,
60399,
42156,
1837,
2405,
7032,
284,
3056,
1235,
341,
197,
11609,
1698,
914,
198,
197,
47418,
394,
914,
198,
197,
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 TestRepository_GetAddAffiliate(t *testing.T) {
db, err := sqlx.Connect("pgx", "host=localhost port=5432 user=postgres dbname=juno password=postgres sslmode=disable")
if err != nil {
t.Fatal(err)
}
// Create the codec
codec := simapp.MakeTestEncodingConfig()
type args struct {
accountFilter filter.Filter
}
tests := []struct {
name string
args args
want []*accountstypes.MsgAddAffiliate
wantErr bool
}{
{
name: "valid",
args: args{
accountFilter: filter.NewFilter().SetArgument(types.FieldCreator, "vcg1ljs7p2p9ae3en8knr3d3ke8srsfcj2zjvefv1g"),
},
want: []*accountstypes.MsgAddAffiliate{
{
Creator: "vcg1ljs7p2p9ae3en8knr3d3ke8srsfcj2zjvefv1g",
AccountHash: "a935ea2c467d7f666ea2a67870564f2efb902c05f0a2bb4b6202832aedd26cd3",
AffiliationHash: "a935ea2c467d7f666ea2a67870564f2efb902c05f0a2bb4b6202832aedd26cd4",
Affiliation: accountstypes.AFFILIATION_KIND_REFERRAL,
Extras: []*extratypes.Extra{
{
Kind: extratypes.EXTRA_KIND_EMAIL,
Data: "rete@gmail",
},
{
Kind: extratypes.EXTRA_KIND_PHONE,
Data: "+380685456",
},
},
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := accountsdb.NewRepository(db, codec.Marshaler)
got, err := r.GetAddAffiliate(tt.args.accountFilter)
if (err != nil) != tt.wantErr {
t.Errorf("Repository.GetAddAffiliate() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Repository.GetAddAffiliate() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/25489 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 828
} | [
2830,
3393,
4624,
13614,
2212,
25841,
34850,
1155,
353,
8840,
836,
8,
341,
20939,
11,
1848,
1669,
5704,
87,
43851,
445,
3517,
87,
497,
330,
3790,
84551,
2635,
28,
20,
19,
18,
17,
1196,
28,
43070,
83492,
45612,
16311,
3552,
28,
43070,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoBrFilter(t *testing.T) {
tests := map[string]string{
"My content": "My content",
"My content \r\nHere.": "My content Here.",
"My\n content\r right\r\n here.": "My content right here.",
"My\ncontent\rright\r\nhere.": "My content right here.",
"My content.\n\nMore content.": "My content.\n\nMore content.",
}
for input, output := range tests {
require.Equal(t, output, NoBrFilter(input))
}
} | explode_data.jsonl/62219 | {
"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,
2753,
6828,
5632,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
30953,
515,
197,
197,
45140,
2213,
788,
3824,
330,
5050,
2213,
756,
197,
197,
45140,
2213,
1124,
81,
1699,
8420,
13,
788,
1843,
330,
5050,
2213,
569... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetFeatures(t *testing.T) {
t.Log("We need to test the GetFeatures.")
{
t.Log("\tChecking GetFeatures for response ")
{
_, msgType := common.Call(client, client.GetFeatures())
if msgType != 17 {
t.Errorf("\t\tExpected msgType=17, received %d", msgType)
} else {
t.Log("\t\tEverything went fine, \\ʕ◔ϖ◔ʔ/ YAY!")
}
}
}
} | explode_data.jsonl/46198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
1949,
21336,
1155,
353,
8840,
836,
8,
1476,
3244,
5247,
445,
1654,
1184,
311,
1273,
279,
2126,
21336,
13053,
197,
515,
197,
3244,
5247,
4921,
83,
40129,
2126,
21336,
369,
2033,
14167,
197,
197,
515,
298,
197,
6878,
3750,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEntryPanicf(t *testing.T) {
errBoom := fmt.Errorf("boom again")
defer func() {
p := recover()
assert.NotNil(t, p)
switch pVal := p.(type) {
case *Entry:
assert.Equal(t, "kaboom true", pVal.Message)
assert.Equal(t, errBoom, pVal.Data["err"])
default:
t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
}
}()
logger := New()
logger.Out = &bytes.Buffer{}
entry := NewEntry(logger)
entry.WithField("err", errBoom).Panicf("kaboom %v", true)
} | explode_data.jsonl/13866 | {
"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,
5874,
47,
31270,
69,
1155,
353,
8840,
836,
8,
341,
9859,
94234,
1669,
8879,
13080,
445,
95316,
1549,
5130,
16867,
2915,
368,
341,
197,
3223,
1669,
11731,
741,
197,
6948,
93882,
1155,
11,
281,
692,
197,
8961,
281,
2208,
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... | 2 |
func TestRegisterNoDefaultProviders(t *testing.T) {
runInfo := &EvalRunInfo{
Proj: &workspace.Project{Name: "test"},
Target: &Target{Name: "test"},
}
newURN := func(t tokens.Type, name string, parent resource.URN) resource.URN {
var pt tokens.Type
if parent != "" {
pt = parent.Type()
}
return resource.NewURN(runInfo.Target.Name, runInfo.Proj.Name, pt, t, tokens.QName(name))
}
newProviderURN := func(pkg tokens.Package, name string, parent resource.URN) resource.URN {
return newURN(providers.MakeProviderType(pkg), name, parent)
}
componentURN := newURN("component", "component", "")
providerARef, err := providers.NewReference(newProviderURN("pkgA", "providerA", ""), "id1")
assert.NoError(t, err)
providerBRef, err := providers.NewReference(newProviderURN("pkgA", "providerB", componentURN), "id2")
assert.NoError(t, err)
providerCRef, err := providers.NewReference(newProviderURN("pkgC", "providerC", ""), "id1")
assert.NoError(t, err)
steps := []RegisterResourceEvent{
// Register a provider.
newProviderEvent("pkgA", "providerA", nil, ""),
// Register a component resource.
&testRegEvent{
goal: resource.NewGoal(componentURN.Type(), componentURN.Name(), false, resource.PropertyMap{}, "", false,
nil, "", []string{}, nil, false, nil, nil, nil, "", nil),
},
// Register a couple resources using provider A.
&testRegEvent{
goal: resource.NewGoal("pkgA:index:typA", "res1", true, resource.PropertyMap{}, componentURN, false, nil,
providerARef.String(), []string{}, nil, false, nil, nil, nil, "", nil),
},
&testRegEvent{
goal: resource.NewGoal("pkgA:index:typA", "res2", true, resource.PropertyMap{}, componentURN, false, nil,
providerARef.String(), []string{}, nil, false, nil, nil, nil, "", nil),
},
// Register two more providers.
newProviderEvent("pkgA", "providerB", nil, ""),
newProviderEvent("pkgC", "providerC", nil, componentURN),
// Register a few resources that use the new providers.
&testRegEvent{
goal: resource.NewGoal("pkgB:index:typB", "res3", true, resource.PropertyMap{}, "", false, nil,
providerBRef.String(), []string{}, nil, false, nil, nil, nil, "", nil),
},
&testRegEvent{
goal: resource.NewGoal("pkgB:index:typC", "res4", true, resource.PropertyMap{}, "", false, nil,
providerCRef.String(), []string{}, nil, false, nil, nil, nil, "", nil),
},
}
// Create and iterate an eval source.
ctx, err := newTestPluginContext(fixedProgram(steps))
assert.NoError(t, err)
iter, res := NewEvalSource(ctx, runInfo, nil, false).Iterate(context.Background(), Options{}, &testProviderSource{})
assert.Nil(t, res)
processed := 0
for {
event, res := iter.Next()
assert.Nil(t, res)
if event == nil {
break
}
reg := event.(RegisterResourceEvent)
goal := reg.Goal()
if providers.IsProviderType(goal.Type) {
assert.NotEqual(t, "default", goal.Name)
}
urn := newURN(goal.Type, string(goal.Name), goal.Parent)
id := resource.ID("")
if goal.Custom {
id = "id"
}
reg.Done(&RegisterResult{
State: resource.NewState(goal.Type, urn, goal.Custom, false, id, goal.Properties, resource.PropertyMap{},
goal.Parent, goal.Protect, false, goal.Dependencies, nil, goal.Provider, goal.PropertyDependencies,
false, nil, nil, nil),
})
processed++
}
assert.Equal(t, len(steps), processed)
} | explode_data.jsonl/6399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1228
} | [
2830,
3393,
8690,
2753,
3675,
37351,
1155,
353,
8840,
836,
8,
341,
56742,
1731,
1669,
609,
54469,
6727,
1731,
515,
197,
197,
61075,
25,
256,
609,
42909,
30944,
63121,
25,
330,
1944,
7115,
197,
197,
6397,
25,
609,
6397,
63121,
25,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStateChangeLog(t *testing.T) {
order := &Order{}
CreateOrderAndExecuteTransition(order, OrderEventCheckout, t, true)
var stateChangeLog transition.StateChangeLog
testdb.Where("refer_table = ? AND refer_id = ?", "orders", order.Id).First(&stateChangeLog)
if stateChangeLog.From != OrderStateDraft {
t.Errorf("state from not set")
}
if stateChangeLog.To != OrderStatePaying {
t.Errorf("state to not set")
}
} | explode_data.jsonl/44771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
1397,
4072,
2201,
1155,
353,
8840,
836,
8,
341,
42245,
1669,
609,
4431,
16094,
75569,
4431,
3036,
17174,
21768,
19385,
11,
7217,
1556,
55145,
11,
259,
11,
830,
692,
2405,
1584,
4072,
2201,
9142,
18942,
4072,
2201,
198,
18185... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteError(t *testing.T) {
t.Parallel()
fName := "TestWriteError"
defer cleanup(fName)
writeOldFile(fName, t)
openFile = func(name string, flags int, perm os.FileMode) (*os.File, error) {
f, err := os.OpenFile(name, flags, perm)
// simulate Write() error by closing the file prematurely
f.Close()
return f, err
}
err := Apply(bytes.NewReader(newFile), Options{TargetPath: fName})
if err == nil {
t.Fatalf("Allowed an update to an empty file")
}
} | explode_data.jsonl/73994 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
7985,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1166,
675,
1669,
330,
2271,
7985,
1454,
698,
16867,
21290,
955,
675,
340,
24945,
18284,
1703,
955,
675,
11,
259,
692,
52199,
1703,
284,
2915,
3153,
914,
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 TestStorageTerm(t *testing.T) {
ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
tests := []struct {
i uint64
werr error
wterm uint64
wpanic bool
}{
{2, ErrCompacted, 0, false},
{3, nil, 3, false},
{4, nil, 4, false},
{5, nil, 5, false},
{6, nil, 0, true},
}
for i, tt := range tests {
s := &MemoryStorage{ents: ents}
func() {
defer func() {
if r := recover(); r != nil {
if !tt.wpanic {
t.Errorf("%d: panic = %v, want %v", i, true, tt.wpanic)
}
}
}()
term, err := s.Term(tt.i)
if err != tt.werr {
t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
}
if term != tt.wterm {
t.Errorf("#%d: term = %d, want %d", i, term, tt.wterm)
}
}()
}
} | explode_data.jsonl/66751 | {
"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,
5793,
17249,
1155,
353,
8840,
836,
8,
341,
197,
805,
1669,
3056,
16650,
22330,
2979,
1552,
25,
220,
18,
11,
17519,
25,
220,
18,
2137,
314,
1552,
25,
220,
19,
11,
17519,
25,
220,
19,
2137,
314,
1552,
25,
220,
20,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestErrorReadingNonFile(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatalf("Couldn't create tmpdir")
}
defer os.RemoveAll(tmpdir)
loadingRules := ClientConfigLoadingRules{
ExplicitPath: tmpdir,
}
_, err = loadingRules.Load()
if err == nil {
t.Fatalf("Expected error for non-file, got none")
}
if !strings.Contains(err.Error(), tmpdir) {
t.Fatalf("Expected error about '%s', got %s", tmpdir, err.Error())
}
} | explode_data.jsonl/67849 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
1454,
31899,
8121,
1703,
1155,
353,
8840,
836,
8,
341,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
38987,
944,
1855,
4174,
3741,
1138,
197,
532,
16867,
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 TestRouter_MatchingOptions_AssignsRouteNamesOverAsMethod(t *testing.T) {
mainRouter := Router{}
_ = mainRouter.As("users.getAs").Get("/users", testHandlerFunc, MatchingOptions{"users.get", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.As("users.createAs").Post("/users", testHandlerFunc, MatchingOptions{"users.create", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.As("users.createAs").Post("/users/create", testHandlerFunc, MatchingOptions{"users.create", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.As("users.updateAs").Put("/users/{id}", testHandlerFunc, MatchingOptions{"users.update", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.As("users.deleteAs").Delete("/users/{id}", testDummyHandlerFunc, MatchingOptions{"users.delete", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.As("users.softDeleteAs").Delete("/users/{id}", testHandlerFunc, MatchingOptions{"users.softDelete", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.Get("/users/profile", testDummyHandlerFunc)
apiRouter := Router{}
_ = apiRouter.Get("/users/account", testHandlerFunc, MatchingOptions{"users.account", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = apiRouter.Get("/users/profile", testHandlerFunc, MatchingOptions{"users.profile", "", []string{}, map[string]string{}, map[string]string{}, nil})
_ = mainRouter.Prefix("/api", &apiRouter)
assertRouteNameHasHandler(t, mainRouter, http.MethodGet, "/users", "users.get")
assertRouteNameHasHandler(t, mainRouter, http.MethodPost, "/users/create", "users.create")
assertRouteNameHasHandler(t, mainRouter, http.MethodPut, "/users/100", "users.update")
assertRouteNameHasHandler(t, mainRouter, http.MethodDelete, "/users/100", "users.delete")
assertRouteNameHasHandler(t, mainRouter, http.MethodDelete, "/users/100", "users.softDelete")
assertRouteNameHasHandler(t, mainRouter, http.MethodGet, "/api/users/account", "users.account")
assertRouteNameHasHandler(t, mainRouter, http.MethodGet, "/api/users/profile", "users.profile")
} | explode_data.jsonl/31731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 740
} | [
2830,
3393,
9523,
1245,
31924,
3798,
62222,
622,
82,
4899,
7980,
1918,
2121,
3523,
1155,
353,
8840,
836,
8,
341,
36641,
9523,
1669,
10554,
31483,
197,
62,
284,
1887,
9523,
20242,
445,
4218,
87280,
1827,
1949,
4283,
4218,
497,
1273,
3050... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.