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 TestExportInfiniteCycle2(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
export {a as b} from './foo'
export {c as d} from './foo'
`,
"/foo.js": `
export {b as c} from './entry'
export {d as a} from './entry'
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
},
expectedCompileLog: `entry.js: error: Detected cycle while resolving import "a"
entry.js: error: Detected cycle while resolving import "c"
foo.js: error: Detected cycle while resolving import "b"
foo.js: error: Detected cycle while resolving import "d"
`,
})
} | explode_data.jsonl/38452 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 281
} | [
2830,
3393,
16894,
641,
25722,
44820,
17,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
59440,
314,
64,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_toExpr(t *testing.T) {
type args struct {
pattern string
}
tests := []struct {
name string
args args
want string
}{
{"empty", args{""}, ""},
{"single star", args{`dir/{*}.js`}, `dir/([^/]+)\.js`},
{"double star", args{`dir/{**}.js`}, `dir/(.+)\.js`},
{"transform", args{`dir/{*|dashed}.js`}, `dir/([^/]+)\.js`},
{"named", args{`dir/{*:path}.js`}, `dir/([^/]+)\.js`},
{"named 2", args{`{**:path}/file.js`}, `(.+)/file\.js`},
{"transform and named", args{`dir/{*|dashed:path}.js`}, `dir/([^/]+)\.js`},
{"constant", args{"src/{controllers}/file.js"}, `src/(controllers)/file\.js`},
{"constant and named", args{"src/{controllers:type}/file.js"}, `src/(controllers)/file\.js`},
{"constant, transformed and named", args{"src/{controllers|dashed:type}/file.js"}, `src/(controllers)/file\.js`},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := toExpr(tt.args.pattern); got != tt.want {
t.Errorf("toExpr() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/73558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 457
} | [
2830,
3393,
2346,
16041,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
3223,
3227,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCheckHelpersVersionComments(t *testing.T) {
testCases := []struct {
name, pkgPath string
expected result
err string
}{
{
name: "valid versions",
pkgPath: "github.com/cjdelisle/matterfoss-server/v5/plugin/checker/internal/test/valid",
expected: result{},
},
{
name: "invalid versions",
pkgPath: "github.com/cjdelisle/matterfoss-server/v5/plugin/checker/internal/test/invalid",
expected: result{
Errors: []string{"internal/test/invalid/invalid.go:20:2: documented minimum server version too low on method LowerVersionMethod"},
Warnings: []string{"internal/test/invalid/invalid.go:23:2: documented minimum server version too high on method HigherVersionMethod"},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
res, err := checkHelpersVersionComments(tc.pkgPath)
assert.Equal(tc.expected, res)
if tc.err != "" {
assert.EqualError(err, tc.err)
} else {
assert.NoError(err)
}
})
}
} | explode_data.jsonl/22977 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 426
} | [
2830,
3393,
3973,
28430,
5637,
17373,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
11,
24793,
1820,
914,
198,
197,
42400,
414,
1102,
198,
197,
9859,
1843,
914,
198,
197,
59403,
197,
197,
515,
298,
116... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecryptKMSWithEncryptionContext(t *testing.T) {
os.Setenv(functionNameEnvVar, mockFunctionName)
defer os.Setenv(functionNameEnvVar, "")
client := mockKMSClientWithEncryptionContext{}
result, _ := decryptKMS(client, mockEncryptedAPIKeyBase64)
assert.Equal(t, expectedDecryptedAPIKey, result)
} | explode_data.jsonl/4337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
89660,
42,
4826,
2354,
79239,
1972,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
2920,
675,
14359,
3962,
11,
7860,
5152,
675,
340,
16867,
2643,
4202,
3160,
2920,
675,
14359,
3962,
11,
85617,
25291,
1669,
7860,
42,
4826,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTokenBalance(t *testing.T) {
client := neorpc.NewClient("http://localhost:30333")
if client == nil {
t.Fail()
}
result := client.GetTokenBalance("0xc2b0fed82b8fa28c358f99849136f45f057bb6fe", "APLNwfJTHp1MBHYNeMAxkeqNCquLpBVjcD")
log.Printf("%+v", result.Result)
} | explode_data.jsonl/9993 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
1949,
3323,
21190,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
834,
269,
3992,
7121,
2959,
445,
1254,
1110,
8301,
25,
18,
15,
18,
18,
18,
1138,
743,
2943,
621,
2092,
341,
197,
3244,
57243,
741,
197,
630,
9559,
1669,
2943,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFybrikApplicationFinalizers(t *testing.T) {
t.Parallel()
g := gomega.NewGomegaWithT(t)
// Set the logger to development mode for verbose logs.
logf.SetLogger(zap.New(zap.UseDevMode(true)))
application := &app.FybrikApplication{}
g.Expect(readObjectFromFile("../../testdata/unittests/data-usage.yaml", application)).NotTo(gomega.HaveOccurred())
// Objects to track in the fake client.
objs := []runtime.Object{
application,
}
// Register operator types with the runtime scheme.
s := utils.NewScheme(g)
// Create a fake client to mock API calls.
cl := fake.NewFakeClientWithScheme(s, objs...)
// Create a FybrikApplicationReconciler object with the scheme and fake client.
r := createTestFybrikApplicationController(cl, s)
g.Expect(r.reconcileFinalizers(application)).To(gomega.BeNil())
g.Expect(application.Finalizers).NotTo(gomega.BeEmpty(), "finalizers have not been created")
// mark application as deleted
application.DeletionTimestamp = &metav1.Time{Time: time.Now()}
g.Expect(r.reconcileFinalizers(application)).To(gomega.BeNil())
g.Expect(application.Finalizers).To(gomega.BeEmpty(), "finalizers have not been removed")
} | explode_data.jsonl/45015 | {
"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,
37,
84307,
20411,
4988,
19357,
12230,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
340,
197,
322,
2573,
279,
5925,
311,
4401,
3856,
369,
13694,
18422,
624,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchemaLogicalType(t *testing.T) {
testSchemaValid(t, `{"type": "long", "logicalType": "timestamp-millis"}`)
testSchemaInvalid(t, `{"type": "bytes", "logicalType": "decimal"}`, "precision")
testSchemaInvalid(t, `{"type": "fixed", "size": 16, "logicalType": "decimal"}`, "precision")
} | explode_data.jsonl/12000 | {
"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,
8632,
64312,
929,
1155,
353,
8840,
836,
8,
341,
18185,
8632,
4088,
1155,
11,
1565,
4913,
1313,
788,
330,
4825,
497,
330,
30256,
929,
788,
330,
13035,
1448,
56212,
1,
27085,
18185,
8632,
7928,
1155,
11,
1565,
4913,
1313,
78... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_templateClient_GetFromURL(t *testing.T) {
g := NewWithT(t)
tmpDir, err := os.MkdirTemp("", "cc")
g.Expect(err).NotTo(HaveOccurred())
defer os.RemoveAll(tmpDir)
configClient, err := config.New("", config.InjectReader(test.NewFakeReader()))
g.Expect(err).NotTo(HaveOccurred())
fakeGithubClient, mux, teardown := test.NewFakeGitHub()
defer teardown()
mux.HandleFunc("/repos/kubernetes-sigs/cluster-api/contents/config/default/cluster-template.yaml", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{
"type": "file",
"encoding": "base64",
"content": "`+base64.StdEncoding.EncodeToString([]byte(template))+`",
"sha": "f5f369044773ff9c6383c087466d12adb6fa0828",
"size": 12,
"name": "cluster-template.yaml",
"path": "config/default/cluster-template.yaml"
}`)
})
path := filepath.Join(tmpDir, "cluster-template.yaml")
g.Expect(os.WriteFile(path, []byte(template), 0600)).To(Succeed())
type args struct {
templateURL string
targetNamespace string
skipTemplateProcess bool
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "Get from local file system",
args: args{
templateURL: path,
targetNamespace: "",
skipTemplateProcess: false,
},
want: template,
wantErr: false,
},
{
name: "Get from GitHub",
args: args{
templateURL: "https://github.com/kubernetes-sigs/cluster-api/blob/main/config/default/cluster-template.yaml",
targetNamespace: "",
skipTemplateProcess: false,
},
want: template,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
gitHubClientFactory := func(configVariablesClient config.VariablesClient) (*github.Client, error) {
return fakeGithubClient, nil
}
processor := yaml.NewSimpleProcessor()
c := newTemplateClient(TemplateClientInput{nil, configClient, processor})
// override the github client factory
c.gitHubClientFactory = gitHubClientFactory
got, err := c.GetFromURL(tt.args.templateURL, tt.args.targetNamespace, tt.args.skipTemplateProcess)
if tt.wantErr {
g.Expect(err).To(HaveOccurred())
return
}
g.Expect(err).NotTo(HaveOccurred())
wantTemplate, err := repository.NewTemplate(repository.TemplateInput{
RawArtifact: []byte(tt.want),
ConfigVariablesClient: configClient.Variables(),
Processor: processor,
TargetNamespace: tt.args.targetNamespace,
SkipTemplateProcess: tt.args.skipTemplateProcess,
})
g.Expect(err).NotTo(HaveOccurred())
g.Expect(got).To(Equal(wantTemplate))
})
}
} | explode_data.jsonl/68534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1145
} | [
2830,
3393,
8693,
2959,
13614,
3830,
3144,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
692,
20082,
6184,
11,
1848,
1669,
2643,
1321,
12438,
12151,
19814,
330,
638,
1138,
3174,
81893,
3964,
568,
2623,
1249,
83844,
239... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServicedCLI_CmdServiceListSnapshots_ShowTagsShort(t *testing.T) {
output := pipe(InitServiceAPITest, "serviced", "service", "list-snapshots", "test-service-1", "-t")
expected :=
"Snapshot Description Tags" +
"\ntest-service-1-snapshot-1 description 1 tag-1" +
"\ntest-service-1-snapshot-2 description 2 tag-2,tag-3" +
"\ntest-service-1-invalid [DEPRECATED]"
outStr := TrimLines(fmt.Sprintf("%s", output))
expected = TrimLines(expected)
if expected != outStr {
t.Fatalf("\ngot:\n%s\nwant:\n%s", outStr, expected)
}
} | explode_data.jsonl/18998 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
39159,
7572,
63959,
98253,
1860,
852,
61871,
27634,
79665,
15930,
12472,
1155,
353,
8840,
836,
8,
341,
21170,
1669,
13647,
7,
3803,
1860,
2537,
952,
477,
11,
330,
30775,
7572,
497,
330,
7936,
497,
330,
1607,
1331,
6861,
2763... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseErrBash(t *testing.T) {
t.Parallel()
p := NewParser(KeepComments)
i := 0
for _, c := range shellTests {
want := c.common
if c.bsmk != nil {
want = c.bsmk
}
if c.bash != nil {
want = c.bash
}
if want == nil {
continue
}
t.Run(fmt.Sprintf("%03d", i), checkError(p, c.in, want.(string)))
i++
}
} | explode_data.jsonl/31437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
14463,
7747,
33,
988,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
1532,
6570,
7,
19434,
17373,
340,
8230,
1669,
220,
15,
198,
2023,
8358,
272,
1669,
2088,
12528,
18200,
341,
197,
50780,
1669,
272,
635... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrganizations_Get(t *testing.T) {
c := qt.New(t)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
out := `{
"id": "my-cool-org",
"type": "organization",
"name": "my-cool-org",
"created_at": "2021-01-14T10:19:23.000Z",
"updated_at": "2021-01-14T10:19:23.000Z"
}`
_, err := w.Write([]byte(out))
c.Assert(err, qt.IsNil)
}))
client, err := NewClient(WithBaseURL(ts.URL))
c.Assert(err, qt.IsNil)
ctx := context.Background()
org, err := client.Organizations.Get(ctx, &GetOrganizationRequest{
Organization: "my-cool-org",
})
c.Assert(err, qt.IsNil)
want := &Organization{
Name: "my-cool-org",
CreatedAt: time.Date(2021, time.January, 14, 10, 19, 23, 000, time.UTC),
UpdatedAt: time.Date(2021, time.January, 14, 10, 19, 23, 000, time.UTC),
}
c.Assert(org, qt.DeepEquals, want)
} | explode_data.jsonl/72400 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 419
} | [
2830,
3393,
23227,
8040,
13614,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
38949,
7121,
1155,
692,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
69794,
7,
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 TestCreateChangesetComments(t *testing.T) {
if testing.Short() {
t.Skip()
}
ctx := context.Background()
db := dbtest.NewDB(t, "")
cstore := store.New(db, nil)
userID := ct.CreateTestUser(t, db, true).ID
batchSpec := ct.CreateBatchSpec(t, ctx, cstore, "test-comments", userID)
otherBatchSpec := ct.CreateBatchSpec(t, ctx, cstore, "test-comments-other", userID)
batchChange := ct.CreateBatchChange(t, ctx, cstore, "test-comments", userID, batchSpec.ID)
otherBatchChange := ct.CreateBatchChange(t, ctx, cstore, "test-comments-other", userID, otherBatchSpec.ID)
repos, _ := ct.CreateTestRepos(t, context.Background(), db, 1)
repo := repos[0]
changeset := ct.CreateChangeset(t, ctx, cstore, ct.TestChangesetOpts{
Repo: repo.ID,
BatchChange: batchChange.ID,
PublicationState: btypes.ChangesetPublicationStatePublished,
})
otherChangeset := ct.CreateChangeset(t, ctx, cstore, ct.TestChangesetOpts{
Repo: repo.ID,
BatchChange: otherBatchChange.ID,
PublicationState: btypes.ChangesetPublicationStatePublished,
})
r := &Resolver{store: cstore}
s, err := graphqlbackend.NewSchema(db, r, nil, nil, nil, nil, nil, nil)
if err != nil {
t.Fatal(err)
}
generateInput := func() map[string]interface{} {
return map[string]interface{}{
"batchChange": marshalBatchChangeID(batchChange.ID),
"changesets": []string{string(marshalChangesetID(changeset.ID))},
"body": "test-body",
}
}
var response struct {
CreateChangesetComments apitest.BulkOperation
}
actorCtx := actor.WithActor(ctx, actor.FromUser(userID))
t.Run("empty body fails", func(t *testing.T) {
input := generateInput()
input["body"] = ""
errs := apitest.Exec(actorCtx, t, s, input, &response, mutationCreateChangesetComments)
if len(errs) != 1 {
t.Fatalf("expected single errors, but got none")
}
if have, want := errs[0].Message, "empty comment body is not allowed"; have != want {
t.Fatalf("wrong error. want=%q, have=%q", want, have)
}
})
t.Run("0 changesets fails", func(t *testing.T) {
input := generateInput()
input["changesets"] = []string{}
errs := apitest.Exec(actorCtx, t, s, input, &response, mutationCreateChangesetComments)
if len(errs) != 1 {
t.Fatalf("expected single errors, but got none")
}
if have, want := errs[0].Message, "specify at least one changeset"; have != want {
t.Fatalf("wrong error. want=%q, have=%q", want, have)
}
})
t.Run("changeset in different batch change fails", func(t *testing.T) {
input := generateInput()
input["changesets"] = []string{string(marshalChangesetID(otherChangeset.ID))}
errs := apitest.Exec(actorCtx, t, s, input, &response, mutationCreateChangesetComments)
if len(errs) != 1 {
t.Fatalf("expected single errors, but got none")
}
if have, want := errs[0].Message, "some changesets could not be found"; have != want {
t.Fatalf("wrong error. want=%q, have=%q", want, have)
}
})
t.Run("runs successfully", func(t *testing.T) {
input := generateInput()
apitest.MustExec(actorCtx, t, s, input, &response, mutationCreateChangesetComments)
if response.CreateChangesetComments.ID == "" {
t.Fatalf("expected bulk operation to be created, but was not")
}
})
} | explode_data.jsonl/53219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1253
} | [
2830,
3393,
4021,
11317,
295,
17373,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
741,
197,
630,
20985,
1669,
2266,
19047,
741,
20939,
1669,
2927,
1944,
7121,
3506,
1155,
11,
14676,
1444,
4314,
1669,
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 TestRetransmitOnSynRcvd(t *testing.T) {
// Send initial SYN.
tcp := make(header.TCP, header.TCPMinimumSize)
tcp.Encode(&header.TCPFields{
SeqNum: 1234,
AckNum: 0,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagSyn,
WindowSize: 30000,
})
tcb := tcpconntrack.TCB{}
tcb.Init(tcp)
// Receive SYN. This will cause the state to go to SYN-RCVD.
tcp.Encode(&header.TCPFields{
SeqNum: 789,
AckNum: 0,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagSyn,
WindowSize: 50000,
})
if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive {
t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive)
}
// Retransmit the original SYN.
tcp.Encode(&header.TCPFields{
SeqNum: 1234,
AckNum: 0,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagSyn,
WindowSize: 30000,
})
if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive {
t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive)
}
// Transmit a SYN-ACK.
tcp.Encode(&header.TCPFields{
SeqNum: 1234,
AckNum: 790,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagSyn | header.TCPFlagAck,
WindowSize: 30000,
})
if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive {
t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive)
}
} | explode_data.jsonl/17724 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 645
} | [
2830,
3393,
12020,
33389,
1763,
1925,
37134,
49,
13122,
67,
1155,
353,
8840,
836,
8,
341,
197,
322,
11000,
2856,
61694,
624,
3244,
4672,
1669,
1281,
25534,
836,
7123,
11,
4247,
836,
7123,
28695,
1695,
340,
3244,
4672,
50217,
2099,
2708,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterManager_AddFilter(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
state := octantFake.NewMockState(controller)
state.EXPECT().AddFilter(octant.Filter{Key: "foo", Value: "bar"})
state.EXPECT().SendAlert(gomock.Any())
manager := api.NewFilterManager()
payload := action.Payload{
"filter": map[string]interface{}{
"key": "foo",
"value": "bar",
},
}
require.NoError(t, manager.AddFilter(state, payload))
} | explode_data.jsonl/48845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
5632,
2043,
21346,
5632,
1155,
353,
8840,
836,
8,
341,
61615,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
6461,
991,
18176,
2822,
24291,
1669,
18491,
517,
52317,
7121,
11571,
1397,
40845,
340,
24291,
22402,
7285,
1005,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreScanIntentsFromTwoTxns(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
store, manualClock := createTestStore(t, testStoreOpts{createSystemRanges: true}, stopper)
// Lay down two intents from two txns to scan over.
key1 := roachpb.Key("bar")
txn1 := newTransaction("test1", key1, 1, store.cfg.Clock)
args := putArgs(key1, []byte("value1"))
assignSeqNumsForReqs(txn1, &args)
if _, pErr := kv.SendWrappedWith(context.Background(), store.TestSender(), roachpb.Header{Txn: txn1}, &args); pErr != nil {
t.Fatal(pErr)
}
key2 := roachpb.Key("foo")
txn2 := newTransaction("test2", key2, 1, store.cfg.Clock)
args = putArgs(key2, []byte("value2"))
assignSeqNumsForReqs(txn2, &args)
if _, pErr := kv.SendWrappedWith(context.Background(), store.TestSender(), roachpb.Header{Txn: txn2}, &args); pErr != nil {
t.Fatal(pErr)
}
// Now, expire the transactions by moving the clock forward. This will
// result in the subsequent scan operation pushing both transactions
// in a single batch.
manualClock.Increment(txnwait.TxnLivenessThreshold.Nanoseconds() + 1)
// Scan the range and verify empty result (expired txn is aborted,
// cleaning up intents).
sArgs := scanArgs(key1, key2.Next())
if reply, pErr := kv.SendWrappedWith(context.Background(), store.TestSender(), roachpb.Header{}, sArgs); pErr != nil {
t.Fatal(pErr)
} else if sReply := reply.(*roachpb.ScanResponse); len(sReply.Rows) != 0 {
t.Errorf("expected empty result; got %+v", sReply.Rows)
}
} | explode_data.jsonl/108 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 589
} | [
2830,
3393,
6093,
26570,
1072,
805,
3830,
11613,
31584,
4412,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
62644,
712,
1669,
2936,
7121,
10674,
712,
741,
16867,
2936,
712,
30213,
5378,
19047,
2398,
57279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHttpCall(t *testing.T) {
hc := New()
handler := hc.Handler()
server := httptest.NewServer(handler)
defer server.Close()
hc.Set(Ready)
resp, err := http.Get(server.URL + "/")
require.NoError(t, err)
assert.Equal(t, http.StatusNoContent, resp.StatusCode)
} | explode_data.jsonl/28498 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
2905,
7220,
1155,
353,
8840,
836,
8,
341,
9598,
66,
1669,
1532,
741,
53326,
1669,
50394,
31010,
2822,
41057,
1669,
54320,
70334,
7121,
5475,
36514,
340,
16867,
3538,
10421,
2822,
9598,
66,
4202,
7,
19202,
692,
34653,
11,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRecogIdentifier(t *testing.T) {
a := assert.New(t)
l := &lexer{}
result := recogIdentifier(l)
r, ok := result.(*recognizeIdentifier)
a.True(ok)
a.Equal(l, r.l)
a.NotNil(r.s)
} | explode_data.jsonl/7677 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
3820,
538,
8714,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
340,
8810,
1669,
609,
38815,
31483,
9559,
1669,
1395,
538,
8714,
2333,
692,
7000,
11,
5394,
1669,
1102,
41399,
33451,
551,
8714,
340,
11323,
32443... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListWithExtensions(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/v2.0/fw/firewalls", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, `
{
"firewalls":[
{
"status": "ACTIVE",
"name": "fw1",
"admin_state_up": false,
"tenant_id": "b4eedccc6fb74fa8a7ad6b08382b852b",
"firewall_policy_id": "34be8c83-4d42-4dca-a74e-b77fffb8e28a",
"id": "fb5b5315-64f6-4ea3-8e58-981cc37c6f61",
"description": "OpenStack firewall 1",
"router_ids": ["abcd1234"]
},
{
"status": "PENDING_UPDATE",
"name": "fw2",
"admin_state_up": true,
"tenant_id": "b4eedccc6fb74fa8a7ad6b08382b852b",
"firewall_policy_id": "34be8c83-4d42-4dca-a74e-b77fffb8e299",
"id": "fb5b5315-64f6-4ea3-8e58-981cc37c6f99",
"description": "OpenStack firewall 2"
}
]
}
`)
})
type FirewallsWithExt struct {
firewalls.Firewall
routerinsertion.FirewallExt
}
allPages, err := firewalls.List(fake.ServiceClient(), nil).AllPages()
th.AssertNoErr(t, err)
var actual []FirewallsWithExt
err = firewalls.ExtractFirewallsInto(allPages, &actual)
th.AssertNoErr(t, err)
th.AssertEquals(t, 2, len(actual))
th.AssertEquals(t, "fb5b5315-64f6-4ea3-8e58-981cc37c6f61", actual[0].ID)
th.AssertEquals(t, "abcd1234", actual[0].RouterIDs[0])
} | explode_data.jsonl/36152 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 857
} | [
2830,
3393,
852,
2354,
31282,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
70479,
1321,
2200,
63623,
4283,
85,
17,
13,
15,
60193,
53010,
86296,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeleteV2Job(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
handleV2JobDelete(t)
err := jobs.Delete(client.ServiceClient(), "986416ea-e26b-40f1-b371-cd7be87376a2", deleteOpts).ExtractErr()
th.AssertNoErr(t, err)
} | explode_data.jsonl/52709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
6435,
53,
17,
12245,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
53822,
53,
17,
12245,
6435,
1155,
692,
9859,
1669,
6887,
18872,
12805,
13860,
2959,
1507,
330,
24,
23,
21,
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 TestReconcileOnCancelledPipelineRun(t *testing.T) {
// TestReconcileOnCancelledPipelineRun runs "Reconcile" on a PipelineRun that has been cancelled.
// It verifies that reconcile is successful, the pipeline status updated and events generated.
prs := []*v1beta1.PipelineRun{createCancelledPipelineRun("test-pipeline-run-cancelled", v1beta1.PipelineRunSpecStatusCancelled)}
ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline}
ts := []*v1beta1.Task{simpleHelloWorldTask}
trs := []*v1beta1.TaskRun{createHelloWorldTaskRun("test-pipeline-run-cancelled-hello-world", "foo",
"test-pipeline-run-cancelled", "test-pipeline")}
cms := getConfigMapsWithEnabledAlphaAPIFields()
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
TaskRuns: trs,
ConfigMaps: cms,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
wantEvents := []string{
"Warning Failed PipelineRun \"test-pipeline-run-cancelled\" was cancelled",
}
reconciledRun, _ := prt.reconcileRun("foo", "test-pipeline-run-cancelled", wantEvents, false)
if reconciledRun.Status.CompletionTime == nil {
t.Errorf("Expected a CompletionTime on invalid PipelineRun but was nil")
}
// This PipelineRun should still be complete and false, and the status should reflect that
if !reconciledRun.Status.GetCondition(apis.ConditionSucceeded).IsFalse() {
t.Errorf("Expected PipelineRun status to be complete and false, but was %v", reconciledRun.Status.GetCondition(apis.ConditionSucceeded))
}
} | explode_data.jsonl/68258 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 554
} | [
2830,
3393,
693,
40446,
457,
1925,
39473,
34656,
6727,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
693,
40446,
457,
1925,
39473,
34656,
6727,
8473,
330,
693,
40446,
457,
1,
389,
264,
40907,
6727,
429,
702,
1012,
25681,
624,
197,
322... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKeywordLimitationOnMetadataAttrs(t *testing.T) {
metadataProcSetup().KeywordLimitation(
t,
tests.NewSet("processor.event", "processor.name",
"process.args",
tests.Group("observer"),
tests.Group("http"),
tests.Group("url"),
tests.Group("context.tags"),
tests.Group("transaction"),
tests.Group("span"),
tests.Group("parent"),
tests.Group("trace"),
tests.Group("user_agent"),
tests.Group("destination"),
),
[]tests.FieldTemplateMapping{
{Template: "agent.", Mapping: "service.agent."},
{Template: "container.", Mapping: "system.container."},
{Template: "kubernetes.", Mapping: "system.kubernetes."},
{Template: "host.os.platform", Mapping: "system.platform"},
{Template: "host.name", Mapping: "system.configured_hostname"},
{Template: "host.", Mapping: "system."},
{Template: "user.name", Mapping: "user.username"},
{Template: "service.node.name", Mapping: "service.node.configured_name"},
//{Template: "url.", Mapping:"context.request.url."},
},
)
} | explode_data.jsonl/64807 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
34481,
16527,
367,
1925,
14610,
53671,
1155,
353,
8840,
836,
8,
341,
2109,
7603,
24508,
21821,
1005,
34481,
16527,
367,
1006,
197,
3244,
345,
197,
78216,
7121,
1649,
445,
29474,
5773,
497,
330,
29474,
2644,
756,
298,
197,
1,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIrisSession(t *testing.T) {
e := irisTester(t)
sub := e.Builder(func(req *httpexpect.Request) {
req.WithURL("http://example.com")
})
sub.POST("/session/set").WithJSON(map[string]string{"name": "test"}).
Expect().
Status(http.StatusOK).Cookies().NotEmpty()
r := sub.GET("/session/get").
Expect().
Status(http.StatusOK).JSON().Object()
r.Equal(map[string]string{
"name": "test",
})
} | explode_data.jsonl/66292 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
40,
5963,
5283,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
63942,
58699,
1155,
692,
28624,
1669,
384,
15641,
18552,
6881,
353,
1254,
17119,
9659,
8,
341,
197,
24395,
26124,
3144,
445,
1254,
1110,
8687,
905,
1138,
197,
8824,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDingTalk_CreateChat(t *testing.T) {
t.Skip()
res, err := client.CreateChat(
request.NewCreatChat("dingtalk", "manager164",
"manager164", "manager164", "manager164").
Build())
// chat79e713edce46ea72ea0dd60fb4f9d6f6
assert.Nil(t, err)
assert.NotNil(t, res)
} | explode_data.jsonl/32606 | {
"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,
35,
287,
36210,
34325,
15672,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
741,
10202,
11,
1848,
1669,
2943,
7251,
15672,
1006,
197,
23555,
7121,
30744,
15672,
445,
6968,
35241,
497,
330,
13297,
16,
21,
19,
756,
298,
197,
1,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDatasourceAsConfig(t *testing.T) {
Convey("Testing datasource as configuration", t, func() {
fakeRepo = &fakeRepository{}
bus.ClearBusHandlers()
bus.AddHandler("test", mockDelete)
bus.AddHandler("test", mockInsert)
bus.AddHandler("test", mockUpdate)
bus.AddHandler("test", mockGet)
bus.AddHandler("test", mockGetAll)
Convey("apply default values when missing", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(withoutDefaults)
if err != nil {
t.Fatalf("applyChanges return an error %v", err)
}
So(len(fakeRepo.inserted), ShouldEqual, 1)
So(fakeRepo.inserted[0].OrgId, ShouldEqual, 1)
So(fakeRepo.inserted[0].Access, ShouldEqual, "proxy")
})
Convey("One configured datasource", func() {
Convey("no datasource in database", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(twoDatasourcesConfig)
if err != nil {
t.Fatalf("applyChanges return an error %v", err)
}
So(len(fakeRepo.deleted), ShouldEqual, 0)
So(len(fakeRepo.inserted), ShouldEqual, 2)
So(len(fakeRepo.updated), ShouldEqual, 0)
})
Convey("One datasource in database with same name", func() {
fakeRepo.loadAll = []*models.DataSource{
{Name: "Graphite", OrgId: 1, Id: 1},
}
Convey("should update one datasource", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(twoDatasourcesConfig)
if err != nil {
t.Fatalf("applyChanges return an error %v", err)
}
So(len(fakeRepo.deleted), ShouldEqual, 0)
So(len(fakeRepo.inserted), ShouldEqual, 1)
So(len(fakeRepo.updated), ShouldEqual, 1)
})
})
Convey("Two datasources with is_default", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(doubleDatasourcesConfig)
Convey("should raise error", func() {
So(err, ShouldEqual, ErrInvalidConfigToManyDefault)
})
})
})
Convey("Multiple datasources in different organizations with isDefault in each organization", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(multipleOrgsWithDefault)
Convey("should not raise error", func() {
So(err, ShouldBeNil)
So(len(fakeRepo.inserted), ShouldEqual, 4)
So(fakeRepo.inserted[0].IsDefault, ShouldBeTrue)
So(fakeRepo.inserted[0].OrgId, ShouldEqual, 1)
So(fakeRepo.inserted[2].IsDefault, ShouldBeTrue)
So(fakeRepo.inserted[2].OrgId, ShouldEqual, 2)
})
})
Convey("Two configured datasource and purge others ", func() {
Convey("two other datasources in database", func() {
fakeRepo.loadAll = []*models.DataSource{
{Name: "old-graphite", OrgId: 1, Id: 1},
{Name: "old-graphite2", OrgId: 1, Id: 2},
}
Convey("should have two new datasources", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(twoDatasourcesConfigPurgeOthers)
if err != nil {
t.Fatalf("applyChanges return an error %v", err)
}
So(len(fakeRepo.deleted), ShouldEqual, 2)
So(len(fakeRepo.inserted), ShouldEqual, 2)
So(len(fakeRepo.updated), ShouldEqual, 0)
})
})
})
Convey("Two configured datasource and purge others = false", func() {
Convey("two other datasources in database", func() {
fakeRepo.loadAll = []*models.DataSource{
{Name: "Graphite", OrgId: 1, Id: 1},
{Name: "old-graphite2", OrgId: 1, Id: 2},
}
Convey("should have two new datasources", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(twoDatasourcesConfig)
if err != nil {
t.Fatalf("applyChanges return an error %v", err)
}
So(len(fakeRepo.deleted), ShouldEqual, 0)
So(len(fakeRepo.inserted), ShouldEqual, 1)
So(len(fakeRepo.updated), ShouldEqual, 1)
})
})
})
Convey("broken yaml should return error", func() {
reader := &configReader{}
_, err := reader.readConfig(brokenYaml)
So(err, ShouldNotBeNil)
})
Convey("skip invalid directory", func() {
cfgProvider := &configReader{log: log.New("test logger")}
cfg, err := cfgProvider.readConfig("./invalid-directory")
if err != nil {
t.Fatalf("readConfig return an error %v", err)
}
So(len(cfg), ShouldEqual, 0)
})
Convey("can read all properties from version 1", func() {
_ = os.Setenv("TEST_VAR", "name")
cfgProvider := &configReader{log: log.New("test logger")}
cfg, err := cfgProvider.readConfig(allProperties)
_ = os.Unsetenv("TEST_VAR")
if err != nil {
t.Fatalf("readConfig return an error %v", err)
}
So(len(cfg), ShouldEqual, 3)
dsCfg := cfg[0]
So(dsCfg.APIVersion, ShouldEqual, 1)
validateDatasourceV1(dsCfg)
validateDeleteDatasources(dsCfg)
dsCount := 0
delDsCount := 0
for _, c := range cfg {
dsCount += len(c.Datasources)
delDsCount += len(c.DeleteDatasources)
}
So(dsCount, ShouldEqual, 2)
So(delDsCount, ShouldEqual, 1)
})
Convey("can read all properties from version 0", func() {
cfgProvider := &configReader{log: log.New("test logger")}
cfg, err := cfgProvider.readConfig(versionZero)
if err != nil {
t.Fatalf("readConfig return an error %v", err)
}
So(len(cfg), ShouldEqual, 1)
dsCfg := cfg[0]
So(dsCfg.APIVersion, ShouldEqual, 0)
validateDatasource(dsCfg)
validateDeleteDatasources(dsCfg)
})
})
} | explode_data.jsonl/63235 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2248
} | [
2830,
3393,
47663,
919,
2121,
2648,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
16451,
69156,
438,
6546,
497,
259,
11,
2915,
368,
341,
197,
1166,
726,
25243,
284,
609,
30570,
4624,
16094,
197,
92530,
13524,
15073,
39949,
741,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTargetLabels(t *testing.T) {
target := newTestTarget("example.com:80", 0, labels.FromStrings("job", "some_job", "foo", "bar"))
want := labels.FromStrings(model.JobLabel, "some_job", "foo", "bar")
got := target.Labels()
require.Equal(t, want, got)
} | explode_data.jsonl/16308 | {
"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,
6397,
23674,
1155,
353,
8840,
836,
8,
341,
28861,
1669,
501,
2271,
6397,
445,
8687,
905,
25,
23,
15,
497,
220,
15,
11,
9201,
11439,
20859,
445,
8799,
497,
330,
14689,
20298,
497,
330,
7975,
497,
330,
2257,
5455,
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,
1... | 1 |
func TestWatchIsClosed(t *testing.T) {
set := New("www", "test", "gotest", []string{TestServer})
watch, err := set.Watch()
if err != nil {
t.Fatal(err)
}
watch.Close()
if watch.IsClosed() == false {
t.Error("should say it's closed right after we close it")
}
} | explode_data.jsonl/20439 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
14247,
3872,
26884,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
1532,
445,
2136,
497,
330,
1944,
497,
330,
22390,
477,
497,
3056,
917,
90,
2271,
5475,
3518,
6692,
754,
11,
1848,
1669,
738,
1175,
754,
741,
743,
1848,
961,
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 TestGenerateCmdMergeAPIModel(t *testing.T) {
cases := []struct {
test func(*testing.T)
name string
}{
{
name: "NoSetFlagDefined",
test: func(t *testing.T) {
g := new(generateCmd)
g.apimodelPath = "../pkg/engine/testdata/simple/kubernetes.json"
err := g.mergeAPIModel()
if err != nil {
t.Fatalf("unexpected error calling mergeAPIModel with no --set flag defined: %s", err.Error())
}
},
},
{
name: "OneFlagSet",
test: func(t *testing.T) {
g := new(generateCmd)
g.apimodelPath = "../pkg/engine/testdata/simple/kubernetes.json"
g.set = []string{"masterProfile.count=3,linuxProfile.adminUsername=testuser"}
err := g.mergeAPIModel()
if err != nil {
t.Fatalf("unexpected error calling mergeAPIModel with one --set flag: %s", err.Error())
}
},
},
{
name: "TwoFlagsSet",
test: func(t *testing.T) {
g := new(generateCmd)
g.apimodelPath = "../pkg/engine/testdata/simple/kubernetes.json"
g.set = []string{"masterProfile.count=3,linuxProfile.adminUsername=testuser"}
err := g.mergeAPIModel()
if err != nil {
t.Fatalf("unexpected error calling mergeAPIModel with one --set flag: %s", err.Error())
}
},
},
{
name: "OverrideArrayFlagSet",
test: func(t *testing.T) {
g := new(generateCmd)
g.apimodelPath = "../pkg/engine/testdata/simple/kubernetes.json"
g.set = []string{"agentPoolProfiles[0].count=1"}
err := g.mergeAPIModel()
if err != nil {
t.Fatalf("unexpected error calling mergeAPIModel with one --set flag to override an array property: %s", err.Error())
}
},
},
{
name: "SshKeyContains==FlagSet",
test: func(t *testing.T) {
g := new(generateCmd)
g.apimodelPath = "../pkg/engine/testdata/simple/kubernetes.json"
g.set = []string{"linuxProfile.ssh.publicKeys[0].keyData=\"ssh-rsa AAAAB3NO8b9== azureuser@cluster.local\",servicePrincipalProfile.clientId=\"123a4321-c6eb-4b61-9d6f-7db123e14a7a\",servicePrincipalProfile.secret=\"=#msRock5!t=\""}
err := g.mergeAPIModel()
if err != nil {
t.Fatalf("unexpected error calling mergeAPIModel with one --set flag to override an array property: %s", err.Error())
}
},
},
{
name: "SimpleQuoteContainingFlagSet",
test: func(t *testing.T) {
g := new(generateCmd)
g.apimodelPath = "../pkg/engine/testdata/simple/kubernetes.json"
g.set = []string{"servicePrincipalProfile.secret='=MsR0ck5!t='"}
err := g.mergeAPIModel()
if err != nil {
t.Fatalf("unexpected error calling mergeAPIModel with one --set flag to override an array property: %s", err.Error())
}
},
},
}
for _, tc := range cases {
c := tc
t.Run(c.name, func(t *testing.T) {
t.Parallel()
c.test(t)
})
}
} | explode_data.jsonl/58944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1232
} | [
2830,
3393,
31115,
15613,
52096,
7082,
1712,
1155,
353,
8840,
836,
8,
1476,
1444,
2264,
1669,
3056,
1235,
341,
197,
18185,
2915,
4071,
8840,
836,
340,
197,
11609,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
2753,
1649,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetPerf(t *testing.T) {
var wg sync.WaitGroup
sl := New()
n := 1000000
wg.Add(1)
go doInsert(sl, &wg, n, false)
wg.Wait()
t0 := time.Now()
total := n * runtime.GOMAXPROCS(0)
for i := 0; i < runtime.GOMAXPROCS(0); i++ {
wg.Add(1)
go doGet(sl, &wg, n)
}
wg.Wait()
dur := time.Since(t0)
fmt.Printf("%d items took %v -> %v items/s\n", total, dur, float64(total)/float64(dur.Seconds()))
} | explode_data.jsonl/32468 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
1949,
3889,
69,
1155,
353,
8840,
836,
8,
341,
2405,
63581,
12811,
28384,
2808,
198,
78626,
1669,
1532,
741,
9038,
1669,
220,
16,
15,
15,
15,
15,
15,
15,
198,
72079,
1904,
7,
16,
340,
30680,
653,
13780,
55691,
11,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTarWithBlockCharFifo(t *testing.T) {
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
origin, err := ioutil.TempDir("", "docker-test-tar-hardlink")
assert.NilError(t, err)
defer os.RemoveAll(origin)
err = ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700)
assert.NilError(t, err)
err = system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5))))
assert.NilError(t, err)
err = system.Mknod(filepath.Join(origin, "3"), unix.S_IFCHR, int(system.Mkdev(int64(12), int64(5))))
assert.NilError(t, err)
err = system.Mknod(filepath.Join(origin, "4"), unix.S_IFIFO, int(system.Mkdev(int64(12), int64(5))))
assert.NilError(t, err)
dest, err := ioutil.TempDir("", "docker-test-tar-hardlink-dest")
assert.NilError(t, err)
defer os.RemoveAll(dest)
// we'll do this in two steps to separate failure
fh, err := Tar(origin, Uncompressed)
assert.NilError(t, err)
// ensure we can read the whole thing with no error, before writing back out
buf, err := ioutil.ReadAll(fh)
assert.NilError(t, err)
bRdr := bytes.NewReader(buf)
err = Untar(bRdr, dest, &TarOptions{Compression: Uncompressed})
assert.NilError(t, err)
changes, err := ChangesDirs(origin, dest)
assert.NilError(t, err)
if len(changes) > 0 {
t.Fatalf("Tar with special device (block, char, fifo) should keep them (recreate them when untar) : %v", changes)
}
} | explode_data.jsonl/81930 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 567
} | [
2830,
3393,
62733,
2354,
4713,
4768,
37,
31497,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
32901,
1155,
11,
2643,
2234,
2423,
368,
961,
220,
15,
11,
330,
4886,
5654,
1273,
429,
7460,
3704,
1138,
197,
8611,
11,
1848,
1669,
43144,
65009... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOutboundListenerConflict_TCPWithCurrentTCP(t *testing.T) {
services := []*model.Service{
buildService("test1.com", "1.2.3.4", protocol.TCP, tnow.Add(1*time.Second)),
buildService("test2.com", "1.2.3.4", protocol.TCP, tnow),
buildService("test3.com", "1.2.3.4", protocol.TCP, tnow.Add(2*time.Second)),
}
p := &fakePlugin{}
listeners := buildOutboundListeners(p, &proxy, nil, nil, services...)
if len(listeners) != 1 {
t.Fatalf("expected %d listeners, found %d", 1, len(listeners))
}
// The filter chains should all be merged into one.
if len(listeners[0].FilterChains) != 1 {
t.Fatalf("expected %d filter chains, found %d", 1, len(listeners[0].FilterChains))
}
verifyOutboundTCPListenerHostname(t, listeners[0], "test2.com")
oldestService := getOldestService(services...)
oldestProtocol := oldestService.Ports[0].Protocol
if oldestProtocol != protocol.HTTP && isHTTPListener(listeners[0]) {
t.Fatal("expected TCP listener, found HTTP")
} else if oldestProtocol == protocol.HTTP && !isHTTPListener(listeners[0]) {
t.Fatal("expected HTTP listener, found TCP")
}
if p.outboundListenerParams[0].Service != oldestService {
t.Fatalf("listener conflict failed to preserve listener for the oldest service")
}
} | explode_data.jsonl/61266 | {
"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,
2662,
10891,
2743,
57974,
50614,
2354,
5405,
49896,
1155,
353,
8840,
836,
8,
341,
1903,
2161,
1669,
29838,
2528,
13860,
515,
197,
69371,
1860,
445,
1944,
16,
905,
497,
330,
16,
13,
17,
13,
18,
13,
19,
497,
11507,
836,
71... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestRunHHFM(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess := newSessionForTesting(t)
defer sess.Close()
builder, err := sess.NewExperimentBuilder("http_header_field_manipulation")
if err != nil {
t.Fatal(err)
}
runexperimentflow(t, builder.NewExperiment(), "")
} | explode_data.jsonl/26319 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
6727,
23180,
25609,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
20599,
1273,
304,
2805,
3856,
1138,
197,
532,
1903,
433,
1669,
501,
5283,
2461,
16451,
1155,
340,
16867,
21875,
10421,
741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSubscribe(t *testing.T) {
x := 0
handler1 := func(msg interface{}) {
x += 1
}
b := NewBroker()
b.Subscribe("topic1", handler1)
b.Publish("topic1", struct{}{})
if x != 1 {
t.Errorf("Expected x to be 1, got %d", x)
}
} | explode_data.jsonl/37064 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
28573,
1155,
353,
8840,
836,
8,
341,
10225,
1669,
220,
15,
198,
53326,
16,
1669,
2915,
8119,
3749,
28875,
341,
197,
10225,
1421,
220,
16,
198,
197,
532,
2233,
1669,
1532,
65545,
2822,
2233,
82628,
445,
16411,
16,
497,
7013... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestBodyCloseDoesntBlock(t *testing.T) {
t.Skipf("Skipping known issue; see golang.org/issue/7121")
if testing.Short() {
t.Skip("skipping in -short mode")
}
defer afterTest(t)
readErrCh := make(chan error, 1)
errCh := make(chan error, 2)
server := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, req *Request) {
go func(body io.Reader) {
_, err := body.Read(make([]byte, 100))
readErrCh <- err
}(req.Body)
time.Sleep(500 * time.Millisecond)
}))
defer server.Close()
closeConn := make(chan bool)
defer close(closeConn)
go func() {
conn, err := net.Dial("tcp", server.Listener.Addr().String())
if err != nil {
errCh <- err
return
}
defer conn.Close()
_, err = conn.Write([]byte("POST / HTTP/1.1\r\nConnection: close\r\nHost: foo\r\nContent-Length: 100000\r\n\r\n"))
if err != nil {
errCh <- err
return
}
// And now just block, making the server block on our
// 100000 bytes of body that will never arrive.
<-closeConn
}()
select {
case err := <-readErrCh:
if err == nil {
t.Error("Read was nil. Expected error.")
}
case err := <-errCh:
t.Error(err)
case <-time.After(5 * time.Second):
t.Error("timeout")
}
} | explode_data.jsonl/22469 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 493
} | [
2830,
3393,
33334,
7925,
21468,
406,
4713,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
69,
445,
85945,
3881,
4265,
26,
1490,
342,
37287,
2659,
14,
11159,
14,
22,
16,
17,
16,
1138,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShutdownStrategy_ShouldExecute(t *testing.T) {
assert.False(t, ShutdownStrategyTerminate.ShouldExecute(true))
assert.False(t, ShutdownStrategyTerminate.ShouldExecute(false))
assert.False(t, ShutdownStrategyStop.ShouldExecute(false))
assert.True(t, ShutdownStrategyStop.ShouldExecute(true))
} | explode_data.jsonl/26044 | {
"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,
62004,
19816,
36578,
616,
17174,
1155,
353,
8840,
836,
8,
341,
6948,
50757,
1155,
11,
65379,
19816,
62519,
26693,
17174,
3715,
1171,
6948,
50757,
1155,
11,
65379,
19816,
62519,
26693,
17174,
3576,
1171,
6948,
50757,
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 |
func Test_postorderTraversal(t *testing.T) {
ast := assert.New(t)
for _, tc := range tcs {
fmt.Printf("~~%v~~\n", tc)
root := PreIn2Tree(tc.pre, tc.in)
ast.Equal(tc.post, postorderTraversal(root), "输入:%v", tc)
}
} | explode_data.jsonl/28335 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
6333,
1358,
76276,
1155,
353,
8840,
836,
8,
341,
88836,
1669,
2060,
7121,
1155,
692,
2023,
8358,
17130,
1669,
2088,
259,
4837,
341,
197,
11009,
19367,
445,
5817,
4,
85,
5817,
59,
77,
497,
17130,
692,
197,
33698,
1669,
4968... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParse_PausedSubscriptionNotification(t *testing.T) {
result := MustParseFile("testdata/subscription_paused_notification.xml")
if n, ok := result.(*webhooks.SubscriptionNotification); !ok {
t.Fatalf("unexpected type: %T, result", n)
} else if diff := cmp.Diff(n, &webhooks.SubscriptionNotification{
Type: webhooks.PausedSubscription,
Account: webhooks.Account{
XMLName: xml.Name{Local: "account"},
Code: "1",
Email: "verena@example.com",
FirstName: "Verena",
LastName: "Example",
},
Subscription: recurly.Subscription{
XMLName: xml.Name{Local: "subscription"},
Plan: recurly.NestedPlan{
Code: "daily_plan",
Name: "daily_plan",
},
UUID: "437a818b9dba81065e444448de931842",
State: "paused",
Quantity: 10,
TotalAmountInCents: 10000,
ActivatedAt: recurly.NewTime(MustParseTime("2018-03-09T17:01:59Z")),
CurrentPeriodStartedAt: recurly.NewTime(MustParseTime("2018-03-10T22:12:08Z")),
CurrentPeriodEndsAt: recurly.NewTime(MustParseTime("2018-03-11T22:12:08Z")),
PausedAt: recurly.NewTime(MustParseTime("2018-03-10T22:12:08Z")),
ResumeAt: recurly.NewTime(MustParseTime("2018-03-20T22:12:08Z")),
RemainingPauseCycles: 9,
},
}); diff != "" {
t.Fatal(diff)
}
} | explode_data.jsonl/76107 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 653
} | [
2830,
3393,
14463,
1088,
64,
2591,
33402,
11196,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
15465,
14463,
1703,
445,
92425,
14,
34404,
55475,
2591,
34296,
9028,
1138,
743,
308,
11,
5394,
1669,
1102,
41399,
2911,
38560,
12391,
12124,
11196,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnversionedGetHealthBundleNoBundleSet(t *testing.T) {
f := newFixture(t)
req := newReqUnversioned(http.MethodGet, "/health?bundle=true", "")
if err := f.executeRequest(req, 200, `{}`); err != nil {
t.Fatalf("Unexpected error while health check: %v", err)
}
} | explode_data.jsonl/78975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
1806,
4366,
291,
1949,
14542,
8409,
2753,
8409,
1649,
1155,
353,
8840,
836,
8,
1476,
1166,
1669,
501,
18930,
1155,
692,
24395,
1669,
501,
27234,
1806,
4366,
291,
19886,
20798,
1949,
11,
3521,
12120,
30,
34518,
11265,
497,
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... | 2 |
func TestDescribeLoadBalancerOnGet(t *testing.T) {
awsServices := NewFakeAWSServices()
c, _ := newAWSCloud(strings.NewReader("[global]"), awsServices)
awsServices.elb.expectDescribeLoadBalancers("aid")
c.GetLoadBalancer(TestClusterName, &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "myservice", UID: "id"}})
} | explode_data.jsonl/12859 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
74785,
5879,
93825,
1925,
1949,
1155,
353,
8840,
836,
8,
341,
197,
8635,
11025,
1669,
1532,
52317,
14419,
1220,
2161,
741,
1444,
11,
716,
1669,
501,
14419,
3540,
52178,
51442,
68587,
10937,
9752,
60,
3975,
31521,
11025,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetRequestWithBackgroundContext(t *testing.T) {
setupServer()
defer teardownServer()
setupDefaultMux(`"body"`)
req := URL("http://example.com/url")
req.SetContext(context.Background())
if err := req.Get(); err != nil {
t.Error(err)
}
assertTextualBody(t, `"body"`, req.Response.Body)
assertMethod(t, "GET", req.Request.Method)
} | explode_data.jsonl/24746 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
1949,
1900,
2354,
8706,
1972,
1155,
353,
8840,
836,
8,
341,
84571,
5475,
741,
16867,
49304,
5475,
741,
84571,
3675,
44,
2200,
5809,
1,
2599,
39917,
692,
24395,
1669,
5548,
445,
1254,
1110,
8687,
905,
57254,
1138,
24395,
4202... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRouterMethodDelete(t *testing.T) {
request := &http.Request{
URL: &url.URL{
Path: "/sha246:41af286dc0b172ed2f1ca934fd2278de4a1192302ffa07087cea2682e7d372e3",
},
Method: "DELETE",
Body: nil,
}
ctrl := gomock.NewController(t)
defer ctrl.Finish()
cmp := setupRouterTestComponents(t, ctrl)
cmp.removeHandler.EXPECT().ServeHTTP(cmp.types.responseWriter, cmp.types.request)
cmp.router.ServeHTTP(cmp.responseWriter, request)
} | explode_data.jsonl/3914 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
9523,
3523,
6435,
1155,
353,
8840,
836,
8,
341,
23555,
1669,
609,
1254,
9659,
515,
197,
79055,
25,
609,
1085,
20893,
515,
298,
69640,
25,
3521,
15247,
17,
19,
21,
25,
19,
16,
2577,
17,
23,
21,
7628,
15,
65,
16,
22,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_translateDeprecatedAutoscalingAPI(t *testing.T) {
const iopString1 = `
components:
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
hpaSpec:
metrics:
- object:
metricName: test1
`
const iopString2 = `
components:
pilot:
k8s:
hpaSpec:
metrics:
- resource:
targetAverageUtilization: 80
`
const iopString3 = `
components:
egressGateways:
- name: istio-egressgateway
enabled: true
k8s:
hpaSpec:
metrics:
- pods:
targetAverageValue: 100m
`
const iopString4 = `
components:
pilot:
enabled: true
k8s:
hpaSpec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: istiod
minReplicas: 1
maxReplicas: 5
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
`
cases := []struct {
name string
iopString string
expectFound bool
}{
{
name: "found deprecated fields ingress",
iopString: iopString1,
expectFound: true,
},
{
name: "found deprecated fields pilot",
iopString: iopString2,
expectFound: true,
},
{
name: "found deprecated fields egress",
iopString: iopString3,
expectFound: true,
},
{
name: "no deprecated fields",
iopString: iopString4,
expectFound: false,
},
}
for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {
var iop *v1alpha1.IstioOperatorSpec
if tt.iopString != "" {
iop = &v1alpha1.IstioOperatorSpec{}
if err := util.UnmarshalWithJSONPB(tt.iopString, iop, true); err != nil {
t.Fatal(err)
}
}
translator := NewTranslator()
values := make(map[string]interface{})
_ = translator.translateDeprecatedAutoscalingFields(values, iop)
val, found, _ := tpath.GetFromStructPath(values, "global.autoscalingv2API")
if tt.expectFound {
assert.Equal(t, found, true)
assert.Equal(t, val, false)
} else {
assert.Equal(t, found, false)
}
})
}
} | explode_data.jsonl/34684 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1149
} | [
2830,
3393,
66381,
51344,
19602,
436,
81552,
7082,
1155,
353,
8840,
836,
8,
341,
4777,
600,
453,
703,
16,
284,
22074,
5149,
510,
220,
78559,
42318,
2284,
510,
262,
481,
829,
25,
5999,
815,
83905,
673,
46473,
198,
414,
8970,
25,
830,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSuffixes(t *testing.T) {
m := NewStringMatcher([]string{"Superman", "uperman", "perman", "erman"})
hits := m.Match([]byte("The Man Of Steel: Superman"))
assert(t, len(hits) == 4)
assert(t, hits[0].Index == 0)
assert(t, hits[1].Index == 1)
assert(t, hits[2].Index == 2)
assert(t, hits[3].Index == 3)
hits = m.MatchThreadSafe([]byte("The Man Of Steel: Superman"))
assert(t, len(hits) == 4)
assert(t, hits[0].Index == 0)
assert(t, hits[1].Index == 1)
assert(t, hits[2].Index == 2)
assert(t, hits[3].Index == 3)
} | explode_data.jsonl/22643 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
40177,
288,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
703,
37554,
10556,
917,
4913,
19284,
1515,
497,
330,
3466,
1515,
497,
330,
712,
1515,
497,
330,
4753,
23625,
9598,
1199,
1669,
296,
36062,
10556,
3782,
445,
785,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSmallestInt(t *testing.T) {
type args struct {
A []int
}
tests := []struct {
name string
args args
want int
}{
{name: "test 1", args: args{A: []int{1, 3, 6, 4, 1, 2}}, want: 5},
{name: "test 2", args: args{A: []int{1, 2, 3}}, want: 4},
{name: "test 3", args: args{A: []int{-1, -3}}, want: 1},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SmallestInt(tt.args.A); got != tt.want {
t.Errorf("SmallestInt() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/78001 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
10673,
19236,
1072,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
22985,
3056,
396,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNullIDResilience(t *testing.T) {
ct.MockRSAKeygen(t)
db := dbtest.NewDB(t, "")
sr := New(store.New(db, nil))
s, err := graphqlbackend.NewSchema(db, sr, nil, nil, nil, nil, nil, nil)
if err != nil {
t.Fatal(err)
}
ctx := backend.WithAuthzBypass(context.Background())
ids := []graphql.ID{
marshalBatchChangeID(0),
marshalChangesetID(0),
marshalBatchSpecRandID(""),
marshalChangesetSpecRandID(""),
marshalBatchChangesCredentialID(0, false),
marshalBatchChangesCredentialID(0, true),
marshalBulkOperationID(""),
}
for _, id := range ids {
var response struct{ Node struct{ ID string } }
query := `query($id: ID!) { node(id: $id) { id } }`
if errs := apitest.Exec(ctx, t, s, map[string]interface{}{"id": id}, &response, query); len(errs) > 0 {
t.Errorf("GraphQL request failed: %#+v", errs[0])
}
if have, want := response.Node.ID, ""; have != want {
t.Errorf("node has wrong ID. have=%q, want=%q", have, want)
}
}
mutations := []string{
fmt.Sprintf(`mutation { closeBatchChange(batchChange: %q) { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { deleteBatchChange(batchChange: %q) { alwaysNil } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { syncChangeset(changeset: %q) { alwaysNil } }`, marshalChangesetID(0)),
fmt.Sprintf(`mutation { reenqueueChangeset(changeset: %q) { id } }`, marshalChangesetID(0)),
fmt.Sprintf(`mutation { applyBatchChange(batchSpec: %q) { id } }`, marshalBatchSpecRandID("")),
fmt.Sprintf(`mutation { createBatchChange(batchSpec: %q) { id } }`, marshalBatchSpecRandID("")),
fmt.Sprintf(`mutation { moveBatchChange(batchChange: %q, newName: "foobar") { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { createBatchChangesCredential(externalServiceKind: GITHUB, externalServiceURL: "http://test", credential: "123123", user: %q) { id } }`, graphqlbackend.MarshalUserID(0)),
fmt.Sprintf(`mutation { deleteBatchChangesCredential(batchChangesCredential: %q) { alwaysNil } }`, marshalBatchChangesCredentialID(0, false)),
fmt.Sprintf(`mutation { deleteBatchChangesCredential(batchChangesCredential: %q) { alwaysNil } }`, marshalBatchChangesCredentialID(0, true)),
fmt.Sprintf(`mutation { createChangesetComments(batchChange: %q, changesets: [], body: "test") { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { createChangesetComments(batchChange: %q, changesets: [%q], body: "test") { id } }`, marshalBatchChangeID(1), marshalChangesetID(0)),
fmt.Sprintf(`mutation { reenqueueChangesets(batchChange: %q, changesets: []) { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { reenqueueChangesets(batchChange: %q, changesets: [%q]) { id } }`, marshalBatchChangeID(1), marshalChangesetID(0)),
fmt.Sprintf(`mutation { mergeChangesets(batchChange: %q, changesets: []) { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { mergeChangesets(batchChange: %q, changesets: [%q]) { id } }`, marshalBatchChangeID(1), marshalChangesetID(0)),
fmt.Sprintf(`mutation { closeChangesets(batchChange: %q, changesets: []) { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { closeChangesets(batchChange: %q, changesets: [%q]) { id } }`, marshalBatchChangeID(1), marshalChangesetID(0)),
fmt.Sprintf(`mutation { publishChangesets(batchChange: %q, changesets: []) { id } }`, marshalBatchChangeID(0)),
fmt.Sprintf(`mutation { publishChangesets(batchChange: %q, changesets: [%q]) { id } }`, marshalBatchChangeID(1), marshalChangesetID(0)),
}
for _, m := range mutations {
var response struct{}
errs := apitest.Exec(ctx, t, s, nil, &response, m)
if len(errs) == 0 {
t.Errorf("expected errors but none returned (mutation: %q)", m)
}
if have, want := errs[0].Error(), fmt.Sprintf("graphql: %s", ErrIDIsZero{}); have != want {
t.Errorf("wrong errors. have=%s, want=%s (mutation: %q)", have, want, m)
}
}
} | explode_data.jsonl/53209 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1515
} | [
2830,
3393,
3280,
915,
1061,
321,
1835,
1155,
353,
8840,
836,
8,
341,
89216,
24664,
73564,
1592,
4370,
1155,
692,
20939,
1669,
2927,
1944,
7121,
3506,
1155,
11,
14676,
1903,
81,
1669,
1532,
31200,
7121,
9791,
11,
2092,
4390,
1903,
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... | 8 |
func TestPubSub_Subscribe(t *testing.T) {
testCases := []struct {
name string
fn func(ctx context.Context, m *ship.Message) error
topic string
subscription string
configure func(t *testing.T, s *suite)
checkResults func(t *testing.T, err error)
}{
{
name: "should return error: subscription some-subscription does not exists",
fn: func(ctx context.Context, m *ship.Message) error {
return nil
},
topic: "some-topic",
subscription: "some-subscription",
configure: func(t *testing.T, s *suite) {
},
checkResults: func(t *testing.T, err error) {
assert.Error(t, err)
assert.Contains(t, err.Error(), "subscription some-subscription does not exists")
},
},
{
name: "should attach a message handler to a subscription",
fn: func(ctx context.Context, m *ship.Message) error {
return nil
},
topic: "some-topic",
subscription: "some-subscription",
configure: func(t *testing.T, s *suite) {
topic, err := s.client.client.CreateTopic(context.Background(), "some-topic")
assert.NoError(t, err)
_, err = s.client.client.CreateSubscription(
context.Background(),
"some-subscription",
pubsub.SubscriptionConfig{
Topic: topic,
},
)
assert.NoError(t, err)
},
checkResults: func(t *testing.T, err error) {
assert.NoError(t, err)
},
},
}
for i := range testCases {
tc := testCases[i]
t.Run(tc.name, func(t *testing.T) {
suite := newTestSuite(t)
defer suite.Teardown(t)
tc.configure(t, suite)
err := suite.client.Subscribe("some-subscription", ship.MessageHandlerFunc(tc.fn))
tc.checkResults(t, err)
})
}
} | explode_data.jsonl/41684 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 724
} | [
2830,
3393,
29162,
3136,
36359,
6273,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
40095,
1843,
2915,
7502,
2266,
9328,
11,
296,
353,
5270,
8472,
8,
1465,
198,
197,
3244,
24810,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFuncCheck(t *testing.T) {
require := require.New(t)
require.Panics(func() {
// too few dots
_ = NewFunc([]Dot{
{
X: 0.0 * DecimalUnit,
Y: 20.0 * DecimalUnit,
},
})
})
require.Panics(func() {
// non monotonic X
_ = NewFunc([]Dot{
{
X: 0.0 * DecimalUnit,
Y: 20.0 * DecimalUnit,
},
{
X: 20.0 * DecimalUnit,
Y: 20.0 * DecimalUnit,
},
{
X: 10.0 * DecimalUnit,
Y: 20.0 * DecimalUnit,
},
})
})
} | explode_data.jsonl/19345 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
9626,
3973,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
17957,
1069,
276,
1211,
18552,
368,
341,
197,
197,
322,
2238,
2421,
30994,
198,
197,
197,
62,
284,
1532,
9626,
10556,
34207,
515,
298,
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... | 1 |
func TestStoreKeyEncodeDecode(t *testing.T) {
testCases := []struct {
key roachpb.Key
expSuffix roachpb.RKey
expDetail roachpb.RKey
}{
{key: StoreIdentKey(), expSuffix: localStoreIdentSuffix, expDetail: nil},
{key: StoreGossipKey(), expSuffix: localStoreGossipSuffix, expDetail: nil},
{key: StoreClusterVersionKey(), expSuffix: localStoreClusterVersionSuffix, expDetail: nil},
{key: StoreLastUpKey(), expSuffix: localStoreLastUpSuffix, expDetail: nil},
{key: StoreHLCUpperBoundKey(), expSuffix: localStoreHLCUpperBoundSuffix, expDetail: nil},
{
key: StoreSuggestedCompactionKey(roachpb.Key("a"), roachpb.Key("z")),
expSuffix: localStoreSuggestedCompactionSuffix,
expDetail: encoding.EncodeBytesAscending(encoding.EncodeBytesAscending(nil, roachpb.Key("a")), roachpb.Key("z")),
},
}
for _, test := range testCases {
t.Run("", func(t *testing.T) {
if suffix, detail, err := DecodeStoreKey(test.key); err != nil {
t.Error(err)
} else if !suffix.Equal(test.expSuffix) {
t.Errorf("expected %s; got %s", test.expSuffix, suffix)
} else if !detail.Equal(test.expDetail) {
t.Errorf("expected %s; got %s", test.expDetail, detail)
}
})
}
} | explode_data.jsonl/56583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 509
} | [
2830,
3393,
6093,
1592,
32535,
32564,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
23634,
981,
926,
610,
16650,
9610,
198,
197,
48558,
40177,
926,
610,
16650,
2013,
1592,
198,
197,
48558,
10649,
926,
610,
1665... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCleanupTaskWithInvalidInterval(t *testing.T) {
ctrl := gomock.NewController(t)
mockTime := mock_ttime.NewMockTime(ctrl)
mockState := mock_dockerstate.NewMockTaskEngineState(ctrl)
mockClient := mock_dockerapi.NewMockDockerClient(ctrl)
mockImageManager := mock_engine.NewMockImageManager(ctrl)
defer ctrl.Finish()
cfg := getTestConfig()
ctx, cancel := context.WithCancel(context.TODO())
defer cancel()
taskEngine := &DockerTaskEngine{
ctx: ctx,
cfg: &cfg,
saver: statemanager.NewNoopStateManager(),
state: mockState,
client: mockClient,
imageManager: mockImageManager,
}
mTask := &managedTask{
ctx: ctx,
cancel: cancel,
Task: testdata.LoadTask("sleep5"),
_time: mockTime,
engine: taskEngine,
acsMessages: make(chan acsTransition),
dockerMessages: make(chan dockerContainerChange),
resourceStateChangeEvent: make(chan resourceStateChange),
cfg: taskEngine.cfg,
saver: taskEngine.saver,
}
mTask.SetKnownStatus(apitaskstatus.TaskStopped)
mTask.SetSentStatus(apitaskstatus.TaskStopped)
container := mTask.Containers[0]
dockerContainer := &apicontainer.DockerContainer{
DockerName: "dockerContainer",
}
// Expectations for triggering cleanup
now := mTask.GetKnownStatusTime()
taskStoppedDuration := -1 * time.Minute
mockTime.EXPECT().Now().Return(now).AnyTimes()
cleanupTimeTrigger := make(chan time.Time)
mockTime.EXPECT().After(gomock.Any()).Return(cleanupTimeTrigger)
go func() {
cleanupTimeTrigger <- now
}()
// Expectations to verify that the task gets removed
mockState.EXPECT().ContainerMapByArn(mTask.Arn).Return(map[string]*apicontainer.DockerContainer{container.Name: dockerContainer}, true)
mockClient.EXPECT().RemoveContainer(gomock.Any(), dockerContainer.DockerName, gomock.Any()).Return(nil)
mockImageManager.EXPECT().RemoveContainerReferenceFromImageState(container).Return(nil)
mockState.EXPECT().RemoveTask(mTask.Task)
mTask.cleanupTask(taskStoppedDuration)
} | explode_data.jsonl/24585 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 877
} | [
2830,
3393,
67335,
6262,
2354,
7928,
10256,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
77333,
1462,
1669,
7860,
528,
1678,
7121,
11571,
1462,
62100,
340,
77333,
1397,
1669,
7860,
814,
13659,
2454,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewExportPipeline(t *testing.T) {
_, err := NewExportPipeline(validConfig)
if err != nil {
t.Fatalf("Failed to create export pipeline with error %v", err)
}
} | explode_data.jsonl/8038 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
3564,
16894,
34656,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
1532,
16894,
34656,
41529,
2648,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
9408,
311,
1855,
7485,
15301,
448,
1465,
1018,
85,
497,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestMockWorkerAndMessage(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
m := mocks.NewMockQueuedMessage(controller)
w := mocks.NewMockWorker(controller)
w.EXPECT().Shutdown().Return(nil)
w.EXPECT().Request().DoAndReturn(func() (core.QueuedMessage, error) {
return m, errors.New("nil")
})
q, err := NewQueue(
WithWorker(w),
WithWorkerCount(1),
)
assert.NoError(t, err)
assert.NotNil(t, q)
q.Start()
time.Sleep(50 * time.Millisecond)
q.Release()
} | explode_data.jsonl/66726 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
11571,
21936,
3036,
2052,
1155,
353,
8840,
836,
8,
341,
61615,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
6461,
991,
18176,
2822,
2109,
1669,
68909,
7121,
11571,
25776,
3260,
2052,
40845,
692,
6692,
1669,
68909,
7121,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOptionExists(t *testing.T) {
p := func(v int) bool {
return v > 0
}
o := gs.Some(1)
assert.True(t, o.Exists(p))
o = gs.Some(-1)
assert.False(t, o.Exists(p))
o = gs.None[int]()
assert.False(t, o.Exists(p))
} | explode_data.jsonl/32429 | {
"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,
5341,
15575,
1155,
353,
8840,
836,
8,
1476,
3223,
1669,
2915,
3747,
526,
8,
1807,
341,
197,
853,
348,
861,
220,
15,
198,
197,
630,
22229,
1669,
28081,
86833,
7,
16,
340,
6948,
32443,
1155,
11,
297,
26996,
1295,
4390,
222... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_DocumentProperties_UpdateDocumentPropertyOnline(t *testing.T) {
config := ReadConfiguration(t)
client, ctx := PrepareTest(t, config)
localFile := "Common/test_multi_pages.docx"
requestProperty := models.DocumentPropertyCreateOrUpdate{
Value: ToStringPointer("Imran Anwar"),
}
options := map[string]interface{}{
}
request := &models.CreateOrUpdateDocumentPropertyOnlineRequest{
Document: OpenFile(t, localFile),
PropertyName: ToStringPointer("AsposeAuthor"),
Property: requestProperty,
Optionals: options,
}
_, _, err := client.WordsApi.CreateOrUpdateDocumentPropertyOnline(ctx, request)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/26162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
1557,
1452,
7903,
47393,
7524,
3052,
19598,
1155,
353,
8840,
836,
8,
341,
262,
2193,
1669,
4457,
7688,
1155,
340,
262,
2943,
11,
5635,
1669,
31166,
2271,
1155,
11,
2193,
340,
262,
2205,
1703,
1669,
330,
10839,
12697,
25133,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReply(t *testing.T) {
message := mockMessage()
go message.Reply("hi there")
reply := <-message.Replies
if reply.Data != "hi there" {
t.Fail()
}
} | explode_data.jsonl/25059 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 61
} | [
2830,
3393,
20841,
1155,
353,
8840,
836,
8,
341,
24753,
1669,
7860,
2052,
741,
30680,
1943,
2817,
2541,
445,
6023,
1052,
1138,
86149,
1669,
9119,
1994,
2817,
7202,
198,
743,
9851,
3336,
961,
330,
6023,
1052,
1,
341,
197,
3244,
57243,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestParseURL(t *testing.T) {
for _, c := range testParseURLCase {
got, err := ParseURL(c.url)
if err != nil {
t.Errorf("TestParseURL(%s - %s) error: \n%s", c.name, c.url, err.Error())
continue
}
if !compareRtmpURL(got, c.expect) {
t.Errorf("TestParseURL(%s - %s)\ngot: %v\nexpect: %v", c.name, c.url, got, c.expect)
}
}
for _, c := range testParseURLErrorCase {
got, err := ParseURL(c.url)
if err == nil {
t.Errorf("TestParseURL(%s - %s) Expect error\ngot: %v", c.name, c.url, got)
}
}
} | explode_data.jsonl/45170 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 263
} | [
2830,
3393,
14463,
3144,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
1273,
14463,
3144,
4207,
341,
197,
3174,
354,
11,
1848,
1669,
14775,
3144,
1337,
7315,
340,
197,
743,
1848,
961,
2092,
341,
298,
3244,
13080,
445,
227... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestSecureHTTPRedirect(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop(context.TODO())
ts := s.(*TestServer)
httpClient, err := s.GetHTTPClient()
if err != nil {
t.Fatal(err)
}
// Avoid automatically following redirects.
httpClient.CheckRedirect = func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
}
origURL := "http://" + ts.Cfg.HTTPAddr
expURL := url.URL{Scheme: "https", Host: ts.Cfg.HTTPAddr, Path: "/"}
if resp, err := httpClient.Get(origURL); err != nil {
t.Fatal(err)
} else {
resp.Body.Close()
if resp.StatusCode != http.StatusTemporaryRedirect {
t.Errorf("expected status code %d; got %d", http.StatusTemporaryRedirect, resp.StatusCode)
}
if redirectURL, err := resp.Location(); err != nil {
t.Error(err)
} else if a, e := redirectURL.String(), expURL.String(); a != e {
t.Errorf("expected location %s; got %s", e, a)
}
}
if resp, err := httpClient.Post(origURL, "text/plain; charset=utf-8", nil); err != nil {
t.Fatal(err)
} else {
resp.Body.Close()
if resp.StatusCode != http.StatusTemporaryRedirect {
t.Errorf("expected status code %d; got %d", http.StatusTemporaryRedirect, resp.StatusCode)
}
if redirectURL, err := resp.Location(); err != nil {
t.Error(err)
} else if a, e := redirectURL.String(), expURL.String(); a != e {
t.Errorf("expected location %s; got %s", e, a)
}
}
} | explode_data.jsonl/70829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 581
} | [
2830,
3393,
49813,
9230,
17725,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1903,
11,
8358,
716,
1669,
3538,
6031,
12101,
5475,
1155,
11,
2331,
8787,
5475,
4117,
37790,
16867,
274,
7758,
18487,
1005,
106... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPipelineError_Fields(t *testing.T) {
Test(t,
That("put ?(fail 1 | fail 2)[reason][type]").Puts("pipeline"),
That("count ?(fail 1 | fail 2)[reason][exceptions]").Puts(2),
That("put ?(fail 1 | fail 2)[reason][exceptions][0][reason][type]").
Puts("fail"),
)
} | explode_data.jsonl/23941 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
34656,
1454,
1400,
6907,
1155,
353,
8840,
836,
8,
341,
73866,
1155,
345,
197,
197,
4792,
445,
628,
937,
7,
18403,
220,
16,
760,
3690,
220,
17,
6620,
19895,
1457,
1313,
44891,
47,
6128,
445,
51258,
4461,
197,
197,
4792,
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 TestCheckInvalidJSON(t *testing.T) {
invalidJSON := `{["a","b","c"]}`
input := &pb.ChaincodeInput{}
if err := json.Unmarshal([]byte(invalidJSON), &input); err == nil {
t.Fail()
t.Logf("Bar argument error should have been caught: %s", invalidJSON)
return
}
invalidJSON = `{"Function":}`
if err := json.Unmarshal([]byte(invalidJSON), &input); err == nil {
t.Fail()
t.Logf("Chaincode argument error: %s", err)
t.Logf("Bar argument error should have been caught: %s", invalidJSON)
return
}
} | explode_data.jsonl/22365 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
3973,
7928,
5370,
1155,
353,
8840,
836,
8,
341,
197,
11808,
5370,
1669,
53692,
1183,
64,
2198,
65,
2198,
66,
1341,
31257,
22427,
1669,
609,
16650,
98269,
1851,
2505,
16094,
743,
1848,
1669,
2951,
38097,
10556,
3782,
5900,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCensorHttpsPasswordRemovesPasswordFromHTTPSURLWithPassword(t *testing.T) {
rawURL := "https://user:password@github.com/foo/bar.git"
censoredURL := CensorHttpsPassword(rawURL)
expectedCensoredURL := "https://user:REDACTED@github.com/foo/bar.git"
if censoredURL != expectedCensoredURL {
t.Error("incorrectly censored URL", "expected", expectedCensoredURL, "actual", censoredURL)
}
} | explode_data.jsonl/68334 | {
"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,
34,
3805,
92869,
4876,
6590,
10088,
4876,
3830,
82354,
3144,
2354,
4876,
1155,
353,
8840,
836,
8,
341,
76559,
3144,
1669,
330,
2428,
1110,
872,
25,
3833,
31,
5204,
905,
60555,
49513,
32799,
698,
1444,
55778,
3144,
1669,
356,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeEncodeMetadata(t *testing.T) {
cids := testutil.GenerateCids(10)
initialMetadata := make(Metadata, 0, 10)
nd := fluent.MustBuildList(basicnode.Prototype.List, 10, func(fla fluent.ListAssembler) {
for _, k := range cids {
blockPresent := rand.Int31()%2 == 0
initialMetadata = append(initialMetadata, Item{k, blockPresent})
fla.AssembleValue().CreateMap(2, func(fma fluent.MapAssembler) {
fma.AssembleEntry("link").AssignLink(cidlink.Link{Cid: k})
fma.AssembleEntry("blockPresent").AssignBool(blockPresent)
})
}
})
// verify metadata matches
encoded, err := EncodeMetadata(initialMetadata)
require.NoError(t, err, "encode errored")
decodedMetadata, err := DecodeMetadata(encoded)
require.NoError(t, err, "decode errored")
require.Equal(t, initialMetadata, decodedMetadata, "metadata changed during encoding and decoding")
// verify metadata is equivalent of IPLD node encoding
encodedNode := new(bytes.Buffer)
err = dagcbor.Encoder(nd, encodedNode)
require.NoError(t, err)
decodedMetadataFromNode, err := DecodeMetadata(encodedNode.Bytes())
require.NoError(t, err)
require.Equal(t, decodedMetadata, decodedMetadataFromNode, "metadata not equal to IPLD encoding")
nb := basicnode.Prototype.List.NewBuilder()
err = dagcbor.Decoder(nb, encodedNode)
require.NoError(t, err)
decodedNode := nb.Build()
require.Equal(t, nd, decodedNode)
nb = basicnode.Prototype.List.NewBuilder()
err = dagcbor.Decoder(nb, bytes.NewReader(encoded))
require.NoError(t, err)
decodedNodeFromMetadata := nb.Build()
require.Equal(t, decodedNode, decodedNodeFromMetadata, "deserialzed metadata does not match deserialized node")
} | explode_data.jsonl/57523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 597
} | [
2830,
3393,
32564,
32535,
14610,
1155,
353,
8840,
836,
8,
341,
1444,
3365,
1669,
1273,
1314,
57582,
34,
3365,
7,
16,
15,
340,
85270,
14610,
1669,
1281,
3189,
7603,
11,
220,
15,
11,
220,
16,
15,
340,
197,
303,
1669,
57768,
50463,
110... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEngineLogf(t *testing.T) {
eng := newTestEngine(t)
defer os.RemoveAll(eng.Root())
input := "Test log line"
if n, err := eng.Logf("%s\n", input); err != nil {
t.Fatal(err)
} else if n < len(input) {
t.Fatalf("Test: Logf() should print at least as much as the input\ninput=%d\nprinted=%d", len(input), n)
}
} | explode_data.jsonl/45352 | {
"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,
4571,
2201,
69,
1155,
353,
8840,
836,
8,
341,
197,
826,
1669,
501,
2271,
4571,
1155,
340,
16867,
2643,
84427,
7,
826,
45345,
2398,
22427,
1669,
330,
2271,
1487,
1555,
698,
743,
308,
11,
1848,
1669,
2922,
98954,
4430,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMemcachedJumpHashSelector_PickSever_ErrNoServers(t *testing.T) {
s := cache.MemcachedJumpHashSelector{}
_, err := s.PickServer("foo")
require.Error(t, memcache.ErrNoServers, err)
} | explode_data.jsonl/2663 | {
"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,
18816,
32918,
33979,
6370,
5877,
1088,
865,
1514,
423,
93623,
2753,
78139,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
6500,
1321,
336,
32918,
33979,
6370,
5877,
16094,
197,
6878,
1848,
1669,
274,
1069,
865,
5475,
445,
7975,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestTailFromBeginning(t *testing.T) {
if os.Getenv("CIRCLE_PROJECT_REPONAME") != "" {
t.Skip("Skipping CI testing due to race conditions")
}
tmpfile, err := ioutil.TempFile("", "")
require.NoError(t, err)
defer os.Remove(tmpfile.Name())
_, err = tmpfile.WriteString("cpu,mytag=foo usage_idle=100\n")
require.NoError(t, err)
tt := NewTail()
tt.FromBeginning = true
tt.Files = []string{tmpfile.Name()}
tt.SetParserFunc(parsers.NewInfluxParser)
defer tt.Stop()
defer tmpfile.Close()
acc := testutil.Accumulator{}
require.NoError(t, tt.Start(&acc))
require.NoError(t, acc.GatherError(tt.Gather))
acc.Wait(1)
acc.AssertContainsTaggedFields(t, "cpu",
map[string]interface{}{
"usage_idle": float64(100),
},
map[string]string{
"mytag": "foo",
"path": tmpfile.Name(),
})
} | explode_data.jsonl/42342 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
44795,
3830,
75290,
1155,
353,
8840,
836,
8,
341,
743,
2643,
64883,
445,
34,
64012,
43804,
2192,
47,
711,
2729,
899,
961,
1591,
341,
197,
3244,
57776,
445,
85945,
20694,
7497,
4152,
311,
6957,
4682,
1138,
197,
630,
20082,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ValidateAppUpdate(t *testing.T) {
ctx := context.Background()
tests := []struct {
name string
obj v1alpha1.App
currentApp v1alpha1.App
expectedErr string
}{
{
name: "case 0: flawless",
obj: v1alpha1.App{
ObjectMeta: metav1.ObjectMeta{
Name: "kiam",
Namespace: "eggs2",
},
Spec: v1alpha1.AppSpec{
Catalog: "giantswarm",
Name: "kiam",
Namespace: "kube-system",
Version: "1.4.0",
},
},
currentApp: v1alpha1.App{
ObjectMeta: metav1.ObjectMeta{
Name: "kiam",
Namespace: "eggs2",
},
Spec: v1alpha1.AppSpec{
Catalog: "giantswarm",
Name: "kiam",
Namespace: "kube-system",
Version: "1.4.0",
},
},
},
{
name: "case 1: changed namespace is rejected",
obj: v1alpha1.App{
ObjectMeta: metav1.ObjectMeta{
Name: "kiam",
Namespace: "eggs2",
},
Spec: v1alpha1.AppSpec{
Catalog: "giantswarm",
Name: "kiam",
Namespace: "default",
Version: "1.4.0",
},
},
currentApp: v1alpha1.App{
ObjectMeta: metav1.ObjectMeta{
Name: "kiam",
Namespace: "eggs2",
},
Spec: v1alpha1.AppSpec{
Catalog: "giantswarm",
Name: "kiam",
Namespace: "kube-system",
Version: "1.4.0",
},
},
expectedErr: "validation error: target namespace for app `kiam` cannot be changed from `kube-system` to `default`",
},
}
for i, tc := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
t.Log(tc.name)
scheme := runtime.NewScheme()
_ = v1alpha1.AddToScheme(scheme)
fakeCtrlClient := fake.NewClientBuilder().
WithScheme(scheme).
Build()
c := Config{
G8sClient: fakeCtrlClient,
K8sClient: clientgofake.NewSimpleClientset(),
Logger: microloggertest.New(),
ProjectName: "app-admission-controller",
Provider: "aws",
}
r, err := NewValidator(c)
if err != nil {
t.Fatalf("error == %#v, want nil", err)
}
_, err = r.ValidateAppUpdate(ctx, tc.obj, tc.currentApp)
switch {
case err != nil && tc.expectedErr == "":
t.Fatalf("error == %#v, want nil", err)
case err == nil && tc.expectedErr != "":
t.Fatalf("error == nil, want non-nil")
}
if err != nil && tc.expectedErr != "" {
if !strings.Contains(err.Error(), tc.expectedErr) {
t.Fatalf("error == %#v, want %#v ", err.Error(), tc.expectedErr)
}
}
})
}
} | explode_data.jsonl/48637 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1242
} | [
2830,
3393,
62,
17926,
2164,
4289,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
22671,
260,
348,
16,
7141,
16,
5105,
198,
197,
20121,
2164,
220,
348,
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... | 9 |
func TestKafkaClient_decodeMemberAssignmentV0_Errors(t *testing.T) {
for _, values := range decodeMemberAssignmentV0Errors {
_, errorAt := decodeMemberAssignmentV0(bytes.NewBuffer(values.Bytes))
assert.Equalf(t, values.ErrorAt, errorAt, "Expected errorAt to be %v, not %v", values.ErrorAt, errorAt)
}
} | explode_data.jsonl/34264 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
42,
21883,
2959,
15227,
9366,
41613,
53,
15,
93623,
1087,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
2750,
1669,
2088,
16895,
9366,
41613,
53,
15,
13877,
341,
197,
197,
6878,
1465,
1655,
1669,
16895,
9366,
41613,
53,
15,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMountingExistingPath(t *testing.T) {
handler := func(w http.ResponseWriter, r *http.Request) {}
defer func() {
if recover() == nil {
t.Error("expected panic()")
}
}()
r := NewRouter()
r.Get("/", handler)
r.Mount("/hi", http.HandlerFunc(handler))
r.Mount("/hi", http.HandlerFunc(handler))
} | explode_data.jsonl/42882 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
16284,
287,
53067,
1820,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
10086,
16867,
2915,
368,
341,
197,
743,
11731,
368,
621,
2092,
341,
298,
3244,
6141,
445,
7325,
2197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOptionForall(t *testing.T) {
s := gs.Some[int](100)
f1 := func(v int) bool {
return v == 100
}
f2 := func(v int) bool {
return v < 0
}
assert.Equal(t, true, s.Forall(f1))
assert.Equal(t, false, s.Forall(f2))
n := gs.None[int]()
assert.Equal(t, true, n.Forall(f1))
assert.Equal(t, true, n.Forall(f2))
} | explode_data.jsonl/32433 | {
"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,
5341,
2461,
541,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
28081,
86833,
18640,
9533,
16,
15,
15,
692,
1166,
16,
1669,
2915,
3747,
526,
8,
1807,
341,
197,
853,
348,
621,
220,
16,
15,
15,
198,
197,
630,
1166,
17,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPing(t *testing.T) {
rsp, err := http.Post(createUrl("/ping"), "", nil)
AssertThat(t, err, Is{nil})
AssertThat(t, rsp, Code{http.StatusOK})
} | explode_data.jsonl/65283 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
69883,
1155,
353,
8840,
836,
8,
341,
7000,
2154,
11,
1848,
1669,
1758,
23442,
32602,
2864,
4283,
9989,
3975,
7342,
2092,
340,
18017,
4792,
1155,
11,
1848,
11,
2160,
90,
8385,
3518,
18017,
4792,
1155,
11,
42160,
11,
6119,
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 |
func TestMapValuePointer(t *testing.T) {
const want = `map[string]*string`
var sb strings.Builder
key, value := Type("string"), Type("string").Pointer()
MapType(key, value).wr(&sb)
assert.Equal(t, want, sb.String())
} | explode_data.jsonl/53149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
2227,
1130,
9084,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
1565,
2186,
14032,
8465,
917,
19324,
2405,
7898,
9069,
15641,
198,
23634,
11,
897,
1669,
3990,
445,
917,
3975,
3990,
445,
917,
1827,
9084,
741,
26873,
929,
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 |
func TestCommandSubcommands(t *testing.T) {
cmd := cli.NewCommand("unit test")
cases := []struct {
giveName string
}{
{giveName: "workers"},
{giveName: "reset"},
{giveName: "serve"},
}
// get all existing subcommands and put into the map
subcommands := make(map[string]*cobra.Command)
for _, sub := range cmd.Commands() {
subcommands[sub.Name()] = sub
}
for _, tt := range cases {
tt := tt
t.Run(tt.giveName, func(t *testing.T) {
if _, exists := subcommands[tt.giveName]; !exists {
assert.Failf(t, "command not found", "command [%s] was not found", tt.giveName)
}
})
}
} | explode_data.jsonl/17535 | {
"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,
4062,
3136,
24270,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
21348,
7121,
4062,
445,
3843,
1273,
5130,
1444,
2264,
1669,
3056,
1235,
341,
197,
3174,
533,
675,
914,
198,
197,
59403,
197,
197,
90,
46430,
675,
25,
330,
54958... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeConfigMap(t *testing.T) {
fake := fake.NewSimpleClientset(&api.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "mycm",
Namespace: "foo",
},
Data: map[string]string{
"key1": "value1",
"key2": "value2",
},
})
c := &describeClient{T: t, Namespace: "foo", Interface: fake}
d := ConfigMapDescriber{c}
out, err := d.Describe("foo", "mycm", printers.DescriberSettings{ShowEvents: true})
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if !strings.Contains(out, "foo") || !strings.Contains(out, "mycm") || !strings.Contains(out, "key1") || !strings.Contains(out, "value1") || !strings.Contains(out, "key2") || !strings.Contains(out, "value2") {
t.Errorf("unexpected out: %s", out)
}
} | explode_data.jsonl/34930 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 306
} | [
2830,
3393,
74785,
2648,
2227,
1155,
353,
8840,
836,
8,
341,
1166,
726,
1669,
12418,
7121,
16374,
2959,
746,
2099,
2068,
10753,
2227,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
2408,
6226,
756,
298,
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... | 8 |
func TestValidName(t *testing.T) {
t.Parallel()
tests := []struct {
name string
in string
want bool
}{
{"Empty", "", false},
{"Simple", "foo", true},
{"MixedCase", "Foo", true},
{"Underscore", "_foo", true},
{"NumberPrefix", "3foo", false},
{"NumberSuffix", "foo3", true},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := ValidName(tc.in)
if got != tc.want {
t.Fatalf("ValidName(%q) got %t, wanted %t",
tc.in, got, tc.want)
}
})
}
} | explode_data.jsonl/55138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
4088,
675,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
17430,
256,
914,
198,
197,
50780,
1807,
198,
197,
59403,
197,
197,
4913,
3522,
497,
7342,
895,
1583,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLevelIter(t *testing.T) {
var iters []*fakeIter
var files []fileMetadata
newIters := func(meta *fileMetadata) (internalIterator, internalIterator, error) {
f := *iters[meta.fileNum]
return &f, nil, nil
}
datadriven.RunTest(t, "testdata/level_iter", func(d *datadriven.TestData) string {
switch d.Cmd {
case "define":
iters = nil
files = nil
for _, line := range strings.Split(d.Input, "\n") {
f := &fakeIter{}
for _, key := range strings.Fields(line) {
j := strings.Index(key, ":")
f.keys = append(f.keys, db.ParseInternalKey(key[:j]))
f.vals = append(f.vals, []byte(key[j+1:]))
}
iters = append(iters, f)
meta := fileMetadata{
fileNum: uint64(len(files)),
}
meta.smallest = f.keys[0]
meta.largest = f.keys[len(f.keys)-1]
files = append(files, meta)
}
return ""
case "iter":
var opts db.IterOptions
for _, arg := range d.CmdArgs {
if len(arg.Vals) != 1 {
return fmt.Sprintf("%s: %s=<value>", d.Cmd, arg.Key)
}
switch arg.Key {
case "lower":
opts.LowerBound = []byte(arg.Vals[0])
case "upper":
opts.UpperBound = []byte(arg.Vals[0])
default:
return fmt.Sprintf("%s: unknown arg: %s", d.Cmd, arg.Key)
}
}
iter := newLevelIter(&opts, db.DefaultComparer.Compare, newIters, files)
defer iter.Close()
return runInternalIterCmd(d, iter)
default:
return fmt.Sprintf("unknown command: %s", d.Cmd)
}
})
} | explode_data.jsonl/5194 | {
"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,
4449,
8537,
1155,
353,
8840,
836,
8,
341,
2405,
432,
388,
29838,
30570,
8537,
198,
2405,
3542,
3056,
1192,
14610,
271,
8638,
2132,
388,
1669,
2915,
45119,
353,
1192,
14610,
8,
320,
10481,
11951,
11,
5306,
11951,
11,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_WriteUint64(t *testing.T) {
t.Run("test", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, testData := range streamTestSuccessCollections["uint64"] {
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.WriteUint64(testData[0].(uint64))
assert(stream.GetBuffer()[i:]).Equals(testData[1])
assert(stream.GetWritePos()).
Equals(len(testData[1].([]byte)) + i)
stream.Release()
}
}
})
} | explode_data.jsonl/21208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
3027,
31825,
21570,
21,
19,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
18185,
6046,
1669,
633,
2271,
6046,
20574,
4859,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAbsCollection_IsNotEmpty(t *testing.T) {
intColl := NewIntCollection([]int{1, 2})
// println(intColl.IsNotEmpty())
if intColl.IsNotEmpty() != true {
t.Fatal("IsNotEmpty 错误")
}
} | explode_data.jsonl/66431 | {
"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,
27778,
6482,
31879,
27416,
1155,
353,
8840,
836,
8,
341,
2084,
15265,
1669,
1532,
1072,
6482,
10556,
396,
90,
16,
11,
220,
17,
3518,
197,
322,
13751,
1548,
15265,
4506,
27416,
2398,
743,
526,
15265,
4506,
27416,
368,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestTime(t *testing.T) {
data := []byte(`{
"code": 0,
"msg": "",
"data": {
"sz002024": {
"qfqday": [
[
"2014-01-02",
"8.93",
"9.03",
"9.17",
"8.88",
"621143.00"
],
[
"2014-01-03",
"9.03",
"9.30",
"9.47",
"8.98",
"1624438.00"
]
]
}
}
}`)
var num []string
n, e := Get(data, "data", "sz002024", "qfqday", 0)
if e != nil {
t.Fatal(e)
}
arr, _ := n.Array()
for _, v := range arr {
s := v.(string)
num = append(num, s)
}
if fmt.Sprintf("%v", num) != "[2014-01-02 8.93 9.03 9.17 8.88 621143.00]" {
t.Fatalf("invalid result")
}
} | explode_data.jsonl/62347 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 600
} | [
2830,
3393,
1462,
1155,
353,
8840,
836,
8,
341,
262,
821,
1669,
3056,
3782,
5809,
515,
414,
330,
1851,
788,
220,
15,
345,
414,
330,
3236,
788,
8324,
414,
330,
691,
788,
341,
286,
330,
14357,
15,
15,
17,
15,
17,
19,
788,
341,
688... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPreparedCommand_CollapseArgs(t *testing.T) {
err := shx.Run("go", "", "run", "", "echo.go", "hello world", "")
if err == nil {
t.Fatal("expected empty arguments to be preserved in the constructor")
}
err = shx.Command("go", "run").Args("", "echo.go", "", "hello world", "").Run()
if err == nil {
t.Fatal("expected empty arguments to be preserved when Args is called")
}
err = shx.Command("go", "", "run", "", "echo.go", "hello world", "").CollapseArgs().Run()
if err != nil {
t.Fatal("expected empty arguments to be removed")
}
} | explode_data.jsonl/57101 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
4703,
7212,
4062,
920,
10786,
4117,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
557,
87,
16708,
445,
3346,
497,
7342,
330,
6108,
497,
7342,
330,
3047,
18002,
497,
330,
14990,
1879,
497,
14676,
743,
1848,
621,
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 TestExtractDeclarationUnsafeSuccess(t *testing.T) {
value := gidlir.Record{
Name: "ExampleStruct",
Fields: []gidlir.Field{
{Key: gidlir.FieldKey{Name: "ThisIsNotAField"}, Value: "foo"},
},
}
decl, err := testSchema(t).ExtractDeclarationUnsafe(value)
if err != nil {
t.Fatalf("ExtractDeclarationUnsafe failed: %s", err)
}
checkStruct(t, decl, "ExampleStruct", false)
} | explode_data.jsonl/21391 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
28959,
24489,
78770,
7188,
1155,
353,
8840,
836,
8,
341,
16309,
1669,
45863,
75,
404,
49959,
515,
197,
21297,
25,
330,
13314,
9422,
756,
197,
197,
8941,
25,
3056,
34849,
75,
404,
17087,
515,
298,
197,
90,
1592,
25,
45863,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGroupByWhenNotExistCols(t *testing.T) {
sqlTests := []struct {
sql string
expectedErrMatch string
}{
{
sql: "select a from t group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.t\\.a'.*",
},
{
// has an as column alias
sql: "select a as tempField from t group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.t\\.a'.*",
},
{
// has as table alias
sql: "select tempTable.a from t as tempTable group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.tempTable\\.a'.*",
},
{
// has a func call
sql: "select length(a) from t group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.t\\.a'.*",
},
{
// has a func call with two cols
sql: "select length(b + a) from t group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.t\\.a'.*",
},
{
// has a func call with two cols
sql: "select length(a + b) from t group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.t\\.a'.*",
},
{
// has a func call with two cols
sql: "select length(a + b) as tempField from t group by b",
expectedErrMatch: ".*contains nonaggregated column 'test\\.t\\.a'.*",
},
}
s := createPlannerSuite()
for _, test := range sqlTests {
sql := test.sql
p, err := buildLogicPlan4GroupBy(s, t, sql)
require.Nil(t, p)
require.Error(t, err)
require.Regexp(t, test.expectedErrMatch, err.Error())
}
} | explode_data.jsonl/50208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 717
} | [
2830,
3393,
2808,
1359,
4498,
45535,
37567,
1155,
353,
8840,
836,
8,
341,
30633,
18200,
1669,
3056,
1235,
341,
197,
30633,
1060,
914,
198,
197,
42400,
7747,
8331,
914,
198,
197,
59403,
197,
197,
515,
298,
30633,
25,
1060,
330,
1742,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUnmarshalZones(t *testing.T) {
d := []byte(`[
{
"nx_ttl":3600,
"retry":7200,
"zone":"test.zone",
"network_pools":[
"p09"
],
"primary":{
"enabled":true,
"secondaries":[
{
"ip":"1.1.1.1",
"notify":true,
"networks":[
],
"port":53
},
{
"ip":"2.2.2.2",
"notify":true,
"networks":[
],
"port":53
}
]
},
"refresh":43200,
"expiry":1209600,
"dns_servers":[
"dns1.p09.nsone.net",
"dns2.p09.nsone.net",
"dns3.p09.nsone.net",
"dns4.p09.nsone.net"
],
"meta":{
},
"link":null,
"serial":1473863358,
"ttl":3600,
"id":"57d95da659272400013334de",
"hostmaster":"hostmaster@nsone.net",
"networks":[
0
],
"pool":"p09"
},
{
"nx_ttl":3600,
"retry":7200,
"zone":"secondary.zone",
"network_pools":[
"p09"
],
"secondary":{
"status":"pending",
"last_xfr":0,
"primary_ip":"1.1.1.1",
"primary_port":53,
"enabled":true,
"tsig":{
"enabled":false,
"hash":null,
"name":null,
"key":null
},
"error":null,
"expired":false
},
"primary":{
"enabled":false,
"secondaries":[
]
},
"refresh":43200,
"expiry":1209600,
"dns_servers":[
"dns1.p09.nsone.net",
"dns2.p09.nsone.net",
"dns3.p09.nsone.net",
"dns4.p09.nsone.net"
],
"meta":{
},
"link":null,
"serial":1473868413,
"ttl":3600,
"id":"57d9727d1c372700011eff6e",
"hostmaster":"hostmaster@nsone.net",
"networks":[
0
],
"pool":"p09"
},
{
"nx_ttl":3600,
"retry":7200,
"zone":"myfailover.com",
"network_pools":[
"p09"
],
"primary":{
"enabled":true,
"secondaries":[
]
},
"refresh":43200,
"expiry":1209600,
"dns_servers":[
"dns1.p09.nsone.net",
"dns2.p09.nsone.net",
"dns3.p09.nsone.net",
"dns4.p09.nsone.net"
],
"meta":{
},
"link":null,
"serial":1473813629,
"ttl":3600,
"id":"57d89c7b1c372700011e0a97",
"hostmaster":"hostmaster@nsone.net",
"networks":[
0
],
"pool":"p09"
}
]
`)
zl := []*Zone{}
if err := json.Unmarshal(d, &zl); err != nil {
t.Error(err)
}
if len(zl) != 3 {
fmt.Println(zl)
t.Error("Do not have 3 zones in list")
}
z := zl[0]
assert.Nil(t, z.Link)
assert.Nil(t, z.Secondary)
assert.Equal(t, z.ID, "57d95da659272400013334de", "Wrong zone id")
assert.Equal(t, z.Zone, "test.zone", "Wrong zone name")
assert.Equal(t, z.TTL, 3600, "Wrong zone ttl")
assert.Equal(t, z.NxTTL, 3600, "Wrong zone nxttl")
assert.Equal(t, z.Retry, 7200, "Wrong zone retry")
assert.Equal(t, z.Serial, 1473863358, "Wrong zone serial")
assert.Equal(t, z.Refresh, 43200, "Wrong zone refresh")
assert.Equal(t, z.Expiry, 1209600, "Wrong zone expiry")
assert.Equal(t, z.Hostmaster, "hostmaster@nsone.net", "Wrong zone hostmaster")
assert.Equal(t, z.Pool, "p09", "Wrong zone pool")
assert.Equal(t, z.NetworkIDs, []int{0}, "Wrong zone network")
assert.Equal(t, z.NetworkPools, []string{"p09"}, "Wrong zone network pools")
assert.Equal(t, z.Meta, &data.Meta{}, "Zone meta should be empty")
dnsServers := []string{
"dns1.p09.nsone.net",
"dns2.p09.nsone.net",
"dns3.p09.nsone.net",
"dns4.p09.nsone.net",
}
assert.Equal(t, z.DNSServers, dnsServers, "Wrong zone dns networks")
primary := &ZonePrimary{
Enabled: true,
Secondaries: []ZoneSecondaryServer{
ZoneSecondaryServer{
IP: "1.1.1.1",
Port: 53,
Notify: true,
NetworkIDs: []int{},
},
ZoneSecondaryServer{
IP: "2.2.2.2",
Port: 53,
Notify: true,
NetworkIDs: []int{},
},
},
}
assert.Equal(t, z.Primary, primary, "Wrong zone primary")
// Check zone with secondaries
secZ := zl[1]
assert.Nil(t, secZ.Link)
assert.Equal(t, secZ.Zone, "secondary.zone", "Wrong zone name")
assert.Equal(t, secZ.Primary, &ZonePrimary{
Enabled: false,
Secondaries: []ZoneSecondaryServer{}}, "Wrong zone secondary primary")
secondary := secZ.Secondary
assert.Nil(t, secondary.Error)
assert.Equal(t, secondary.Status, "pending", "Wrong zone secondary status")
assert.Equal(t, secondary.LastXfr, 0, "Wrong zone secondary last xfr")
assert.Equal(t, secondary.PrimaryIP, "1.1.1.1", "Wrong zone secondary primary ip")
assert.Equal(t, secondary.PrimaryPort, 53, "Wrong zone secondary primary port")
assert.Equal(t, secondary.Enabled, true, "Wrong zone secondary enabled")
assert.Equal(t, secondary.TSIG, &TSIG{
Enabled: false,
Hash: "",
Name: "",
Key: ""}, "Wrong zone secondary tsig")
} | explode_data.jsonl/58567 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2758
} | [
2830,
3393,
1806,
27121,
57,
3154,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
3056,
3782,
5809,
9640,
256,
314,
2303,
414,
330,
23357,
87157,
788,
18,
21,
15,
15,
345,
414,
330,
44848,
788,
22,
17,
15,
15,
345,
414,
330,
8684,
3252... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRPC_QueryNodeParams(t *testing.T) {
codec.UpgradeHeight = 7000
gBZ, _, _, _ := fiveValidatorsOneAppGenesis()
_, _, cleanup := NewInMemoryTendermintNode(t, gBZ)
_, stopCli, evtChan := subscribeTo(t, tmTypes.EventNewBlock)
<-evtChan // Wait for block
var params = HeightParams{
Height: 0,
}
q := newQueryRequest("nodeparams", newBody(params))
rec := httptest.NewRecorder()
NodeParams(rec, q, httprouter.Params{})
resp := getJSONResponse(rec)
assert.NotNil(t, resp)
assert.NotEmpty(t, resp)
assert.True(t, strings.Contains(rec.Body.String(), "max_validators"))
<-evtChan // Wait for block
params = HeightParams{
Height: 2,
}
q = newQueryRequest("nodeparams", newBody(params))
rec = httptest.NewRecorder()
NodeParams(rec, q, httprouter.Params{})
resp = getJSONResponse(rec)
assert.NotNil(t, resp)
assert.NotEmpty(t, resp)
assert.True(t, strings.Contains(rec.Body.String(), "max_validators"))
cleanup()
stopCli()
} | explode_data.jsonl/44716 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
29528,
48042,
1955,
4870,
1155,
353,
8840,
836,
8,
341,
43343,
66,
13,
43861,
3640,
284,
220,
22,
15,
15,
15,
198,
3174,
33,
57,
11,
8358,
8358,
716,
1669,
4236,
31748,
3966,
2164,
84652,
741,
197,
6878,
8358,
21290,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJsonIO(t *testing.T) {
WriteGameFileToJson(testObjects.TestGame)
var gameFromDisk = ReadGameFileFromJson(testObjects.TestGame.Title)
assert.Equal(t, testObjects.TestGame.WorldWidth, gameFromDisk.WorldWidth)
assert.Equal(t, testObjects.TestGame.WorldLayout, gameFromDisk.WorldLayout)
assert.Equal(t, testObjects.TestGame.StartingRoom, gameFromDisk.StartingRoom)
assert.Equal(t, testObjects.TestGame.Inventory, gameFromDisk.Inventory)
} | explode_data.jsonl/23312 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
5014,
3810,
1155,
353,
8840,
836,
8,
341,
60373,
4868,
1703,
78967,
8623,
11543,
8787,
4868,
340,
2405,
1809,
3830,
47583,
284,
4457,
4868,
1703,
3830,
5014,
8623,
11543,
8787,
4868,
22967,
692,
6948,
12808,
1155,
11,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileServiceInstanceFailsWithDeletedPlan(t *testing.T) {
fakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, noFakeActions())
addGetNamespaceReaction(fakeKubeClient)
sharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())
sharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())
sp := getTestClusterServicePlan()
sp.Status.RemovedFromBrokerCatalog = true
sharedInformers.ClusterServicePlans().Informer().GetStore().Add(sp)
instance := getTestServiceInstanceWithClusterRefs()
if err := reconcileServiceInstance(t, testController, instance); err == nil {
t.Fatalf("This should fail")
}
brokerActions := fakeClusterServiceBrokerClient.Actions()
assertNumberOfBrokerActions(t, brokerActions, 0)
instanceKey := testNamespace + "/" + testServiceInstanceName
// Since synchronous operation, must not make it into the polling queue.
if testController.instancePollingQueue.NumRequeues(instanceKey) != 0 {
t.Fatalf("Expected polling queue to not have any record of test instance")
}
actions := fakeCatalogClient.Actions()
assertNumberOfActions(t, actions, 1)
// verify no kube actions
kubeActions := fakeKubeClient.Actions()
assertNumberOfActions(t, kubeActions, 0)
updatedServiceInstance := assertUpdateStatus(t, actions[0], instance)
assertServiceInstanceReadyFalse(t, updatedServiceInstance, errorDeletedClusterServicePlanReason)
events := getRecordedEvents(testController)
expectedEvent := warningEventBuilder(errorDeletedClusterServicePlanReason).msgf(
"ClusterServicePlan (K8S: %q ExternalName: %q) has been deleted; cannot provision.",
"cspguid", "test-clusterserviceplan",
)
if err := checkEvents(events, expectedEvent.stringArr()); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/58142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 566
} | [
2830,
3393,
693,
40446,
457,
1860,
2523,
37,
6209,
2354,
26039,
20485,
1155,
353,
8840,
836,
8,
341,
1166,
726,
42,
3760,
2959,
11,
12418,
41606,
2959,
11,
12418,
28678,
1860,
65545,
2959,
11,
1273,
2051,
11,
6094,
37891,
388,
1669,
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... | 4 |
func TestGetMarginMarketInfo(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := f.GetMarginMarketInfo(context.Background(), "BTC_USD")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15173 | {
"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,
1949,
21681,
38822,
1731,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
741,
197,
532,
197,
6878,
1848,
1669,
282,
2234,
21681,
38822,
1731,
5378,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIdentityResponseHeaders(t *testing.T) {
defer afterTest(t)
log.SetOutput(ioutil.Discard) // is noisy otherwise
defer log.SetOutput(os.Stderr)
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
w.Header().Set("Transfer-Encoding", "identity")
w.(Flusher).Flush()
fmt.Fprintf(w, "I am an identity response.")
}))
defer ts.Close()
res, err := Get(ts.URL)
if err != nil {
t.Fatalf("Get error: %v", err)
}
defer res.Body.Close()
if g, e := res.TransferEncoding, []string(nil); !reflect.DeepEqual(g, e) {
t.Errorf("expected TransferEncoding of %v; got %v", e, g)
}
if _, haveCL := res.Header["Content-Length"]; haveCL {
t.Errorf("Unexpected Content-Length")
}
if !res.Close {
t.Errorf("expected Connection: close; got %v", res.Close)
}
} | explode_data.jsonl/22406 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
18558,
2582,
10574,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
6725,
4202,
5097,
1956,
30158,
909,
47560,
8,
442,
374,
49280,
5937,
198,
16867,
1487,
4202,
5097,
9638,
77319,
692,
57441,
1669,
54320,
70334,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOptionBool_EncodedLength(t *testing.T) {
assertEncodedLength(t, []encodedLengthAssert{
{NewOptionBool(NewBool(false)), 1},
{NewOptionBool(NewBool(true)), 1},
{NewOptionBoolEmpty(), 1},
})
} | explode_data.jsonl/40247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
5341,
11233,
93529,
6737,
4373,
1155,
353,
8840,
836,
8,
341,
6948,
46795,
4373,
1155,
11,
3056,
19329,
4373,
8534,
515,
197,
197,
90,
3564,
5341,
11233,
35063,
11233,
3576,
5731,
220,
16,
1583,
197,
197,
90,
3564,
5341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerSideRendering(t *testing.T) {
tcs := []tt.TestCase{
{
Desc: "Modifies document only once",
// The expected output is actually not correctly server-side
// rendered, but the presence of i-amphtml-layout attribute halts
// processing, so this is effectively a no-op.
Input: tt.Concat(tt.Doctype,
"<html ⚡ i-amphtml-layout><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body>",
"<amp-img layout=container></amp-img>",
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
"<html ⚡ i-amphtml-layout><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body>",
"<amp-img layout=container></amp-img>",
"</body></html>"),
},
{
Desc: "Boilerplate removed and preserves noscript in body",
Input: tt.Concat(tt.Doctype,
"<html ⚡><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body><noscript><img src=lemur.png></noscript></body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡ i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,
tt.LinkFavicon, tt.LinkCanonical,
"</head><body>",
"<noscript><img src=lemur.png></noscript>",
"</body></html>"),
},
{
Desc: "Boilerplate removed and no changes within template tag",
Input: tt.Concat(tt.Doctype,
"<html ⚡><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body>",
"<template><amp-img height=42 layout=responsive width=42></amp-img></template>",
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡ i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,
tt.LinkFavicon, tt.LinkCanonical,
"</head><body>",
`<template><amp-img height="42" layout="responsive" width="42"></amp-img></template>`,
"</body></html>"),
},
{
Desc: "Boilerplate removed and layout applied",
Input: tt.Concat(tt.Doctype,
"<html ⚡><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body>",
`<amp-img class="" layout=container></amp-img>`,
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡ i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,
tt.LinkFavicon, tt.LinkCanonical,
"</head><body>",
`<amp-img class="i-amphtml-layout-container" layout="container" i-amphtml-layout="container"></amp-img>`,
"</body></html>"),
},
{
Desc: "Amp4Email Boilerplate removed and layout applied",
Input: tt.Concat(tt.Doctype,
"<html ⚡4email><head>",
tt.MetaCharset, tt.ScriptAMPRuntime, tt.StyleAMP4EmailBoilerplate,
"</head><body>",
"<amp-img layout=container></amp-img>",
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡4email i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.ScriptAMPRuntime,
"</head><body>",
`<amp-img layout="container" class="i-amphtml-layout-container" i-amphtml-layout="container"></amp-img>`,
"</body></html>"),
},
{
Desc: "Amp4Ads Boilerplate removed and layout applied",
Input: tt.Concat(tt.Doctype,
"<html ⚡4ads><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,
tt.StyleAMP4AdsBoilerplate,
"</head><body>",
"<amp-img layout=container></amp-img>",
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡4ads i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,
"</head><body>",
`<amp-img layout="container" class="i-amphtml-layout-container" i-amphtml-layout="container"></amp-img>`,
"</body></html>"),
},
{
Desc: "Boilerplate removed despite sizes (in head tho)",
Input: tt.Concat(tt.Doctype,
"<html ⚡><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
`<link rel="shortcut icon" type="a" href="b" sizes="c">`,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body>",
"<amp-img layout=container></amp-img>",
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡ i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
`<link rel="shortcut icon" type="a" href="b" sizes="c">`,
tt.LinkCanonical,
"</head><body>",
`<amp-img layout="container" class="i-amphtml-layout-container" i-amphtml-layout="container"></amp-img>`,
"</body></html>"),
},
{
Desc: "Boilerplate removed when amp-experiment is present but empty",
Input: tt.Concat(tt.Doctype,
"<html ⚡><head>",
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime, tt.LinkFavicon,
tt.LinkCanonical, tt.StyleAMPBoilerplate, tt.NoscriptAMPBoilerplate,
"</head><body>",
`<amp-experiment><script type="application/json">{ }</script></amp-experiment>`,
"</body></html>"),
Expected: tt.Concat(tt.Doctype,
`<html ⚡ i-amphtml-layout="" i-amphtml-no-boilerplate=""><head>`,
tt.MetaCharset, tt.MetaViewport, tt.ScriptAMPRuntime,
tt.LinkFavicon, tt.LinkCanonical,
"</head><body>",
`<amp-experiment class=i-amphtml-layout-container i-amphtml-layout=container><script type="application/json">{ }</script></amp-experiment>`,
"</body></html>"),
},
}
runServerSideRenderingTestcases(t, tcs)
} | explode_data.jsonl/27808 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2780
} | [
2830,
3393,
5475,
16384,
36056,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
5566,
31363,
515,
197,
197,
515,
298,
10957,
3300,
25,
330,
4459,
9606,
2197,
1172,
3055,
756,
298,
197,
322,
576,
3601,
2550,
374,
3520,
537,
12440... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConcurrentSetDeadline(t *testing.T) {
ln := newLocalListener(t, "tcp")
defer ln.Close()
const goroutines = 8
const conns = 10
const tries = 100
var c [conns]Conn
for i := 0; i < conns; i++ {
var err error
c[i], err = Dial(ln.Addr().Network(), ln.Addr().String())
if err != nil {
t.Fatal(err)
}
defer c[i].Close()
}
var wg sync.WaitGroup
wg.Add(goroutines)
now := time.Now()
for i := 0; i < goroutines; i++ {
go func(i int) {
defer wg.Done()
// Make the deadlines steadily earlier,
// to trigger runtime adjusttimers calls.
for j := tries; j > 0; j-- {
for k := 0; k < conns; k++ {
c[k].SetReadDeadline(now.Add(2*time.Hour + time.Duration(i*j*k)*time.Second))
c[k].SetWriteDeadline(now.Add(1*time.Hour + time.Duration(i*j*k)*time.Second))
}
}
}(i)
}
wg.Wait()
} | explode_data.jsonl/77463 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 383
} | [
2830,
3393,
1109,
3231,
1649,
83593,
1155,
353,
8840,
836,
8,
341,
197,
2261,
1669,
501,
7319,
2743,
1155,
11,
330,
27161,
1138,
16867,
29390,
10421,
2822,
4777,
45198,
28628,
284,
220,
23,
198,
4777,
390,
4412,
284,
220,
16,
15,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAssetServiceUpdateAssetByID(t *testing.T) {
// case 1
AssetRepo.On("UpdateAssetByID", int64(1), "v1", map[string]interface{}{"name": "123"}).Once().Return(nil)
testutil.Play(t, AssetSrv, "UpdateAssetByID", int64(1), "v1", map[string]interface{}{"name": "123"}).Match(nil)
// case 2
AssetRepo.On("UpdateAssetByID", int64(1), "v1", map[string]interface{}{"name": "1234"}).Once().Return(errors.New("Duplicate"))
testutil.Play(t, AssetSrv, "UpdateAssetByID", int64(1), "v1", map[string]interface{}{"name": "1234"}).Match(errors.New("Duplicate"))
} | explode_data.jsonl/24296 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
16604,
1860,
4289,
16604,
60572,
1155,
353,
8840,
836,
8,
341,
197,
322,
1142,
220,
16,
198,
197,
16604,
25243,
8071,
445,
4289,
16604,
60572,
497,
526,
21,
19,
7,
16,
701,
330,
85,
16,
497,
2415,
14032,
31344,
6257,
491... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMaxSubscriptions(t *testing.T) {
opts := DefaultOptions()
opts.MaxSubs = 10
s := RunServer(opts)
defer s.Shutdown()
addr := fmt.Sprintf("nats://%s:%d", opts.Host, opts.Port)
nc, err := nats.Connect(addr)
if err != nil {
t.Fatalf("Error creating client: %v\n", err)
}
defer nc.Close()
for i := 0; i < 10; i++ {
_, err := nc.Subscribe(fmt.Sprintf("foo.%d", i), func(*nats.Msg) {})
if err != nil {
t.Fatalf("Error subscribing: %v\n", err)
}
}
// This should cause the error.
nc.Subscribe("foo.22", func(*nats.Msg) {})
nc.Flush()
if err := nc.LastError(); err == nil {
t.Fatal("Expected an error but got none\n")
}
} | explode_data.jsonl/3608 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
5974,
3136,
29966,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
7899,
3798,
741,
64734,
14535,
3136,
82,
284,
220,
16,
15,
198,
1903,
1669,
6452,
5475,
30885,
340,
16867,
274,
10849,
18452,
2822,
53183,
1669,
8879,
17305,
445,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSequenceBumpedNewSeq(t *testing.T) {
hmock := httptest.NewClient()
client := &Client{
AuroraURL: "https://localhost/",
HTTP: hmock,
}
effectRequest := EffectRequest{ForAccount: "GCDIZFWLOTBWHTPODXCBH6XNXPFMSQFRVIDRP3JLEKQZN66G7NF3ANOD"}
testCases := []struct {
desc string
payload string
}{
{
desc: "new_seq as a string",
payload: sequenceBumpedPage,
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
hmock.On(
"GET",
"https://localhost/accounts/GCDIZFWLOTBWHTPODXCBH6XNXPFMSQFRVIDRP3JLEKQZN66G7NF3ANOD/effects",
).ReturnString(200, tc.payload)
efp, err := client.Effects(effectRequest)
if assert.NoError(t, err) {
assert.Len(t, efp.Embedded.Records, 1)
}
effect, ok := efp.Embedded.Records[0].(effects.SequenceBumped)
assert.True(t, ok)
assert.Equal(t, int64(300000000000), effect.NewSeq)
})
}
} | explode_data.jsonl/28814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 431
} | [
2830,
3393,
14076,
33,
60192,
3564,
20183,
1155,
353,
8840,
836,
8,
341,
9598,
16712,
1669,
54320,
70334,
7121,
2959,
741,
25291,
1669,
609,
2959,
515,
197,
22985,
324,
6215,
3144,
25,
330,
2428,
1110,
8301,
35075,
197,
197,
9230,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFloat32_Has(t *testing.T) {
testcases := []struct {
name string
s Float32
input float32
expect bool
}{
{
name: "test Float32 Has, s has input element",
s: map[float32]struct{}{1: {}, 1.5: {}, 1.2: {}},
input: 1,
expect: true,
},
{
name: "test Float32 Has, s does not have element",
s: map[float32]struct{}{1: {}, 1.5: {}, 1.2: {}},
input: 2,
expect: false,
},
}
for _, tc := range testcases {
t.Logf("running scenario: %s", tc.name)
actual := tc.s.Has(tc.input)
if actual != tc.expect {
t.Errorf("expect return: %v, but got: %v", tc.expect, actual)
}
}
} | explode_data.jsonl/60107 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 313
} | [
2830,
3393,
5442,
18,
17,
2039,
300,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
1903,
414,
13001,
18,
17,
198,
197,
22427,
220,
2224,
18,
17,
198,
197,
24952,
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... | 3 |
func TestPoll(t *testing.T) {
handler := mockHandler{}
poll := Poller{
IntervalMs: 100,
Handler: &handler,
}
assert.NilError(t, poll.Start())
assert.Error(t, poll.Start(), "Already running")
time.Sleep(2 * time.Second)
assert.NilError(t, poll.Stop())
assert.Error(t, poll.Stop(), "Not running")
if handler.count < 18 || handler.count > 22 {
log.Printf("handler count: %v", handler.count)
assert.NotNil(t, errors.New("poller did not successfully"))
}
} | explode_data.jsonl/18036 | {
"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,
49207,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
7860,
3050,
31483,
3223,
965,
1669,
24385,
261,
515,
197,
197,
10256,
21634,
25,
220,
16,
15,
15,
345,
197,
197,
3050,
25,
262,
609,
17905,
345,
197,
630,
6948,
59678,
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... | 3 |
func TestAllowPersonalInfo(t *testing.T) {
vendorListData := tcf1MarshalVendorList(tcf1VendorList{
VendorListVersion: 1,
Vendors: []tcf1Vendor{
{ID: 2, Purposes: []int{1}}, // cookie reads/writes
{ID: 3, Purposes: []int{1, 3}}, // ad personalization
},
})
perms := permissionsImpl{
cfg: config.GDPR{
HostVendorID: 2,
},
vendorIDs: map[openrtb_ext.BidderName]uint16{
openrtb_ext.BidderAppnexus: 2,
openrtb_ext.BidderPubmatic: 3,
},
fetchVendorList: map[uint8]func(ctx context.Context, id uint16) (vendorlist.VendorList, error){
tcf1SpecVersion: listFetcher(map[uint16]vendorlist.VendorList{
1: parseVendorListData(t, vendorListData),
}),
tcf2SpecVersion: listFetcher(map[uint16]vendorlist.VendorList{
1: parseVendorListData(t, vendorListData),
}),
},
}
// PI needs both purposes to succeed
allowPI, _, _, err := perms.PersonalInfoAllowed(context.Background(), openrtb_ext.BidderAppnexus, "", "BOS2bx5OS2bx5ABABBAAABoAAAABBwAA")
assertNilErr(t, err)
assertBoolsEqual(t, false, allowPI)
allowPI, _, _, err = perms.PersonalInfoAllowed(context.Background(), openrtb_ext.BidderPubmatic, "", "BOS2bx5OS2bx5ABABBAAABoAAAABBwAA")
assertNilErr(t, err)
assertBoolsEqual(t, true, allowPI)
// Assert that an item that otherwise would not be allowed PI access, gets approved because it is found in the GDPR.NonStandardPublishers array
perms.cfg.NonStandardPublisherMap = map[string]struct{}{"appNexusAppID": {}}
allowPI, _, _, err = perms.PersonalInfoAllowed(context.Background(), openrtb_ext.BidderAppnexus, "appNexusAppID", "BOS2bx5OS2bx5ABABBAAABoAAAABBwAA")
assertNilErr(t, err)
assertBoolsEqual(t, true, allowPI)
} | explode_data.jsonl/46161 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 703
} | [
2830,
3393,
18605,
34027,
1731,
1155,
353,
8840,
836,
8,
341,
5195,
8029,
852,
1043,
1669,
259,
9792,
16,
55438,
44691,
852,
1155,
9792,
16,
44691,
852,
515,
197,
17446,
8029,
852,
5637,
25,
220,
16,
345,
197,
17446,
32885,
25,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnmarshalStrict(t *testing.T) {
t.Parallel()
tests := []struct {
name string
hcl string
want interface{}
wantErr error
}{
{"Empty", "", map[string]interface{}{}, nil},
{"Empty list", "[]", map[string]interface{}(nil), fmt.Errorf("reflect.Set: value of type []interface {} is not assignable to type map[string]interface {}")},
{"List of int", "[1,2,3]", map[string]interface{}(nil), fmt.Errorf("reflect.Set: value of type []interface {} is not assignable to type map[string]interface {}")},
{"Array of map", "a { b { c { d = 1 e = 2 }}}", map[string]interface{}{"a": map[string]interface{}{"b": map[string]interface{}{"c": map[string]interface{}{"d": 1, "e": 2}}}}, nil},
{"Map", fmt.Sprint(dictFixture), dictFixture.Native(), nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var out map[string]interface{}
err := Unmarshal([]byte(tt.hcl), &out)
assert.Equal(t, tt.want, out)
if tt.wantErr == nil {
assert.NoError(t, err)
} else {
assert.EqualError(t, err, tt.wantErr.Error())
}
})
}
} | explode_data.jsonl/60154 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 447
} | [
2830,
3393,
1806,
27121,
41857,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
9598,
564,
257,
914,
198,
197,
50780,
262,
3749,
16094,
197,
50780,
7747,
1465,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetCipherEngineUndefined(t *testing.T) {
c := &Client{}
v := &schemas.S5{}
cipherEngine, err := c.getCipherEngine(v)
assert.Equal(t, fmt.Errorf("you need to specify a S5 cipher engine"), err)
assert.Equal(t, cipherEngine, nil)
} | explode_data.jsonl/51174 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
1949,
79460,
4571,
30571,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
2959,
16094,
5195,
1669,
609,
56543,
808,
20,
31483,
1444,
10558,
4571,
11,
1848,
1669,
272,
22494,
10558,
4571,
3747,
340,
6948,
12808,
1155,
11,
8879... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepareNetworkLabels(t *testing.T) {
project := types.Project{
Name: "myProject",
Networks: types.Networks(map[string]types.NetworkConfig{"skynet": {}}),
}
prepareNetworks(&project)
assert.DeepEqual(t, project.Networks["skynet"].Labels, types.Labels(map[string]string{
"com.docker.compose.network": "skynet",
"com.docker.compose.project": "myProject",
"com.docker.compose.version": api.ComposeVersion,
}))
} | explode_data.jsonl/72627 | {
"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,
50590,
12320,
23674,
1155,
353,
8840,
836,
8,
341,
72470,
1669,
4494,
30944,
515,
197,
21297,
25,
257,
330,
2408,
7849,
756,
197,
197,
12320,
82,
25,
4494,
30149,
82,
9147,
14032,
60,
9242,
30149,
2648,
4913,
4886,
97988,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewSchema(t *testing.T) {
type args struct {
opts Options
}
tests := []struct {
name string
args args
want *Schema
}{
{"default", args{DefaultOptions}, &Schema{Fields: []Field{},
Options: DefaultOptions}},
{"custom-stopwords", args{Options{Stopwords: []string{"custom"}}}, &Schema{Fields: []Field{},
Options: Options{Stopwords: []string{"custom"}}}},
{"no-frequencies", args{Options{NoFrequencies: true}}, &Schema{Fields: []Field{},
Options: Options{NoFrequencies: true}}},
{"no-highlights", args{Options{NoHighlights: true}}, &Schema{Fields: []Field{},
Options: Options{NoHighlights: true}}},
{"skip-initial-scan", args{Options{SkipInitialScan: true}}, &Schema{Fields: []Field{},
Options: Options{SkipInitialScan: true}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewSchema(tt.args.opts); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewSchema() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/72798 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 391
} | [
2830,
3393,
3564,
8632,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
64734,
14566,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
353,
8632,
198,
197,
59403,
197,
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... | 2 |
func TestCompare(t *testing.T) {
a := Version{1, 2, 0, 0}
b := Version{1, 2, 1, 0}
c := Version{2, 0, 1, 0}
if x := a.Compare(b); x != -1 {
t.Errorf("expected %v < %v, got %d", a, b, x)
}
if x := b.Compare(a); x != 1 {
t.Errorf("expected %v > %v, got %d", b, a, x)
}
if x := b.Compare(c); x != -1 {
t.Errorf("expected %v < %v, got %d", b, c, x)
}
if x := b.Compare(b); x != 0 {
t.Errorf("expected %v = %v, got %d", b, b, x)
}
} | explode_data.jsonl/74327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
27374,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
6079,
90,
16,
11,
220,
17,
11,
220,
15,
11,
220,
15,
532,
2233,
1669,
6079,
90,
16,
11,
220,
17,
11,
220,
16,
11,
220,
15,
532,
1444,
1669,
6079,
90,
17,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPostfixIncBracket(t *testing.T) {
const SCRIPT = `
var o = {x: 42};
var trace = "";
function F1() {
trace += "First!";
return o;
}
function F2() {
trace += "Second!";
return "x";
}
var rv = F1()[F2()]++;
rv += trace + o.x;
`
testScript(SCRIPT, asciiString("42First!Second!43"), t)
} | explode_data.jsonl/75249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
4133,
5743,
39245,
58500,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
297,
284,
314,
87,
25,
220,
19,
17,
2440,
2405,
11655,
284,
21238,
7527,
434,
16,
368,
341,
2760,
11655,
1421,
330,
5338,
26782,
2760,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateKubeAPIServer(t *testing.T) {
str := "foobar"
authzMode := "RBAC,Webhook"
grid := []struct {
Input kops.KubeAPIServerConfig
Cluster *kops.Cluster
ExpectedErrors []string
ExpectedDetail string
}{
{
Input: kops.KubeAPIServerConfig{
ProxyClientCertFile: &str,
},
ExpectedErrors: []string{
"Forbidden::KubeAPIServer",
},
ExpectedDetail: "proxyClientCertFile and proxyClientKeyFile must both be specified (or neither)",
},
{
Input: kops.KubeAPIServerConfig{
ProxyClientKeyFile: &str,
},
ExpectedErrors: []string{
"Forbidden::KubeAPIServer",
},
ExpectedDetail: "proxyClientCertFile and proxyClientKeyFile must both be specified (or neither)",
},
{
Input: kops.KubeAPIServerConfig{
ServiceNodePortRange: str,
},
ExpectedErrors: []string{
"Invalid value::KubeAPIServer.serviceNodePortRange",
},
},
{
Input: kops.KubeAPIServerConfig{
AuthorizationMode: &authzMode,
},
ExpectedErrors: []string{
"Required value::KubeAPIServer.authorizationWebhookConfigFile",
},
ExpectedDetail: "Authorization mode Webhook requires authorizationWebhookConfigFile to be specified",
},
{
Input: kops.KubeAPIServerConfig{
AuthorizationMode: fi.String("RBAC"),
},
Cluster: &kops.Cluster{
Spec: kops.ClusterSpec{
Authorization: &kops.AuthorizationSpec{
RBAC: &kops.RBACAuthorizationSpec{},
},
KubernetesVersion: "1.19.0",
CloudProvider: "aws",
},
},
ExpectedErrors: []string{
"Required value::KubeAPIServer.authorizationMode",
},
},
{
Input: kops.KubeAPIServerConfig{
AuthorizationMode: fi.String("RBAC,Node"),
},
Cluster: &kops.Cluster{
Spec: kops.ClusterSpec{
Authorization: &kops.AuthorizationSpec{
RBAC: &kops.RBACAuthorizationSpec{},
},
KubernetesVersion: "1.19.0",
CloudProvider: "aws",
},
},
},
{
Input: kops.KubeAPIServerConfig{
AuthorizationMode: fi.String("RBAC,Node,Bogus"),
},
Cluster: &kops.Cluster{
Spec: kops.ClusterSpec{
Authorization: &kops.AuthorizationSpec{
RBAC: &kops.RBACAuthorizationSpec{},
},
KubernetesVersion: "1.19.0",
CloudProvider: "aws",
},
},
ExpectedErrors: []string{
"Unsupported value::KubeAPIServer.authorizationMode",
},
},
}
for _, g := range grid {
if g.Cluster == nil {
g.Cluster = &kops.Cluster{
Spec: kops.ClusterSpec{
KubernetesVersion: "1.20.0",
},
}
}
errs := validateKubeAPIServer(&g.Input, g.Cluster, field.NewPath("KubeAPIServer"))
testErrors(t, g.Input, errs, g.ExpectedErrors)
if g.ExpectedDetail != "" {
found := false
for _, err := range errs {
if err.Detail == g.ExpectedDetail {
found = true
}
}
if !found {
for _, err := range errs {
t.Logf("found detail: %q", err.Detail)
}
t.Errorf("did not find expected error %q", g.ExpectedDetail)
}
}
}
} | explode_data.jsonl/61616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1369
} | [
2830,
3393,
17926,
42,
3760,
2537,
1637,
2836,
1155,
353,
8840,
836,
8,
341,
11355,
1669,
330,
50267,
698,
78011,
89,
3636,
1669,
330,
29259,
1706,
11,
5981,
20873,
1837,
49018,
1669,
3056,
1235,
341,
197,
66588,
688,
595,
3721,
11352,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.