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 TestProjectMatcher(t *testing.T) {
files := map[string]bool{
"main.go": true,
"./sdsds.go": true,
"C:/mydsadsa.go": true,
"C:\\something\\go\\anything.go\\ok.go": true,
"22312main.go": true,
"323232.go": true,
"-myfile2.go": true,
"_____.go": true,
".gooutput": !isWindows, // on non-windows the event is .gooutputblablabla, so we check for '.go'
".god": !isWindows,
".goo": !isWindows,
".go.dgo": !isWindows,
"": false,
}
for k, v := range files {
if gotV := DefaultGoMatcher(k); gotV != v {
t.Fatalf("Matcher, expected %#v but got %#v for filename %s", v, gotV, k)
}
}
} | explode_data.jsonl/41673 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 624
} | [
2830,
3393,
7849,
37554,
1155,
353,
8840,
836,
8,
341,
74075,
1669,
2415,
14032,
96436,
515,
197,
197,
1,
3817,
18002,
788,
7561,
830,
345,
197,
197,
95092,
82,
5356,
5356,
18002,
788,
999,
830,
345,
197,
197,
46316,
14375,
2408,
5356... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteAllSnapshotsForSource(t *testing.T) {
t.Parallel()
runner := testenv.NewInProcRunner(t)
e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, runner)
defer e.RunAndExpectSuccess(t, "repo", "disconnect")
e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir1)
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir1)
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir1)
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir2)
e.RunAndExpectSuccess(t, "snapshot", "create", sharedTestDataDir2)
// first source is header + 3 lines, 2nd source is header + 2 lines + separator between them.
e.RunAndVerifyOutputLineCount(t, 8, "snapshot", "list", "-l")
// failure cases
e.RunAndExpectFailure(t, "snapshot", "delete", "--all-snapshots-for-source", "no-such-user@no-such-host:/tmp")
e.RunAndExpectFailure(t, "snapshot", "delete", "--all-snapshots-for-source", testutil.TempDirectory(t))
// dry run has no effect
e.RunAndExpectSuccess(t, "snapshot", "delete", "--all-snapshots-for-source", sharedTestDataDir2)
e.RunAndVerifyOutputLineCount(t, 8, "snapshot", "list", "-l")
// passing --delete actually removes snapshots
e.RunAndExpectSuccess(t, "snapshot", "delete", "--all-snapshots-for-source", sharedTestDataDir2, "--delete")
e.RunAndVerifyOutputLineCount(t, 4, "snapshot", "list", "-l")
e.RunAndExpectSuccess(t, "snapshot", "delete", "--all-snapshots-for-source", sharedTestDataDir1, "--delete")
e.RunAndVerifyOutputLineCount(t, 0, "snapshot", "list", "-l")
} | explode_data.jsonl/61160 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 595
} | [
2830,
3393,
6435,
2403,
61871,
27634,
2461,
3608,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
41736,
1669,
1273,
3160,
7121,
641,
24508,
19486,
1155,
340,
7727,
1669,
1273,
3160,
7121,
3140,
952,
477,
1155,
11,
1273,
316... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPushEventCommit_String(t *testing.T) {
v := PushEventCommit{
Message: String(""),
Author: &CommitAuthor{},
URL: String(""),
Distinct: Bool(false),
SHA: String(""),
ID: String(""),
TreeID: String(""),
Timestamp: &Timestamp{},
Committer: &CommitAuthor{},
}
want := `github.PushEventCommit{Message:"", Author:github.CommitAuthor{}, URL:"", Distinct:false, SHA:"", ID:"", TreeID:"", Timestamp:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Committer:github.CommitAuthor{}}`
if got := v.String(); got != want {
t.Errorf("PushEventCommit.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33276 | {
"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,
16644,
1556,
33441,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
22950,
1556,
33441,
515,
197,
46733,
25,
256,
923,
445,
4461,
197,
197,
7133,
25,
262,
609,
33441,
7133,
38837,
197,
79055,
25,
981,
923,
445,
4461,
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 TestABCIQuery(t *testing.T) {
for i, c := range GetClients() {
// write something
k, v, tx := MakeTxKV()
bres, err := c.BroadcastTxCommit(tx)
require.Nil(t, err, "%d: %+v", i, err)
apph := bres.Height + 1 // this is where the tx will be applied to the state
// wait before querying
client.WaitForHeight(c, apph, nil)
res, err := c.ABCIQuery("/key", k)
qres := res.Response
if assert.Nil(t, err) && assert.True(t, qres.IsOK()) {
assert.EqualValues(t, v, qres.Value)
}
}
} | explode_data.jsonl/48946 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
1867,
11237,
2859,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
272,
1669,
2088,
2126,
47174,
368,
341,
197,
197,
322,
3270,
2494,
198,
197,
16463,
11,
348,
11,
9854,
1669,
7405,
31584,
82707,
741,
197,
2233,
416,
11,
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... | 4 |
func TestTime(t *testing.T) {
now := time.Now()
newNow := time.Unix(now.Unix(), 0).UTC()
fmt.Printf("now: %+v\n", now.Location())
fmt.Printf("nowNow: %+v\n", newNow.Location())
startTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), 0, 0, time.UTC)
fmt.Printf("startTime: %+v\n", startTime.Location())
newStartTime := time.Date(newNow.Year(), newNow.Month(), newNow.Day(), newNow.Hour(), newNow.Minute(), 0, 0, time.UTC)
endTime := newStartTime.Add(time.Minute)
fmt.Println(endTime.Location())
fmt.Printf("now: %+v, start: %+v, newStartTime: %+v, end: %+v, startTS: %d, endTS: %d, diff: %d\n",
now, startTime, newStartTime, endTime, startTime.Unix(), endTime.Unix(), endTime.Unix()-newStartTime.Unix())
ts := now.Unix()
m := (ts / 60) * 60
fmt.Printf("old: %d, anchor: %d\n", ts, m)
} | explode_data.jsonl/77880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 346
} | [
2830,
3393,
1462,
1155,
353,
8840,
836,
8,
1476,
80922,
1669,
882,
13244,
741,
8638,
7039,
1669,
882,
10616,
941,
32263,
10616,
941,
1507,
220,
15,
568,
21183,
741,
11009,
19367,
445,
3328,
25,
68524,
85,
1699,
497,
1431,
4515,
2398,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetCurlCommand_emptyStringBody(t *testing.T) {
t.Skip("broken right now because lib is out of date (master vs 2.2.0)")
req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString(""))
req.Header.Set("Content-Type", "application/json")
libCommand, _ := http2curl.GetCurlCommand(req)
command, _ := GetCurlCommand(req)
if libCommand.String() != command.String() {
t.Errorf("expected library command: %s and command: %s to match", libCommand, command)
}
// Output:
// curl -X 'PUT' -d '' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu'
} | explode_data.jsonl/61002 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
1949,
34,
1085,
4062,
15124,
703,
5444,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
445,
48909,
1290,
1431,
1576,
3051,
374,
700,
315,
2400,
320,
13629,
6165,
220,
17,
13,
17,
13,
15,
19107,
24395,
11,
716,
1669,
1758,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMultipleWithEq(t *testing.T) {
var args struct {
Foo []int
Bar []string
}
err := parse("--foo 1 2 3 --bar=x", &args)
require.NoError(t, err)
assert.Equal(t, []int{1, 2, 3}, args.Foo)
assert.Equal(t, []string{"x"}, args.Bar)
} | explode_data.jsonl/13007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
32089,
2354,
27312,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
12727,
2624,
3056,
396,
198,
197,
197,
3428,
3056,
917,
198,
197,
532,
9859,
1669,
4715,
21549,
7975,
220,
16,
220,
17,
220,
18,
1177,
2257,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConverterRecursiveMapStruct(t *testing.T) {
fieldMap := make(map[string]codegen.FieldMapperEntry)
fieldMap["Five.One"] = codegen.FieldMapperEntry{
QualifiedName: "Three.Two",
Override: true,
}
fieldMap["Five.Two"] = codegen.FieldMapperEntry{
QualifiedName: "Four.One",
Override: true,
}
lines, err := convertTypes(
"Foo", "Bar",
`struct NestedFoo {
1: required string one
2: optional string two
}
struct RecurFoo {
1: required string seven
2: optional RecurFoo eight
}
struct Foo {
1: required NestedFoo three
2: required NestedFoo four
3: optional RecurFoo six
}
struct Bar {
1: required NestedFoo three
2: optional NestedFoo five
3: optional RecurFoo six
}`,
nil,
fieldMap,
)
assert.NoError(t, err)
assertPrettyEqual(t, trim(`
inOriginal := in; _ = inOriginal
outOriginal := out; _ = outOriginal
var convertNestedFooHelper1 func(in *structs.NestedFoo) (out *structs.NestedFoo)
convertNestedFooHelper1 = func(in *structs.NestedFoo) (out *structs.NestedFoo) {
if in != nil {
out = &structs.NestedFoo{}
out.One = string(in.One)
out.Two = (*string)(in.Two)
} else {
out = nil
}
return
}
out.Three = convertNestedFooHelper1(in.Three)
if inOriginal.Three != nil && inOriginal.Three.Two != nil {
if outOriginal.Five == nil {
outOriginal.Five = &structs.NestedFoo{}
}
out.Five.One = *(inOriginal.Three.Two)
}
if inOriginal.Four != nil {
if outOriginal.Five == nil {
outOriginal.Five = &structs.NestedFoo{}
}
out.Five.Two = (*string)(&(inOriginal.Four.One))
}
var convertRecurFooHelper2 func(in *structs.RecurFoo) (out *structs.RecurFoo)
convertRecurFooHelper2 = func(in *structs.RecurFoo) (out *structs.RecurFoo) {
if in != nil {
out = &structs.RecurFoo{}
out.Seven = string(in.Seven)
out.Eight = convertRecurFooHelper2(in.Eight)
} else {
out = nil
}
return
}
out.Six = convertRecurFooHelper2(in.Six)`),
lines)
} | explode_data.jsonl/62100 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 894
} | [
2830,
3393,
14920,
78542,
2227,
9422,
1155,
353,
8840,
836,
8,
341,
39250,
2227,
1669,
1281,
9147,
14032,
60,
95859,
17087,
10989,
5874,
340,
39250,
2227,
1183,
37020,
37067,
1341,
284,
2038,
4370,
17087,
10989,
5874,
515,
197,
16995,
928... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSliceAllMatch(t *testing.T) {
tests := []struct {
name string
input []int
predicate func(v int) bool
want bool
}{
{
name: "case",
input: []int{1, 2},
predicate: func(v int) bool { return v < 3 },
want: true,
},
{
name: "case",
input: []int{1, 2},
predicate: func(v int) bool { return v > 3 },
want: false,
},
{
name: "case",
input: newArrayN(100, 200),
predicate: func(v int) bool { return v > 100 },
want: false,
},
{
name: "case",
input: newArrayN(100, 200),
predicate: func(v int) bool { return v < 200 },
want: true,
},
{
name: "empty",
input: []int{},
predicate: func(v int) bool { return v > 3 },
want: true,
},
{
name: "nil",
input: nil,
predicate: func(v int) bool { return v > 3 },
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewSlice(tt.input).AllMatch(tt.predicate)
assert.Equal(t, tt.want, got)
got = NewSlice(tt.input).Parallel(2).AllMatch(tt.predicate)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/55740 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 613
} | [
2830,
3393,
33236,
2403,
8331,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
22427,
257,
3056,
396,
198,
197,
3223,
16874,
2915,
3747,
526,
8,
1807,
198,
197,
50780,
414,
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... | 1 |
func TestDeletePolicyObjectsWhileComponentInstancesAreStillRunningFails(t *testing.T) {
// Start with empty actual state & empty policy
empty := newTestData(t, builder.NewPolicyBuilder())
actualState := empty.resolution()
assert.Equal(t, 0, len(empty.resolution().ComponentInstanceMap), "Initial state should not have any components")
assert.Equal(t, 0, len(actualState.ComponentInstanceMap), "Actual state should not have any components at this point")
// Generate policy
generated := newTestData(t, makePolicyBuilder())
assert.Equal(t, 2, len(generated.resolution().ComponentInstanceMap), "Desired state should not be empty")
// Run apply to update actual state
applier := NewEngineApply(
generated.policy(),
generated.resolution(),
actual.NewNoOpActionStateUpdater(actualState),
generated.external(),
mockRegistry(true, false),
diff.NewPolicyResolutionDiff(generated.resolution(), actualState).ActionPlan,
event.NewLog(logrus.DebugLevel, "test-apply"),
action.NewApplyResultUpdaterImpl(),
)
// Check that policy apply finished with expected results
actualState = applyAndCheck(t, applier, action.ApplyResult{Success: 4, Failed: 0, Skipped: 0})
assert.Equal(t, 2, len(actualState.ComponentInstanceMap), "Actual state have components instances transferred to it")
// Reset policy back to empty
reset := newTestData(t, builder.NewPolicyBuilder())
// Run apply to update actual state
applierNext := NewEngineApply(
reset.policy(),
reset.resolution(),
actual.NewNoOpActionStateUpdater(actualState),
generated.external(),
mockRegistry(true, false),
diff.NewPolicyResolutionDiff(reset.resolution(), actualState).ActionPlan,
event.NewLog(logrus.DebugLevel, "test-apply"),
action.NewApplyResultUpdaterImpl(),
)
// detach successful, deletion fails
actualState = applyAndCheck(t, applierNext, action.ApplyResult{Success: 2, Failed: 2, Skipped: 0})
assert.Equal(t, 2, len(actualState.ComponentInstanceMap), "Actual state should still have component instances after actions failing")
} | explode_data.jsonl/74191 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 595
} | [
2830,
3393,
6435,
13825,
11543,
7983,
2189,
42725,
11526,
23322,
18990,
37,
6209,
1155,
353,
8840,
836,
8,
341,
197,
322,
5145,
448,
4287,
5042,
1584,
609,
4287,
4842,
198,
197,
3194,
1669,
501,
83920,
1155,
11,
7363,
7121,
13825,
3297,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExportProtocolConformation_metricsInFirstMessage(t *testing.T) {
t.Skipf("Currently disabled, this test is flaky on Windows. Enable this test when the following are fixed:\nIssue %s\n",
"https://github.com/census-instrumentation/opencensus-service/issues/225",
)
metricSink := newMetricAppender()
_, port, doneFn := ocReceiverOnGRPCServer(t, metricSink)
defer doneFn()
metricsClient, metricsClientDoneFn, err := makeMetricsServiceClient(port)
require.NoError(t, err, "Failed to create the gRPC MetricsService_ExportClient: %v", err)
defer metricsClientDoneFn()
mLi := []*metricspb.Metric{makeMetric(10), makeMetric(11)}
ni := &commonpb.Node{
Identifier: &commonpb.ProcessIdentifier{Pid: 1},
LibraryInfo: &commonpb.LibraryInfo{Language: commonpb.LibraryInfo_JAVA},
}
err = metricsClient.Send(&agentmetricspb.ExportMetricsServiceRequest{Node: ni, Metrics: mLi})
require.NoError(t, err, "Failed to send the first message: %v", err)
// Give it time to be sent over the wire, then exported.
<-time.After(100 * time.Millisecond)
// Examination time!
resultsMapping := make(map[string][]*metricspb.Metric)
metricSink.forEachEntry(func(node *commonpb.Node, metrics []*metricspb.Metric) {
resultsMapping[nodeToKey(node)] = metrics
})
if g, w := len(resultsMapping), 1; g != w {
t.Errorf("Results mapping: Got len(keys) %d Want %d", g, w)
}
// Check for the keys
wantLengths := map[string]int{
nodeToKey(ni): 2,
}
for key, wantLength := range wantLengths {
gotLength := len(resultsMapping[key])
if gotLength != wantLength {
t.Errorf("Exported metrics:: Key: %s\nGot length %d\nWant length %d", key, gotLength, wantLength)
}
}
// And finally ensure that the protos' serializations are equivalent to the expected
wantContents := map[string][]*metricspb.Metric{
nodeToKey(ni): mLi,
}
gotBlob, _ := json.Marshal(resultsMapping)
wantBlob, _ := json.Marshal(wantContents)
if !bytes.Equal(gotBlob, wantBlob) {
t.Errorf("Unequal serialization results\nGot:\n\t%s\nWant:\n\t%s\n", gotBlob, wantBlob)
}
} | explode_data.jsonl/1889 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 755
} | [
2830,
3393,
16894,
20689,
1109,
1627,
37686,
641,
5338,
2052,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
69,
445,
33714,
8386,
11,
419,
1273,
374,
1320,
28100,
389,
5515,
13,
18567,
419,
1273,
979,
279,
2701,
525,
8356,
7190,
77,
4200... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSyncPodsUnhealthy(t *testing.T) {
const (
unhealthyContainerID = "1234"
infraContainerID = "9876"
)
dm, fakeDocker := newTestDockerManager()
pod := makePod("foo", &api.PodSpec{
Containers: []api.Container{{Name: "unhealthy"}},
})
fakeDocker.SetFakeRunningContainers([]*FakeContainer{
{
ID: unhealthyContainerID,
Name: "/k8s_unhealthy_foo_new_12345678_42",
},
{
ID: infraContainerID,
Name: "/k8s_POD." + strconv.FormatUint(generatePodInfraContainerHash(pod), 16) + "_foo_new_12345678_42",
}})
dm.livenessManager.Set(kubecontainer.DockerID(unhealthyContainerID).ContainerID(), proberesults.Failure, pod)
runSyncPod(t, dm, fakeDocker, pod, nil, false)
verifyCalls(t, fakeDocker, []string{
// Kill the unhealthy container.
"stop",
// Restart the unhealthy container.
"create", "start", "inspect_container",
})
if err := fakeDocker.AssertStopped([]string{unhealthyContainerID}); err != nil {
t.Errorf("%v", err)
}
} | explode_data.jsonl/31167 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
12154,
23527,
82,
1806,
37028,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
20479,
37028,
4502,
915,
284,
330,
16,
17,
18,
19,
698,
197,
197,
92317,
4502,
915,
257,
284,
330,
24,
23,
22,
21,
698,
197,
340,
2698,
76,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetCellStyleFont(t *testing.T) {
f, err := prepareTestBook1()
if !assert.NoError(t, err) {
t.FailNow()
}
var style int
style, err = f.NewStyle(`{"font":{"bold":true,"italic":true,"family":"Berlin Sans FB Demi","size":36,"color":"#777777","underline":"single"}}`)
if !assert.NoError(t, err) {
t.FailNow()
}
assert.NoError(t, f.SetCellStyle("Sheet2", "A1", "A1", style))
style, err = f.NewStyle(`{"font":{"italic":true,"underline":"double"}}`)
if !assert.NoError(t, err) {
t.FailNow()
}
assert.NoError(t, f.SetCellStyle("Sheet2", "A2", "A2", style))
style, err = f.NewStyle(`{"font":{"bold":true}}`)
if !assert.NoError(t, err) {
t.FailNow()
}
assert.NoError(t, f.SetCellStyle("Sheet2", "A3", "A3", style))
style, err = f.NewStyle(`{"font":{"bold":true,"family":"","size":0,"color":"","underline":""}}`)
if !assert.NoError(t, err) {
t.FailNow()
}
assert.NoError(t, f.SetCellStyle("Sheet2", "A4", "A4", style))
style, err = f.NewStyle(`{"font":{"color":"#777777"}}`)
if !assert.NoError(t, err) {
t.FailNow()
}
assert.NoError(t, f.SetCellStyle("Sheet2", "A5", "A5", style))
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetCellStyleFont.xlsx")))
} | explode_data.jsonl/36975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 520
} | [
2830,
3393,
1649,
15171,
5447,
1155,
353,
8840,
836,
8,
341,
1166,
11,
1848,
1669,
10549,
2271,
7134,
16,
741,
743,
753,
2207,
35699,
1155,
11,
1848,
8,
341,
197,
3244,
57243,
7039,
741,
197,
630,
2405,
1707,
526,
198,
42551,
11,
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... | 7 |
func TestMin(t *testing.T) {
t.Parallel()
testCases := []struct {
slice []float64
val float64
}{
{
slice: []float64{1, 2, 3, 4},
val: 1,
},
{
slice: []float64{-1, -2, -3, -4},
val: -4,
},
{
slice: []float64{math.Inf(-1), 2, 3, math.Inf(1)},
val: math.Inf(-1),
},
}
r := reducer.Min()
for _, c := range testCases {
val, err := r.Reduce(c.slice)
require.NoError(t, err)
require.Equal(t, c.val, val)
}
} | explode_data.jsonl/4719 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
6217,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
37302,
1669,
3056,
1235,
341,
197,
1903,
4754,
3056,
3649,
21,
19,
198,
197,
19302,
256,
2224,
21,
19,
198,
197,
59403,
197,
197,
515,
298,
1903,
4754,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcile_DependencyValidationsImmediatelyFailPipelineRun(t *testing.T) {
names.TestingSeed()
ctx := context.Background()
cfg := config.NewStore(logtesting.TestLogger(t))
ctx = cfg.ToContext(ctx)
prs := []*v1beta1.PipelineRun{
parse.MustParsePipelineRun(t, `
metadata:
name: pipelinerun-param-invalid-result-variable
namespace: foo
spec:
pipelineSpec:
tasks:
- name: pt0
taskSpec:
steps:
- image: foo:latest
- name: pt1
params:
- name: p
value: $(tasks.pt0.results.r1)
taskSpec:
params:
- name: p
steps:
- image: foo:latest
serviceAccountName: test-sa
`),
parse.MustParsePipelineRun(t, `
metadata:
name: pipelinerun-pipeline-result-invalid-result-variable
namespace: foo
spec:
pipelineSpec:
results:
- name: pr
value: $(tasks.pt0.results.r)
tasks:
- name: pt0
taskSpec:
steps:
- image: foo:latest
- name: pt1
taskSpec:
steps:
- image: foo:latest
serviceAccountName: test-sa
`),
parse.MustParsePipelineRun(t, `
metadata:
name: pipelinerun-with-optional-workspace-validation
namespace: foo
spec:
pipelineSpec:
tasks:
- name: unit-test-1
taskSpec:
steps:
- image: foo:latest
workspaces:
- name: ws
workspaces:
- name: ws
workspace: optional-workspace
workspaces:
- name: optional-workspace
optional: true
serviceAccountName: test-sa
`),
}
d := test.Data{
PipelineRuns: prs,
ServiceAccounts: []*corev1.ServiceAccount{{
ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.ServiceAccountName, Namespace: "foo"},
}},
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
run1, _ := prt.reconcileRun("foo", "pipelinerun-param-invalid-result-variable", nil, true)
run2, _ := prt.reconcileRun("foo", "pipelinerun-pipeline-result-invalid-result-variable", nil, true)
run3, _ := prt.reconcileRun("foo", "pipelinerun-with-optional-workspace-validation", nil, true)
cond1 := run1.Status.GetCondition(apis.ConditionSucceeded)
cond2 := run2.Status.GetCondition(apis.ConditionSucceeded)
cond3 := run3.Status.GetCondition(apis.ConditionSucceeded)
for _, c := range []*apis.Condition{cond1, cond2, cond3} {
if c.Status != corev1.ConditionFalse {
t.Errorf("expected Succeeded/False condition but saw: %v", c)
}
}
if cond1.Reason != ReasonInvalidTaskResultReference {
t.Errorf("expected invalid task reference condition but saw: %v", cond1)
}
if cond2.Reason != ReasonInvalidTaskResultReference {
t.Errorf("expected invalid task reference condition but saw: %v", cond2)
}
if cond3.Reason != ReasonRequiredWorkspaceMarkedOptional {
t.Errorf("expected optional workspace not supported condition but saw: %v", cond3)
}
} | explode_data.jsonl/27333 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1170
} | [
2830,
3393,
693,
40446,
457,
1557,
40529,
4088,
804,
95693,
19524,
34656,
6727,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
2822,
20985,
1669,
2266,
19047,
741,
50286,
1669,
2193,
7121,
6093,
12531,
8840,
8787,
7395,
1155,
1171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestContextRenderHTML2(t *testing.T) {
w := httptest.NewRecorder()
c, router := CreateTestContext(w)
// print debug warning log when Engine.trees > 0
router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})
assert.Len(t, router.trees, 1)
templ := template.Must(template.New("t").Parse(`Hello {{.name}}`))
re := captureOutput(t, func() {
SetMode(DebugMode)
router.SetHTMLTemplate(templ)
SetMode(TestMode)
})
assert.Equal(t, "[GIN-debug] [WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called\nat initialization. ie. before any route is registered or the router is listening in a socket:\n\n\trouter := gin.Default()\n\trouter.SetHTMLTemplate(template) // << good place\n\n", re)
c.HTML(http.StatusCreated, "t", H{"name": "alexandernyquist"})
assert.Equal(t, http.StatusCreated, w.Code)
assert.Equal(t, "Hello alexandernyquist", w.Body.String())
assert.Equal(t, "text/html; charset=utf-8", w.Header().Get("Content-Type"))
} | explode_data.jsonl/26782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 355
} | [
2830,
3393,
1972,
6750,
5835,
17,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
54320,
70334,
7121,
47023,
741,
1444,
11,
9273,
1669,
4230,
2271,
1972,
3622,
692,
197,
322,
1173,
7390,
9958,
1487,
979,
8200,
734,
7858,
861,
220,
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... | 1 |
func TestProvider_Derive(t *testing.T) {
cases := []struct {
name string
data []byte
expected string
}{
{
name: "text variation 1",
data: []byte("foo"),
expected: "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
},
{
name: "text variation 2",
data: []byte("bar"),
expected: "fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9",
},
{
name: "text variation 3",
data: []byte("baz"),
expected: "baa5a0964d3320fbc0c6a922140453c8513ea24ab8fd0577034804a967248096",
},
{
name: "byte sequence",
data: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},
expected: "9a89c68c4c5e28b8c4a5567673d462fff515db46116f9900624d09c474f593fb",
},
}
for i := range cases {
t.Run(
cases[i].name,
func(t *testing.T) {
sut := newSUT()
result := sut.Derive(cases[i].data)
assert.Equal(t, cases[i].expected, result)
},
)
}
} | explode_data.jsonl/59597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 506
} | [
2830,
3393,
5179,
1557,
261,
533,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
8924,
257,
3056,
3782,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
257,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_isInterleave(t *testing.T) {
assert := assert.New(t)
assert.False(isInterleave("a", "b", "abc"))
assert.True(isInterleave("aabcc", "dbbca", "aadbbcbcac"))
assert.False(isInterleave("aabcc", "dbbca", "aadbbbaccc"))
assert.True(isInterleave("", "", ""))
assert.True(isInterleave("a", "", "a"))
assert.True(isInterleave("", "a", "a"))
assert.True(isInterleave("a", "b", "ab"))
assert.True(isInterleave("b", "a", "ab"))
} | explode_data.jsonl/43221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
6892,
3306,
21510,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
6948,
50757,
9623,
3306,
21510,
445,
64,
497,
330,
65,
497,
330,
13683,
28075,
6948,
32443,
9623,
3306,
21510,
445,
88607,
638,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInsert(t *testing.T) {
s := NewScope()
items := []ScopeItem{
{100, 400}, {600, 200}, {50, 40}, {10, 40}, {550, 20}, {570, 30}, {1000, 300}, {1300, 200}, {900, 100},
}
itemsShould := []ScopeItem{
{10, 80}, {100, 400}, {550, 250}, {900, 600},
}
size := uint64(0)
for _, v := range items {
s.Insert(v.Address, v.Size)
size += v.Size
}
should(t, s, itemsShould, size)
} | explode_data.jsonl/17762 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
13780,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1532,
10803,
741,
46413,
1669,
3056,
10803,
1234,
515,
197,
197,
90,
16,
15,
15,
11,
220,
19,
15,
15,
2137,
314,
21,
15,
15,
11,
220,
17,
15,
15,
2137,
314,
20,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestValidateLimitRangeForLocalStorage(t *testing.T) {
testCases := []struct {
name string
spec core.LimitRangeSpec
}{
{
name: "all-fields-valid",
spec: core.LimitRangeSpec{
Limits: []core.LimitRangeItem{
{
Type: core.LimitTypePod,
Max: getLocalStorageResourceList("10000Mi"),
Min: getLocalStorageResourceList("100Mi"),
MaxLimitRequestRatio: getLocalStorageResourceList(""),
},
{
Type: core.LimitTypeContainer,
Max: getLocalStorageResourceList("10000Mi"),
Min: getLocalStorageResourceList("100Mi"),
Default: getLocalStorageResourceList("500Mi"),
DefaultRequest: getLocalStorageResourceList("200Mi"),
MaxLimitRequestRatio: getLocalStorageResourceList(""),
},
},
},
},
}
// Enable feature LocalStorageCapacityIsolation
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.LocalStorageCapacityIsolation, true)()
for _, testCase := range testCases {
limitRange := &core.LimitRange{ObjectMeta: metav1.ObjectMeta{Name: testCase.name, Namespace: "foo"}, Spec: testCase.spec}
if errs := ValidateLimitRange(limitRange); len(errs) != 0 {
t.Errorf("Case %v, unexpected error: %v", testCase.name, errs)
}
}
// Disable feature LocalStorageCapacityIsolation
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.LocalStorageCapacityIsolation, false)()
for _, testCase := range testCases {
limitRange := &core.LimitRange{ObjectMeta: metav1.ObjectMeta{Name: testCase.name, Namespace: "foo"}, Spec: testCase.spec}
if errs := ValidateLimitRange(limitRange); len(errs) == 0 {
t.Errorf("Case %v, expected feature gate unable error but actually no error", testCase.name)
}
}
} | explode_data.jsonl/1043 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 751
} | [
2830,
3393,
17926,
16527,
6046,
2461,
90464,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
98100,
6200,
1214,
2353,
6046,
8327,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
541,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseOrderTime(t *testing.T) {
expected := int64(1534794360)
actual := parseOrderTime("2018-08-20 19:20:46").Unix()
if expected != actual {
t.Errorf("Test Failed. TestParseOrderTime expected: %d, got %d", expected, actual)
}
} | explode_data.jsonl/14544 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
14463,
4431,
1462,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
526,
21,
19,
7,
16,
20,
18,
19,
22,
24,
19,
18,
21,
15,
340,
88814,
1669,
4715,
4431,
1462,
445,
17,
15,
16,
23,
12,
15,
23,
12,
17,
15,
220,
16,
24,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReader(t *testing.T) {
ctx := context.Background()
flags.Set(t, "auth.enable_anonymous_usage", "true")
te := getTestEnv(t, emptyUserMap)
ctx, err := prefix.AttachUserPrefixToContext(ctx, te)
if err != nil {
t.Errorf("error attaching user prefix: %v", err)
}
peer := fmt.Sprintf("localhost:%d", app.FreePort(t))
c := cacheproxy.NewCacheProxy(te, te.GetCache(), peer)
if err := c.StartListening(); err != nil {
t.Fatalf("Error setting up cacheproxy: %s", err)
}
waitUntilServerIsAlive(peer)
randomSrc := &randomDataMaker{rand.NewSource(time.Now().Unix())}
testSizes := []int64{
1, 10, 100, 1000, 10000, 1000000, 10000000,
}
for _, testSize := range testSizes {
remoteInstanceName := fmt.Sprintf("prefix/%d", testSize)
isolation := &dcpb.Isolation{CacheType: dcpb.Isolation_CAS_CACHE, RemoteInstanceName: remoteInstanceName}
// Read some random bytes.
buf := new(bytes.Buffer)
io.CopyN(buf, randomSrc, testSize)
readSeeker := bytes.NewReader(buf.Bytes())
// Compute a digest for the random bytes.
d, err := digest.Compute(readSeeker)
if err != nil {
t.Fatal(err)
}
readSeeker.Seek(0, 0)
// Set the random bytes in the cache (with a prefix)
cache, err := te.GetCache().WithIsolation(ctx, interfaces.CASCacheType, remoteInstanceName)
require.NoError(t, err)
err = cache.Set(ctx, d, buf.Bytes())
if err != nil {
t.Fatal(err)
}
// Remote-read the random bytes back.
r, err := c.RemoteReader(ctx, peer, isolation, d, 0)
if err != nil {
t.Fatal(err)
}
d2 := testdigest.ReadDigestAndClose(t, r)
if d.GetHash() != d2.GetHash() {
t.Fatalf("Digest uploaded %q != %q downloaded", d.GetHash(), d2.GetHash())
}
}
} | explode_data.jsonl/69641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 667
} | [
2830,
3393,
5062,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
59516,
4202,
1155,
11,
330,
3242,
28697,
12008,
9757,
31507,
497,
330,
1866,
1138,
197,
665,
1669,
633,
2271,
14359,
1155,
11,
4287,
1474,
2227,
692,
20985,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestValidateMatchFails(t *testing.T) {
tests := []struct {
match v1.Match
upstreamNames sets.String
msg string
}{
{
match: v1.Match{
Conditions: []v1.Condition{},
Action: &v1.Action{
Pass: "test",
},
},
upstreamNames: map[string]sets.Empty{
"test": {},
},
msg: "invalid number of conditions",
},
{
match: v1.Match{
Conditions: []v1.Condition{
{
Cookie: "version",
Value: `v1"`,
},
},
Action: &v1.Action{
Pass: "test",
},
},
upstreamNames: map[string]sets.Empty{
"test": {},
},
msg: "invalid condition",
},
{
match: v1.Match{
Conditions: []v1.Condition{
{
Cookie: "version",
Value: "v1",
},
},
Action: &v1.Action{},
},
upstreamNames: map[string]sets.Empty{},
msg: "invalid action",
},
{
match: v1.Match{
Conditions: []v1.Condition{
{
Cookie: "version",
Value: "v1",
},
},
Action: &v1.Action{
Pass: "test-1",
},
Splits: []v1.Split{
{
Weight: 90,
Action: &v1.Action{
Pass: "test-1",
},
},
{
Weight: 10,
Action: &v1.Action{
Pass: "test-2",
},
},
},
},
upstreamNames: map[string]sets.Empty{
"test-1": {},
"test-2": {},
},
msg: "both splits and action are set",
},
}
for _, test := range tests {
allErrs := validateMatch(test.match, field.NewPath("match"), test.upstreamNames, "")
if len(allErrs) == 0 {
t.Errorf("validateMatch() returned no errors for invalid input for the case of %s", test.msg)
}
}
} | explode_data.jsonl/65852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 890
} | [
2830,
3393,
17926,
8331,
37,
6209,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
47706,
260,
348,
16,
36062,
198,
197,
59810,
4027,
7980,
7289,
6431,
198,
197,
21169,
1843,
914,
198,
197,
59403,
197,
197,
515,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestEOSIsAddressFormatValid(t *testing.T) {
validator := &EOS{}
var validCases = []string{
"eosnationftw",
"atticlabeosb",
"helloeoscnbp",
"eosasia11111",
"zbeosbp11111",
"eoshuobipool",
"big.one",
"okcapitalbp1",
}
for _, addr := range validCases {
assert.True(t, validator.IsAddressFormatValid(addr, Mainnet), addr)
}
var invalidCases = []string{
"1YURbVuocZZZPi8LPU6GfAcKShYY7hLXbrG75v9zBXbS2zaqaHfSmGJvNEZwU3oETNZdPNxqLwR5C",
"EOS4xXY8vZU1VGiggW5Qn7AhFcp5ti8vnWe9TVt8nUy1sUdFrLVUC",
"eosnationft0",
"Atticlabeosb",
"eosasi!11111 ",
"hello.1000",
"0001hello",
"",
}
for _, addr := range invalidCases {
assert.False(t, validator.IsAddressFormatValid(addr, Mainnet), addr)
}
} | explode_data.jsonl/59997 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 374
} | [
2830,
3393,
55940,
3872,
4286,
4061,
4088,
1155,
353,
8840,
836,
8,
341,
197,
16112,
1669,
609,
55940,
31483,
2405,
2697,
37302,
284,
3056,
917,
515,
197,
197,
1,
84399,
98795,
723,
86,
756,
197,
197,
1,
1587,
87367,
8229,
436,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestListInvalidGroupVersionKind(t *testing.T) {
g := NewWithT(t)
clientSet := kube.NewFakeClient()
store := memory.NewController(memory.Make(collections.All))
controller := NewController(clientSet, store, controller2.Options{})
typ := config.GroupVersionKind{Kind: "wrong-kind"}
c, err := controller.List(typ, "ns1")
g.Expect(c).To(HaveLen(0))
g.Expect(err).To(HaveOccurred())
} | explode_data.jsonl/61229 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
852,
7928,
2808,
5637,
10629,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
340,
25291,
1649,
1669,
80958,
7121,
52317,
2959,
741,
57279,
1669,
4938,
7121,
2051,
63230,
50133,
1337,
3107,
16764,
1171,
61615,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetFreePort(t *testing.T) {
t.Parallel()
port, err := GetFreePort()
if err != nil {
t.Error(err)
}
if port == 0 {
t.Error("port is 0")
}
ip, err := LocalIP()
if err != nil {
t.Error(err)
}
// Try to listen on the port
l, err := net.Listen("tcp", ip.String()+":"+strconv.Itoa(port))
if err != nil {
t.Error(err)
}
defer l.Close()
} | explode_data.jsonl/58670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
1949,
10940,
7084,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
52257,
11,
1848,
1669,
2126,
10940,
7084,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
532,
743,
2635,
621,
220,
15,
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... | 5 |
func TestPreparedCommand_RunE_Fail(t *testing.T) {
stderr := shx.RecordStderr()
defer stderr.Release()
err := shx.RunE("go", "run")
gotStderr := stderr.Output()
if err == nil {
t.Fatal("expected the shx.Command to fail")
}
wantStderr := "no go files listed"
assert.Contains(t, gotStderr, wantStderr)
} | explode_data.jsonl/57096 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
4703,
7212,
4062,
84158,
36,
1400,
604,
1155,
353,
8840,
836,
8,
341,
6736,
615,
1669,
557,
87,
49959,
22748,
615,
741,
16867,
26436,
58693,
2822,
9859,
1669,
557,
87,
16708,
36,
445,
3346,
497,
330,
6108,
1138,
3174,
354,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBulkExists(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
t.Errorf("unexpected method. want=%s have=%s", "GET", r.Method)
}
if r.URL.Path != "/exists" {
t.Errorf("unexpected method. want=%s have=%s", "/exists", r.URL.Path)
}
if diff := cmp.Diff("1,2,3,4,5", r.URL.Query().Get("ids")); diff != "" {
t.Errorf("unexpected ids (-want +got):\n%s", diff)
}
_, _ = w.Write([]byte(`{"1": false, "2": true, "3": false, "4": true, "5": true}`))
}))
defer ts.Close()
client := &bundleManagerClientImpl{bundleManagerURL: ts.URL}
existsMap, err := client.Exists(context.Background(), []int{1, 2, 3, 4, 5})
if err != nil {
t.Fatalf("unexpected error checking bulk exists: %s", err)
}
expected := map[int]bool{
1: false,
2: true,
3: false,
4: true,
5: true,
}
if diff := cmp.Diff(expected, existsMap); diff != "" {
t.Errorf("unexpected exists map (-want +got):\n%s", diff)
}
} | explode_data.jsonl/21438 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 437
} | [
2830,
3393,
88194,
15575,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
330,
3806,
1,
341,
298,
3244,
13080,
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... | 4 |
func TestConstructPermanentFailureAnswer(t *testing.T) {
msg := diam.NewMessage(diam.AuthenticationInformation, diam.RequestFlag, diam.TGPP_S6A_APP_ID, 1, 2, dict.Default)
serverCfg := &mconfig.DiamServerConfig{
DestHost: "magma_host",
DestRealm: "magma_realm",
}
response := hss.ConstructFailureAnswer(msg, datatype.UTF8String("magma"), serverCfg, 1000)
assert.Equal(t, msg.Header.CommandCode, response.Header.CommandCode)
assert.Equal(t, uint8(0), response.Header.CommandFlags)
assert.Equal(t, uint32(diam.TGPP_S6A_APP_ID), response.Header.ApplicationID)
assert.Equal(t, uint32(1), response.Header.HopByHopID)
assert.Equal(t, uint32(2), response.Header.EndToEndID)
_, err := response.FindAVP(avp.ExperimentalResult, dict.UndefinedVendorID)
assert.NoError(t, err)
var aia definitions.AIA
err = response.Unmarshal(&aia)
assert.NoError(t, err)
assert.Equal(t, uint32(1000), aia.ExperimentalResult.ExperimentalResultCode)
assert.Equal(t, datatype.DiameterIdentity("magma_host"), aia.OriginHost)
assert.Equal(t, datatype.DiameterIdentity("magma_realm"), aia.OriginRealm)
assert.Equal(t, "magma", aia.SessionID)
} | explode_data.jsonl/19999 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 434
} | [
2830,
3393,
28468,
78793,
17507,
16141,
1155,
353,
8840,
836,
8,
341,
21169,
1669,
12757,
7121,
2052,
1500,
4932,
40673,
14873,
11,
12757,
9659,
12135,
11,
12757,
836,
38,
4406,
1098,
21,
32,
16410,
3450,
11,
220,
16,
11,
220,
17,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetUserWithAcceptedTermsOfServiceWithAdminUser(t *testing.T) {
th := Setup(t).InitBasic()
th.LoginSystemAdmin()
defer th.TearDown()
user := th.BasicUser
tos, _ := th.App.CreateTermsOfService("Dummy TOS", user.Id)
ruser, _, err := th.SystemAdminClient.GetUser(user.Id, "")
require.NoError(t, err)
CheckUserSanitization(t, ruser)
require.Equal(t, user.Email, ruser.Email)
assert.Empty(t, ruser.TermsOfServiceId)
th.App.SaveUserTermsOfService(user.Id, tos.Id, true)
ruser, _, err = th.SystemAdminClient.GetUser(user.Id, "")
require.NoError(t, err)
CheckUserSanitization(t, ruser)
require.Equal(t, user.Email, ruser.Email)
// admin can view anyone's TOS details
assert.Equal(t, tos.Id, ruser.TermsOfServiceId)
} | explode_data.jsonl/47489 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
1949,
1474,
2354,
65906,
43128,
2124,
1860,
2354,
7210,
1474,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
70479,
32499,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
2822,
19060,
1669,
270,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckpoint(t *testing.T) {
resourceName1 := "domain1.com/resource1"
resourceName2 := "domain2.com/resource2"
resourceName3 := "domain2.com/resource3"
as := assert.New(t)
tmpDir, err := ioutil.TempDir("", "checkpoint")
as.Nil(err)
defer os.RemoveAll(tmpDir)
ckm, err := checkpointmanager.NewCheckpointManager(tmpDir)
as.Nil(err)
testManager := &ManagerImpl{
endpoints: make(map[string]endpointInfo),
healthyDevices: make(map[string]sets.String),
unhealthyDevices: make(map[string]sets.String),
allocatedDevices: make(map[string]sets.String),
podDevices: newPodDevices(),
checkpointManager: ckm,
}
testManager.podDevices.insert("pod1", "con1", resourceName1,
constructDevices([]string{"dev1", "dev2"}),
constructAllocResp(map[string]string{"/dev/r1dev1": "/dev/r1dev1", "/dev/r1dev2": "/dev/r1dev2"},
map[string]string{"/home/r1lib1": "/usr/r1lib1"}, map[string]string{}))
testManager.podDevices.insert("pod1", "con1", resourceName2,
constructDevices([]string{"dev1", "dev2"}),
constructAllocResp(map[string]string{"/dev/r2dev1": "/dev/r2dev1", "/dev/r2dev2": "/dev/r2dev2"},
map[string]string{"/home/r2lib1": "/usr/r2lib1"},
map[string]string{"r2devices": "dev1 dev2"}))
testManager.podDevices.insert("pod1", "con2", resourceName1,
constructDevices([]string{"dev3"}),
constructAllocResp(map[string]string{"/dev/r1dev3": "/dev/r1dev3"},
map[string]string{"/home/r1lib1": "/usr/r1lib1"}, map[string]string{}))
testManager.podDevices.insert("pod2", "con1", resourceName1,
constructDevices([]string{"dev4"}),
constructAllocResp(map[string]string{"/dev/r1dev4": "/dev/r1dev4"},
map[string]string{"/home/r1lib1": "/usr/r1lib1"}, map[string]string{}))
testManager.podDevices.insert("pod3", "con3", resourceName3,
checkpoint.DevicesPerNUMA{nodeWithoutTopology: []string{"dev5"}},
constructAllocResp(map[string]string{"/dev/r1dev5": "/dev/r1dev5"},
map[string]string{"/home/r1lib1": "/usr/r1lib1"}, map[string]string{}))
testManager.healthyDevices[resourceName1] = sets.NewString()
testManager.healthyDevices[resourceName1].Insert("dev1")
testManager.healthyDevices[resourceName1].Insert("dev2")
testManager.healthyDevices[resourceName1].Insert("dev3")
testManager.healthyDevices[resourceName1].Insert("dev4")
testManager.healthyDevices[resourceName1].Insert("dev5")
testManager.healthyDevices[resourceName2] = sets.NewString()
testManager.healthyDevices[resourceName2].Insert("dev1")
testManager.healthyDevices[resourceName2].Insert("dev2")
testManager.healthyDevices[resourceName3] = sets.NewString()
testManager.healthyDevices[resourceName3].Insert("dev5")
expectedPodDevices := testManager.podDevices
expectedAllocatedDevices := testManager.podDevices.devices()
expectedAllDevices := testManager.healthyDevices
err = testManager.writeCheckpoint()
as.Nil(err)
testManager.podDevices = newPodDevices()
err = testManager.readCheckpoint()
as.Nil(err)
as.Equal(expectedPodDevices.size(), testManager.podDevices.size())
for podUID, containerDevices := range expectedPodDevices.devs {
for conName, resources := range containerDevices {
for resource := range resources {
expDevices := expectedPodDevices.containerDevices(podUID, conName, resource)
testDevices := testManager.podDevices.containerDevices(podUID, conName, resource)
as.True(reflect.DeepEqual(expDevices, testDevices))
opts1 := expectedPodDevices.deviceRunContainerOptions(podUID, conName)
opts2 := testManager.podDevices.deviceRunContainerOptions(podUID, conName)
as.Equal(len(opts1.Envs), len(opts2.Envs))
as.Equal(len(opts1.Mounts), len(opts2.Mounts))
as.Equal(len(opts1.Devices), len(opts2.Devices))
}
}
}
as.True(reflect.DeepEqual(expectedAllocatedDevices, testManager.allocatedDevices))
as.True(reflect.DeepEqual(expectedAllDevices, testManager.healthyDevices))
} | explode_data.jsonl/82146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1462
} | [
2830,
3393,
92688,
1155,
353,
8840,
836,
8,
341,
50346,
675,
16,
1669,
330,
12204,
16,
905,
53100,
16,
698,
50346,
675,
17,
1669,
330,
12204,
17,
905,
53100,
17,
698,
50346,
675,
18,
1669,
330,
12204,
17,
905,
53100,
18,
698,
60451,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_IsExit(t *testing.T) {
commands := []string{"GET"}
cmd, _ := NewCommand(commands)
if cmd.IsExit() {
t.Errorf("unwanted IsExit(), wanted false")
}
commands = []string{"exit"}
cmd, _ = NewCommand(commands)
if !cmd.IsExit() {
t.Errorf("unwanted IsExit(), wanted true")
}
} | explode_data.jsonl/79582 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
31879,
15339,
1155,
353,
8840,
836,
8,
341,
197,
24270,
1669,
3056,
917,
4913,
3806,
16707,
25920,
11,
716,
1669,
1532,
4062,
71192,
692,
743,
5439,
4506,
15339,
368,
341,
197,
3244,
13080,
445,
359,
86592,
2160,
15339,
1507... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestErrorRunningInvalidJs(t *testing.T) {
t.Parallel()
ctx := NewIsolate().NewContext()
res, err := ctx.Eval(`kajsdfa91j23e`, "junk.js")
if err == nil {
t.Errorf("Expected error, but got result: %v", res)
}
} | explode_data.jsonl/81542 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
1454,
18990,
7928,
30480,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
1532,
3872,
33066,
1005,
3564,
1972,
2822,
10202,
11,
1848,
1669,
5635,
5142,
831,
5809,
74,
23720,
97549,
24,
16,
73,
17,
18,
68... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_SalesReports_Filter_FillByDefault(t *testing.T) {
filter := &SalesReportsFilter{}
filter.Daily().TypeSales().SubTypeSummary().Version10()
assert.Equal(t, SalesReportTypeSales, filter.ReportType)
assert.Equal(t, SalesReportSubTypeSummary, filter.ReportSubType)
assert.Equal(t, SalesReportFrequencyDaily, filter.Frequency)
assert.Equal(t, SalesReportVersion10, filter.Version)
} | explode_data.jsonl/60782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
1098,
3831,
23748,
68935,
1400,
483,
1359,
3675,
1155,
353,
8840,
836,
8,
341,
50108,
1669,
609,
35418,
23748,
5632,
16094,
50108,
909,
5069,
1005,
929,
35418,
1005,
3136,
929,
19237,
1005,
5637,
16,
15,
741,
6948,
12808,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPaintClippedCirle(t *testing.T) {
run(t, func(o *op.Ops) {
r := float32(10)
clip.RRect{Rect: f32.Rect(20, 20, 40, 40), SE: r, SW: r, NW: r, NE: r}.Add(o)
clip.Rect(image.Rect(0, 0, 30, 50)).Add(o)
paint.Fill(o, colornames.Red)
}, func(r result) {
r.expect(21, 21, colornames.White)
r.expect(25, 30, colornames.Red)
r.expect(31, 30, colornames.White)
})
} | explode_data.jsonl/18104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 192
} | [
2830,
3393,
18098,
5066,
6450,
34,
404,
273,
1155,
353,
8840,
836,
8,
341,
56742,
1155,
11,
2915,
10108,
353,
453,
8382,
1690,
8,
341,
197,
7000,
1669,
2224,
18,
17,
7,
16,
15,
340,
197,
197,
7974,
2013,
4415,
90,
4415,
25,
282,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeSnappyPayload(t *testing.T) {
r := bytes.NewReader(sampleSnappyInform)
inform, err := DecodeHeader(r)
assert.Nil(t, err, "if this fails, look at TestDecodeSnappyHeader")
payload, err := inform.DecodePayload(r, "")
assert.Nil(t, err, "payload failed? we should check more specific error here")
assert.True(t, json.Valid(payload), "payload is not valid json, so decode likely failed")
t.Logf("payload: %s", payload)
} | explode_data.jsonl/38402 | {
"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,
32564,
20720,
11144,
29683,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
5820,
68587,
32968,
20720,
11144,
37891,
340,
17430,
627,
11,
1848,
1669,
50194,
4047,
2601,
340,
6948,
59678,
1155,
11,
1848,
11,
330,
333,
419,
14525,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecoverParserError(t *testing.T) {
p := newParser("foo bar")
var err error
e := errors.New("custom error")
defer func() {
require.Equal(t, e.Error(), err.Error())
}()
defer p.recover(&err)
panic(e)
} | explode_data.jsonl/3396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
693,
3688,
6570,
1454,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
501,
6570,
445,
7975,
3619,
1138,
2405,
1848,
1465,
271,
7727,
1669,
5975,
7121,
445,
9163,
1465,
5130,
16867,
2915,
368,
341,
197,
17957,
12808,
1155,
11,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestAESKeyGen(t *testing.T) {
t.Parallel()
provider, _, cleanup := currentTestConfig.Provider(t)
defer cleanup()
k, err := provider.KeyGen(&bccsp.AESKeyGenOpts{Temporary: false})
if err != nil {
t.Fatalf("Failed generating AES_256 key [%s]", err)
}
if k == nil {
t.Fatal("Failed generating AES_256 key. Key must be different from nil")
}
if !k.Private() {
t.Fatal("Failed generating AES_256 key. Key should be private")
}
if !k.Symmetric() {
t.Fatal("Failed generating AES_256 key. Key should be symmetric")
}
pk, err := k.PublicKey()
if err == nil {
t.Fatal("Error should be different from nil in this case")
}
if pk != nil {
t.Fatal("Return value should be equal to nil in this case")
}
} | explode_data.jsonl/29271 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
69168,
1592,
9967,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
19979,
11,
8358,
21290,
1669,
1482,
2271,
2648,
36208,
1155,
340,
16867,
21290,
2822,
16463,
11,
1848,
1669,
9109,
9610,
9967,
2099,
69018,
2154,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestReadChallengeTx_validSignedByServer(t *testing.T) {
serverKP := newKeypair0()
clientKP := newKeypair1()
txSource := NewSimpleAccount(serverKP.Address(), -1)
op := ManageData{
SourceAccount: clientKP.Address(),
Name: "testanchor.stellar.org auth",
Value: []byte(base64.StdEncoding.EncodeToString(make([]byte, 48))),
}
webAuthDomainOp := ManageData{
SourceAccount: serverKP.Address(),
Name: "web_auth_domain",
Value: []byte("testwebauth.stellar.org"),
}
tx, err := NewTransaction(
TransactionParams{
SourceAccount: &txSource,
IncrementSequenceNum: true,
Operations: []Operation{&op, &webAuthDomainOp},
BaseFee: MinBaseFee,
Timebounds: NewTimeout(1000),
},
)
assert.NoError(t, err)
tx, err = tx.Sign(network.TestNetworkPassphrase, serverKP)
assert.NoError(t, err)
tx64, err := tx.Base64()
require.NoError(t, err)
readTx, readClientAccountID, _, err := ReadChallengeTx(tx64, serverKP.Address(), network.TestNetworkPassphrase, "testwebauth.stellar.org", []string{"testanchor.stellar.org"})
assert.Equal(t, tx, readTx)
assert.Equal(t, clientKP.Address(), readClientAccountID)
assert.NoError(t, err)
} | explode_data.jsonl/20701 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 517
} | [
2830,
3393,
4418,
62078,
31584,
8337,
49312,
1359,
5475,
1155,
353,
8840,
836,
8,
341,
41057,
65036,
1669,
501,
6608,
1082,
1310,
15,
741,
25291,
65036,
1669,
501,
6608,
1082,
1310,
16,
741,
46237,
3608,
1669,
1532,
16374,
7365,
21421,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindNextPageToken(t *testing.T) {
tests := []struct {
input url.URL
expect *PageToken
pass bool
}{
{url.URL{RawQuery: "nextPageToken=ZABMLg=="}, &PageToken{Limit: 100, Page: 11852}, true},
// Other query params should be ignored
{url.URL{RawQuery: "filter=foobar&nextPageToken=ZABMLg=="}, &PageToken{Limit: 100, Page: 11852}, true},
// Lack of a nextPageToken value is ok
{url.URL{RawQuery: "filter=foobar"}, nil, true},
// More than one value for nextPageToken is not acceptable
{url.URL{RawQuery: "nextPageToken=LQAJAA==&nextPageToken=_wMAAA=="}, nil, false},
// Unparseable values result in an error
{url.URL{RawQuery: "nextPageToken=bogus"}, nil, false},
// Ensure validation code is being called
{url.URL{RawQuery: "nextPageToken="}, nil, false},
}
for i, tt := range tests {
next, err := findNextPageToken(&tt.input, testTokenLimit)
if tt.pass != (err == nil) {
t.Errorf("case %d: pass=%t, err=%v", i, tt.pass, err)
}
if !reflect.DeepEqual(next, tt.expect) {
t.Errorf("case %d: expected %v, got %v", i, tt.expect, next)
}
}
} | explode_data.jsonl/14975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 434
} | [
2830,
3393,
9885,
5847,
2665,
3323,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
220,
2515,
20893,
198,
197,
24952,
353,
2665,
3323,
198,
197,
41431,
256,
1807,
198,
197,
59403,
197,
197,
90,
1085,
20893,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStatisticSample(t *testing.T) {
data := `metrics0{code="200"} 1
metrics0{code="201"} 2
`
r, err := relabel.NewRegexp("200")
require.NoError(t, err)
s, err := StatisticSample([]byte(data), "", []*relabel.Config{
{
SourceLabels: []model.LabelName{"code"},
Regex: r,
Action: relabel.Drop,
},
})
require.NoError(t, err)
require.Equal(t, int64(1), s)
} | explode_data.jsonl/45860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
93014,
17571,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
1565,
43262,
15,
90,
1851,
428,
17,
15,
15,
9207,
220,
16,
198,
43262,
15,
90,
1851,
428,
17,
15,
16,
9207,
220,
17,
198,
3989,
7000,
11,
1848,
1669,
1351,
780,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_StrStrMap_MapCopy(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
m := gmap.NewStrStrMap()
m.Set("1", "1")
m.Set("2", "2")
t.Assert(m.Get("1"), "1")
t.Assert(m.Get("2"), "2")
data := m.MapCopy()
t.Assert(data["1"], "1")
t.Assert(data["2"], "2")
data["3"] = "3"
t.Assert(m.Get("3"), "")
m.Set("4", "4")
t.Assert(data["4"], "")
})
} | explode_data.jsonl/36013 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
46171,
2580,
2227,
56992,
12106,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
2109,
1669,
342,
2186,
7121,
2580,
2580,
2227,
741,
197,
2109,
4202,
445,
16,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestShmMemoryRegion(t *testing.T) {
if !SetupOptional() {
t.Skip("skipping TestShmMemoryRegion")
return
}
buf, err := shm.NewBufferTmpfs(64<<20, shm.PROT_RDWR)
if err != nil {
panic(err)
}
mr, err := RegisterMemory(buf.Bytes())
if err != nil {
panic(err)
}
checkClose(mr)
checkClose(buf)
buf, err = shm.NewBufferHugepages(64<<20, shm.PROT_RDWR)
if err != nil {
panic(err)
}
mr, err = RegisterMemory(buf.Bytes())
if err != nil {
panic(err)
}
checkClose(mr)
checkClose(buf)
} | explode_data.jsonl/69348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
2016,
76,
10642,
14091,
1155,
353,
8840,
836,
8,
341,
743,
753,
21821,
15309,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
3393,
2016,
76,
10642,
14091,
1138,
197,
853,
198,
197,
532,
26398,
11,
1848,
1669,
76500,
7121,
40... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiplePackageImport(t *testing.T) {
_, err := Import(".", "testdata/multi", 0)
mpe, ok := err.(*MultiplePackageError)
if !ok {
t.Fatal(`Import("testdata/multi") did not return MultiplePackageError.`)
}
want := &MultiplePackageError{
Dir: filepath.FromSlash("testdata/multi"),
Packages: []string{"main", "test_package"},
Files: []string{"file.go", "file_appengine.go"},
}
if !reflect.DeepEqual(mpe, want) {
t.Errorf("got %#v; want %#v", mpe, want)
}
} | explode_data.jsonl/515 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
32089,
13100,
11511,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
13213,
64217,
330,
92425,
3183,
7068,
497,
220,
15,
340,
2109,
375,
11,
5394,
1669,
1848,
41399,
32089,
13100,
1454,
340,
743,
753,
562,
341,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestIsValidWithInvalidChips(t *testing.T) {
testHeader(t, 123, 1<<7 /* "future chip" bit that must never be set */, "extra sound chip section contains unsupported values", getIsValidError)
} | explode_data.jsonl/74783 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 57
} | [
2830,
3393,
55470,
2354,
7928,
1143,
3077,
1155,
353,
8840,
836,
8,
341,
18185,
4047,
1155,
11,
220,
16,
17,
18,
11,
220,
16,
2442,
22,
1391,
330,
21055,
16392,
1,
2699,
429,
1969,
2581,
387,
738,
36572,
330,
15460,
5112,
16392,
377... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReason(t *testing.T) {
err := errors.New("ordinary error")
tt.Test(t, tt.Fn("Reason", Reason), tt.Table{
tt.Args(err).Rets(err),
tt.Args(makeException(err)).Rets(err),
})
} | explode_data.jsonl/23937 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
25139,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
5975,
7121,
445,
21031,
1465,
1138,
3244,
83,
8787,
1155,
11,
17853,
991,
77,
445,
25139,
497,
26759,
701,
17853,
18257,
515,
197,
3244,
83,
51015,
3964,
568,
49,
1415,
3964... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPSendFile(t *testing.T) {
outDir := tempDir(t)
expectedBytes := []byte("hello")
buf := bytes.NewReader(expectedBytes)
req, err := http.NewRequest("POST", "/", buf)
require.NoError(t, err)
req.Header.Set("Content-Length", strconv.Itoa(len(expectedBytes)))
stdOut := bytes.NewBufferString("")
cmd, err := CreateHTTPUpload(
HTTPTransferRequest{
FileName: "filename",
RemoteLocation: outDir,
HTTPRequest: req,
Progress: stdOut,
User: "test-user",
})
require.NoError(t, err)
err = runSCP(cmd, "-v", "-t", outDir)
require.NoError(t, err)
bytesReceived, err := ioutil.ReadFile(filepath.Join(outDir, "filename"))
require.NoError(t, err)
require.Empty(t, cmp.Diff(string(bytesReceived), string(expectedBytes)))
} | explode_data.jsonl/74621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 309
} | [
2830,
3393,
9230,
11505,
1703,
1155,
353,
8840,
836,
8,
341,
13967,
6184,
1669,
2730,
6184,
1155,
692,
42400,
7078,
1669,
3056,
3782,
445,
14990,
1138,
26398,
1669,
5820,
68587,
15253,
7078,
340,
24395,
11,
1848,
1669,
1758,
75274,
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 TestMultipleAPIGroupsCoveringSingleRule(t *testing.T) {
escalationTest{
ownerRules: []authorizationapi.PolicyRule{
{APIGroups: []string{"group1"}, Verbs: sets.NewString("delete"), Resources: sets.NewString("deployments")},
{APIGroups: []string{"group1"}, Verbs: sets.NewString("delete"), Resources: sets.NewString("builds")},
{APIGroups: []string{"group1"}, Verbs: sets.NewString("update"), Resources: sets.NewString("builds", "deployments")},
{APIGroups: []string{"group2"}, Verbs: sets.NewString("delete"), Resources: sets.NewString("deployments")},
{APIGroups: []string{"group2"}, Verbs: sets.NewString("delete"), Resources: sets.NewString("builds")},
{APIGroups: []string{"group2"}, Verbs: sets.NewString("update"), Resources: sets.NewString("builds", "deployments")},
},
servantRules: []authorizationapi.PolicyRule{
{APIGroups: []string{"group1", "group2"}, Verbs: sets.NewString("delete", "update"), Resources: sets.NewString("builds", "deployments")},
},
expectedCovered: true,
expectedUncoveredRules: []authorizationapi.PolicyRule{},
}.test(t)
} | explode_data.jsonl/9044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
32089,
7082,
22173,
30896,
287,
10888,
11337,
1155,
353,
8840,
836,
8,
341,
80629,
278,
367,
2271,
515,
197,
197,
8118,
26008,
25,
3056,
39554,
2068,
1069,
8018,
11337,
515,
298,
197,
90,
7082,
22173,
25,
3056,
917,
4913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplySimple(t *testing.T) {
t.Parallel()
fName := "TestApplySimple"
defer cleanup(fName)
writeOldFile(fName, t)
err := Apply(bytes.NewReader(newFile), Options{
TargetPath: fName,
})
validateUpdate(fName, err, t)
} | explode_data.jsonl/73980 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
28497,
16374,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
675,
1669,
330,
2271,
28497,
16374,
698,
16867,
21290,
955,
675,
340,
24945,
18284,
1703,
955,
675,
11,
259,
692,
9859,
1669,
20552,
23158,
68587,
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 Test_getWorkflowsHandler(t *testing.T) {
api, db, _ := newTestAPI(t)
u, pass := assets.InsertLambdaUser(t, api.mustDB())
proj := assets.InsertTestProject(t, db, api.Cache, sdk.RandomString(10), sdk.RandomString(10))
require.NoError(t, group.InsertLinkGroupUser(context.TODO(), api.mustDB(), &group.LinkGroupUser{
GroupID: proj.ProjectGroups[0].Group.ID,
AuthentifiedUserID: u.ID,
Admin: true,
}))
pip := sdk.Pipeline{
ProjectID: proj.ID,
ProjectKey: proj.Key,
Name: "pip1",
}
test.NoError(t, pipeline.InsertPipeline(api.mustDB(), &pip))
wf := sdk.Workflow{
Name: "workflow1",
ProjectID: proj.ID,
ProjectKey: proj.Key,
WorkflowData: sdk.WorkflowData{
Node: sdk.Node{
Name: "root",
Context: &sdk.NodeContext{
PipelineID: pip.ID,
},
},
},
}
test.NoError(t, workflow.Insert(context.TODO(), api.mustDB(), api.Cache, *proj, &wf))
vars := map[string]string{
"permProjectKey": proj.Key,
}
uri := api.Router.GetRoute("GET", api.getWorkflowsHandler, vars)
test.NotEmpty(t, uri)
req := assets.NewAuthentifiedRequest(t, u, pass, "GET", uri, nil)
//Do the request
w := httptest.NewRecorder()
api.Router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
wfList := []sdk.Workflow{}
test.NoError(t, json.Unmarshal(w.Body.Bytes(), &wfList))
require.Len(t, wfList, 1)
for _, w := range wfList {
assert.Equal(t, true, w.Permissions.Readable, "readable should be true")
assert.Equal(t, true, w.Permissions.Writable, "writable should be true")
assert.Equal(t, true, w.Permissions.Executable, "writable should be true")
}
var err error
userAdmin, passAdmin := assets.InsertAdminUser(t, db)
uri = api.Router.GetRoute("GET", api.getWorkflowsHandler, vars)
req, err = http.NewRequest("GET", uri, nil)
test.NoError(t, err)
assets.AuthentifyRequest(t, req, userAdmin, passAdmin)
// Do the request
w = httptest.NewRecorder()
api.Router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
wfList = []sdk.Workflow{}
test.NoError(t, json.Unmarshal(w.Body.Bytes(), &wfList))
for _, w := range wfList {
assert.Equal(t, true, w.Permissions.Readable, "readable should be true")
assert.Equal(t, true, w.Permissions.Writable, "writable should be true")
assert.Equal(t, true, w.Permissions.Executable, "executable should be true")
}
userMaintainer, passMaintainer := assets.InsertMaintainerUser(t, db)
uri = api.Router.GetRoute("GET", api.getWorkflowsHandler, vars)
req, err = http.NewRequest("GET", uri, nil)
test.NoError(t, err)
assets.AuthentifyRequest(t, req, userMaintainer, passMaintainer)
// Do the request
w = httptest.NewRecorder()
api.Router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
wfList = []sdk.Workflow{}
test.NoError(t, json.Unmarshal(w.Body.Bytes(), &wfList))
for _, w := range wfList {
assert.Equal(t, true, w.Permissions.Readable, "readable should be true")
assert.Equal(t, false, w.Permissions.Writable, "writable should be false")
assert.Equal(t, false, w.Permissions.Executable, "executable should be false")
}
} | explode_data.jsonl/31066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1290
} | [
2830,
3393,
3062,
6776,
38140,
3050,
1155,
353,
8840,
836,
8,
341,
54299,
11,
2927,
11,
716,
1669,
501,
2271,
7082,
1155,
692,
10676,
11,
1494,
1669,
11770,
23142,
58266,
1474,
1155,
11,
6330,
69419,
3506,
2398,
197,
30386,
1669,
11770,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteV2RecordBatch(t *testing.T) {
if !ktesting.KafkaIsAtLeast("0.11.0") {
t.Skip("RecordBatch was added in kafka 0.11.0")
return
}
client, topic, shutdown := newLocalClientAndTopic()
defer shutdown()
msgs := make([]Message, 15)
for i := range msgs {
value := fmt.Sprintf("Sample message content: %d!", i)
msgs[i] = Message{Key: []byte("Key"), Value: []byte(value), Headers: []Header{Header{Key: "hk", Value: []byte("hv")}}}
}
w := &Writer{
Addr: TCP("localhost:9092"),
Topic: topic,
BatchTimeout: 100 * time.Millisecond,
BatchSize: 5,
Transport: client.Transport,
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if err := w.WriteMessages(ctx, msgs...); err != nil {
t.Errorf("Failed to write v2 messages to kafka: %v", err)
return
}
w.Close()
r := NewReader(ReaderConfig{
Brokers: []string{"localhost:9092"},
Topic: topic,
MaxWait: 100 * time.Millisecond,
})
defer r.Close()
msg, err := r.ReadMessage(context.Background())
if err != nil {
t.Error("Failed to read message")
return
}
if string(msg.Key) != "Key" {
t.Error("Received message's key doesn't match")
return
}
if msg.Headers[0].Key != "hk" {
t.Error("Received message header's key doesn't match")
return
}
} | explode_data.jsonl/26906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 530
} | [
2830,
3393,
7985,
53,
17,
6471,
21074,
1155,
353,
8840,
836,
8,
341,
743,
753,
74,
8840,
11352,
21883,
3872,
1655,
81816,
445,
15,
13,
16,
16,
13,
15,
899,
341,
197,
3244,
57776,
445,
6471,
21074,
572,
3694,
304,
67852,
220,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestLocateMissingUUIDInTokenInContext(t *testing.T) {
tk := jwt.New(jwt.SigningMethodRS256)
ctx := goajwt.WithJWT(context.Background(), tk)
manager := createManager(t)
_, err := manager.Locate(ctx)
if err == nil {
t.Error("Should have returned error on missing token in contex", err)
}
} | explode_data.jsonl/54989 | {
"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,
9152,
349,
25080,
24754,
641,
3323,
641,
1972,
1155,
353,
8840,
836,
8,
341,
3244,
74,
1669,
24589,
7121,
3325,
9306,
41152,
287,
3523,
11451,
17,
20,
21,
340,
20985,
1669,
728,
1630,
9306,
26124,
55172,
5378,
19047,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInstanceNamesUniqueAndValid(t *testing.T) {
instance := &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Namespace: "ns", Name: "some-such",
},
}
type test struct {
name string
value metav1.ObjectMeta
}
t.Run("ConfigMaps", func(t *testing.T) {
names := sets.NewString()
for _, tt := range []test{
{"InstanceConfigMap", InstanceConfigMap(instance)},
} {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.value.Namespace, instance.Namespace)
assert.Assert(t, tt.value.Name != instance.Name, "may collide")
assert.Assert(t, !names.Has(tt.value.Name), "%q defined already", tt.value.Name)
assert.Assert(t, nil == validation.IsDNS1123Label(tt.value.Name))
names.Insert(tt.value.Name)
})
}
})
t.Run("PVCs", func(t *testing.T) {
names := sets.NewString()
for _, tt := range []test{
{"InstancePostgresDataVolume", InstancePostgresDataVolume(instance)},
{"InstancePostgresWALVolume", InstancePostgresWALVolume(instance)},
} {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.value.Namespace, instance.Namespace)
assert.Assert(t, tt.value.Name != instance.Name, "may collide")
assert.Assert(t, !names.Has(tt.value.Name), "%q defined already", tt.value.Name)
assert.Assert(t, nil == validation.IsDNS1123Label(tt.value.Name))
names.Insert(tt.value.Name)
})
}
})
t.Run("Secrets", func(t *testing.T) {
names := sets.NewString()
for _, tt := range []test{
{"InstanceCertificates", InstanceCertificates(instance)},
} {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.value.Namespace, instance.Namespace)
assert.Assert(t, tt.value.Name != instance.Name, "may collide")
assert.Assert(t, !names.Has(tt.value.Name), "%q defined already", tt.value.Name)
assert.Assert(t, nil == validation.IsDNS1123Label(tt.value.Name))
names.Insert(tt.value.Name)
})
}
})
} | explode_data.jsonl/22346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 803
} | [
2830,
3393,
2523,
7980,
22811,
3036,
4088,
1155,
353,
8840,
836,
8,
341,
56256,
1669,
609,
676,
3492,
16,
18942,
1262,
1649,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
90823,
25,
330,
4412,
497,
3988,
25,
330,
14689,
1331... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMd5(t *testing.T) {
rand.Seed(time.Now().UnixNano())
ast := assert.New(t)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
md5Str := r.Header.Get("X-Md5")
b, err := ioutil.ReadAll(r.Body)
ast.Nil(err)
if len(b) == 0 {
ast.Equal("", md5Str, r.URL.Path)
return
}
hexB := md5.Sum(b)
md5exp := hex.EncodeToString(hexB[:])
ast.Equal(md5exp, md5Str, r.URL.Path)
return
}))
defer ts.Close()
md5tp := NewTransport(http.DefaultTransport)
client := http.Client{Transport: md5tp}
_, err := client.Get(ts.URL + "/testget")
ast.Nil(err)
for n := 1; n <= 5000; n *= 2 {
path := "/" + strconv.Itoa(n)
b := make([]byte, n)
rand.Read(b)
reader := bytes.NewBuffer(b)
_, err := client.Post(ts.URL+path, "application/octet-stream", reader)
ast.Nil(err)
}
} | explode_data.jsonl/13550 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
72529,
20,
1155,
353,
8840,
836,
8,
1476,
7000,
437,
5732,
291,
9730,
13244,
1005,
55832,
83819,
12367,
88836,
1669,
2060,
7121,
1155,
692,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoOverlap(t *testing.T) {
for _, c := range testVectors {
s, _ := NewUnauthenticatedCipher(hexDecode(c.key), hexDecode(c.nonce))
input := hexDecode(c.input)
output := make([]byte, len(input))
s.XORKeyStream(output, input)
got := hex.EncodeToString(output)
if got != c.output {
t.Errorf("length=%v: got %#v, want %#v", len(input), got, c.output)
}
}
} | explode_data.jsonl/80521 | {
"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,
2753,
82171,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
1273,
84744,
341,
197,
1903,
11,
716,
1669,
1532,
1806,
57707,
79460,
44660,
32564,
1337,
4735,
701,
12371,
32564,
1337,
1253,
13184,
1171,
197,
22427,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncodeEmpty(t *testing.T) {
for _, m := range []proto.Message{nil, (*testpb.TestAllTypes)(nil), &testpb.TestAllTypes{}} {
isValid := m != nil && m.ProtoReflect().IsValid()
b, err := proto.Marshal(m)
if err != nil {
t.Errorf("proto.Marshal() = %v", err)
}
if isNil := b == nil; isNil == isValid {
t.Errorf("proto.Marshal() == nil: %v, want %v", isNil, !isValid)
}
b, err = proto.MarshalOptions{}.Marshal(m)
if err != nil {
t.Errorf("proto.MarshalOptions{}.Marshal() = %v", err)
}
if isNil := b == nil; isNil == isValid {
t.Errorf("proto.MarshalOptions{}.Marshal() = %v, want %v", isNil, !isValid)
}
}
} | explode_data.jsonl/1542 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
32535,
3522,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
296,
1669,
2088,
3056,
15110,
8472,
90,
8385,
11,
4609,
1944,
16650,
8787,
2403,
4173,
2376,
8385,
701,
609,
1944,
16650,
8787,
2403,
4173,
90,
3417,
341,
197,
19907,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestFilters_highway_with_name(t *testing.T) {
filterTest(
t,
`
tables:
highway:
fields:
- name: id
type: id
- key: highway
name: highway
type: string
- key: name
name: name
type: string
filters:
require:
name: ["__any__"]
reject:
highway: ["no","none"]
mapping:
highway:
- __any__
type: linestring
`,
// Accept
[]element.Tags{
element.Tags{"highway": "residential", "name": "N1"},
element.Tags{"highway": "service", "name": "N2"},
element.Tags{"highway": "track", "name": "N3"},
element.Tags{"highway": "unclassified", "name": "N4"},
element.Tags{"highway": "path", "name": "N5"},
element.Tags{"highway": "", "name": "🌍🌎🌏"},
element.Tags{"highway": "_", "name": "N6"},
element.Tags{"highway": "y", "name": "N7"},
element.Tags{"highway": "tower_block", "name": "N8"},
element.Tags{"highway": "shed", "name": "N9"},
element.Tags{"highway": "office", "name": "N10"},
element.Tags{"highway": "SheD", "name": "N11"},
element.Tags{"highway": "oFFice", "name": "N12"},
element.Tags{"highway": "❤", "name": "❤"},
element.Tags{"highway": "Ümlåütê", "name": "Ümlåütê"},
element.Tags{"highway": "木", "name": "木"},
},
// Reject
[]element.Tags{
element.Tags{"highway": "no", "name": "N1"},
element.Tags{"highway": "none", "name": "N2"},
element.Tags{"highway": "yes"},
element.Tags{"highway": "no"},
element.Tags{"highway": "none"},
element.Tags{"highway": "No"},
element.Tags{"highway": "NO"},
element.Tags{"highway": "NONe"},
element.Tags{"highway": "Garage"},
element.Tags{"highway": "residential"},
element.Tags{"highway": "path"},
element.Tags{"highway": "tower-block"},
element.Tags{"highway": "❤"},
element.Tags{"highway": "Ümlåütê"},
element.Tags{"highway": "木"},
element.Tags{"admin_level": "2"},
element.Tags{"admin_level": "4"},
element.Tags{"boundary": "administrative"},
element.Tags{"boundary": "maritime"},
element.Tags{"name": "maritime"},
},
)
} | explode_data.jsonl/25614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 916
} | [
2830,
3393,
28351,
22680,
3117,
6615,
1269,
1155,
353,
8840,
836,
8,
341,
50108,
2271,
1006,
197,
3244,
345,
197,
197,
3989,
32110,
510,
220,
26736,
510,
262,
5043,
510,
262,
481,
829,
25,
877,
198,
414,
943,
25,
877,
198,
262,
481,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCryptionHandlerWriteHeader(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "/any", nil)
handler := CryptionHandler(aesKey)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusServiceUnavailable)
}))
recorder := httptest.NewRecorder()
handler.ServeHTTP(recorder, req)
assert.Equal(t, http.StatusServiceUnavailable, recorder.Code)
} | explode_data.jsonl/24319 | {
"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,
34,
15597,
3050,
7985,
4047,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
54320,
70334,
75274,
19886,
20798,
1949,
11,
3521,
3767,
497,
2092,
340,
53326,
1669,
356,
15597,
3050,
2877,
288,
1592,
2376,
1254,
89164,
18552,
3622,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRedirectWithSetWebRootKeepsParams(t *testing.T) {
oldConfig := config.Get()
defer config.Set(oldConfig)
conf := new(config.Config)
conf.Server.WebRoot = "/test"
config.Set(conf)
router := NewRouter()
ts := httptest.NewServer(router)
defer ts.Close()
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
resp, err := client.Get(ts.URL + "/test")
if err != nil {
t.Fatal(err)
}
body, _ := ioutil.ReadAll(resp.Body)
assert.Equal(t, 200, resp.StatusCode, "Response should not redirect")
resp, err = client.Get(ts.URL + "/test/")
if err != nil {
t.Fatal(err)
}
body2, _ := ioutil.ReadAll(resp.Body)
assert.Equal(t, 200, resp.StatusCode, string(body2))
assert.Equal(t, string(body), string(body2), "Response with and without the trailing slash on the webroot are not the same")
} | explode_data.jsonl/14287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
17725,
2354,
1649,
5981,
8439,
6608,
7124,
4870,
1155,
353,
8840,
836,
8,
341,
61828,
2648,
1669,
2193,
2234,
741,
16867,
2193,
4202,
21972,
2648,
692,
67850,
1669,
501,
8754,
10753,
340,
67850,
22997,
6473,
8439,
284,
3521,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetMarginBillDetails(t *testing.T) {
request := okgroup.GetMarginBillDetailsRequest{
InstrumentID: spotCurrency,
Limit: 100,
}
_, err := o.GetMarginBillDetails(request)
testStandardErrorHandling(t, err)
} | explode_data.jsonl/30174 | {
"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,
27476,
7799,
1155,
353,
8840,
836,
8,
341,
23555,
1669,
5394,
4074,
2234,
21681,
27476,
7799,
1900,
515,
197,
197,
56324,
915,
25,
7702,
26321,
345,
197,
15070,
2353,
25,
286,
220,
16,
15,
15,
345,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceInstancesStore(t *testing.T) {
store := serviceInstancesStore{
ip2instance: map[string][]*model.ServiceInstance{},
instances: map[instancesKey]map[configKey][]*model.ServiceInstance{},
instancesBySE: map[types.NamespacedName]map[configKey][]*model.ServiceInstance{},
}
instances := []*model.ServiceInstance{
makeInstance(selector, "1.1.1.1", 444, selector.Spec.(*networking.ServiceEntry).Ports[0], nil, PlainText),
makeInstance(selector, "1.1.1.1", 445, selector.Spec.(*networking.ServiceEntry).Ports[1], nil, PlainText),
makeInstance(dnsSelector, "1.1.1.1", 444, dnsSelector.Spec.(*networking.ServiceEntry).Ports[0], nil, PlainText),
}
cKey := configKey{
namespace: "default",
name: "test-wle",
}
store.addInstances(cKey, instances)
// 1. test getByIP
gotInstances := store.getByIP("1.1.1.1")
if !reflect.DeepEqual(instances, gotInstances) {
t.Errorf("got unexpected instances : %v", gotInstances)
}
// 2. test getAll
gotInstances = store.getAll()
if !reflect.DeepEqual(instances, gotInstances) {
t.Errorf("got unexpected instances : %v", gotInstances)
}
// 3. test getByKey
gotInstances = store.getByKey(instancesKey{
hostname: "selector.com",
namespace: "selector",
})
expected := []*model.ServiceInstance{
makeInstance(selector, "1.1.1.1", 444, selector.Spec.(*networking.ServiceEntry).Ports[0], nil, PlainText),
makeInstance(selector, "1.1.1.1", 445, selector.Spec.(*networking.ServiceEntry).Ports[1], nil, PlainText),
}
if !reflect.DeepEqual(gotInstances, expected) {
t.Errorf("got unexpected instances : %v", gotInstances)
}
// 4. test getServiceEntryInstances
expectedSeInstances := map[configKey][]*model.ServiceInstance{cKey: {
makeInstance(selector, "1.1.1.1", 444, selector.Spec.(*networking.ServiceEntry).Ports[0], nil, PlainText),
makeInstance(selector, "1.1.1.1", 445, selector.Spec.(*networking.ServiceEntry).Ports[1], nil, PlainText),
}}
key := types.NamespacedName{Namespace: selector.Namespace, Name: selector.Name}
store.updateServiceEntryInstances(key, expectedSeInstances)
gotSeInstances := store.getServiceEntryInstances(key)
if !reflect.DeepEqual(gotSeInstances, expectedSeInstances) {
t.Errorf("got unexpected se instances : %v", gotSeInstances)
}
// 5. test deleteServiceEntryInstances
store.deleteServiceEntryInstances(key, cKey)
gotSeInstances = store.getServiceEntryInstances(key)
if len(gotSeInstances) != 0 {
t.Errorf("got unexpected instances %v", gotSeInstances)
}
// 6. test deleteAllServiceEntryInstances
store.deleteAllServiceEntryInstances(key)
gotSeInstances = store.getServiceEntryInstances(key)
if len(gotSeInstances) != 0 {
t.Errorf("got unexpected instances %v", gotSeInstances)
}
// 7. test deleteInstances
store.deleteInstances(cKey, instances)
gotInstances = store.getAll()
if len(gotInstances) != 0 {
t.Errorf("got unexpected instances %v", gotSeInstances)
}
} | explode_data.jsonl/64845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1057
} | [
2830,
3393,
1860,
42725,
6093,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
2473,
42725,
6093,
515,
197,
46531,
17,
4851,
25,
256,
2415,
14032,
45725,
9,
2528,
13860,
2523,
38837,
197,
197,
47825,
25,
257,
2415,
58,
47825,
1592,
60,
218... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientRefreshBehaviour(t *testing.T) {
seedBroker := NewMockBroker(t, 1)
leader := NewMockBroker(t, 5)
metadataResponse1 := new(MetadataResponse)
metadataResponse1.AddBroker(leader.Addr(), leader.BrokerID())
seedBroker.Returns(metadataResponse1)
metadataResponse2 := new(MetadataResponse)
metadataResponse2.AddBroker(leader.Addr(), leader.BrokerID())
metadataResponse2.AddTopicPartition("my_topic", 0xb, leader.BrokerID(), nil, nil, nil, ErrNoError)
seedBroker.Returns(metadataResponse2)
client, err := NewClient([]string{seedBroker.Addr()}, NewTestConfig())
if err != nil {
t.Fatal(err)
}
parts, err := client.Partitions("my_topic")
if err != nil {
t.Error(err)
} else if len(parts) != 1 || parts[0] != 0xb {
t.Error("Client returned incorrect partitions for my_topic:", parts)
}
tst, err := client.Leader("my_topic", 0xb)
if err != nil {
t.Error(err)
} else if tst.ID() != 5 {
t.Error("Leader for my_topic had incorrect ID.")
}
leader.Close()
seedBroker.Close()
safeClose(t, client)
} | explode_data.jsonl/54406 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
2959,
14567,
14174,
1155,
353,
8840,
836,
8,
341,
197,
22602,
65545,
1669,
1532,
11571,
65545,
1155,
11,
220,
16,
340,
197,
37391,
1669,
1532,
11571,
65545,
1155,
11,
220,
20,
692,
2109,
7603,
2582,
16,
1669,
501,
3189,
76... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestStreamEmptyPayload(t *testing.T) {
w := bytes.NewBuffer(nil)
writer := NewWriter(w)
_, err := writer.Write(nil)
failOnError(t, "failed to write empty slice", err)
err = writer.Close()
failOnError(t, "failed to close", err)
compressed := w.Bytes()
t.Logf("compressed buffer: 0x%x", compressed)
// Now recheck that if we decompress, we get empty slice
r := bytes.NewBuffer(compressed)
reader := NewReader(r)
decompressed, err := ioutil.ReadAll(reader)
failOnError(t, "failed to read", err)
err = reader.Close()
failOnError(t, "failed to close", err)
if string(decompressed) != "" {
t.Fatalf("Expected empty slice as decompressed, got %v instead", decompressed)
}
} | explode_data.jsonl/70462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
3027,
3522,
29683,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
5820,
7121,
4095,
27907,
340,
38959,
1669,
1532,
6492,
3622,
340,
197,
6878,
1848,
1669,
6916,
4073,
27907,
340,
63052,
74945,
1155,
11,
330,
16091,
311,
3270,
428... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCT_PresetShadowEffectConstructor(t *testing.T) {
v := dml.NewCT_PresetShadowEffect()
if v == nil {
t.Errorf("dml.NewCT_PresetShadowEffect must return a non-nil value")
}
if err := v.Validate(); err != nil {
t.Errorf("newly constructed dml.CT_PresetShadowEffect should validate: %s", err)
}
} | explode_data.jsonl/66813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
1162,
1088,
9716,
23667,
7738,
13288,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
294,
1014,
7121,
1162,
1088,
9716,
23667,
7738,
741,
743,
348,
621,
2092,
341,
197,
3244,
13080,
445,
67,
1014,
7121,
1162,
1088,
9716,
23667,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegrationPlugins(t *testing.T) {
t.Parallel()
tc := mock.NewIntegrationTestConfig(t)
client := New(tc)
// Test: List
listResult, err := client.ListPlugins(nil)
require.NoError(t, err)
if len(listResult) == 0 {
t.Skip("Skipping `GetPlugin()` integration test due to zero plugins found")
return
}
// Test: Get
qp := GetPluginParams{
Detailed: true,
}
getResult, err := client.GetPlugin(listResult[0].ID, &qp)
require.NoError(t, err)
require.NotNil(t, getResult)
require.NotNil(t, getResult.Details)
} | explode_data.jsonl/27201 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
52464,
45378,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78255,
1669,
7860,
7121,
52464,
2271,
2648,
1155,
340,
25291,
1669,
1532,
44415,
692,
197,
322,
3393,
25,
1759,
198,
14440,
2077,
11,
1848,
1669,
2943,
581... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSokuonB(t *testing.T) {
const want = "bbabbibbubbebbo"
for _, v := range []string{"っばっびっぶっべっぼ", "ッバッビッブッベッボ"} {
got, err := KanaToRomaji(v)
assert.Equal(t, want, got)
assert.Nil(t, err)
}
} | explode_data.jsonl/11351 | {
"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,
50,
16493,
263,
33,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
330,
6066,
12523,
579,
65,
392,
90805,
749,
1837,
2023,
8358,
348,
1669,
2088,
3056,
917,
4913,
41791,
80119,
41791,
124406,
125388,
114,
41791,
124192,
1253... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestForceDelete(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
MockForceDeleteResponse(t)
res := volumeactions.ForceDelete(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
th.AssertNoErr(t, res.Err)
} | explode_data.jsonl/20633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
18573,
6435,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
9209,
1176,
18573,
6435,
2582,
1155,
692,
10202,
1669,
8123,
4020,
991,
16316,
6435,
12805,
13860,
2959,
1507,
330,
67,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestScheduled(t *testing.T) {
n := NewScheduler()
n.Every(1).Second().Do(task)
if !n.Scheduled(task) {
t.Fatal("Task was scheduled but function couldn't find it")
}
} | explode_data.jsonl/63491 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
88137,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
1532,
38878,
741,
9038,
5142,
1204,
7,
16,
568,
15666,
1005,
5404,
17483,
340,
743,
753,
77,
808,
26644,
17483,
8,
341,
197,
3244,
26133,
445,
6262,
572,
13537,
714,
729,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBaseTable_Name(t *testing.T) {
tests := []struct {
name string
b *BaseTable
want string
}{
{
name: "1",
b: NewBaseTable("db", "schema", "table"),
want: "table",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.b.Name(); got != tt.want {
t.Errorf("BaseTable.Name() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/20041 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
3978,
2556,
19015,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
2233,
262,
353,
3978,
2556,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
16,
756,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateCouchDBSystemDBs(t *testing.T) {
config := testConfig()
couchDBEnv.startCouchDB(t)
config.Address = couchDBEnv.couchAddress
defer couchDBEnv.cleanup(config)
config.CreateGlobalChangesDB = true
//create a new connection
couchInstance, err := createCouchInstance(config, &disabled.Provider{})
assert.NoError(t, err, "Error when trying to CreateCouchInstance")
err = createSystemDatabasesIfNotExist(couchInstance)
assert.NoError(t, err, "Error when trying to create system databases")
db := couchDatabase{couchInstance: couchInstance, dbName: "_users"}
//Retrieve the info for the new database and make sure the name matches
dbResp, _, errdb := db.getDatabaseInfo()
assert.NoError(t, errdb, "Error when trying to retrieve _users database information")
assert.Equal(t, "_users", dbResp.DbName)
db = couchDatabase{couchInstance: couchInstance, dbName: "_replicator"}
//Retrieve the info for the new database and make sure the name matches
dbResp, _, errdb = db.getDatabaseInfo()
assert.NoError(t, errdb, "Error when trying to retrieve _replicator database information")
assert.Equal(t, "_replicator", dbResp.DbName)
db = couchDatabase{couchInstance: couchInstance, dbName: "_global_changes"}
//Retrieve the info for the new database and make sure the name matches
dbResp, _, errdb = db.getDatabaseInfo()
assert.NoError(t, errdb, "Error when trying to retrieve _global_changes database information")
assert.Equal(t, "_global_changes", dbResp.DbName)
} | explode_data.jsonl/39978 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 464
} | [
2830,
3393,
4021,
34,
3026,
3506,
2320,
3506,
82,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
1273,
2648,
741,
1444,
3026,
3506,
14359,
4962,
34,
3026,
3506,
1155,
340,
25873,
26979,
284,
26148,
3506,
14359,
520,
3026,
4286,
198,
16867,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandleOutbound(t *testing.T) {
svc, err := New(&protocol.MockProvider{
ServiceMap: map[string]interface{}{
mediator.Coordination: &mockroute.MockMediatorSvc{},
},
})
require.NoError(t, err)
_, err = svc.HandleOutbound(service.DIDCommMsgMap{}, "", "")
require.Error(t, err)
require.Contains(t, err.Error(), "not implemented")
} | explode_data.jsonl/30529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
6999,
2662,
10891,
1155,
353,
8840,
836,
8,
341,
1903,
7362,
11,
1848,
1669,
1532,
2099,
17014,
24664,
5179,
515,
197,
91619,
2227,
25,
2415,
14032,
31344,
67066,
298,
197,
4404,
850,
52114,
98244,
25,
609,
16712,
8966,
2466... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSmiRouter_SetRoutes(t *testing.T) {
canary := newTestSMICanary()
mocks := newFixture(canary)
router := &SmiRouter{
logger: mocks.logger,
flaggerClient: mocks.flaggerClient,
smiClient: mocks.meshClient,
kubeClient: mocks.kubeClient,
}
err := router.Reconcile(mocks.canary)
require.NoError(t, err)
p, c, m, err := router.GetRoutes(mocks.canary)
require.NoError(t, err)
p = 50
c = 50
m = false
err = router.SetRoutes(mocks.canary, p, c, m)
require.NoError(t, err)
ts, err := router.smiClient.SplitV1alpha1().TrafficSplits("default").Get("podinfo", metav1.GetOptions{})
require.NoError(t, err)
var pRoute smiv1.TrafficSplitBackend
var cRoute smiv1.TrafficSplitBackend
_, primaryName, canaryName := canary.GetServiceNames()
for _, dest := range ts.Spec.Backends {
if dest.Service == primaryName {
pRoute = dest
}
if dest.Service == canaryName {
cRoute = dest
}
}
assert.Equal(t, strconv.Itoa(p), pRoute.Weight.String())
assert.Equal(t, strconv.Itoa(c), cRoute.Weight.String())
} | explode_data.jsonl/8373 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 446
} | [
2830,
3393,
50,
8155,
9523,
14812,
26653,
1155,
353,
8840,
836,
8,
341,
92936,
658,
1669,
501,
2271,
9501,
1317,
276,
658,
741,
2109,
25183,
1669,
501,
18930,
90651,
658,
340,
67009,
1669,
609,
50,
8155,
9523,
515,
197,
17060,
25,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDingTalk_GetChatQRCode(t *testing.T) {
res, err := client.GetChatQRCode("chat8ff884ef696f5717678c6280edfdbbf1", "manager164")
assert.Nil(t, err)
assert.NotNil(t, res)
assert.NotNil(t, res.Url)
} | explode_data.jsonl/32609 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
35,
287,
36210,
13614,
15672,
30465,
2078,
1155,
353,
8840,
836,
8,
341,
10202,
11,
1848,
1669,
2943,
2234,
15672,
30465,
2078,
445,
9686,
23,
542,
23,
23,
19,
823,
21,
24,
21,
69,
20,
22,
16,
22,
21,
22,
23,
66,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshal_WithFloat(t *testing.T) {
type testStruct struct {
Floatval float64
}
testUnmarshal(t, []testcase{
{`floatval = 0.0`, nil, &testStruct{0.0}},
{`floatval = +0.0`, nil, &testStruct{0.0}},
{`floatval = -0.0`, nil, &testStruct{-0.0}},
{`floatval = 0.1`, nil, &testStruct{0.1}},
{`floatval = +0.1`, nil, &testStruct{0.1}},
{`floatval = -0.1`, nil, &testStruct{-0.1}},
{`floatval = 0.2`, nil, &testStruct{0.2}},
{`floatval = +0.2`, nil, &testStruct{0.2}},
{`floatval = -0.2`, nil, &testStruct{-0.2}},
{`floatval = 1.0`, nil, &testStruct{1.0}},
{`floatval = +1.0`, nil, &testStruct{1.0}},
{`floatval = -1.0`, nil, &testStruct{-1.0}},
{`floatval = 1.1`, nil, &testStruct{1.1}},
{`floatval = +1.1`, nil, &testStruct{1.1}},
{`floatval = -1.1`, nil, &testStruct{-1.1}},
{`floatval = 3.1415`, nil, &testStruct{3.1415}},
{`floatval = +3.1415`, nil, &testStruct{3.1415}},
{`floatval = -3.1415`, nil, &testStruct{-3.1415}},
{`floatval = 10.2e5`, nil, &testStruct{10.2e5}},
{`floatval = +10.2e5`, nil, &testStruct{10.2e5}},
{`floatval = -10.2e5`, nil, &testStruct{-10.2e5}},
{`floatval = 10.2E5`, nil, &testStruct{10.2e5}},
{`floatval = +10.2E5`, nil, &testStruct{10.2e5}},
{`floatval = -10.2E5`, nil, &testStruct{-10.2e5}},
{`floatval = 5e+22`, nil, &testStruct{5e+22}},
{`floatval = 1e6`, nil, &testStruct{1e6}},
{`floatval = -2E-2`, nil, &testStruct{-2E-2}},
{`floatval = 6.626e-34`, nil, &testStruct{6.626e-34}},
{`floatval = 9_224_617.445_991_228_313`, nil, &testStruct{9224617.445991228313}},
{`floatval = 1e1_00`, nil, &testStruct{1e100}},
{`floatval = 1e02`, nil, &testStruct{1e2}},
{`floatval = _1e1_00`, lineError(1, errParse), &testStruct{}},
{`floatval = 1e1_00_`, lineError(1, errParse), &testStruct{}},
})
} | explode_data.jsonl/52954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 911
} | [
2830,
3393,
1806,
27121,
62,
2354,
5442,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
9422,
2036,
341,
197,
197,
5442,
831,
2224,
21,
19,
198,
197,
532,
18185,
1806,
27121,
1155,
11,
3056,
1944,
5638,
515,
197,
197,
90,
63,
3649,
831,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestModifyContext(t *testing.T) {
conf := clientcmdapi.Config{
Contexts: map[string]*clientcmdapi.Context{
"shaker-context": {AuthInfo: "blue-user", Cluster: "big-cluster", Namespace: "saw-ns"},
"not-this": {AuthInfo: "blue-user", Cluster: "big-cluster", Namespace: "saw-ns"}}}
test := createContextTest{
testContext: "shaker-context",
description: "Testing for modify a already exist context",
config: conf,
args: []string{"shaker-context"},
flags: []string{
"--cluster=cluster_nickname",
"--user=user_nickname",
"--namespace=namespace",
},
expected: `Context "shaker-context" modified.` + "\n",
expectedConfig: clientcmdapi.Config{
Contexts: map[string]*clientcmdapi.Context{
"shaker-context": {AuthInfo: "user_nickname", Cluster: "cluster_nickname", Namespace: "namespace"},
"not-this": {AuthInfo: "blue-user", Cluster: "big-cluster", Namespace: "saw-ns"}}},
}
test.run(t)
} | explode_data.jsonl/12534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
44427,
1972,
1155,
353,
8840,
836,
8,
341,
67850,
1669,
2943,
8710,
2068,
10753,
515,
197,
70871,
82,
25,
2415,
14032,
8465,
2972,
8710,
2068,
9328,
515,
298,
197,
1,
927,
4407,
63633,
788,
314,
5087,
1731,
25,
330,
12203,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteFieldFromFuncDeclParams(t *testing.T) {
t.Run("normal fields", func(t *testing.T) {
var src = `
package main
import "context"
type A struct {}
func f(ctx context.Context, a int, b float, c bool, d string, e A, f interface{}) {}
func main() {}
`
var expectedTemplate = `
package main
import "context"
type A struct {}
func f(%s) {}
func main() {}
`
df, _ := ParseSrcFileFromBytes([]byte(src))
cases := []struct {
field *dst.Field
expectedFargs string
expectedModified bool
}{
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("a")},
Type: dst.NewIdent("int"),
}, "ctx context.Context, b float, c bool, d string, e A, f interface{}", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("b")},
Type: dst.NewIdent("float"),
}, "ctx context.Context, c bool, d string, e A, f interface{}", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("c")},
Type: dst.NewIdent("bool"),
}, "ctx context.Context, d string, e A, f interface{}", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("d")},
Type: dst.NewIdent("string"),
}, "ctx context.Context, e A, f interface{}", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("e")},
Type: dst.NewIdent("A"),
}, "ctx context.Context, f interface{}", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("f")},
Type: &dst.InterfaceType{},
}, "ctx context.Context", true},
}
for _, c := range cases {
var buf *bytes.Buffer
assert.True(t, c.expectedModified, DeleteFieldFromFuncDeclParams(df, "f", c.field))
buf = printToBuf(df)
assertCodesEqual(t, fmt.Sprintf(expectedTemplate, c.expectedFargs), buf.String())
}
var finalExpect = `
package main
type A struct {}
func f() {}
func main() {}
`
var buf *bytes.Buffer
assert.True(t, true, DeleteFieldFromFuncDeclParams(df, "f", &dst.Field{
Names: []*dst.Ident{dst.NewIdent("ctx")},
Type: &dst.Ident{
Name: "Context",
Path: "context",
},
}))
buf = printToBuf(df)
assertCodesEqual(t, finalExpect, buf.String())
})
t.Run("decl inside decl", func(t *testing.T) {
var src = `
package main
func f(a int, b int, compare func(b int, d int) bool) bool { return true }
`
var expectedTemplate = `
package main
func f(%s) bool { return true }
`
cases := []struct {
field *dst.Field
expectedArgs string
expectedModified bool
}{
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("a")},
Type: dst.NewIdent("int"),
}, "b int, compare func(b int, d int) bool", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("b")},
Type: dst.NewIdent("int"),
}, "a int, compare func(b int, d int) bool", true},
{&dst.Field{
Names: []*dst.Ident{dst.NewIdent("d")},
Type: dst.NewIdent("int"),
}, "a int, b int, compare func(b int, d int) bool", false},
}
for _, c := range cases {
var buf *bytes.Buffer
df, _ := ParseSrcFileFromBytes([]byte(src))
assert.Equal(t, c.expectedModified, DeleteFieldFromFuncDeclParams(df, "f", c.field))
buf = printToBuf(df)
assertCodesEqual(t, fmt.Sprintf(expectedTemplate, c.expectedArgs), buf.String())
}
})
t.Run("decl inside decl2", func(t *testing.T) {
var src = `
package main
func rpc(ctx context.Context, hashKey string, timeout time.Duration, fn func(*AccountServiceClient) error) error {
return clientThrift.RpcWithContext(ctx, hashKey, timeout, func(c interface{}) error {
ct, ok := c.(*AccountServiceClient)
if ok {
return fn(ct)
} else {
return fmt.Errorf("reflect client thrift error")
}
})
}
`
var expected = `
package main
func rpc(ctx context.Context, hashKey string, timeout time.Duration) error {
return clientThrift.RpcWithContext(ctx, hashKey, timeout, func(c interface{}) error {
ct, ok := c.(*AccountServiceClient)
if ok {
return fn(ct)
} else {
return fmt.Errorf("reflect client thrift error")
}
})
}
`
df, _ := ParseSrcFileFromBytes([]byte(src))
fn := &dst.Field{
Names: []*dst.Ident{dst.NewIdent("fn")},
Type: &dst.FuncType{
Params: &dst.FieldList{
List: []*dst.Field{
{
Type: &dst.StarExpr{
X: dst.NewIdent("AccountServiceClient"),
},
},
},
},
Results: &dst.FieldList{
List: []*dst.Field{
{
Type: dst.NewIdent("error"),
},
},
},
},
}
modified := DeleteFieldFromFuncDeclParams(df, "rpc", fn)
assert.Equal(t, true, modified)
var buf *bytes.Buffer
buf = printToBuf(df)
assertCodesEqual(t, expected, buf.String())
})
} | explode_data.jsonl/7164 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2078
} | [
2830,
3393,
6435,
1877,
3830,
9626,
21629,
4870,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
8252,
5043,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2405,
2286,
284,
22074,
197,
197,
1722,
1887,
271,
197,
21918,
330,
2147,
1837... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Process(t *testing.T) {
cmd := cmder.New(sleep, five)
err := cmd.Start()
if err != nil {
t.Error(err)
}
process := cmd.Process()
if process == nil {
t.Errorf("Expected non-nil process. Got nil value.")
}
err = cmd.Kill()
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/70668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
70241,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
9961,
1107,
7121,
1141,
3499,
11,
4236,
692,
9859,
1669,
5439,
12101,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
630,
53314,
1669,
5439,
29012,
741,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRatelimit(t *testing.T) {
Convey("Make a new controller", t, func() {
port := test.GetFreePort()
baseURL := test.GetBaseURL(port)
conf := config.New()
conf.HTTP.Port = port
rate := 1
conf.HTTP.Ratelimit = &config.RatelimitConfig{
Rate: &rate,
}
ctlr := api.NewController(conf)
ctlr.Config.Storage.RootDirectory = t.TempDir()
go startServer(ctlr)
defer stopServer(ctlr)
test.WaitTillServerReady(baseURL)
Convey("Ratelimit", func() {
client := resty.New()
// first request should succeed
resp, err := client.R().Get(baseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
// second request back-to-back should fail
resp, err = client.R().Get(baseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusTooManyRequests)
})
})
Convey("Make a new controller", t, func() {
port := test.GetFreePort()
baseURL := test.GetBaseURL(port)
conf := config.New()
conf.HTTP.Port = port
conf.HTTP.Ratelimit = &config.RatelimitConfig{
Methods: []config.MethodRatelimitConfig{
{
Method: http.MethodGet,
Rate: 1,
},
},
}
ctlr := api.NewController(conf)
ctlr.Config.Storage.RootDirectory = t.TempDir()
go startServer(ctlr)
defer stopServer(ctlr)
test.WaitTillServerReady(baseURL)
Convey("Method Ratelimit", func() {
client := resty.New()
// first request should succeed
resp, err := client.R().Get(baseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
// second request back-to-back should fail
resp, err = client.R().Get(baseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusTooManyRequests)
})
})
Convey("Make a new controller", t, func() {
port := test.GetFreePort()
baseURL := test.GetBaseURL(port)
conf := config.New()
conf.HTTP.Port = port
rate := 1
conf.HTTP.Ratelimit = &config.RatelimitConfig{
Rate: &rate, // this dominates
Methods: []config.MethodRatelimitConfig{
{
Method: http.MethodGet,
Rate: 100,
},
},
}
ctlr := api.NewController(conf)
ctlr.Config.Storage.RootDirectory = t.TempDir()
go startServer(ctlr)
defer stopServer(ctlr)
test.WaitTillServerReady(baseURL)
Convey("Global and Method Ratelimit", func() {
client := resty.New()
// first request should succeed
resp, err := client.R().Get(baseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
// second request back-to-back should fail
resp, err = client.R().Get(baseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusTooManyRequests)
})
})
} | explode_data.jsonl/77683 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1183
} | [
2830,
3393,
49,
83326,
2353,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
8078,
264,
501,
6461,
497,
259,
11,
2915,
368,
341,
197,
52257,
1669,
1273,
2234,
10940,
7084,
741,
197,
24195,
3144,
1669,
1273,
2234,
3978,
3144,
21230,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEvalActionNode(t *testing.T) {
var data = make(VarMap)
data.Set("user", &User{
"José Santos", "email@example.com",
})
RunJetTest(t, nil, nil, "actionNode", `hello {{"world"}}`, `hello world`)
RunJetTest(t, data, nil, "actionNode_func", `hello {{lower: "WORLD"}}`, `hello world`)
RunJetTest(t, data, nil, "actionNode_funcPipe", `hello {{lower: "WORLD" |upper}}`, `hello WORLD`)
RunJetTest(t, data, nil, "actionNode_funcPipeArg", `hello {{lower: "WORLD-" |upper|repeat: 2}}`, `hello WORLD-WORLD-`)
RunJetTest(t, data, nil, "actionNode_Field", `Oi {{ user.Name }}`, `Oi José Santos`)
RunJetTest(t, data, nil, "actionNode_Field2", `Oi {{ user.Name }}<{{ user.Email }}>`, `Oi José Santos<email@example.com>`)
RunJetTest(t, data, nil, "actionNode_Method", `Oi {{ user.Format: "%s<%s>" }}`, `Oi José Santos<email@example.com>`)
RunJetTest(t, data, nil, "actionNode_Add", `{{ 2+1 }}`, fmt.Sprint(2+1))
RunJetTest(t, data, nil, "actionNode_Add3", `{{ 2+1+4 }}`, fmt.Sprint(2+1+4))
RunJetTest(t, data, nil, "actionNode_Add3Minus", `{{ 2+1+4-3 }}`, fmt.Sprint(2+1+4-3))
RunJetTest(t, data, nil, "actionNode_AddIntString", `{{ 2+"1" }}`, "3")
RunJetTest(t, data, nil, "actionNode_AddStringInt", `{{ "1"+2 }}`, "12")
RunJetTest(t, data, nil, "actionNode_NumberNegative", `{{ -5 }}`, "-5")
RunJetTest(t, data, nil, "actionNode_NumberNegative_1", `{{ 1 + -5 }}`, fmt.Sprint(1+-5))
//this is an error RunJetTest(t, data, nil, "actionNode_AddStringInt", `{{ "1"-2 }}`, "12")
RunJetTest(t, data, nil, "actionNode_Mult", `{{ 4*4 }}`, fmt.Sprint(4*4))
RunJetTest(t, data, nil, "actionNode_MultAdd", `{{ 2+4*4 }}`, fmt.Sprint(2+4*4))
RunJetTest(t, data, nil, "actionNode_MultAdd1", `{{ 4*2+4 }}`, fmt.Sprint(4*2+4))
RunJetTest(t, data, nil, "actionNode_MultAdd2", `{{ 2+4*2+4 }}`, fmt.Sprint(2+4*2+4))
RunJetTest(t, data, nil, "actionNode_MultFloat", `{{ 1.23*1 }}`, fmt.Sprint(1*1.23))
RunJetTest(t, data, nil, "actionNode_Mod", `{{ 3%2 }}`, fmt.Sprint(3%2))
RunJetTest(t, data, nil, "actionNode_MultMod", `{{ (1*3)%2 }}`, fmt.Sprint((1*3)%2))
RunJetTest(t, data, nil, "actionNode_MultDivMod", `{{ (2*5)/ 3 %1 }}`, fmt.Sprint((2*5)/3%1))
RunJetTest(t, data, nil, "actionNode_Comparation", `{{ (2*5)==10 }}`, fmt.Sprint((2*5) == 10))
RunJetTest(t, data, nil, "actionNode_Comparatation2", `{{ (2*5)==5 }}`, fmt.Sprint((2*5) == 5))
RunJetTest(t, data, nil, "actionNode_Logical", `{{ (2*5)==5 || true }}`, fmt.Sprint((2*5) == 5 || true))
RunJetTest(t, data, nil, "actionNode_Logical2", `{{ (2*5)==5 || false }}`, fmt.Sprint((2*5) == 5 || false))
RunJetTest(t, data, nil, "actionNode_NumericCmp", `{{ 5*5 > 2*12.5 }}`, fmt.Sprint(5*5 > 2*12.5))
RunJetTest(t, data, nil, "actionNode_NumericCmp1", `{{ 5*5 >= 2*12.5 }}`, fmt.Sprint(5*5 >= 2*12.5))
RunJetTest(t, data, nil, "actionNode_NumericCmp1", `{{ 5 * 5 > 2 * 12.5 == 5 * 5 > 2 * 12.5 }}`, fmt.Sprint((5*5 > 2*12.5) == (5*5 > 2*12.5)))
} | explode_data.jsonl/22893 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1289
} | [
2830,
3393,
54469,
2512,
1955,
1155,
353,
8840,
836,
8,
341,
2405,
821,
284,
1281,
7,
3962,
2227,
692,
8924,
4202,
445,
872,
497,
609,
1474,
515,
197,
197,
1,
96956,
963,
47623,
497,
330,
2332,
35487,
905,
756,
197,
8824,
85952,
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... | 3 |
func TestOpIf(t *testing.T) {
assert := assert.New(t)
jl := NewEmpty()
AddOpIf(jl)
TestCases{
// http://jsonlogic.com/operations.html#if
{Logic: `{"if":[true,"yes","no"]}`, Data: `null`, Result: "yes"},
{Logic: `{"if":[false,"yes","no"]}`, Data: `null`, Result: "no"},
// Zero param.
{Logic: `{"if":[]}`, Data: `null`, Result: nil},
// One param.
{Logic: `{"if":"xxx"}`, Data: `null`, Result: "xxx"},
// Two params.
{Logic: `{"if":[true,"1"]}`, Data: `null`, Result: "1"},
{Logic: `{"if":[false,"1"]}`, Data: `null`, Result: nil},
}.Run(assert, jl)
} | explode_data.jsonl/38295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
7125,
2679,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
12428,
75,
1669,
1532,
3522,
741,
37972,
7125,
2679,
3325,
75,
340,
73866,
37302,
515,
197,
197,
322,
1758,
1110,
2236,
24225,
905,
14,
38163,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_DescribeRegionsWithRPCrequestWith3XX(t *testing.T) {
client, err := ecs.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
assert.Nil(t, err)
request := ecs.CreateDescribeRegionsRequest()
request.Scheme = "HTTP"
ts := mockServer(307, `{"error"}`)
defer ts.Close()
domain := strings.Replace(ts.URL, "http://", "", 1)
request.Domain = domain
response, err := client.DescribeRegions(request)
assert.NotNil(t, err)
assert.Equal(t, 307, response.GetHttpStatus())
assert.Equal(t, "{\"error\"}", response.GetHttpContentString())
} | explode_data.jsonl/56880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
98054,
3114,
79284,
2354,
29528,
2035,
2354,
18,
6148,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
78422,
7121,
2959,
2354,
6054,
1592,
9638,
64883,
445,
77431,
3450,
3975,
2643,
64883,
445,
55749,
6600,
3450,
3975,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReadChallengeTx_invalidOperationWrongType(t *testing.T) {
serverKP := newKeypair0()
clientKP := newKeypair1()
txSource := NewSimpleAccount(serverKP.Address(), -1)
op := BumpSequence{
SourceAccount: clientKP.Address(),
BumpTo: 0,
}
tx, err := NewTransaction(
TransactionParams{
SourceAccount: &txSource,
IncrementSequenceNum: true,
Operations: []Operation{&op},
BaseFee: MinBaseFee,
Timebounds: NewTimeout(300),
},
)
assert.NoError(t, err)
tx, err = tx.Sign(network.TestNetworkPassphrase, serverKP)
assert.NoError(t, err)
tx64, err := tx.Base64()
require.NoError(t, err)
readTx, readClientAccountID, _, err := ReadChallengeTx(tx64, serverKP.Address(), network.TestNetworkPassphrase, "testwebauth.stellar.org", []string{"testanchor.stellar.org"})
assert.Equal(t, tx, readTx)
assert.Equal(t, "", readClientAccountID)
assert.EqualError(t, err, "operation type should be manage_data")
} | explode_data.jsonl/20708 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
4418,
62078,
31584,
31433,
8432,
29185,
929,
1155,
353,
8840,
836,
8,
341,
41057,
65036,
1669,
501,
6608,
1082,
1310,
15,
741,
25291,
65036,
1669,
501,
6608,
1082,
1310,
16,
741,
46237,
3608,
1669,
1532,
16374,
7365,
21421,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlugin_GetInventory_MaxMDT(t *testing.T) {
var brickAllocations []datamodel.Brick
for i := 1; i <= 26; i = i + 2 {
brickAllocations = append(brickAllocations, datamodel.Brick{
BrickHostName: datamodel.BrickHostName(fmt.Sprintf("dac%d", i)),
Device: "nvme1n1",
})
brickAllocations = append(brickAllocations, datamodel.Brick{
BrickHostName: datamodel.BrickHostName(fmt.Sprintf("dac%d", i)),
Device: "nvme2n1",
})
}
for i := 1; i <= 4; i = i + 2 {
brickAllocations = append(brickAllocations, datamodel.Brick{
BrickHostName: datamodel.BrickHostName(fmt.Sprintf("dac%d", i)),
Device: "nvme3n1",
})
}
fsUuid := "abcdefgh"
result := getInventory(Lustre, fsUuid, brickAllocations)
expected := `dacs:
children:
abcdefgh:
hosts:
dac1:
mgs: sdb
mdts: {nvme1n1: 0}
osts: {nvme1n1: 0, nvme2n1: 1, nvme3n1: 26}
dac3:
mdts: {nvme1n1: 1}
osts: {nvme1n1: 2, nvme2n1: 3, nvme3n1: 27}
dac5:
mdts: {nvme1n1: 2}
osts: {nvme1n1: 4, nvme2n1: 5}
dac7:
mdts: {nvme1n1: 3}
osts: {nvme1n1: 6, nvme2n1: 7}
dac9:
mdts: {nvme1n1: 4}
osts: {nvme1n1: 8, nvme2n1: 9}
dac11:
mdts: {nvme1n1: 5}
osts: {nvme1n1: 10, nvme2n1: 11}
dac13:
mdts: {nvme1n1: 6}
osts: {nvme1n1: 12, nvme2n1: 13}
dac15:
mdts: {nvme1n1: 7}
osts: {nvme1n1: 14, nvme2n1: 15}
dac17:
mdts: {nvme1n1: 8}
osts: {nvme1n1: 16, nvme2n1: 17}
dac19:
mdts: {nvme1n1: 9}
osts: {nvme1n1: 18, nvme2n1: 19}
dac21:
mdts: {nvme1n1: 10}
osts: {nvme1n1: 20, nvme2n1: 21}
dac23:
mdts: {nvme1n1: 11}
osts: {nvme1n1: 22, nvme2n1: 23}
dac25:
mdts: {nvme1n1: 12}
osts: {nvme1n1: 24, nvme2n1: 25}
vars:
fs_name: abcdefgh
lnet_suffix: ""
mdt_size_mb: "20480"
mgsnode: dac1
`
assert.Equal(t, expected, result)
} | explode_data.jsonl/15873 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1339
} | [
2830,
3393,
11546,
13614,
22319,
58843,
6076,
51,
1155,
353,
8840,
836,
8,
341,
2405,
24837,
25154,
804,
3056,
5911,
40259,
1785,
12649,
198,
2023,
600,
1669,
220,
16,
26,
600,
2651,
220,
17,
21,
26,
600,
284,
600,
488,
220,
17,
341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUserUsageStatistics_LogCodeHostIntegrationUsage(t *testing.T) {
db := setupForTest(t)
user := types.User{
ID: 1,
}
err := logLocalEvent(context.Background(), db, "hover", "https://sourcegraph.example.com/", user.ID, "test-cookie-id", "CODEHOSTINTEGRATION", nil)
if err != nil {
t.Fatal(err)
}
a, err := GetByUserID(context.Background(), db, user.ID)
if err != nil {
t.Fatal(err)
}
diff := a.LastCodeHostIntegrationTime.Unix() - time.Now().Unix()
if wantMaxDiff := 10; diff > int64(wantMaxDiff) || diff < -int64(wantMaxDiff) {
t.Errorf("got %d seconds apart, wanted less than %d seconds apart", diff, wantMaxDiff)
}
} | explode_data.jsonl/66477 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
1474,
14783,
38599,
44083,
2078,
9296,
52464,
14783,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
6505,
2461,
2271,
1155,
692,
19060,
1669,
4494,
7344,
515,
197,
29580,
25,
220,
16,
345,
197,
532,
9859,
1669,
1487,
7319,
1556,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_fetchRepoIndex(t *testing.T) {
tests := []struct {
name string
url string
}{
{"valid HTTP URL", "http://my.examplerepo.com"},
{"valid HTTPS URL", "https://my.examplerepo.com"},
{"valid trailing URL", "https://my.examplerepo.com/"},
{"valid subpath URL", "https://subpath.test/subpath/"},
{"valid URL with trailing spaces", "https://subpath.test/subpath/ "},
{"valid URL with leading spaces", " https://subpath.test/subpath/"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
netClient = &goodHTTPClient{}
_, err := fetchRepoIndex(tt.url, "")
assert.NoErr(t, err)
})
}
t.Run("authenticated request", func(t *testing.T) {
netClient = &authenticatedHTTPClient{}
_, err := fetchRepoIndex("https://my.examplerepo.com", "Bearer ThisSecretAccessTokenAuthenticatesTheClient")
assert.NoErr(t, err)
})
t.Run("failed request", func(t *testing.T) {
netClient = &badHTTPClient{}
_, err := fetchRepoIndex("https://my.examplerepo.com", "")
assert.ExistsErr(t, err, "failed request")
})
} | explode_data.jsonl/67799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
11803,
25243,
1552,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
19320,
220,
914,
198,
197,
59403,
197,
197,
4913,
1891,
10130,
5548,
497,
330,
1254,
1110,
2408,
94117,
500,
485,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddServiceWithUnknownEventKindShouldNotPanic(t *testing.T) {
h, l := newHandler()
h.Handle(resource.Event{
Kind: resource.None,
Entry: entryForService(serviceName, createTime, "v1"),
})
expectNoNotification(t, l)
} | explode_data.jsonl/37582 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
2212,
1860,
2354,
13790,
1556,
10629,
14996,
2623,
47,
31270,
1155,
353,
8840,
836,
8,
341,
9598,
11,
326,
1669,
501,
3050,
2822,
9598,
31421,
23599,
6904,
515,
197,
197,
10629,
25,
220,
5101,
18475,
345,
197,
197,
5874,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetDeletableResources(t *testing.T) {
tests := map[string]struct {
serverResources []*metav1.APIResourceList
err error
deletableResources map[schema.GroupVersionResource]struct{}
}{
"no error": {
serverResources: []*metav1.APIResourceList{
{
// Valid GroupVersion
GroupVersion: "apps/v1",
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod", Verbs: metav1.Verbs{"delete", "list", "watch"}},
{Name: "services", Namespaced: true, Kind: "Service"},
},
},
{
// Invalid GroupVersion, should be ignored
GroupVersion: "foo//whatever",
APIResources: []metav1.APIResource{
{Name: "bars", Namespaced: true, Kind: "Bar", Verbs: metav1.Verbs{"delete", "list", "watch"}},
},
},
{
// Valid GroupVersion, missing required verbs, should be ignored
GroupVersion: "acme/v1",
APIResources: []metav1.APIResource{
{Name: "widgets", Namespaced: true, Kind: "Widget", Verbs: metav1.Verbs{"delete"}},
},
},
},
err: nil,
deletableResources: map[schema.GroupVersionResource]struct{}{
{Group: "apps", Version: "v1", Resource: "pods"}: {},
},
},
"nonspecific failure, includes usable results": {
serverResources: []*metav1.APIResourceList{
{
GroupVersion: "apps/v1",
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod", Verbs: metav1.Verbs{"delete", "list", "watch"}},
{Name: "services", Namespaced: true, Kind: "Service"},
},
},
},
err: fmt.Errorf("internal error"),
deletableResources: map[schema.GroupVersionResource]struct{}{
{Group: "apps", Version: "v1", Resource: "pods"}: {},
},
},
"partial discovery failure, includes usable results": {
serverResources: []*metav1.APIResourceList{
{
GroupVersion: "apps/v1",
APIResources: []metav1.APIResource{
{Name: "pods", Namespaced: true, Kind: "Pod", Verbs: metav1.Verbs{"delete", "list", "watch"}},
{Name: "services", Namespaced: true, Kind: "Service"},
},
},
},
err: &discovery.ErrGroupDiscoveryFailed{
Groups: map[schema.GroupVersion]error{
{Group: "foo", Version: "v1"}: fmt.Errorf("discovery failure"),
},
},
deletableResources: map[schema.GroupVersionResource]struct{}{
{Group: "apps", Version: "v1", Resource: "pods"}: {},
},
},
"discovery failure, no results": {
serverResources: nil,
err: fmt.Errorf("internal error"),
deletableResources: map[schema.GroupVersionResource]struct{}{},
},
}
for name, test := range tests {
t.Logf("testing %q", name)
client := &fakeServerResources{
PreferredResources: test.serverResources,
Error: test.err,
}
actual := GetDeletableResources(client)
if !reflect.DeepEqual(test.deletableResources, actual) {
t.Errorf("expected resources:\n%v\ngot:\n%v", test.deletableResources, actual)
}
}
} | explode_data.jsonl/62007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1284
} | [
2830,
3393,
1949,
1912,
1149,
480,
11277,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
41057,
11277,
262,
29838,
4059,
402,
16,
24922,
4783,
852,
198,
197,
9859,
394,
1465,
198,
197,
58351,
1149,
480,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRandom(t *testing.T) {
pw := Random()
if len(pw) < 4 {
t.Errorf("too short")
}
if len(strings.Fields(pw)) < 4 {
t.Errorf("too few words")
}
} | explode_data.jsonl/72596 | {
"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,
13999,
1155,
353,
8840,
836,
8,
341,
92752,
1669,
10612,
741,
743,
2422,
1295,
86,
8,
366,
220,
19,
341,
197,
3244,
13080,
445,
36127,
2805,
1138,
197,
532,
743,
2422,
51442,
42809,
1295,
86,
593,
366,
220,
19,
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
] | 3 |
func TestGetEarliestTaskStatusForContainersEmptyTask(t *testing.T) {
testTask := &Task{}
assert.Equal(t, testTask.getEarliestKnownTaskStatusForContainers(), apitaskstatus.TaskStatusNone)
} | explode_data.jsonl/37213 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 62
} | [
2830,
3393,
1949,
17813,
23138,
6262,
2522,
2461,
74632,
3522,
6262,
1155,
353,
8840,
836,
8,
341,
18185,
6262,
1669,
609,
6262,
16094,
6948,
12808,
1155,
11,
1273,
6262,
670,
17813,
23138,
48206,
6262,
2522,
2461,
74632,
1507,
1443,
275,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVariableSubstitutions(t *testing.T) {
g := NewWithT(t)
env := map[string]string{
"KUBECONFIG": "~/.kube/config",
}
args := map[string]string{
"cluster-name": "idd",
"provider-name": "name",
"random": "r1",
"uuid": "uu-uu",
"tempdir": "/tmp",
"zone-selector": "zone",
}
var1, err := utils.SubstituteVariable("qwe ${KUBECONFIG} $(uuid) BBB", env, args)
g.Expect(err).To(BeNil())
g.Expect(var1).To(Equal("qwe ~/.kube/config uu-uu BBB"))
} | explode_data.jsonl/59868 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
7827,
3136,
92678,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
692,
57538,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
42,
42389,
24652,
788,
51269,
11930,
97717,
14730,
756,
197,
630,
31215,
1669,
2415,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerraformToPulumiNameWithSchemaInfoOverride(t *testing.T) {
tfs := map[string]*schema.Schema{
"list_property": {
Type: schema.TypeList,
},
}
// Override the List from the TF Schema with our own SchemaInfo overrides
maxItemsOne := true
ps := map[string]*SchemaInfo{
"list_property": {
MaxItemsOne: &maxItemsOne,
},
}
name := TerraformToPulumiName("list_property", shimv1.NewSchema(tfs["list_property"]), ps["list_property"], false)
if name != "listProperty" {
t.Errorf("Expected `listProperty`, got %s", name)
}
} | explode_data.jsonl/36106 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
51,
13886,
627,
1249,
47,
65482,
675,
2354,
8632,
1731,
2177,
1155,
353,
8840,
836,
8,
341,
3244,
3848,
1669,
2415,
14032,
8465,
17349,
21105,
515,
197,
197,
1,
1607,
16638,
788,
341,
298,
27725,
25,
10802,
10184,
852,
345... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRun(t *testing.T) {
s := newServer(t)
defer s.Close()
testContent := `{"groupName":"im","code":0,"msg":"success","data":"im分组接收消息"}`
resp, err := http.Post(s.ClientURL, "application/json", strings.NewReader(testContent))
Convey("测试发送消息到指定分组", t, func() {
Convey("是否有报错", func() {
So(err, ShouldBeNil)
})
})
defer resp.Body.Close()
retMessage := retMessage{}
message, err := ioutil.ReadAll(resp.Body)
err = json.Unmarshal(message, &retMessage)
Convey("验证json解析返回的内容", t, func() {
err := json.Unmarshal(message, &retMessage)
Convey("是否解析成功", func() {
So(err, ShouldBeNil)
})
Convey("Code格式", func() {
So(retMessage.Code, ShouldEqual, 0)
})
Convey("Msg格式", func() {
So(retMessage.Msg, ShouldEqual, "success")
})
})
} | explode_data.jsonl/35466 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 396
} | [
2830,
3393,
6727,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
5475,
1155,
340,
16867,
274,
10421,
2822,
18185,
2762,
1669,
1565,
4913,
90631,
3252,
318,
2198,
1851,
788,
15,
1335,
3236,
3252,
5630,
2198,
691,
3252,
318,
17177,
40027,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestComma(t *testing.T) {
type testList []struct {
name, got, exp string
}
l := testList{
{"0", comma(0), "0"},
{"10", comma(10), "10"},
{"100", comma(100), "100"},
{"1,000", comma(1000), "1,000"},
{"10,000", comma(10000), "10,000"},
{"100,000", comma(100000), "100,000"},
{"10,000,000", comma(10000000), "10,000,000"},
{"10,100,000", comma(10100000), "10,100,000"},
{"10,010,000", comma(10010000), "10,010,000"},
{"10,001,000", comma(10001000), "10,001,000"},
{"123,456,789", comma(123456789), "123,456,789"},
{"maxint", comma(9.223372e+18), "9,223,372,000,000,000,000"},
{"math.maxint", comma(math.MaxInt64), "9,223,372,036,854,775,807"},
{"math.minint", comma(math.MinInt64), "-9,223,372,036,854,775,808"},
{"minint", comma(-9.223372e+18), "-9,223,372,000,000,000,000"},
{"-123,456,789", comma(-123456789), "-123,456,789"},
{"-10,100,000", comma(-10100000), "-10,100,000"},
{"-10,010,000", comma(-10010000), "-10,010,000"},
{"-10,001,000", comma(-10001000), "-10,001,000"},
{"-10,000,000", comma(-10000000), "-10,000,000"},
{"-100,000", comma(-100000), "-100,000"},
{"-10,000", comma(-10000), "-10,000"},
{"-1,000", comma(-1000), "-1,000"},
{"-100", comma(-100), "-100"},
{"-10", comma(-10), "-10"},
}
for _, test := range l {
if test.got != test.exp {
t.Errorf("On %v, expected '%v', but got '%v'",
test.name, test.exp, test.got)
}
}
} | explode_data.jsonl/17007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 693
} | [
2830,
3393,
1092,
1728,
1155,
353,
8840,
836,
8,
972,
13158,
1273,
852,
3056,
1235,
972,
197,
11609,
11,
2684,
11,
1343,
914,
319,
197,
2570,
8810,
1669,
1273,
852,
1666,
197,
197,
4913,
15,
497,
31683,
7,
15,
701,
330,
15,
45426,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntDataPointSlice_RemoveIf(t *testing.T) {
// Test RemoveIf on empty slice
emptySlice := NewIntDataPointSlice()
emptySlice.RemoveIf(func(el IntDataPoint) bool {
t.Fail()
return false
})
// Test RemoveIf
filtered := generateTestIntDataPointSlice()
pos := 0
filtered.RemoveIf(func(el IntDataPoint) bool {
pos++
return pos%3 == 0
})
assert.Equal(t, 5, filtered.Len())
} | explode_data.jsonl/32710 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
1072,
1043,
2609,
33236,
66843,
2679,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
10783,
2679,
389,
4287,
15983,
198,
197,
3194,
33236,
1669,
1532,
1072,
1043,
2609,
33236,
741,
197,
3194,
33236,
13270,
2679,
18552,
18584,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRun(t *testing.T) {
pipe := pipeline.Pipeline{
Name: "test", Filters: []*pipeline.Filter{
{
Type: pipeline.FILTER_BLACK,
Rule: "mysql",
},
},
}
f, err := New(WithPipe(&pipe))
f.InChan = make(chan *message2.Message, 1)
f.OutChan = make(chan *message2.Message, 1)
if err != nil {
t.Error(err)
}
ctx, cancel := context.WithCancel(context.Background())
err = f.Run(ctx)
if err != nil {
t.Error(err)
}
inMsg := &message2.Message{
Content: &message2.Content{
Head: &message2.Head{
Database: "mysql",
Table: "user",
},
},
}
f.InChan <- inMsg
outMsg := <-f.OutChan
if outMsg.Filter == false {
t.Fail()
}
cancel()
} | explode_data.jsonl/80625 | {
"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,
6727,
1155,
353,
8840,
836,
8,
341,
197,
13768,
1669,
15301,
1069,
8790,
515,
197,
21297,
25,
330,
1944,
497,
45012,
25,
29838,
51258,
31696,
515,
298,
197,
515,
571,
27725,
25,
15301,
991,
15315,
56555,
345,
571,
11143,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegerPk(t *testing.T) {
its := []IntegerPk{
{ID: math.MinInt64, Value: "-"},
{ID: 0, Value: "0"},
{ID: math.MaxInt64, Value: "+"},
}
num, err := dORM.InsertMulti(len(its), its)
throwFail(t, err)
throwFail(t, AssertIs(num, len(its)))
for _, intPk := range its {
out := IntegerPk{ID: intPk.ID}
err = dORM.Read(&out)
throwFail(t, err)
throwFail(t, AssertIs(out.Value, intPk.Value))
}
num, err = dORM.InsertMulti(1, []*IntegerPk{{
ID: 1, Value: "ok",
}})
throwFail(t, err)
throwFail(t, AssertIs(num, 1))
} | explode_data.jsonl/18161 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 256
} | [
2830,
3393,
3486,
58415,
1155,
353,
8840,
836,
8,
341,
197,
1199,
1669,
3056,
3486,
58415,
515,
197,
197,
90,
915,
25,
6888,
17070,
1072,
21,
19,
11,
5162,
25,
6523,
7115,
197,
197,
90,
915,
25,
220,
15,
11,
5162,
25,
330,
15,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSequence(t *testing.T) {
t.Parallel()
val := Sequence{
Literal("a"),
Literal("b"),
Literal("c"),
}
if val.String() != "abc" {
t.Error("unexpected result")
}
} | explode_data.jsonl/32141 | {
"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,
14076,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
19302,
1669,
28871,
515,
197,
15070,
9953,
445,
64,
4461,
197,
15070,
9953,
445,
65,
4461,
197,
15070,
9953,
445,
66,
4461,
197,
630,
743,
1044,
6431,
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 TestClientSubscribe(t *testing.T) {
server := newTestServer()
defer server.Stop()
client := DialInProc(server)
defer client.Close()
nc := make(chan int) //用于获取通知结果
count := 10 //模拟通知10次
sub, err := client.Subscribe(context.Background(), "nftest", nc, "someSubscription", count, 0)
if err != nil {
t.Fatal("can't subscribe:", err)
}
for i := 0; i < count; i++ { //尝试获取10次结果
if val := <-nc; val != i { //获取结果
t.Fatalf("value mismatch: got %d, want %d", val, i)
}
}
sub.Unsubscribe()
select {
case v := <-nc:
t.Fatal("received value after unsubscribe:", v)
case err := <-sub.Err():
if err != nil {
t.Fatalf("Err returned a non-nil error after explicit unsubscribe: %q", err)
}
case <-time.After(1 * time.Second):
t.Fatalf("subscription not closed within 1s after unsubscribe")
}
} | explode_data.jsonl/64465 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 378
} | [
2830,
3393,
2959,
28573,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
501,
2271,
5475,
741,
16867,
3538,
30213,
741,
25291,
1669,
66155,
641,
24508,
21421,
340,
16867,
2943,
10421,
2822,
197,
1016,
1669,
1281,
35190,
526,
8,
442,
100751,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractError(t *testing.T) {
rc := mutate.Extract(invalidImage{})
if _, err := io.Copy(ioutil.Discard, rc); err == nil {
t.Errorf("rc.Read; got nil error")
} else if !strings.Contains(err.Error(), errInvalidImage.Error()) {
t.Errorf("rc.Read; got %v, want %v", err, errInvalidImage)
}
} | explode_data.jsonl/3088 | {
"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,
28959,
1454,
1155,
353,
8840,
836,
8,
341,
30295,
1669,
67182,
5121,
2144,
5900,
1891,
1906,
37790,
743,
8358,
1848,
1669,
6399,
31770,
1956,
30158,
909,
47560,
11,
10192,
1215,
1848,
621,
2092,
341,
197,
3244,
13080,
445,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCollectorAutoscalersOnByDefault(t *testing.T) {
// prepare
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
c := NewCollector(jaeger)
// test
a := c.Autoscalers()
// verify
assert.Len(t, a, 1)
assert.Len(t, a[0].Spec.Metrics, 2)
assert.Contains(t, []corev1.ResourceName{a[0].Spec.Metrics[0].Resource.Name, a[0].Spec.Metrics[1].Resource.Name}, corev1.ResourceCPU)
assert.Contains(t, []corev1.ResourceName{a[0].Spec.Metrics[0].Resource.Name, a[0].Spec.Metrics[1].Resource.Name}, corev1.ResourceMemory)
assert.Equal(t, int32(90), *a[0].Spec.Metrics[0].Resource.Target.AverageUtilization)
assert.Equal(t, int32(90), *a[0].Spec.Metrics[1].Resource.Target.AverageUtilization)
} | explode_data.jsonl/59534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
53694,
19602,
436,
5416,
388,
1925,
1359,
3675,
1155,
353,
8840,
836,
8,
341,
197,
322,
10549,
198,
197,
5580,
1878,
1669,
348,
16,
7121,
52445,
1878,
52613,
98932,
68552,
675,
63121,
25,
330,
2408,
73655,
23625,
1444,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.