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 TestUnmarshalCustomTag(t *testing.T) {
buf := bytes.NewBuffer(testDocBasicToml)
result := testDocCustomTag{}
err := NewDecoder(buf).SetTagName("file").Decode(&result)
if err != nil {
t.Fatal(err)
}
expected := testDocCustomTagData
if !reflect.DeepEqual(result, expected) {
resStr, _ := json.MarshalIndent(result, "", " ")
expStr, _ := json.MarshalIndent(expected, "", " ")
t.Errorf("Bad unmarshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expStr, resStr)
}
} | explode_data.jsonl/46337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
1806,
27121,
10268,
5668,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
5820,
7121,
4095,
8623,
9550,
15944,
24732,
75,
692,
9559,
1669,
1273,
9550,
10268,
5668,
16094,
9859,
1669,
1532,
20732,
10731,
568,
1649,
22616,
445,
1192,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSignature(t *testing.T) {
// From twilio docs
// https://www.twilio.com/docs/api/security#validating-requests
const (
reqURL = "https://mycompany.com/myapp.php?foo=1&bar=2"
authToken = "12345"
// Twilio's example code seems to be incorrect (includes an extra `=`)
// so this is different than the test example.
expectedSignature = "GvWf1cFY/Q7PnoempGyD5oXAezc="
)
v := make(url.Values)
v.Set("Digits", "1234")
v.Set("To", "+18005551212")
v.Set("From", "+14158675310")
v.Set("Caller", "+14158675310")
v.Set("CallSid", "CA1234567890ABCDE")
sig := Signature(authToken, reqURL, v)
assert.Equal(t, expectedSignature, string(sig))
} | explode_data.jsonl/1953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
25088,
1155,
353,
8840,
836,
8,
1476,
197,
322,
5542,
4384,
33329,
26340,
198,
197,
322,
220,
3703,
1110,
2136,
14701,
33329,
905,
25967,
10508,
71422,
2,
1891,
1095,
12,
36242,
271,
4777,
2399,
197,
24395,
3144,
262,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateWindow(t *testing.T) {
duration, _ := time.ParseDuration("1m")
internalDuration := config.Duration(duration)
c := &CloudWatch{
Namespace: "AWS/ELB",
Delay: internalDuration,
Period: internalDuration,
}
now := time.Now()
assert.True(t, c.windowEnd.IsZero())
assert.True(t, c.windowStart.IsZero())
c.updateWindow(now)
newStartTime := c.windowEnd
// initial window just has a single period
assert.EqualValues(t, c.windowEnd, now.Add(-time.Duration(c.Delay)))
assert.EqualValues(t, c.windowStart, now.Add(-time.Duration(c.Delay)).Add(-time.Duration(c.Period)))
now = time.Now()
c.updateWindow(now)
// subsequent window uses previous end time as start time
assert.EqualValues(t, c.windowEnd, now.Add(-time.Duration(c.Delay)))
assert.EqualValues(t, c.windowStart, newStartTime)
} | explode_data.jsonl/56721 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 301
} | [
2830,
3393,
4289,
4267,
1155,
353,
8840,
836,
8,
341,
89300,
11,
716,
1669,
882,
8937,
12945,
445,
16,
76,
1138,
33343,
12945,
1669,
2193,
33795,
48148,
692,
1444,
1669,
609,
16055,
14247,
515,
197,
90823,
25,
330,
36136,
14,
2749,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWorkflowError(t *testing.T) {
wf := NewWorkflow("testWorkflowError", nil)
step := func(args interface{}) error {
if args == nil {
return errors.New("Step args cannot be nil")
}
return nil
}
wf.With("VerifyArgsNotNil", step)
err := wf.Start()
assert.Error(t, err)
assert.Equal(t, "Step args cannot be nil", err.Error())
} | explode_data.jsonl/15566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
62768,
1454,
1155,
353,
8840,
836,
8,
341,
6692,
69,
1669,
1532,
62768,
445,
1944,
62768,
1454,
497,
2092,
692,
77093,
1669,
2915,
7356,
3749,
28875,
1465,
341,
197,
743,
2827,
621,
2092,
341,
298,
853,
5975,
7121,
445,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventsWriter_WriteEventsUntilStopped(t *testing.T) {
groupName := "my-log-group"
testCases := map[string]struct {
setUpMocks func(m writeEventMocks)
wantedError error
}{
"error getting log events": {
setUpMocks: func(m writeEventMocks) {
m.logGetter.EXPECT().LogEvents(groupName, gomock.Any(), gomock.Any()).
Return(&cloudwatchlogs.LogEventsOutput{}, errors.New("error getting log events"))
},
wantedError: errors.New("get task log events: error getting log events"),
},
"error describing tasks": {
setUpMocks: func(m writeEventMocks) {
m.logGetter.EXPECT().LogEvents(gomock.Any(), gomock.Any(), gomock.Any()).
Return(&cloudwatchlogs.LogEventsOutput{
Events: []*cloudwatchlogs.Event{},
}, nil).AnyTimes()
m.describer.EXPECT().DescribeTasks("cluster", []string{"task-1", "task-2", "task-3"}).
Return(nil, errors.New("error describing tasks"))
},
wantedError: errors.New("describe tasks: error describing tasks"),
},
"success": {
setUpMocks: func(m writeEventMocks) {
m.logGetter.EXPECT().LogEvents(gomock.Any(), gomock.Any(), gomock.Any()).
Return(&cloudwatchlogs.LogEventsOutput{
Events: []*cloudwatchlogs.Event{},
}, nil).AnyTimes()
m.describer.EXPECT().DescribeTasks("cluster", []string{"task-1", "task-2", "task-3"}).
Return([]*ecs.Task{
{
TaskArn: aws.String("task-1"),
LastStatus: aws.String(ecs.DesiredStatusStopped),
},
{
TaskArn: aws.String("task-2"),
LastStatus: aws.String(ecs.DesiredStatusStopped),
},
{
TaskArn: aws.String("task-3"),
LastStatus: aws.String(ecs.DesiredStatusStopped),
},
}, nil)
},
},
}
now := time.Now()
tomorrow := now.AddDate(0, 0, 1)
theDayAfter := now.AddDate(0, 0, 2)
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
tasks := []*task.Task{
{
TaskARN: "task-1",
ClusterARN: "cluster",
StartedAt: &now,
},
{
TaskARN: "task-2",
ClusterARN: "cluster",
StartedAt: &tomorrow,
},
{
TaskARN: "task-3",
ClusterARN: "cluster",
StartedAt: &theDayAfter,
},
}
mocks := writeEventMocks{
logGetter: mocks.NewMocklogGetter(ctrl),
describer: mocks.NewMockTasksDescriber(ctrl),
}
tc.setUpMocks(mocks)
ew := &TaskClient{
GroupName: groupName,
Tasks: tasks,
Writer: mockWriter{},
EventsLogger: mocks.logGetter,
Describer: mocks.describer,
}
err := ew.WriteEventsUntilStopped()
if tc.wantedError != nil {
require.EqualError(t, tc.wantedError, err.Error())
} else {
require.NoError(t, err)
}
})
}
} | explode_data.jsonl/75654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1304
} | [
2830,
3393,
7900,
6492,
31825,
7900,
24493,
59803,
1155,
353,
8840,
836,
8,
341,
44260,
675,
1669,
330,
2408,
46332,
4351,
698,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
8196,
2324,
72577,
2915,
1255,
3270,
1556,
72577,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDaoResTagCount(t *testing.T) {
var (
c = context.TODO()
oid = int64(0)
tp = int32(0)
)
convey.Convey("ResTagCount", t, func(ctx convey.C) {
count, err := d.ResTagCount(c, oid, tp)
ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(count, convey.ShouldBeGreaterThanOrEqualTo, 0)
})
})
} | explode_data.jsonl/46397 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
12197,
1061,
5668,
2507,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
1444,
256,
284,
2266,
90988,
741,
197,
197,
588,
284,
526,
21,
19,
7,
15,
340,
197,
73423,
220,
284,
526,
18,
17,
7,
15,
340,
197,
340,
37203,
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 TestMultiSiteBundles(t *testing.T) {
assert := require.New(t)
b := newTestSitesBuilder(t)
b.WithConfigFile("toml", `
baseURL = "http://example.com/"
defaultContentLanguage = "en"
[languages]
[languages.en]
weight = 10
contentDir = "content/en"
[languages.nn]
weight = 20
contentDir = "content/nn"
`)
b.WithContent("en/mybundle/index.md", `
---
headless: true
---
`)
b.WithContent("nn/mybundle/index.md", `
---
headless: true
---
`)
b.WithContent("en/mybundle/data.yaml", `data en`)
b.WithContent("en/mybundle/forms.yaml", `forms en`)
b.WithContent("nn/mybundle/data.yaml", `data nn`)
b.WithContent("en/_index.md", `
---
Title: Home
---
Home content.
`)
b.WithContent("en/section-not-bundle/_index.md", `
---
Title: Section Page
---
Section content.
`)
b.WithContent("en/section-not-bundle/single.md", `
---
Title: Section Single
Date: 2018-02-01
---
Single content.
`)
b.Build(BuildCfg{})
b.AssertFileContent("public/nn/mybundle/data.yaml", "data nn")
b.AssertFileContent("public/nn/mybundle/forms.yaml", "forms en")
b.AssertFileContent("public/mybundle/data.yaml", "data en")
b.AssertFileContent("public/mybundle/forms.yaml", "forms en")
assert.False(b.CheckExists("public/nn/nn/mybundle/data.yaml"))
assert.False(b.CheckExists("public/en/mybundle/data.yaml"))
homeEn := b.H.Sites[0].home
assert.NotNil(homeEn)
assert.Equal(2018, homeEn.Date().Year())
b.AssertFileContent("public/section-not-bundle/index.html", "Section Page", "Content: <p>Section content.</p>")
b.AssertFileContent("public/section-not-bundle/single/index.html", "Section Single", "|<p>Single content.</p>")
} | explode_data.jsonl/68131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 655
} | [
2830,
3393,
20358,
17597,
33,
49204,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
1373,
7121,
1155,
340,
2233,
1669,
501,
2271,
93690,
3297,
1155,
340,
2233,
26124,
2648,
1703,
445,
37401,
75,
497,
1565,
271,
3152,
3144,
284,
330,
1254,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseIfStatement(t *testing.T) {
p := createParser(`if x == 2 {
}`)
bvmUtils.Assert(t, isIfStatement(p), "should detect if statement")
parseIfStatement(p)
bvmUtils.AssertNow(t, len(p.errs) == 0, fmt.Sprintln(p.errs))
first := p.scope.Next()
bvmUtils.Assert(t, first.Type() == ast.IfStatement, "Asteroid Errors: Node Error: Wrong node type. ")
} | explode_data.jsonl/49710 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
14463,
2679,
8636,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1855,
6570,
5809,
333,
856,
621,
220,
17,
1476,
197,
27085,
2233,
7338,
4209,
11711,
1155,
11,
374,
2679,
8636,
1295,
701,
330,
5445,
11140,
421,
5114,
1138,
751... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStringToIPNet(t *testing.T) {
ipNetString := "192.168.0.100/24"
ipNetExpected := net.IPNet{
IP: net.IPv4(192, 168, 0, 100),
Mask: net.CIDRMask(24, 32),
}
ipNet := StringToIPNet(ipNetString)
if !reflect.DeepEqual(*ipNet, ipNetExpected) {
t.Errorf("test fails, expected %+v but got %+v", ipNetExpected, ipNet)
}
} | explode_data.jsonl/52247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
703,
1249,
3298,
6954,
1155,
353,
8840,
836,
8,
341,
46531,
6954,
703,
1669,
330,
16,
24,
17,
13,
16,
21,
23,
13,
15,
13,
16,
15,
15,
14,
17,
19,
698,
46531,
6954,
18896,
1669,
4179,
46917,
6954,
515,
197,
197,
3298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseSwitchStatementExclusive(t *testing.T) {
p := createParser(`exclusive switch x {}
`)
bvmUtils.Assert(t, isSwitchStatement(p), "should detect switch statement")
parseSwitchStatement(p)
} | explode_data.jsonl/49722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
14463,
16837,
8636,
70405,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1855,
6570,
5809,
89122,
3398,
856,
5613,
286,
1565,
340,
2233,
7338,
4209,
11711,
1155,
11,
374,
16837,
8636,
1295,
701,
330,
5445,
11140,
3398,
5114,
113... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuild_WithRepositoryAlias(t *testing.T) {
// Dependency repository is aliased in Chart.yaml
checkBuildWithOptionalFields(t, "with-repository-alias", chart.Dependency{
Repository: "@test",
})
} | explode_data.jsonl/24406 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
11066,
62,
2354,
4624,
22720,
1155,
353,
8840,
836,
8,
341,
197,
322,
32977,
12542,
374,
18991,
1475,
304,
21266,
33406,
198,
25157,
11066,
2354,
15309,
8941,
1155,
11,
330,
4197,
5504,
3099,
12,
14956,
497,
9487,
49918,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStackSize(t *testing.T) {
stacker := stack.Stack{}
stacker.Push("First")
stacker.Push("Seconds")
if stacker.Len() != 2 {
t.Errorf("Size of stack should be 2, not %d\n", stacker.Len())
}
stacker.Pop()
if stacker.Len() != 1 {
t.Errorf("Size of stack should be 1, not %d\n", stacker.Len())
}
} | explode_data.jsonl/81420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
74026,
1155,
353,
8840,
836,
8,
341,
48227,
261,
1669,
5611,
58646,
31483,
48227,
261,
34981,
445,
5338,
1138,
48227,
261,
34981,
445,
15343,
5130,
743,
5611,
261,
65819,
368,
961,
220,
17,
341,
197,
3244,
13080,
445,
1695,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTabContainer_Resize_Empty(t *testing.T) {
tabs := container.NewAppTabs()
tabs.Resize(fyne.NewSize(10, 10))
size := tabs.Size()
assert.Equal(t, float32(10), size.Height)
assert.Equal(t, float32(10), size.Width)
} | explode_data.jsonl/32314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
8582,
4502,
62,
30561,
76060,
1595,
1155,
353,
8840,
836,
8,
341,
3244,
3435,
1669,
5476,
7121,
2164,
36985,
741,
3244,
3435,
77707,
955,
81708,
7121,
1695,
7,
16,
15,
11,
220,
16,
15,
1171,
13832,
1669,
22398,
2465,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFormatterObjectArguments(test *testing.T) {
formatted, err := formatter.New().Format("{.Z} {.Y} {.X} {.Z}", struct {
X, Y, Z int
}{
X: 4,
Y: 5,
Z: 6,
}, "b")
assert.NoError(test, err)
assert.Equal(test, "6 5 4 6 b", formatted)
} | explode_data.jsonl/39733 | {
"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,
14183,
1190,
19139,
8623,
353,
8840,
836,
8,
341,
37410,
12127,
11,
1848,
1669,
24814,
7121,
1005,
4061,
13976,
13,
57,
92,
50336,
56,
92,
50336,
55,
92,
50336,
57,
9545,
2036,
341,
197,
22123,
11,
809,
11,
1863,
526,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewClient(t *testing.T) {
// Setup our config
if err := setupConfig(); err != nil {
t.Fatalf("failed to setup config with error: %v", err.Error())
}
// Create our email client
client, err := yoemail.NewClient()
if err != nil {
t.Fatalf("failed to init client with error: %v", err.Error())
}
// Make sure our client type is MailGun
switch client.(type) {
case *yoemail.MailGun:
// Success do nothing
default:
t.Fatalf("invalid client type returned: %v", reflect.TypeOf(client).String())
}
} | explode_data.jsonl/40767 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
3564,
2959,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
1039,
2193,
198,
743,
1848,
1669,
6505,
2648,
2129,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
16091,
311,
6505,
2193,
448,
1465,
25,
1018,
85,
497,
1848,
6141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_MapToMapDeep(t *testing.T) {
type Ids struct {
Id int
Uid int
}
type Base struct {
Ids
Time string
}
type User struct {
Base
Name string
}
params := g.Map{
"key": g.Map{
"id": 1,
"name": "john",
},
}
gtest.C(t, func(t *gtest.T) {
m := (map[string]*User)(nil)
err := gconv.MapToMap(params, &m)
t.Assert(err, nil)
t.Assert(len(m), 1)
t.Assert(m["key"].Id, 1)
t.Assert(m["key"].Name, "john")
})
} | explode_data.jsonl/41427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 237
} | [
2830,
3393,
56992,
1249,
2227,
33464,
1155,
353,
8840,
836,
8,
341,
13158,
5223,
82,
2036,
341,
197,
67211,
220,
526,
198,
197,
15980,
307,
526,
198,
197,
532,
13158,
5351,
2036,
341,
197,
197,
12701,
198,
197,
67567,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFlattenResourceLoadBalancerSubnetSpecInto(t *testing.T) {
_default := map[string]interface{}{
"name": "",
"private_ipv4_address": nil,
"allocation_id": nil,
}
type args struct {
in kops.LoadBalancerSubnetSpec
}
tests := []struct {
name string
args args
want map[string]interface{}
}{
{
name: "default",
args: args{
in: kops.LoadBalancerSubnetSpec{},
},
want: _default,
},
{
name: "Name - default",
args: args{
in: func() kops.LoadBalancerSubnetSpec {
subject := kops.LoadBalancerSubnetSpec{}
subject.Name = ""
return subject
}(),
},
want: _default,
},
{
name: "PrivateIpv4Address - default",
args: args{
in: func() kops.LoadBalancerSubnetSpec {
subject := kops.LoadBalancerSubnetSpec{}
subject.PrivateIPv4Address = nil
return subject
}(),
},
want: _default,
},
{
name: "AllocationID - default",
args: args{
in: func() kops.LoadBalancerSubnetSpec {
subject := kops.LoadBalancerSubnetSpec{}
subject.AllocationID = nil
return subject
}(),
},
want: _default,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := map[string]interface{}{}
FlattenResourceLoadBalancerSubnetSpecInto(tt.args.in, got)
if diff := cmp.Diff(tt.want, got); diff != "" {
t.Errorf("FlattenResourceLoadBalancerSubnetSpec() mismatch (-want +got):\n%s", diff)
}
})
}
} | explode_data.jsonl/3625 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 671
} | [
2830,
3393,
3882,
14456,
4783,
5879,
93825,
3136,
4711,
8327,
26591,
1155,
353,
8840,
836,
8,
341,
197,
9993,
1669,
2415,
14032,
31344,
67066,
197,
197,
31486,
788,
338,
8324,
197,
197,
1,
1996,
49378,
19,
6744,
788,
2092,
345,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReplaceFileTarWrapper(t *testing.T) {
filesInArchive := 20
testcases := []struct {
doc string
filename string
modifier TarModifierFunc
expected string
fileCount int
}{
{
doc: "Modifier creates a new file",
filename: "newfile",
modifier: createModifier(t),
expected: "the new content",
fileCount: filesInArchive + 1,
},
{
doc: "Modifier replaces a file",
filename: "file-2",
modifier: createOrReplaceModifier,
expected: "the new content",
fileCount: filesInArchive,
},
{
doc: "Modifier replaces the last file",
filename: fmt.Sprintf("file-%d", filesInArchive-1),
modifier: createOrReplaceModifier,
expected: "the new content",
fileCount: filesInArchive,
},
{
doc: "Modifier appends to a file",
filename: "file-3",
modifier: appendModifier,
expected: "fooo\nnext line",
fileCount: filesInArchive,
},
}
for _, testcase := range testcases {
sourceArchive, cleanup := buildSourceArchive(t, filesInArchive)
defer cleanup()
resultArchive := ReplaceFileTarWrapper(
sourceArchive,
map[string]TarModifierFunc{testcase.filename: testcase.modifier})
actual := readFileFromArchive(t, resultArchive, testcase.filename, testcase.fileCount, testcase.doc)
assert.Check(t, is.Equal(testcase.expected, actual), testcase.doc)
}
} | explode_data.jsonl/79261 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 556
} | [
2830,
3393,
23107,
1703,
62733,
11542,
1155,
353,
8840,
836,
8,
341,
74075,
641,
42502,
1669,
220,
17,
15,
198,
18185,
23910,
1669,
3056,
1235,
341,
197,
59536,
981,
914,
198,
197,
66434,
220,
914,
198,
197,
42228,
3049,
220,
23959,
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... | 2 |
func TestBuild(t *testing.T) {
ensure := ensure.New(t)
type Mocks struct {
LambgoFileLoader *mock_lambgofile.MockLoaderAPI
Builder *mock_builder.MockLambdaBuilderAPI
}
exampleError := errors.New("something went wrong")
defaultWd := func() (string, error) {
return "/test", nil
}
table := []struct {
Name string
ExpectedError error
Flags []string
Getwd func() (string, error)
Mocks *Mocks
SetupMocks func(*Mocks)
Subject *cmd.App
}{
{
Name: "with valid execution",
Getwd: defaultWd,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().
LoadConfig("/test").
Return(&lambgofile.Config{
RootPath: "/some/root/path",
}, nil)
m.Builder.EXPECT().
BuildBinaries(&lambgofile.Config{
RootPath: "/some/root/path",
}).
Return(nil)
},
},
{
Name: "with valid execution: disable parallel generation",
Flags: []string{"--disable-parallel"},
Getwd: defaultWd,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().
LoadConfig("/test").
Return(&lambgofile.Config{
RootPath: "/some/root/path",
}, nil)
m.Builder.EXPECT().
BuildBinaries(&lambgofile.Config{
DisableParallelBuild: true,
RootPath: "/some/root/path",
}).
Return(nil)
},
},
{
Name: "with valid execution: filter using --only flag",
Flags: []string{"--only", "abc/123", "--only", "xyz/456"},
Getwd: defaultWd,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().
LoadConfig("/test").
Return(&lambgofile.Config{
RootPath: "/some/root/path",
BuildPaths: []string{"first/0", "abc/123", "xyz/456", "qwerty/789"},
}, nil)
m.Builder.EXPECT().
BuildBinaries(&lambgofile.Config{
RootPath: "/some/root/path",
BuildPaths: []string{"abc/123", "xyz/456"},
}).
Return(nil)
},
},
{
Name: "with valid execution: filter using --only flag with directory filter",
Flags: []string{"--only", "nested/", "--only", "xyz/456"},
Getwd: defaultWd,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().
LoadConfig("/test").
Return(&lambgofile.Config{
RootPath: "/some/root/path",
BuildPaths: []string{"first/0", "abc/123", "xyz/456", "qwerty/789", "nested/one", "nested/two"},
}, nil)
m.Builder.EXPECT().
BuildBinaries(&lambgofile.Config{
RootPath: "/some/root/path",
BuildPaths: []string{"nested/one", "nested/two", "xyz/456"},
}).
Return(nil)
},
},
{
Name: "when error loading working directory",
Getwd: func() (string, error) { return "", exampleError },
ExpectedError: exampleError,
},
{
Name: "when cannot load config",
Getwd: defaultWd,
ExpectedError: exampleError,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().LoadConfig("/test").Return(nil, exampleError)
},
},
{
Name: "when cannot filter a build path with --only",
Flags: []string{"--only", "abc/123", "--only", "xyz"}, // xyz doesn't end in a /, thus it should not prefix match
Getwd: defaultWd,
ExpectedError: cmd.ErrCannotFilterBuildPaths,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().
LoadConfig("/test").
Return(&lambgofile.Config{
RootPath: "/some/root/path",
BuildPaths: []string{"abc/123", "xyz/456"},
}, nil)
},
},
{
Name: "when cannot generate mocks",
Getwd: defaultWd,
ExpectedError: exampleError,
SetupMocks: func(m *Mocks) {
m.LambgoFileLoader.EXPECT().
LoadConfig("/test").
Return(&lambgofile.Config{
RootPath: "/some/root/path",
}, nil)
m.Builder.EXPECT().
BuildBinaries(&lambgofile.Config{
RootPath: "/some/root/path",
}).
Return(exampleError)
},
},
}
ensure.RunTableByIndex(table, func(ensure ensurepkg.Ensure, i int) {
entry := table[i]
entry.Subject.Getwd = entry.Getwd
err := entry.Subject.Run(append([]string{"lambgo", "build"}, entry.Flags...))
ensure(err).IsError(entry.ExpectedError)
})
} | explode_data.jsonl/63633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1953
} | [
2830,
3393,
11066,
1155,
353,
8840,
836,
8,
341,
197,
27289,
1669,
5978,
7121,
1155,
692,
13158,
14563,
82,
2036,
341,
197,
15070,
2969,
3346,
1703,
9181,
353,
16712,
907,
2969,
70,
65273,
24664,
9181,
7082,
198,
197,
197,
3297,
688,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddHeaders(t *testing.T) {
bc := newTestChain(t)
defer bc.Close()
lastBlock := bc.topBlock.Load().(*block.Block)
h1 := newBlock(bc.config, 1, lastBlock.Hash()).Header()
h2 := newBlock(bc.config, 2, h1.Hash()).Header()
h3 := newBlock(bc.config, 3, h2.Hash()).Header()
require.NoError(t, bc.AddHeaders())
require.NoError(t, bc.AddHeaders(h1, h2))
require.NoError(t, bc.AddHeaders(h2, h3))
assert.Equal(t, h3.Index, bc.HeaderHeight())
assert.Equal(t, uint32(0), bc.BlockHeight())
assert.Equal(t, h3.Hash(), bc.CurrentHeaderHash())
// Add them again, they should not be added.
require.NoError(t, bc.AddHeaders(h3, h2, h1))
assert.Equal(t, h3.Index, bc.HeaderHeight())
assert.Equal(t, uint32(0), bc.BlockHeight())
assert.Equal(t, h3.Hash(), bc.CurrentHeaderHash())
h4 := newBlock(bc.config, 4, h3.Hash().Reverse()).Header()
h5 := newBlock(bc.config, 5, h4.Hash()).Header()
assert.Error(t, bc.AddHeaders(h4, h5))
assert.Equal(t, h3.Index, bc.HeaderHeight())
assert.Equal(t, uint32(0), bc.BlockHeight())
assert.Equal(t, h3.Hash(), bc.CurrentHeaderHash())
h6 := newBlock(bc.config, 4, h3.Hash()).Header()
h6.Script.InvocationScript = nil
assert.Error(t, bc.AddHeaders(h6))
assert.Equal(t, h3.Index, bc.HeaderHeight())
assert.Equal(t, uint32(0), bc.BlockHeight())
assert.Equal(t, h3.Hash(), bc.CurrentHeaderHash())
} | explode_data.jsonl/74536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 561
} | [
2830,
3393,
2212,
10574,
1155,
353,
8840,
836,
8,
341,
2233,
66,
1669,
501,
2271,
18837,
1155,
340,
16867,
17916,
10421,
741,
33096,
4713,
1669,
17916,
8772,
4713,
13969,
1005,
4071,
4574,
28477,
340,
9598,
16,
1669,
501,
4713,
96055,
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 TestSelectEncoding(t *testing.T) {
tests := []struct {
optionalName string
given string
expected string
isErr bool
}{
{given: "", expected: "identity", optionalName: "is empty but present, only identity"},
{given: "*", expected: "*"},
{given: "gzip", expected: "gzip"},
{given: "deflate", expected: "deflate"},
{given: "whatever", expected: "", isErr: true, optionalName: "whatever, not supported"},
{given: "whatever, *", expected: "*", optionalName: "whatever, but also a star"},
{given: "gzip, deflate", expected: "gzip"},
{given: "whatever, gzip, deflate", expected: "gzip"},
{given: "gzip, whatever, deflate", expected: "gzip"},
{given: "gzip, deflate, whatever", expected: "gzip"},
{given: "gzip,deflate", expected: "gzip"},
{given: "gzip,whatever,deflate", expected: "gzip"},
{given: "whatever,gzip,deflate", expected: "gzip"},
{given: "gzip,deflate,whatever", expected: "gzip"},
{given: "deflate, gzip", expected: "deflate"},
{given: "whatever, deflate, gzip", expected: "deflate"},
{given: "deflate, whatever, gzip", expected: "deflate"},
{given: "deflate, gzip, whatever", expected: "deflate"},
{given: "deflate, gzip", expected: "deflate"},
{given: "whatever,deflate,gzip", expected: "deflate"},
{given: "deflate,whatever,gzip", expected: "deflate"},
{given: "deflate,gzip,whatever", expected: "deflate"},
{given: "gzip;q=1.0, deflate;q=1.0", expected: "gzip", optionalName: "equal weights"},
{given: "deflate;q=1.0, gzip;q=1.0", expected: "deflate", optionalName: "equal weights 2"},
{given: "gzip;q=1.0, deflate;q=0.5", expected: "gzip"},
{given: "gzip;q=1.0, deflate;q=0.5, *;q=0.2", expected: "gzip"},
{given: "deflate;q=1.0, gzip;q=0.5", expected: "deflate"},
{given: "deflate;q=1.0, gzip;q=0.5, *;q=0.2", expected: "deflate"},
{given: "gzip;q=0.5, deflate;q=1.0", expected: "deflate"},
{given: "gzip;q=0.5, deflate;q=1.0, *;q=0.2", expected: "deflate"},
{given: "deflate;q=0.5, gzip;q=1.0", expected: "gzip"},
{given: "deflate;q=0.5, gzip;q=1.0, *;q=0.2", expected: "gzip"},
{given: "whatever;q=1.0, *;q=0.2", expected: "*"},
{given: "deflate, gzip;q=1.0", expected: "deflate"},
{given: "deflate, gzip;q=0.5", expected: "deflate"},
{given: "deflate;q=0.5, gzip", expected: "gzip"},
{given: "deflate;q=0.5, gzip;q=-0.5", expected: "deflate"},
{given: "deflate;q=0.5, gzip;q=1.5", expected: "gzip"},
}
for _, tc := range tests {
t.Run(fmt.Sprintf("encoding %q is parsed as %s ; error is expected: %t ; %s", tc.given, tc.expected, tc.isErr, tc.optionalName), func(t *testing.T) {
// when
result, err := parseAcceptEncoding(tc.given)
// then
assert.Equal(t, tc.isErr, err != nil)
assert.Equal(t, tc.expected, result)
})
}
} | explode_data.jsonl/52419 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1191
} | [
2830,
3393,
3379,
14690,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
12807,
675,
914,
198,
197,
3174,
2071,
286,
914,
198,
197,
42400,
257,
914,
198,
197,
19907,
7747,
286,
1807,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBoxFillWriterDoesNotAlterForeground(t *testing.T) {
bfw := createBoxFillWriter(NewRect(1, 1, 5, 5), termbox.ColorCyan)
for x := 0; x < 10; x++ {
for y := 0; y < 10; y++ {
fgAttribute, _ := bfw(termbox.ColorWhite, termbox.ColorBlack, point{x, y})
assert.Equal(t, termbox.ColorWhite, fgAttribute,
"Expected (%d,%d) to not have changed foreground colour.", x, y)
}
}
} | explode_data.jsonl/30728 | {
"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,
1611,
14449,
6492,
21468,
2623,
74290,
25982,
1155,
353,
8840,
836,
8,
341,
2233,
20564,
1669,
1855,
1611,
14449,
6492,
35063,
4415,
7,
16,
11,
220,
16,
11,
220,
20,
11,
220,
20,
701,
4647,
2011,
6669,
34,
8339,
692,
202... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRefreshWithUpdateError(t *testing.T) {
defer monkeyPatchGopherCloudAuth().Unpatch()
defer monkeyPatchGopherCloudComputeClientWithError().Unpatch()
clouds := fakeClouds()
errs := clouds.Refresh()
assert.NotEmpty(t, errs)
} | explode_data.jsonl/57476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
14567,
2354,
4289,
1454,
1155,
353,
8840,
836,
8,
341,
16867,
38703,
43622,
38,
16940,
16055,
5087,
1005,
1806,
3400,
741,
16867,
38703,
43622,
38,
16940,
16055,
46254,
2959,
66102,
1005,
1806,
3400,
741,
197,
12361,
82,
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 |
func TestInMemoryChannelGetCondition(t *testing.T) {
tests := []struct {
name string
cs *InMemoryChannelStatus
condQuery apis.ConditionType
want *apis.Condition
}{{
name: "single condition",
cs: &InMemoryChannelStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{
condReady,
},
},
},
condQuery: apis.ConditionReady,
want: &condReady,
}, {
name: "unknown condition",
cs: &InMemoryChannelStatus{
Status: duckv1beta1.Status{
Conditions: []apis.Condition{
condReady,
condDispatcherNotReady,
},
},
},
condQuery: apis.ConditionType("foo"),
want: nil,
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := test.cs.GetCondition(test.condQuery)
if diff := cmp.Diff(test.want, got); diff != "" {
t.Errorf("unexpected condition (-want, +got) = %v", diff)
}
})
}
} | explode_data.jsonl/22195 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
641,
10642,
9629,
1949,
10547,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
71899,
286,
353,
641,
10642,
9629,
2522,
198,
197,
197,
1297,
2859,
97723,
75134,
929,
198,
197,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSyncer_isThisCluster(t *testing.T) {
tests := []struct {
name string
managedClusterName string
placement v1alpha1.Placement
want bool
}{
{"same cluster single placement", "mycluster1", v1alpha1.Placement{Clusters: []v1alpha1.Cluster{{Name: "mycluster1"}}}, true},
{"same cluster multi-placement", "mycluster1", v1alpha1.Placement{Clusters: []v1alpha1.Cluster{{Name: "othercluster"}, {Name: "mycluster1"}}}, true},
{"different cluster single placement", "mycluster1", v1alpha1.Placement{Clusters: []v1alpha1.Cluster{{Name: "othercluster"}}}, false},
{"different cluster multi-placement", "mycluster1", v1alpha1.Placement{Clusters: []v1alpha1.Cluster{{Name: "othercluster"}, {Name: "mycluster2"}}}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &Syncer{
ManagedClusterName: tt.managedClusterName,
}
if got := s.isThisCluster(tt.placement); got != tt.want {
t.Errorf("isThisCluster() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/42634 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 439
} | [
2830,
3393,
12154,
261,
6892,
1986,
28678,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
2290,
914,
198,
197,
197,
25270,
28678,
675,
914,
198,
197,
197,
16101,
688,
348,
16,
7141,
16,
21368,
6346,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_convert(t *testing.T) {
s1 := convert("PAYPALISHIRING", 3)
if s1 != "PAHNAPLSIIGYIR" {
t.Error(s1, "PAHNAPLSIIGYIR")
}
} | explode_data.jsonl/59809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
34910,
1155,
353,
8840,
836,
8,
341,
1903,
16,
1669,
5508,
445,
59897,
73342,
16444,
2801,
1718,
497,
220,
18,
340,
743,
274,
16,
961,
330,
8041,
43165,
2537,
7268,
40,
1914,
56,
2801,
1,
341,
197,
3244,
6141,
1141,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestValidateAndBuildNodeBNameKeySuccess(t *testing.T) {
name := "name"
prefix := "RAN"
delimiter := ":"
key, err := ValidateAndBuildNodeBNameKey(name)
if err != nil{
t.Errorf("#utils_test.TestValidateAndBuildNodeBNameKey - failed to validate key parameter")
}
assert.Contains(t, key, name)
assert.Contains(t, key, delimiter)
assert.Contains(t, key, prefix)
} | explode_data.jsonl/33036 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
17926,
3036,
11066,
1955,
33,
675,
1592,
7188,
1155,
353,
8840,
836,
8,
341,
11609,
1669,
330,
606,
698,
3223,
5060,
1669,
330,
49,
1093,
698,
69509,
17700,
1669,
13022,
698,
23634,
11,
1848,
1669,
23282,
3036,
11066,
1955,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetFlavorRaid(t *testing.T) {
testFlavorId := "BBC-G4-01S"
rep, err := BBC_CLIENT.GetFlavorRaid(testFlavorId)
fmt.Println(rep)
ExpectEqual(t.Errorf, err, nil)
} | explode_data.jsonl/4055 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
1949,
3882,
3292,
49,
3779,
1155,
353,
8840,
836,
8,
341,
18185,
3882,
3292,
764,
1669,
330,
66755,
12010,
19,
12,
15,
16,
50,
698,
73731,
11,
1848,
1669,
18096,
22521,
2234,
3882,
3292,
49,
3779,
8623,
3882,
3292,
764,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_addSubscriber_Paracheck(t *testing.T) {
chain, mock33 := createBlockChain(t)
defer mock33.Close()
subscribe := new(types.PushSubscribeReq)
subscribe.LastSequence = 1
err := chain.procSubscribePush(subscribe)
assert.Equal(t, err, types.ErrInvalidParam)
} | explode_data.jsonl/61712 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
2891,
40236,
1088,
277,
1777,
377,
1155,
353,
8840,
836,
8,
341,
197,
8819,
11,
7860,
18,
18,
1669,
1855,
4713,
18837,
1155,
340,
16867,
7860,
18,
18,
10421,
741,
28624,
6273,
1669,
501,
52613,
34981,
28573,
27234,
340,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntExpressionBIT_OR(t *testing.T) {
assertClauseSerialize(t, table1ColInt.BIT_OR(table2ColInt), "(table1.col_int | table2.col_int)")
assertClauseSerialize(t, table1ColInt.BIT_OR(Int(11)), "(table1.col_int | $1)", int64(11))
} | explode_data.jsonl/41463 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
1072,
9595,
20917,
19834,
1155,
353,
8840,
836,
8,
341,
6948,
28482,
15680,
1155,
11,
1965,
16,
6127,
1072,
1785,
952,
19834,
15761,
17,
6127,
1072,
701,
11993,
2005,
16,
13414,
4042,
760,
1965,
17,
13414,
4042,
19107,
6948,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIDPCanHandleUnencryptedResponse(t *testing.T) {
test := NewIdentifyProviderTest(t)
test.IDP.SessionProvider = &mockSessionProvider{
GetSessionFunc: func(w http.ResponseWriter, r *http.Request, req *IdpAuthnRequest) *Session {
return &Session{ID: "f00df00df00d", UserName: "alice"}
},
}
metadata := EntityDescriptor{}
err := xml.Unmarshal(
golden.Get(t, "TestIDPCanHandleUnencryptedResponse_idp_metadata.xml"),
&metadata)
assert.Check(t, err)
test.IDP.ServiceProviderProvider = &mockServiceProviderProvider{
GetServiceProviderFunc: func(r *http.Request, serviceProviderID string) (*EntityDescriptor, error) {
if serviceProviderID == "https://gitlab.example.com/users/saml/metadata" {
return &metadata, nil
}
return nil, os.ErrNotExist
},
}
req := IdpAuthnRequest{
Now: TimeNow(),
IDP: &test.IDP,
RequestBuffer: golden.Get(t, "TestIDPCanHandleUnencryptedResponse_request"),
}
req.HTTPRequest, _ = http.NewRequest("POST", "http://idp.example.com/saml/sso", nil)
err = req.Validate()
assert.Check(t, err)
err = DefaultAssertionMaker{}.MakeAssertion(&req, &Session{
ID: "f00df00df00d",
UserName: "alice",
})
assert.Check(t, err)
err = req.MakeAssertionEl()
assert.Check(t, err)
err = req.MakeResponse()
assert.Check(t, err)
doc := etree.NewDocument()
doc.SetRoot(req.ResponseEl)
doc.Indent(2)
responseStr, _ := doc.WriteToString()
golden.Assert(t, responseStr, t.Name()+"_response")
} | explode_data.jsonl/19836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 590
} | [
2830,
3393,
915,
4872,
276,
6999,
1806,
36444,
2582,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
1532,
28301,
1437,
5179,
2271,
1155,
340,
18185,
9910,
47,
20674,
5179,
284,
609,
16712,
5283,
5179,
515,
197,
37654,
5283,
9626,
25,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMakerGhostingAfterTakerRedeem(t *testing.T) {
tLog.Info("=== SETUP")
cancelCtx, err := setup()
if err != nil {
t.Fatal(err)
}
tLog.Info("=== SETUP COMPLETED")
defer teardown(cancelCtx)
var qty, rate uint64 = 1 * lotSize, 250 * rateStep // 10 DCR at 0.00025 BTC/DCR
client1.isSeller, client2.isSeller = true, false
c1OrderID, c2OrderID, err := placeTestOrders(qty, rate)
if err != nil {
t.Fatal(err)
}
// Monitor trades and stop at order.TakerSwapCast
monitorTrades, ctx := errgroup.WithContext(context.Background())
monitorTrades.Go(func() error {
return monitorOrderMatchingAndTradeNeg(ctx, client1, c1OrderID, order.TakerSwapCast)
})
monitorTrades.Go(func() error {
return monitorOrderMatchingAndTradeNeg(ctx, client2, c2OrderID, order.TakerSwapCast)
})
if err = monitorTrades.Wait(); err != nil {
t.Fatal(err)
}
// Resume trades but disable Maker's ability to notify the server
// after redeeming Taker's swap.
resumeTrade := func(ctx context.Context, client *tClient, orderID string) error {
tracker, err := client.findOrder(orderID)
if err != nil {
return err
}
finalStatus := order.MatchComplete
tracker.mtx.Lock()
for _, match := range tracker.matches {
side, status := match.Side, match.Status
client.log("trade %s paused at %s", token(match.MatchID[:]), status)
if side == order.Maker {
client.log("%s: disconnecting DEX before redeeming Taker's swap", side)
client.dc().connMaster.Disconnect()
finalStatus = order.MakerRedeemed // maker shouldn't get past this state
} else {
client.log("%s: resuming trade negotiations to audit Maker's redeem", side)
client.noRedeemWait = true
}
// Resume maker to redeem even though the redeem request to server
// will fail (disconnected) after the redeem bcast.
match.swapErr = nil
}
tracker.mtx.Unlock()
// force next action since trade.tick() will not be called for disconnected dcs.
if _, err = client.core.tick(tracker); err != nil {
client.log("tick failure: %v", err)
}
// Propagation to miners can take some time after the send RPC
// completes, especially with SPV wallets, so wait a bit before mining
// blocks in monitorTrackedTrade.
time.Sleep(sleepFactor * time.Second)
return monitorTrackedTrade(ctx, client, tracker, finalStatus)
}
resumeTrades, ctx := errgroup.WithContext(context.Background())
resumeTrades.Go(func() error {
return resumeTrade(ctx, client1, c1OrderID)
})
resumeTrades.Go(func() error {
return resumeTrade(ctx, client2, c2OrderID)
})
if err = resumeTrades.Wait(); err != nil {
t.Fatal(err)
}
// Allow some time for balance changes to be properly reported.
// There is usually a split-second window where a locked output
// has been spent but the spending tx is still in mempool. This
// will cause the txout to be included in the wallets locked
// balance, causing a higher than actual balance report.
time.Sleep(4 * sleepFactor * time.Second)
for _, client := range clients {
if err = client.assertBalanceChanges(); err != nil {
t.Fatal(err)
}
}
tLog.Infof("Trades completed. Maker went dark at %s, Taker continued till %s.",
order.MakerRedeemed, order.MatchComplete)
} | explode_data.jsonl/30473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1112
} | [
2830,
3393,
33259,
64686,
287,
6025,
51,
4407,
6033,
68,
336,
1155,
353,
8840,
836,
8,
341,
3244,
2201,
20132,
445,
8707,
90857,
1138,
84441,
23684,
11,
1848,
1669,
6505,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandshakeClientECDHEECDSAAES(t *testing.T) {
test := &clientTest{
name: "ECDHE-ECDSA-AES",
args: []string{"-cipher", "ECDHE-ECDSA-AES128-SHA"},
cert: testECDSACertificate,
key: testECDSAPrivateKey,
}
runClientTestTLS10(t, test)
runClientTestTLS11(t, test)
runClientTestTLS12(t, test)
} | explode_data.jsonl/27694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
2314,
29661,
2959,
36,
6484,
1799,
7498,
5936,
6029,
1570,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
609,
2972,
2271,
515,
197,
11609,
25,
330,
36,
6484,
1799,
12,
7498,
72638,
6691,
1570,
756,
197,
31215,
25,
3056,
917,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSyncer_SyncAny_reject_format(t *testing.T) {
syncer, connSnapshot := setupOfferSyncer(t)
// s22 is tried first, which reject s22 and s12, then s11 will abort.
s22 := &snapshot{Height: 2, Format: 2, Chunks: 3, Hash: []byte{1, 2, 3}}
s12 := &snapshot{Height: 1, Format: 2, Chunks: 3, Hash: []byte{1, 2, 3}}
s11 := &snapshot{Height: 1, Format: 1, Chunks: 3, Hash: []byte{1, 2, 3}}
_, err := syncer.AddSnapshot(simplePeer("id"), s22)
require.NoError(t, err)
_, err = syncer.AddSnapshot(simplePeer("id"), s12)
require.NoError(t, err)
_, err = syncer.AddSnapshot(simplePeer("id"), s11)
require.NoError(t, err)
connSnapshot.On("OfferSnapshotSync", abci.RequestOfferSnapshot{
Snapshot: toABCI(s22), AppHash: []byte("app_hash"),
}).Once().Return(&abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_REJECT_FORMAT}, nil)
connSnapshot.On("OfferSnapshotSync", abci.RequestOfferSnapshot{
Snapshot: toABCI(s11), AppHash: []byte("app_hash"),
}).Once().Return(&abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ABORT}, nil)
_, _, err = syncer.SyncAny(0)
assert.Equal(t, errAbort, err)
connSnapshot.AssertExpectations(t)
} | explode_data.jsonl/46288 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 466
} | [
2830,
3393,
12154,
261,
1098,
1721,
8610,
1288,
583,
8955,
1155,
353,
8840,
836,
8,
341,
1903,
1721,
261,
11,
4534,
15009,
1669,
6505,
39462,
12154,
261,
1155,
692,
197,
322,
274,
17,
17,
374,
6679,
1156,
11,
892,
7850,
274,
17,
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 TestCommandRunHappy(t *testing.T) {
testDir, err := initTestFiles(map[string]string{
"foo.yaml": `
pipeline:
processors:
- text:
ignored: this field is ignored
operator: to_upper`,
"foo_benthos_test.yaml": `
tests:
- name: example test
target_processors: '/pipeline/processors'
environment: {}
input_batch:
- content: 'example content'
output_batches:
-
- content_equals: EXAMPLE CONTENT`,
"bar.yaml": `
pipeline:
processors:
- text:
operator: to_upper`,
"bar_benthos_test.yaml": `
tests:
- name: example test
target_processors: '/pipeline/processors'
environment: {}
input_batch:
- content: 'example content'
output_batches:
-
- content_equals: example content`,
})
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(testDir)
if !test.Run(filepath.Join(testDir, "foo.yaml"), "_benthos_test", false) {
t.Error("Unexpected result")
}
if test.Run(filepath.Join(testDir, "foo.yaml"), "_benthos_test", true) {
t.Error("Unexpected result")
}
if test.Run(testDir, "_benthos_test", true) {
t.Error("Unexpected result")
}
} | explode_data.jsonl/34067 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 487
} | [
2830,
3393,
4062,
6727,
32847,
1155,
353,
8840,
836,
8,
341,
18185,
6184,
11,
1848,
1669,
2930,
2271,
10809,
9147,
14032,
30953,
515,
197,
197,
1,
7975,
33406,
788,
22074,
51258,
510,
220,
36586,
510,
220,
481,
1467,
510,
414,
12036,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDataSourcesFailure(t *testing.T) {
Convey("Given a data source", t, func() {
ctx := NewContext(nil)
srcs := newDataSources(NTBox, "test_component")
r, s := newPipe("test", 1)
srcs.add("test_node", r)
Reset(func() {
s.close()
})
stopped := make(chan error, 1)
go func() {
stopped <- srcs.pour(ctx, WriterFunc(func(ctx *Context, t *Tuple) error {
return errors.New("error")
}), 4)
}()
srcs.state.Wait(TSRunning)
Reset(func() {
srcs.stop(ctx)
})
t := &Tuple{
InputName: "some_component",
Data: data.Map{
"v": data.Int(1),
},
}
Convey("When writing a tuple to it and the connected node returns an error", func() {
So(s.Write(ctx, t), ShouldBeNil)
srcs.stop(ctx)
So(<-stopped, ShouldBeNil)
Convey("Then numError should be increased", func() {
So(srcs.numErrors, ShouldEqual, 1)
})
})
})
} | explode_data.jsonl/38416 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
93200,
32200,
17507,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
264,
821,
2530,
497,
259,
11,
2915,
368,
341,
197,
20985,
1669,
1532,
1972,
27907,
340,
197,
41144,
82,
1669,
51523,
32200,
7,
6408,
1611,
11,
330,
1944... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCryptoUnboxBytes32NoEncryptionKey(t *testing.T) {
tc := SetupEngineTest(t, "crypto")
defer tc.Cleanup()
secretUI := &libkb.TestSecretUI{}
_, err := UnboxBytes32(tc.G, secretUI, keybase1.UnboxBytes32Arg{})
if _, ok := err.(libkb.SelfNotFoundError); !ok {
t.Errorf("expected SelfNotFoundError, got %v", err)
}
} | explode_data.jsonl/16764 | {
"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,
58288,
1806,
2011,
7078,
18,
17,
2753,
79239,
1592,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
18626,
4571,
2271,
1155,
11,
330,
35772,
1138,
16867,
17130,
727,
60639,
2822,
197,
20474,
2275,
1669,
609,
2740,
21310,
8787,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestHTTPServerWSRateLimit(t *testing.T) {
t.Parallel()
reg := apiRegMutWrapper{mut: &http.ServeMux{}}
rlConf := ratelimit.NewConfig()
rlConf.Type = ratelimit.TypeLocal
rlConf.Local.Count = 1
rlConf.Local.Interval = "60s"
mgrConf := manager.NewConfig()
mgrConf.RateLimits["foorl"] = rlConf
mgr, err := manager.New(mgrConf, reg, log.Noop(), metrics.Noop())
if err != nil {
t.Fatal(err)
}
conf := input.NewConfig()
conf.HTTPServer.WSPath = "/testws"
conf.HTTPServer.WSWelcomeMessage = "test welcome"
conf.HTTPServer.WSRateLimitMessage = "test rate limited"
conf.HTTPServer.RateLimit = "foorl"
h, err := input.NewHTTPServer(conf, mgr, log.Noop(), metrics.Noop())
if err != nil {
t.Fatal(err)
}
server := httptest.NewServer(reg.mut)
defer server.Close()
purl, err := url.Parse(server.URL + "/testws")
if err != nil {
t.Fatal(err)
}
purl.Scheme = "ws"
var client *websocket.Conn
if client, _, err = websocket.DefaultDialer.Dial(purl.String(), http.Header{}); err != nil {
t.Fatal(err)
}
go func() {
var ts types.Transaction
select {
case ts = <-h.TransactionChan():
case <-time.After(time.Second):
t.Error("Timed out waiting for message")
}
select {
case ts.ResponseChan <- response.NewAck():
case <-time.After(time.Second):
t.Error("Timed out waiting for response")
}
}()
var msgBytes []byte
if _, msgBytes, err = client.ReadMessage(); err != nil {
t.Fatal(err)
}
if exp, act := "test welcome", string(msgBytes); exp != act {
t.Errorf("Unexpected welcome message: %v != %v", act, exp)
}
if err = client.WriteMessage(
websocket.BinaryMessage, []byte("hello world"),
); err != nil {
t.Fatal(err)
}
if err = client.WriteMessage(
websocket.BinaryMessage, []byte("hello world"),
); err != nil {
t.Fatal(err)
}
if _, msgBytes, err = client.ReadMessage(); err != nil {
t.Fatal(err)
}
if exp, act := "test rate limited", string(msgBytes); exp != act {
t.Errorf("Unexpected rate limit message: %v != %v", act, exp)
}
h.CloseAsync()
if err := h.WaitForClose(time.Second * 5); err != nil {
t.Error(err)
}
} | explode_data.jsonl/40363 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 841
} | [
2830,
3393,
9230,
5475,
7433,
11564,
16527,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
37013,
1669,
6330,
3477,
51440,
11542,
90,
6984,
25,
609,
1254,
83535,
44,
2200,
6257,
630,
197,
2381,
15578,
1669,
11244,
301,
2353,
712... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSHAAndTagAndVersion(t *testing.T) {
{
sset, err := makeStatefulSet(&monitoringv1.Alertmanager{
Spec: monitoringv1.AlertmanagerSpec{
Tag: "my-unrelated-tag",
Version: "v0.15.3",
},
}, defaultTestConfig, "")
if err != nil {
t.Fatalf("Unexpected error while making StatefulSet: %v", err)
}
image := sset.Spec.Template.Spec.Containers[0].Image
expected := "quay.io/prometheus/alertmanager:my-unrelated-tag"
if image != expected {
t.Fatalf("Unexpected container image.\n\nExpected: %s\n\nGot: %s", expected, image)
}
}
{
sset, err := makeStatefulSet(&monitoringv1.Alertmanager{
Spec: monitoringv1.AlertmanagerSpec{
SHA: "7384a79f4b4991bf8269e7452390249b7c70bcdd10509c8c1c6c6e30e32fb324",
Tag: "my-unrelated-tag",
Version: "v0.15.3",
},
}, defaultTestConfig, "")
if err != nil {
t.Fatalf("Unexpected error while making StatefulSet: %v", err)
}
image := sset.Spec.Template.Spec.Containers[0].Image
expected := "quay.io/prometheus/alertmanager@sha256:7384a79f4b4991bf8269e7452390249b7c70bcdd10509c8c1c6c6e30e32fb324"
if image != expected {
t.Fatalf("Unexpected container image.\n\nExpected: %s\n\nGot: %s", expected, image)
}
}
{
image := "my-registry/alertmanager:latest"
sset, err := makeStatefulSet(&monitoringv1.Alertmanager{
Spec: monitoringv1.AlertmanagerSpec{
SHA: "7384a79f4b4991bf8269e7452390249b7c70bcdd10509c8c1c6c6e30e32fb324",
Tag: "my-unrelated-tag",
Version: "v0.15.3",
Image: &image,
},
}, defaultTestConfig, "")
if err != nil {
t.Fatalf("Unexpected error while making StatefulSet: %v", err)
}
resultImage := sset.Spec.Template.Spec.Containers[0].Image
expected := "my-registry/alertmanager:latest"
if resultImage != expected {
t.Fatalf("Unexpected container image.\n\nExpected: %s\n\nGot: %s", expected, resultImage)
}
}
} | explode_data.jsonl/25251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 831
} | [
2830,
3393,
33145,
3036,
5668,
3036,
5637,
1155,
353,
8840,
836,
8,
341,
197,
515,
197,
1903,
746,
11,
1848,
1669,
1281,
1397,
1262,
1649,
2099,
32225,
287,
85,
16,
40143,
13297,
515,
298,
7568,
992,
25,
16558,
85,
16,
40143,
13297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateInitiator_FeedsErrors(t *testing.T) {
t.Parallel()
store, cleanup := cltest.NewStore(t)
defer cleanup()
bridge := &models.BridgeType{
Name: models.MustNewTaskType("testbridge"),
URL: cltest.WebURL(t, "https://testing.com/bridges"),
}
require.NoError(t, store.CreateBridgeType(bridge))
job := cltest.NewJob()
tests := []struct {
description string
FeedsJSON string
}{
{"invalid url", `["invalid/url"]`},
{"invalid bridge name", `[{"bridge": "doesnotexist"}]`},
{"invalid url type", `[1]`},
{"invalid bridge type", `[{"bridge": 1}]`},
{"valid url, invalid bridge", `["http://example.com", {"bridge": "doesnotexist"}]`},
{"invalid url, valid bridge", `["invalid/url", {"bridge": "testbridge"}]`},
{"missing bridge", `[{"bridgeName": "doesnotexist"}]`},
{"unsupported bridge properties", `[{"bridge": "testbridge", "foo": "bar"}]`},
{"invalid entry", `["http://example.com", {"bridge": "testbridge"}, 1]`},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
var initr models.Initiator
require.NoError(t, json.Unmarshal([]byte(validInitiator), &initr))
initr.Feeds = cltest.JSONFromString(t, test.FeedsJSON)
err := services.ValidateInitiator(initr, job, store)
require.Error(t, err)
})
}
} | explode_data.jsonl/75337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 497
} | [
2830,
3393,
17926,
3803,
36122,
1400,
68,
6767,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
57279,
11,
21290,
1669,
1185,
1944,
7121,
6093,
1155,
340,
16867,
21290,
2822,
197,
13709,
1669,
609,
6507,
1785,
11183,
929,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTimeWithinTimeRangeNextDay(t *testing.T) {
// Now test end time before start time (e.g. overnight)
timeRange, _ := NewTimeRange("23:00-01:00")
newTime := getDateForTime(23, 30)
if !timeRange.HasTime(newTime) {
t.Fail()
}
} | explode_data.jsonl/61797 | {
"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,
1462,
41961,
1462,
6046,
5847,
10159,
1155,
353,
8840,
836,
8,
341,
197,
322,
4695,
1273,
835,
882,
1573,
1191,
882,
320,
68,
1302,
13,
24398,
340,
21957,
6046,
11,
716,
1669,
1532,
1462,
6046,
445,
17,
18,
25,
15,
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 TestArranging_ExecuteOutbound(t *testing.T) {
const errMsg = "test error"
ctrl := gomock.NewController(t)
defer ctrl.Finish()
messenger := serviceMocks.NewMockMessenger(ctrl)
messenger.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
messenger.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Return(errors.New(errMsg))
followup, action, err := (&arranging{}).ExecuteOutbound(messenger, &metaData{
transitionalPayload: transitionalPayload{Action: Action{Msg: service.NewDIDCommMsgMap(struct{}{})}},
})
require.NoError(t, err)
require.NoError(t, action())
require.Equal(t, &noOp{}, followup)
// Send an error
followup, action, err = (&arranging{}).ExecuteOutbound(messenger, &metaData{
transitionalPayload: transitionalPayload{Action: Action{Msg: service.NewDIDCommMsgMap(struct{}{})}},
})
require.NoError(t, err)
require.Contains(t, fmt.Sprintf("%v", action()), errMsg)
require.Equal(t, &noOp{}, followup)
} | explode_data.jsonl/66244 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 359
} | [
2830,
3393,
8838,
8595,
83453,
2662,
10891,
1155,
353,
8840,
836,
8,
341,
4777,
60078,
284,
330,
1944,
1465,
1837,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
2109,
40137,
1669,
2473,
72577,
7121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRejectControlCharacters(t *testing.T) {
tests := []string{
"http://foo.com/?foo\nbar",
"http\r://foo.com/",
"http://foo\x7f.com/",
}
for _, s := range tests {
_, err := Parse(s)
const wantSub = "net/url: invalid control character in URL"
if got := fmt.Sprint(err); !strings.Contains(got, wantSub) {
t.Errorf("Parse(%q) error = %q; want substring %q", s, got, wantSub)
}
}
// But don't reject non-ASCII CTLs, at least for now:
if _, err := Parse("http://foo.com/ctl\x80"); err != nil {
t.Errorf("error parsing URL with non-ASCII control byte: %v", err)
}
} | explode_data.jsonl/71740 | {
"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,
78413,
3273,
37489,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
917,
515,
197,
197,
76932,
1110,
7975,
905,
17763,
7975,
1699,
2257,
756,
197,
197,
76932,
12016,
1110,
7975,
905,
35075,
197,
197,
76932,
1110,
7975,
3462... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalUnmarshalPubKeyTable(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
t.Parallel()
sf := newTestFile()
sf.addRandomHostKeys(10)
// Marshal pubKeyTable.
raw, err := marshalPubKeyTable(sf.pubKeyTable)
if err != nil {
t.Fatal("Failed to marshal pubKeyTable", err)
}
// Unmarshal pubKeyTable.
pubKeyTable, err := unmarshalPubKeyTable(raw)
if err != nil {
t.Fatal("Failed to unmarshal pubKeyTable", err)
}
// Compare them.
if len(sf.pubKeyTable) != len(pubKeyTable) {
t.Fatalf("Lengths of tables don't match %v vs %v",
len(sf.pubKeyTable), len(pubKeyTable))
}
for i, spk := range pubKeyTable {
if spk.Used != sf.pubKeyTable[i].Used {
t.Fatal("Use fields don't match")
}
if !spk.PublicKey.Equals(sf.pubKeyTable[i].PublicKey) {
t.Fatal("Keys don't match")
}
}
} | explode_data.jsonl/25110 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 345
} | [
2830,
3393,
55438,
1806,
27121,
29162,
1592,
2556,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
7039,
741,
197,
532,
3244,
41288,
7957,
2822,
53024,
1669,
501,
2271,
1703,
741,
53024,
1364,
13999,
9296,
88... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestMatchQueryString(t *testing.T) {
hreq := &definition.Request{}
hval := make(definition.Values)
hval["test"] = []string{"test"}
hreq.QueryStringParameters = hval
mreq := &definition.Request{}
mval := make(definition.Values)
mval["test"] = []string{"test"}
mreq.QueryStringParameters = mval
m := MockMatch{}
if m, err := m.Match(hreq, mreq); !m {
t.Error(err)
}
mval["test2"] = []string{"test2"}
if m, _ := m.Match(hreq, mreq); m {
t.Error("Not expected match")
}
} | explode_data.jsonl/1091 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
8331,
67001,
1155,
353,
8840,
836,
8,
1476,
9598,
2958,
1669,
609,
18375,
9659,
16094,
9598,
831,
1669,
1281,
7,
18375,
35145,
340,
9598,
831,
1183,
1944,
1341,
284,
3056,
917,
4913,
1944,
16707,
9598,
2958,
49919,
9706,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeNetworkPolicies(t *testing.T) {
expectedTime, err := time.Parse("2006-01-02 15:04:05 Z0700 MST", "2017-06-04 21:45:56 -0700 PDT")
if err != nil {
t.Errorf("unable to parse time %q error: %s", "2017-06-04 21:45:56 -0700 PDT", err)
}
expectedOut := `Name: network-policy-1
Namespace: default
Created on: 2017-06-04 21:45:56 -0700 PDT
Labels: <none>
Annotations: <none>
Spec:
PodSelector: foo in (bar1,bar2),foo2 notin (bar1,bar2),id1=app1,id2=app2
Allowing ingress traffic:
To Port: 80/TCP
To Port: 82/TCP
From PodSelector: id=app2,id2=app3
From NamespaceSelector: id=app2,id2=app3
From NamespaceSelector: foo in (bar1,bar2),id=app2,id2=app3
From IPBlock:
CIDR: 192.168.0.0/16
Except: 192.168.3.0/24, 192.168.4.0/24
----------
To Port: <any> (traffic allowed to all ports)
From: <any> (traffic not restricted by source)
Allowing egress traffic:
To Port: 80/TCP
To Port: 82/TCP
To PodSelector: id=app2,id2=app3
To NamespaceSelector: id=app2,id2=app3
To NamespaceSelector: foo in (bar1,bar2),id=app2,id2=app3
To IPBlock:
CIDR: 192.168.0.0/16
Except: 192.168.3.0/24, 192.168.4.0/24
----------
To Port: <any> (traffic allowed to all ports)
To: <any> (traffic not restricted by source)
Policy Types: Ingress, Egress
`
port80 := intstr.FromInt(80)
port82 := intstr.FromInt(82)
protoTCP := api.ProtocolTCP
versionedFake := fake.NewSimpleClientset(&networking.NetworkPolicy{
ObjectMeta: metav1.ObjectMeta{
Name: "network-policy-1",
Namespace: "default",
CreationTimestamp: metav1.NewTime(expectedTime),
},
Spec: networking.NetworkPolicySpec{
PodSelector: metav1.LabelSelector{
MatchLabels: map[string]string{
"id1": "app1",
"id2": "app2",
},
MatchExpressions: []metav1.LabelSelectorRequirement{
{Key: "foo", Operator: "In", Values: []string{"bar1", "bar2"}},
{Key: "foo2", Operator: "NotIn", Values: []string{"bar1", "bar2"}},
},
},
Ingress: []networking.NetworkPolicyIngressRule{
{
Ports: []networking.NetworkPolicyPort{
{Port: &port80},
{Port: &port82, Protocol: &protoTCP},
},
From: []networking.NetworkPolicyPeer{
{
PodSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"id": "app2",
"id2": "app3",
},
},
},
{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"id": "app2",
"id2": "app3",
},
},
},
{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"id": "app2",
"id2": "app3",
},
MatchExpressions: []metav1.LabelSelectorRequirement{
{Key: "foo", Operator: "In", Values: []string{"bar1", "bar2"}},
},
},
},
{
IPBlock: &networking.IPBlock{
CIDR: "192.168.0.0/16",
Except: []string{"192.168.3.0/24", "192.168.4.0/24"},
},
},
},
},
{},
},
Egress: []networking.NetworkPolicyEgressRule{
{
Ports: []networking.NetworkPolicyPort{
{Port: &port80},
{Port: &port82, Protocol: &protoTCP},
},
To: []networking.NetworkPolicyPeer{
{
PodSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"id": "app2",
"id2": "app3",
},
},
},
{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"id": "app2",
"id2": "app3",
},
},
},
{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"id": "app2",
"id2": "app3",
},
MatchExpressions: []metav1.LabelSelectorRequirement{
{Key: "foo", Operator: "In", Values: []string{"bar1", "bar2"}},
},
},
},
{
IPBlock: &networking.IPBlock{
CIDR: "192.168.0.0/16",
Except: []string{"192.168.3.0/24", "192.168.4.0/24"},
},
},
},
},
{},
},
PolicyTypes: []networking.PolicyType{networking.PolicyTypeIngress, networking.PolicyTypeEgress},
},
})
d := NetworkPolicyDescriber{versionedFake}
out, err := d.Describe("", "network-policy-1", printers.DescriberSettings{})
if err != nil {
t.Errorf("unexpected error: %s", err)
}
if out != expectedOut {
t.Errorf("want:\n%s\ngot:\n%s", expectedOut, out)
}
} | explode_data.jsonl/34949 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2341
} | [
2830,
3393,
74785,
12320,
47,
42038,
1155,
353,
8840,
836,
8,
341,
42400,
1462,
11,
1848,
1669,
882,
8937,
445,
17,
15,
15,
21,
12,
15,
16,
12,
15,
17,
220,
16,
20,
25,
15,
19,
25,
15,
20,
1863,
15,
22,
15,
15,
84280,
497,
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... | 4 |
func TestDaoRelationsByTid(t *testing.T) {
var (
c = context.TODO()
tid = int64(0)
start = int32(0)
end = int32(0)
)
convey.Convey("RelationsByTid", t, func(ctx convey.C) {
res, oids, err := d.RelationsByTid(c, tid, start, end)
ctx.Convey("Then err should be nil.res,oids should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(oids, convey.ShouldHaveLength, 0)
ctx.So(res, convey.ShouldHaveLength, 0)
})
})
} | explode_data.jsonl/46394 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
12197,
74164,
1359,
51,
307,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
1444,
257,
284,
2266,
90988,
741,
197,
3244,
307,
256,
284,
526,
21,
19,
7,
15,
340,
197,
21375,
284,
526,
18,
17,
7,
15,
340,
197,
6246,
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 TestGetKind(t *testing.T) {
for _, tc := range []struct {
desc string
convertFn interface{}
wantKind reflect.Kind
wantErr bool
}{
{"convertIntToInt64Fn", convertIntToInt64Fn, reflect.Int64, false},
{"convertInt8ToInt64Fn", convertInt8ToInt64Fn, reflect.Int64, false},
{"convertInt16ToInt64Fn", convertInt16ToInt64Fn, reflect.Int64, false},
{"convertInt32ToInt64Fn", convertInt32ToInt64Fn, reflect.Int64, false},
{"convertInt64ToInt64Fn", convertInt64ToInt64Fn, reflect.Int64, false},
{"convertUintToInt64Fn", convertUintToInt64Fn, reflect.Int64, false},
{"convertUint8ToInt64Fn", convertUint8ToInt64Fn, reflect.Int64, false},
{"convertUint16ToInt64Fn", convertUint16ToInt64Fn, reflect.Int64, false},
{"convertUint32ToInt64Fn", convertUint32ToInt64Fn, reflect.Int64, false},
{"convertUint64ToInt64Fn", convertUint64ToInt64Fn, reflect.Int64, false},
{"convertFloat32ToFloat64Fn", convertFloat32ToFloat64Fn, reflect.Float64, false},
{"convertFloat64Fn", convertFloat64ToFloat64Fn, reflect.Float64, false},
{"nil interface", nil, reflect.Invalid, true},
{"function with less than 2 return values", func() int64 { return int64(0) }, reflect.Invalid, true},
} {
kind, err := getKind(tc.convertFn)
if (err != nil) != tc.wantErr {
t.Errorf("With %s, got=%v error, wantErr=%t", tc.desc, err, tc.wantErr)
}
if !reflect.DeepEqual(kind, tc.wantKind) {
t.Errorf("With %s, got=%v , expected=%v", tc.desc, kind, tc.wantKind)
}
}
} | explode_data.jsonl/42974 | {
"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,
1949,
10629,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
41653,
414,
914,
198,
197,
197,
14166,
24911,
3749,
16094,
197,
50780,
10629,
220,
8708,
54199,
198,
197,
50780,
7747,
256,
1807... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRepositoryGet(t *testing.T) {
for k, v := range samples {
model, err := sr.Get(v.ID)
if k != 3 {
if err != nil {
t.Fatalf("sr.Get: %d %v", k, err)
}
if model != v {
t.Fatalf("sr.Get != sample - %d", k)
}
} else {
if err != repo.ErrInvalidID {
t.Fatalf("sr.Get != repo.ErrInvalidID")
}
}
}
} | explode_data.jsonl/75693 | {
"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,
4624,
1949,
1155,
353,
8840,
836,
8,
341,
2023,
595,
11,
348,
1669,
2088,
10469,
341,
197,
19727,
11,
1848,
1669,
18962,
2234,
3747,
9910,
692,
197,
743,
595,
961,
220,
18,
341,
298,
743,
1848,
961,
2092,
341,
571,
3244,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSamplingPolicyDecisionNotSampled(t *testing.T) {
const maxSize = 100
const decisionWaitSeconds = 5
// For this test explicitly control the timer calls and batcher, and set a mock
// sampling policy evaluator.
msp := new(consumertest.TracesSink)
mpe := &mockPolicyEvaluator{}
mtt := &manualTTicker{}
tsp := &tailSamplingSpanProcessor{
ctx: context.Background(),
nextConsumer: msp,
maxNumTraces: maxSize,
logger: zap.NewNop(),
decisionBatcher: newSyncIDBatcher(decisionWaitSeconds),
policies: []*Policy{{Name: "mock-policy", Evaluator: mpe, ctx: context.TODO()}},
deleteChan: make(chan pdata.TraceID, maxSize),
policyTicker: mtt,
}
_, batches := generateIdsAndBatches(210)
currItem := 0
numSpansPerBatchWindow := 10
// First evaluations shouldn't have anything to evaluate, until decision wait time passed.
for evalNum := 0; evalNum < decisionWaitSeconds; evalNum++ {
for ; currItem < numSpansPerBatchWindow*(evalNum+1); currItem++ {
tsp.ConsumeTraces(context.Background(), batches[currItem])
require.True(t, mtt.Started, "Time ticker was expected to have started")
}
tsp.samplingPolicyOnTick()
require.False(
t,
msp.SpansCount() != 0 || mpe.EvaluationCount != 0,
"policy for initial items was evaluated before decision wait period",
)
}
// Now the first batch that waited the decision period.
mpe.NextDecision = sampling.NotSampled
tsp.samplingPolicyOnTick()
require.EqualValues(t, 0, msp.SpansCount(), "exporter should have received zero spans")
require.EqualValues(t, 4, mpe.EvaluationCount, "policy should have been evaluated 4 times")
// Late span of a non-sampled trace should be ignored
tsp.ConsumeTraces(context.Background(), batches[0])
require.Equal(t, 0, msp.SpansCount())
require.Equal(t, 1, mpe.LateArrivingSpansCount, "policy was not notified of the late span")
mpe.NextDecision = sampling.Unspecified
mpe.NextError = errors.New("mock policy error")
tsp.samplingPolicyOnTick()
require.EqualValues(t, 0, msp.SpansCount(), "exporter should have received zero spans")
require.EqualValues(t, 6, mpe.EvaluationCount, "policy should have been evaluated 6 times")
// Late span of a non-sampled trace should be ignored
tsp.ConsumeTraces(context.Background(), batches[0])
require.Equal(t, 0, msp.SpansCount())
require.Equal(t, 2, mpe.LateArrivingSpansCount, "policy was not notified of the late span")
} | explode_data.jsonl/31675 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 880
} | [
2830,
3393,
98622,
13825,
74846,
2623,
17571,
67,
1155,
353,
8840,
836,
8,
341,
4777,
61935,
284,
220,
16,
15,
15,
198,
4777,
5480,
14190,
15343,
284,
220,
20,
198,
197,
322,
1752,
419,
1273,
20975,
2524,
279,
9021,
6738,
323,
7162,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetRoleFullnames(t *testing.T) {
host := &Host{
Roles: Roles{
"My-Service": []string{"db-master", "db-slave"},
"My-Service2": []string{"proxy"},
},
}
fullnames := host.GetRoleFullnames()
sort.Strings(fullnames)
if !reflect.DeepEqual(fullnames, []string{"My-Service2:proxy", "My-Service:db-master", "My-Service:db-slave"}) {
t.Error("RoleFullnames should be ['My-Service2:proxy', My-Service:db-master', 'My-Service:db-slave'] but: ", fullnames)
}
} | explode_data.jsonl/63817 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
1949,
9030,
9432,
11400,
1155,
353,
8840,
836,
8,
341,
63104,
1669,
609,
9296,
515,
197,
11143,
7151,
25,
50907,
515,
298,
197,
45140,
12,
1860,
788,
220,
3056,
917,
4913,
1999,
50903,
497,
330,
1999,
58097,
523,
7115,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDuplicateRowInvalidRownum(t *testing.T) {
const sheet = "Sheet1"
outFile := filepath.Join("test", "TestDuplicateRowInvalidRownum.%s.xlsx")
cells := map[string]string{
"A1": "A1 Value",
"A2": "A2 Value",
"A3": "A3 Value",
"B1": "B1 Value",
"B2": "B2 Value",
"B3": "B3 Value",
}
invalidIndexes := []int{-100, -2, -1, 0}
for _, row := range invalidIndexes {
name := fmt.Sprintf("%d", row)
t.Run(name, func(t *testing.T) {
xlsx := NewFile()
for col, val := range cells {
xlsx.SetCellStr(sheet, col, val)
}
assert.EqualError(t, xlsx.DuplicateRow(sheet, row), fmt.Sprintf("invalid row number %d", row))
for col, val := range cells {
v, err := xlsx.GetCellValue(sheet, col)
assert.NoError(t, err)
if !assert.Equal(t, val, v) {
t.FailNow()
}
}
assert.NoError(t, xlsx.SaveAs(fmt.Sprintf(outFile, name)))
})
}
for _, row1 := range invalidIndexes {
for _, row2 := range invalidIndexes {
name := fmt.Sprintf("[%d,%d]", row1, row2)
t.Run(name, func(t *testing.T) {
xlsx := NewFile()
for col, val := range cells {
xlsx.SetCellStr(sheet, col, val)
}
assert.EqualError(t, xlsx.DuplicateRowTo(sheet, row1, row2), fmt.Sprintf("invalid row number %d", row1))
for col, val := range cells {
v, err := xlsx.GetCellValue(sheet, col)
assert.NoError(t, err)
if !assert.Equal(t, val, v) {
t.FailNow()
}
}
assert.NoError(t, xlsx.SaveAs(fmt.Sprintf(outFile, name)))
})
}
}
} | explode_data.jsonl/30502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 726
} | [
2830,
3393,
53979,
3102,
7928,
49,
779,
372,
1155,
353,
8840,
836,
8,
341,
4777,
10834,
284,
330,
10541,
16,
698,
13967,
1703,
1669,
26054,
22363,
445,
1944,
497,
330,
2271,
53979,
3102,
7928,
49,
779,
372,
22445,
82,
46838,
5130,
144... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientRTMPRead(t *testing.T) {
p, ok := testProgram("hlsDisable: yes\n")
require.Equal(t, true, ok)
defer p.close()
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsp://localhost:8554/teststream",
})
require.NoError(t, err)
defer cnt1.close()
time.Sleep(1 * time.Second)
cnt2, err := newContainer("ffmpeg", "dest", []string{
"-i", "rtmp://localhost:1935/teststream",
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
} | explode_data.jsonl/63221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
2959,
5350,
5781,
4418,
1155,
353,
8840,
836,
8,
341,
3223,
11,
5394,
1669,
1273,
10690,
445,
71,
4730,
25479,
25,
9834,
1699,
1138,
17957,
12808,
1155,
11,
830,
11,
5394,
340,
16867,
281,
4653,
2822,
60553,
16,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExists(t *testing.T) {
t.Run("Topic exists test", func(t *testing.T) {
Init(clientId)
_, err := Exists(topicName)
if err != nil {
t.Error(err)
} else {
log.Println("Exists topic test is successful.")
}
})
} | explode_data.jsonl/4855 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
15575,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
26406,
6724,
1273,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
98762,
12805,
764,
692,
197,
197,
6878,
1848,
1669,
72426,
43839,
675,
692,
197,
743,
1848,
961,
2092,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestService_UnShorten(t *testing.T) {
type fields struct {
ctx context.Context
}
type args struct {
param *RedirectLinkRequest
}
tests := []struct {
name string
fields fields
args args
want string
wantErr bool
}{
{
name: "短连接还原",
fields: fields{
ctx: context.Background(),
},
args: args{
&RedirectLinkRequest{Sc: "MJR"},
},
wantErr: false,
},
}
setup()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
svc := &Service{
ctx: tt.fields.ctx,
}
got, err := svc.UnShorten(tt.args.param)
if (err != nil) != tt.wantErr {
t.Errorf("UnShorten() error = %v, wantErr %v", err, tt.wantErr)
return
}
t.Logf("get: %v", got)
})
}
} | explode_data.jsonl/81478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
1860,
40687,
12472,
268,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
20985,
2266,
9328,
198,
197,
532,
13158,
2827,
2036,
341,
197,
36037,
353,
17725,
3939,
1900,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestModifyCount(t *testing.T) {
t.Run("empty", func(t *testing.T) {
sql := MysqlModifier.Count("select ? from x", "")
t.Log(sql)
if strings.TrimSpace(sql) != "SELECT COUNT(0) FROM (select ? from x) AS __hp_tempCountTl" {
t.Fail()
}
})
t.Run("test", func(t *testing.T) {
sql := MysqlModifier.Count("select ? from x", "test")
t.Log(sql)
if strings.TrimSpace(sql) != "SELECT COUNT(`test`) FROM (select ? from x) AS __hp_tempCountTl" {
t.Fail()
}
})
} | explode_data.jsonl/64347 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
44427,
2507,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
3194,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
30633,
1669,
386,
14869,
34405,
6134,
445,
1742,
937,
504,
856,
497,
14676,
197,
3244,
5247,
13148,
692,
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 TestEventCloseSyscallFailure(t *testing.T) {
event := NewEvent(5)
closeProc = SimpleMockProc(0, 0, ErrorNotSupported)
err := event.Close()
require.Error(t, err)
require.Contains(t, err.Error(), "failed to close event handle")
} | explode_data.jsonl/57219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
1556,
7925,
32792,
6659,
17507,
1155,
353,
8840,
836,
8,
341,
28302,
1669,
1532,
1556,
7,
20,
340,
27873,
24508,
284,
8993,
11571,
24508,
7,
15,
11,
220,
15,
11,
4600,
2623,
34636,
340,
9859,
1669,
1538,
10421,
741,
17957,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObjects_Delete(t *testing.T) {
m := NewClient(os.Getenv("MNUBO_CLIENT_ID"), os.Getenv("MNUBO_CLIENT_SECRET"), os.Getenv("MNUBO_HOST"))
id := uuid.New().String()
o := SimpleObject{
XDeviceID: id,
XObjectType: "rand",
}
var results interface{}
e1, e2 := m.Objects.Create(o, &results), m.Objects.Delete(id)
if e1 != nil {
t.Errorf("client call failed: %+v", e1)
}
if e2 != nil {
t.Errorf("client call failed: %+v", e2)
}
} | explode_data.jsonl/81382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
11543,
57418,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
2959,
9638,
64883,
445,
44,
3926,
4677,
22521,
3450,
3975,
2643,
64883,
445,
44,
3926,
4677,
22521,
31408,
3975,
2643,
64883,
445,
44,
3926,
4677,
17213,
5455,
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... | 3 |
func TestContext2Plan_createBefore_maintainRoot(t *testing.T) {
m := testModule(t, "plan-cbd-maintain-root")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
Variables: InputValues{
"in": &InputValue{
Value: cty.StringVal("a,b,c"),
SourceType: ValueFromCaller,
},
},
})
plan, diags := ctx.Plan()
if diags.HasErrors() {
t.Fatalf("unexpected errors: %s", diags.Err())
}
if !ctx.State().Empty() {
t.Fatal("expected empty state, got:", ctx.State())
}
if len(plan.Changes.Resources) != 4 {
t.Error("expected 4 resource in plan, got", len(plan.Changes.Resources))
}
for _, res := range plan.Changes.Resources {
// these should all be creates
if res.Action != plans.Create {
t.Fatalf("unexpected action %s for %s", res.Action, res.Addr.String())
}
}
} | explode_data.jsonl/28638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
1972,
17,
20485,
8657,
10227,
717,
1641,
466,
8439,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1273,
3332,
1155,
11,
330,
10393,
1786,
8940,
1448,
1641,
466,
39214,
1138,
3223,
1669,
1273,
5179,
445,
8635,
1138,
3223,
98063,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewBuilderMux(t *testing.T) {
tests := []struct {
description string
pipelines []latestV1.Pipeline
pipeBuilder func(latestV1.Pipeline) (PipelineBuilder, error)
shouldErr bool
expectedBuilders []string
expectedConcurrency int
}{
{
description: "only local builder",
pipelines: []latestV1.Pipeline{
{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{LocalBuild: &latestV1.LocalBuild{Concurrency: util.IntPtr(1)}}}},
},
pipeBuilder: newMockPipelineBuilder,
expectedBuilders: []string{"local"},
expectedConcurrency: 1,
},
{
description: "only cluster builder",
pipelines: []latestV1.Pipeline{
{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{Cluster: &latestV1.ClusterDetails{}}}},
},
pipeBuilder: newMockPipelineBuilder,
expectedBuilders: []string{"cluster"},
},
{
description: "only gcb builder",
pipelines: []latestV1.Pipeline{
{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{GoogleCloudBuild: &latestV1.GoogleCloudBuild{}}}},
},
pipeBuilder: newMockPipelineBuilder,
expectedBuilders: []string{"gcb"},
},
{
description: "min non-zero concurrency",
pipelines: []latestV1.Pipeline{
{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{LocalBuild: &latestV1.LocalBuild{Concurrency: util.IntPtr(0)}}}},
{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{LocalBuild: &latestV1.LocalBuild{Concurrency: util.IntPtr(3)}}}},
{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{Cluster: &latestV1.ClusterDetails{Concurrency: 2}}}},
},
pipeBuilder: newMockPipelineBuilder,
expectedBuilders: []string{"local", "local", "cluster"},
expectedConcurrency: 2,
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
cfg := &mockConfig{pipelines: test.pipelines}
b, err := NewBuilderMux(cfg, nil, test.pipeBuilder)
t.CheckError(test.shouldErr, err)
if test.shouldErr {
return
}
t.CheckTrue(len(b.builders) == len(test.expectedBuilders))
for i := range b.builders {
t.CheckDeepEqual(test.expectedBuilders[i], b.builders[i].(*mockPipelineBuilder).builderType)
}
t.CheckDeepEqual(test.expectedConcurrency, b.concurrency)
})
}
} | explode_data.jsonl/22141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 962
} | [
2830,
3393,
3564,
3297,
44,
2200,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
260,
914,
198,
197,
3223,
93997,
1843,
3056,
19350,
53,
16,
1069,
8790,
198,
197,
197,
13768,
3297,
260,
2915,
2333,
13893,
53,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNilOutZerValueAppSources(t *testing.T) {
var spec *argoappv1.ApplicationSpec
{
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Kustomize: &argoappv1.ApplicationSourceKustomize{NamePrefix: "foo"}}})
assert.NotNil(t, spec.Source.Kustomize)
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Kustomize: &argoappv1.ApplicationSourceKustomize{NamePrefix: ""}}})
assert.Nil(t, spec.Source.Kustomize)
}
{
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Kustomize: &argoappv1.ApplicationSourceKustomize{NameSuffix: "foo"}}})
assert.NotNil(t, spec.Source.Kustomize)
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Kustomize: &argoappv1.ApplicationSourceKustomize{NameSuffix: ""}}})
assert.Nil(t, spec.Source.Kustomize)
}
{
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Helm: &argoappv1.ApplicationSourceHelm{ValueFiles: []string{"values.yaml"}}}})
assert.NotNil(t, spec.Source.Helm)
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Helm: &argoappv1.ApplicationSourceHelm{ValueFiles: []string{}}}})
assert.Nil(t, spec.Source.Helm)
}
{
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Ksonnet: &argoappv1.ApplicationSourceKsonnet{Environment: "foo"}}})
assert.NotNil(t, spec.Source.Ksonnet)
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Ksonnet: &argoappv1.ApplicationSourceKsonnet{Environment: ""}}})
assert.Nil(t, spec.Source.Ksonnet)
}
{
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Directory: &argoappv1.ApplicationSourceDirectory{Recurse: true}}})
assert.NotNil(t, spec.Source.Directory)
spec = NormalizeApplicationSpec(&argoappv1.ApplicationSpec{Source: argoappv1.ApplicationSource{Directory: &argoappv1.ApplicationSourceDirectory{Recurse: false}}})
assert.Nil(t, spec.Source.Directory)
}
} | explode_data.jsonl/49987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 760
} | [
2830,
3393,
19064,
2662,
57,
261,
1130,
2164,
32200,
1155,
353,
8840,
836,
8,
341,
2405,
1398,
353,
12088,
676,
85,
16,
17521,
8327,
198,
197,
515,
197,
98100,
284,
68092,
4988,
8327,
2099,
12088,
676,
85,
16,
17521,
8327,
90,
3608,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateValidation(t *testing.T) {
out := jen.NewFile("main")
sym, err := symbols.ProjectByDir(".", symbols.All)
assert.NoError(t, err, "parse")
userA, err := sym.FindSymbol("UserA", sym.Package.FindFile("gen_test.go"))
assert.NoError(t, err, "find struct UserA")
generated, err := GenerateValidation(userA, sym, []string{"UserID"})
assert.NoError(t, err, "generate")
out.Add(generated)
buf := &bytes.Buffer{}
err = out.Render(buf)
assert.NoError(t, err, "render")
assert.Equal(t, sampleRequired, buf.String(), "compare generated")
} | explode_data.jsonl/50765 | {
"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,
31115,
13799,
1155,
353,
8840,
836,
8,
341,
13967,
1669,
502,
268,
7121,
1703,
445,
3817,
1138,
1903,
1600,
11,
1848,
1669,
17738,
30944,
1359,
6184,
64217,
17738,
16764,
340,
6948,
35699,
1155,
11,
1848,
11,
330,
6400,
1138... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateSubLink(t *testing.T) {
validSubIface := "lo.10"
invalidSubIface1 := "lo"
invalidSubIface2 := "lo:10"
invalidSubIface3 := "foo123.456"
// test a valid parent_iface.vlan_id
_, _, err := parseVlan(validSubIface)
if err != nil {
t.Fatalf("failed subinterface validation: %v", err)
}
// test an invalid vid with a valid parent link
_, _, err = parseVlan(invalidSubIface1)
if err == nil {
t.Fatalf("failed subinterface validation test: %s", invalidSubIface1)
}
// test a valid vid with a valid parent link with an invalid delimiter
_, _, err = parseVlan(invalidSubIface2)
if err == nil {
t.Fatalf("failed subinterface validation test: %v", invalidSubIface2)
}
// test an invalid parent link with a valid vid
_, _, err = parseVlan(invalidSubIface3)
if err == nil {
t.Fatalf("failed subinterface validation test: %v", invalidSubIface3)
}
} | explode_data.jsonl/51912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
17926,
3136,
3939,
1155,
353,
8840,
836,
8,
341,
56322,
3136,
40,
1564,
1669,
330,
385,
13,
16,
15,
698,
197,
11808,
3136,
40,
1564,
16,
1669,
330,
385,
698,
197,
11808,
3136,
40,
1564,
17,
1669,
330,
385,
25,
16,
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... | 5 |
func TestFailureBadRefs(t *testing.T) {
badRefsESSpan, err := loadESSpanFixture(1)
require.NoError(t, err)
badRefsESSpan.References = []Reference{
{
RefType: "makeOurOwnCasino",
TraceID: "1",
},
}
failingSpanTransform(t, &badRefsESSpan, "not a valid SpanRefType string makeOurOwnCasino")
} | explode_data.jsonl/5148 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
17507,
17082,
82807,
1155,
353,
8840,
836,
8,
341,
2233,
329,
82807,
9996,
848,
11,
1848,
1669,
2795,
9996,
848,
18930,
7,
16,
340,
17957,
35699,
1155,
11,
1848,
340,
2233,
329,
82807,
9996,
848,
2817,
4901,
284,
3056,
885... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRandomPort(t *testing.T) {
m := map[int]int{}
kub := &instance{
randomPorts: map[int]int{},
}
for i := 0; i < 100; i++ {
p := kub.RandomPort()
if p < 1024 {
t.Errorf("Invalid random port %d", p)
break
}
if _, ok := m[p]; ok {
t.Errorf("Random port collision, port %d already provided", p)
break
}
m[p] = p
}
} | explode_data.jsonl/50059 | {
"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,
13999,
7084,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
2415,
18640,
63025,
16094,
16463,
392,
1669,
609,
4851,
515,
197,
83628,
68273,
25,
2415,
18640,
63025,
38837,
197,
532,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSearchAllTeamsSanitization(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(),
Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com,localhost",
})
CheckNoError(t, resp)
team2, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(),
Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com,localhost",
})
CheckNoError(t, resp)
t.Run("non-team user", func(t *testing.T) {
client := th.CreateClient()
th.LoginBasic2WithClient(client)
rteams, resp := client.SearchTeams(&model.TeamSearch{Term: t.Name()})
CheckNoError(t, resp)
for _, rteam := range rteams {
require.Empty(t, rteam.Email, "should've sanitized email")
require.Empty(t, rteam.AllowedDomains, "should've sanitized allowed domains")
require.Empty(t, rteam.InviteId, "should have sanitized inviteid")
}
})
t.Run("team user", func(t *testing.T) {
th.LinkUserToTeam(th.BasicUser2, team)
client := th.CreateClient()
th.LoginBasic2WithClient(client)
rteams, resp := client.SearchTeams(&model.TeamSearch{Term: t.Name()})
CheckNoError(t, resp)
for _, rteam := range rteams {
require.Empty(t, rteam.Email, "should've sanitized email")
require.Empty(t, rteam.AllowedDomains, "should've sanitized allowed domains")
require.NotEmpty(t, rteam.InviteId, "should have not sanitized inviteid")
}
})
t.Run("team admin", func(t *testing.T) {
rteams, resp := th.Client.SearchTeams(&model.TeamSearch{Term: t.Name()})
CheckNoError(t, resp)
for _, rteam := range rteams {
if rteam.Id == team.Id || rteam.Id == team2.Id || rteam.Id == th.BasicTeam.Id {
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
require.NotEmpty(t, rteam.InviteId, "should have not sanitized inviteid")
}
}
})
t.Run("system admin", func(t *testing.T) {
rteams, resp := th.SystemAdminClient.SearchTeams(&model.TeamSearch{Term: t.Name()})
CheckNoError(t, resp)
for _, rteam := range rteams {
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
require.NotEmpty(t, rteam.InviteId, "should have not sanitized inviteid")
}
})
} | explode_data.jsonl/70719 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 978
} | [
2830,
3393,
5890,
2403,
60669,
23729,
275,
2022,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
197,
9196,
11,
9039,
1669,
270,
11716,
7251,
14597,
2099,
2528,
65842,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReadConfig(t *testing.T) {
configStr := `apiVersion: v1
kind: PodNodeConstraintsConfig
nodeSelectorLabelBlacklist:
- bogus
- foo
`
buf := bytes.NewBufferString(configStr)
config, err := readConfig(buf)
if err != nil {
t.Fatalf("unexpected error reading config: %v", err)
}
if len(config.NodeSelectorLabelBlacklist) == 0 {
t.Fatalf("NodeSelectorLabelBlacklist didn't take specified value")
}
} | explode_data.jsonl/37023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
4418,
2648,
1155,
353,
8840,
836,
8,
341,
25873,
2580,
1669,
1565,
2068,
5637,
25,
348,
16,
198,
15314,
25,
16821,
1955,
12925,
2648,
198,
3509,
5877,
2476,
14417,
1607,
510,
220,
481,
59920,
198,
220,
481,
15229,
198,
398... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContext2Plan_pathVar(t *testing.T) {
cwd, err := os.Getwd()
if err != nil {
t.Fatalf("err: %s", err)
}
m := testModule(t, "plan-path-var")
p := testProvider("aws")
p.GetSchemaReturn = &ProviderSchema{
ResourceTypes: map[string]*configschema.Block{
"aws_instance": {
Attributes: map[string]*configschema.Attribute{
"cwd": {Type: cty.String, Optional: true},
"module": {Type: cty.String, Optional: true},
"root": {Type: cty.String, Optional: true},
},
},
},
}
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
})
plan, diags := ctx.Plan()
if diags.HasErrors() {
t.Fatalf("err: %s", diags.Err())
}
schema := p.GetSchemaReturn.ResourceTypes["aws_instance"]
ty := schema.ImpliedType()
if len(plan.Changes.Resources) != 1 {
t.Fatal("expected 1 changes, got", len(plan.Changes.Resources))
}
for _, res := range plan.Changes.Resources {
ric, err := res.Decode(ty)
if err != nil {
t.Fatal(err)
}
switch i := ric.Addr.String(); i {
case "aws_instance.foo":
if res.Action != plans.Create {
t.Fatalf("resource %s should be created", i)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
"cwd": cty.StringVal(cwd + "/barpath"),
"module": cty.StringVal(m.Module.SourceDir + "/foopath"),
"root": cty.StringVal(m.Module.SourceDir + "/barpath"),
}), ric.After)
default:
t.Fatal("unknown instance:", i)
}
}
} | explode_data.jsonl/28693 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 683
} | [
2830,
3393,
1972,
17,
20485,
2638,
3962,
1155,
353,
8840,
836,
8,
341,
1444,
6377,
11,
1848,
1669,
2643,
2234,
6377,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
615,
25,
1018,
82,
497,
1848,
340,
197,
630,
2109,
1669,
127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSocketWriter_unixgram(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "telegraf")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
sock := filepath.Join(tmpdir, "sw.TSW_unixgram.sock")
listener, err := net.ListenPacket("unixgram", sock)
require.NoError(t, err)
sw := newSocketWriter()
sw.Address = "unixgram://" + sock
err = sw.Connect()
require.NoError(t, err)
testSocketWriter_packet(t, sw, listener)
} | explode_data.jsonl/34020 | {
"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,
10286,
6492,
80572,
1520,
1155,
353,
8840,
836,
8,
341,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
15410,
76039,
1138,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
84427,
10368,
3741,
340,
85809,
1669,
260... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStackTrace(t *testing.T) {
st := genStack1()
t.Logf("Stack trace:\n%s", PrintStackTrace(st))
encoded := EncodeStackTrace(st)
t.Logf("encoded:\n%s", encoded)
if !strings.Contains(encoded, `"function":"genStack1"`) ||
!strings.Contains(encoded, `"function":"genStack2"`) {
t.Fatalf("function genStack not in call stack:\n%s", encoded)
}
st2, b := DecodeStackTrace(encoded)
if !b {
t.Fatalf("decode failed")
}
if !reflect.DeepEqual(st, st2) {
t.Fatalf("stack traces not identical: %v", pretty.Diff(st, st2))
}
} | explode_data.jsonl/55532 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 225
} | [
2830,
3393,
7657,
1155,
353,
8840,
836,
8,
341,
18388,
1669,
4081,
4336,
16,
2822,
3244,
98954,
445,
4336,
11655,
7190,
77,
12952,
497,
8213,
7657,
5895,
4390,
197,
19329,
1669,
56562,
7657,
5895,
340,
3244,
98954,
445,
19329,
7190,
77,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParseImageStreamTagName(t *testing.T) {
tests := map[string]struct {
id string
expectedName string
expectedTag string
expectError bool
}{
"empty id": {
id: "",
expectError: true,
},
"missing semicolon": {
id: "hello",
expectError: true,
},
"too many semicolons": {
id: "a:b:c",
expectError: true,
},
"empty name": {
id: ":tag",
expectError: true,
},
"empty tag": {
id: "name",
expectError: true,
},
"happy path": {
id: "name:tag",
expectError: false,
expectedName: "name",
expectedTag: "tag",
},
}
for description, testCase := range tests {
name, tag, err := ParseImageStreamTagName(testCase.id)
gotError := err != nil
if e, a := testCase.expectError, gotError; e != a {
t.Fatalf("%s: expected err: %t, got: %t: %s", description, e, a, err)
}
if err != nil {
continue
}
if e, a := testCase.expectedName, name; e != a {
t.Errorf("%s: name: expected %q, got %q", description, e, a)
}
if e, a := testCase.expectedTag, tag; e != a {
t.Errorf("%s: tag: expected %q, got %q", description, e, a)
}
}
} | explode_data.jsonl/40824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 569
} | [
2830,
3393,
14463,
1906,
3027,
22616,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
15710,
1843,
914,
198,
197,
42400,
675,
914,
198,
197,
42400,
5668,
220,
914,
198,
197,
24952,
1454,
220,
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... | 6 |
func TestClient_CancelJobRun(t *testing.T) {
t.Parallel()
app, cleanup := cltest.NewApplication(t, cltest.EthMockRegisterChainID)
defer cleanup()
require.NoError(t, app.Start())
job := cltest.NewJobWithWebInitiator()
require.NoError(t, app.Store.CreateJob(&job))
run := cltest.NewJobRun(job)
require.NoError(t, app.Store.CreateJobRun(&run))
client, _ := app.NewClientAndRenderer()
set := flag.NewFlagSet("cancel", 0)
set.Parse([]string{run.ID.String()})
c := cli.NewContext(nil, set, nil)
require.NoError(t, client.CancelJobRun(c))
runs := cltest.MustAllJobsWithStatus(t, app.Store, models.RunStatusCancelled)
require.Len(t, runs, 1)
assert.Equal(t, models.RunStatusCancelled, runs[0].GetStatus())
assert.NotNil(t, runs[0].FinishedAt)
} | explode_data.jsonl/78864 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
2959,
97485,
12245,
6727,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
28236,
11,
21290,
1669,
1185,
1944,
7121,
4988,
1155,
11,
1185,
1944,
5142,
339,
11571,
8690,
18837,
915,
340,
16867,
21290,
741,
17957,
35699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSomething(t *testing.T) {
paths := eachDir("/foo/b//bar/")
if len(paths) != 4 {
t.Fail()
}
// TODO: fix me for windows
if runtime.GOOS != "windows" {
paths = eachDir("/")
if len(paths) != 1 && paths[0] != "/" {
t.Fail()
}
}
} | explode_data.jsonl/20889 | {
"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,
23087,
1155,
353,
8840,
836,
8,
341,
197,
21623,
1669,
1817,
6184,
4283,
7975,
3470,
322,
2257,
53006,
743,
2422,
54728,
8,
961,
220,
19,
341,
197,
3244,
57243,
741,
197,
532,
197,
322,
5343,
25,
5046,
752,
369,
11030,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue262(t *testing.T) {
// Continue does not work when the current breakpoint is set on a NOP instruction
protest.AllowRecording(t)
withTestProcess("issue262", t, func(p *proc.Target, fixture protest.Fixture) {
setFileBreakpoint(p, t, fixture.Source, 11)
assertNoError(p.Continue(), t, "Continue()")
err := p.Continue()
if err == nil {
t.Fatalf("No error on second continue")
}
_, exited := err.(proc.ErrProcessExited)
if !exited {
t.Fatalf("Process did not exit after second continue: %v", err)
}
})
} | explode_data.jsonl/56235 | {
"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,
42006,
17,
21,
17,
1155,
353,
8840,
836,
8,
341,
197,
322,
15003,
1558,
537,
975,
979,
279,
1482,
52745,
374,
738,
389,
264,
86376,
7600,
198,
197,
776,
1944,
29081,
52856,
1155,
340,
46948,
2271,
7423,
445,
11159,
17,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestModuleFailsToHandle(t *testing.T) {
// Arrange
logger, err := zap.NewDevelopment()
require.NoError(t, err, "failed to get logger")
config := getConfigWithAuthListener(t, []string{"auth"}, []int{1}, true)
loader := loaderstest.MockLoader{}
mModule1 := createMockHandlerWithReturn(nil, errors.New("failed to handle"))
loader.On("LoadModule", "module.auth.1").Return(mModule1, nil)
server, err := New(config, logger, &loader)
assert.Equal(t, err, nil)
isReady := server.StartAndWait()
require.True(t, isReady, "failed to initialize the server")
// Act
packet := radius.New(radius.CodeAccessRequest, []byte(config.Secret))
client := radius.Client{
Retry: 0,
}
go func() {
port := config.Listeners[0].Extra["Port"].(int)
client.Exchange(
context.Background(),
packet,
fmt.Sprintf(":%d", port),
)
}()
time.Sleep(time.Millisecond * 500)
// Assert
assert.NotNil(t, server)
mModule1.AssertExpectations(t)
} | explode_data.jsonl/59972 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 356
} | [
2830,
3393,
3332,
37,
6209,
1249,
6999,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
17060,
11,
1848,
1669,
32978,
7121,
39419,
741,
17957,
35699,
1155,
11,
1848,
11,
330,
16091,
311,
633,
5925,
1138,
25873,
1669,
66763,
2354,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerAddEventWithGoodController(t *testing.T) {
c, tc := makeController("apps/v1", "ReplicaSet")
c.Add(simpleOwnedPod("unit", "test"))
validateSent(t, tc, sourcesv1beta1.ApiServerSourceAddRefEventType)
} | explode_data.jsonl/39263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
2051,
2212,
1556,
2354,
15216,
2051,
1155,
353,
8840,
836,
8,
341,
1444,
11,
17130,
1669,
1281,
2051,
445,
27635,
5457,
16,
497,
330,
18327,
15317,
1649,
1138,
1444,
1904,
1141,
6456,
57641,
23527,
445,
3843,
497,
330,
1944,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStubsVersions_NotSorted(t *testing.T) {
bp := `
cc_library {
name: "libfoo",
srcs: ["foo.c"],
stubs: {
versions: ["29", "current", "R"],
},
}
`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
testCcErrorWithConfig(t, `"libfoo" .*: versions: not sorted`, config)
} | explode_data.jsonl/53367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
623,
15738,
69015,
60816,
51051,
1155,
353,
8840,
836,
8,
341,
2233,
79,
1669,
22074,
197,
63517,
39461,
341,
298,
11609,
25,
330,
2740,
7975,
756,
298,
41144,
82,
25,
4383,
7975,
520,
8097,
298,
18388,
15738,
25,
341,
571... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldNotHashPasswordWithNonExistentAlgorithm(t *testing.T) {
hash, err := HashPassword("password", "BpLnfgDsc2WD8F2q", "bogus",
schema.DefaultCIPasswordConfiguration.Iterations, schema.DefaultCIPasswordConfiguration.Memory*1024,
schema.DefaultCIPasswordConfiguration.Parallelism, schema.DefaultCIPasswordConfiguration.KeyLength,
schema.DefaultCIPasswordConfiguration.SaltLength)
assert.Equal(t, "", hash)
assert.EqualError(t, err, "Hashing algorithm input of 'bogus' is invalid, only values of argon2id and 6 are supported")
} | explode_data.jsonl/40169 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
14996,
2623,
6370,
4876,
2354,
8121,
840,
18128,
27847,
1155,
353,
8840,
836,
8,
341,
50333,
11,
1848,
1669,
6531,
4876,
445,
3833,
497,
330,
33,
79,
40101,
4817,
35,
2388,
17,
17563,
23,
37,
17,
80,
497,
330,
65,
538,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParse_SubscriptionPauseCanceledNotification(t *testing.T) {
result := MustParseFile("testdata/subscription_pause_canceled_notification.xml")
if n, ok := result.(*webhooks.SubscriptionNotification); !ok {
t.Fatalf("unexpected type: %T, result", n)
} else if diff := cmp.Diff(n, &webhooks.SubscriptionNotification{
Type: webhooks.PauseCanceledSubscription,
Account: webhooks.Account{
XMLName: xml.Name{Local: "account"},
Code: "1",
Email: "verena@example.com",
FirstName: "Verena",
LastName: "Example",
},
Subscription: recurly.Subscription{
XMLName: xml.Name{Local: "subscription"},
Plan: recurly.NestedPlan{
Code: "daily_plan",
Name: "daily_plan",
},
UUID: "437b9def1c442e659f90f4416086dd66",
State: "active",
Quantity: 1,
TotalAmountInCents: 2000,
ActivatedAt: recurly.NewTime(MustParseTime("2018-03-09T22:12:36Z")),
CurrentPeriodStartedAt: recurly.NewTime(MustParseTime("2018-03-09T22:12:36Z")),
CurrentPeriodEndsAt: recurly.NewTime(MustParseTime("2019-03-09T22:12:36Z")),
},
}); diff != "" {
t.Fatal(diff)
}
} | explode_data.jsonl/76112 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 549
} | [
2830,
3393,
14463,
36359,
12124,
28391,
63263,
11196,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
15465,
14463,
1703,
445,
92425,
14,
34404,
59989,
666,
38392,
34296,
9028,
1138,
743,
308,
11,
5394,
1669,
1102,
41399,
2911,
38560,
12391,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNamespaceIndexDisabledQuery(t *testing.T) {
ns, closer := newTestNamespace(t)
defer closer()
ctx := context.NewBackground()
query := index.Query{
Query: xidx.NewTermQuery([]byte("foo"), []byte("bar")),
}
opts := index.QueryOptions{}
_, err := ns.QueryIDs(ctx, query, opts)
require.Error(t, err)
require.NoError(t, ns.Close())
} | explode_data.jsonl/35380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
22699,
1552,
25907,
2859,
1155,
353,
8840,
836,
8,
341,
84041,
11,
12128,
1669,
501,
2271,
22699,
1155,
340,
16867,
12128,
2822,
20985,
1669,
2266,
7121,
8706,
741,
27274,
1669,
1922,
15685,
515,
197,
60362,
25,
856,
6361,
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... | 1 |
func TestEmptyUnmarshalOmit(t *testing.T) {
result := emptyMarshalTestStruct2{}
err := Unmarshal(emptyTestToml, &result)
expected := emptyTestData2
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(result, expected) {
t.Errorf("Bad empty omit unmarshal: expected %v, got %v", expected, result)
}
} | explode_data.jsonl/46319 | {
"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,
3522,
1806,
27121,
46,
1763,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
4287,
55438,
2271,
9422,
17,
16094,
9859,
1669,
1230,
27121,
24216,
2271,
24732,
75,
11,
609,
1382,
340,
42400,
1669,
4287,
83920,
17,
198,
743,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestShouldUpgradeAllToLatest(t *testing.T) {
// prepare
nsn := types.NamespacedName{Name: "my-instance", Namespace: "default"}
existing := v1alpha1.OpenTelemetryCollector{
ObjectMeta: metav1.ObjectMeta{
Name: nsn.Name,
Namespace: nsn.Namespace,
Labels: map[string]string{
"app.kubernetes.io/managed-by": "opentelemetry-operator",
},
},
}
existing.Status.Version = "0.0.1" // this is the first version we have an upgrade function
err := k8sClient.Create(context.Background(), &existing)
require.NoError(t, err)
err = k8sClient.Status().Update(context.Background(), &existing)
require.NoError(t, err)
currentV := version.Get()
currentV.OpenTelemetryCollector = upgrade.Latest.String()
// sanity check
persisted := &v1alpha1.OpenTelemetryCollector{}
err = k8sClient.Get(context.Background(), nsn, persisted)
require.NoError(t, err)
require.Equal(t, "0.0.1", persisted.Status.Version)
// test
err = upgrade.ManagedInstances(context.Background(), logger, currentV, k8sClient)
assert.NoError(t, err)
// verify
err = k8sClient.Get(context.Background(), nsn, persisted)
assert.NoError(t, err)
assert.Equal(t, upgrade.Latest.String(), persisted.Status.Version)
// cleanup
assert.NoError(t, k8sClient.Delete(context.Background(), &existing))
} | explode_data.jsonl/36805 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 465
} | [
2830,
3393,
14996,
43861,
2403,
1249,
31992,
1155,
353,
8840,
836,
8,
341,
197,
322,
10549,
198,
84041,
77,
1669,
4494,
98932,
68552,
675,
63121,
25,
330,
2408,
73655,
497,
41962,
25,
330,
2258,
16707,
8122,
11083,
1669,
348,
16,
7141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGenModel_Issue423(t *testing.T) {
specDoc, err := loads.Spec("../fixtures/bugs/423/swagger.json")
require.NoError(t, err)
definitions := specDoc.Spec().Definitions
schema := definitions["SRN"]
opts := opts()
genModel, err := makeGenDefinition("SRN", "models", schema, specDoc, opts)
require.NoError(t, err)
buf := bytes.NewBuffer(nil)
require.NoError(t, opts.templates.MustGet("model").Execute(buf, genModel))
ct, err := opts.LanguageOpts.FormatContent("SRN.go", buf.Bytes())
require.NoError(t, err)
res := string(ct)
assertInCode(t, "propSite, err := UnmarshalSite(bytes.NewBuffer(data.Site), runtime.JSONConsumer())", res)
assertInCode(t, "result.siteField = propSite", res)
} | explode_data.jsonl/2548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
9967,
1712,
7959,
83890,
19,
17,
18,
1155,
353,
8840,
836,
8,
341,
98100,
9550,
11,
1848,
1669,
20907,
36473,
17409,
45247,
14,
56176,
14,
19,
17,
18,
80930,
4323,
1138,
17957,
35699,
1155,
11,
1848,
692,
7452,
4054,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseLetStatements(t *testing.T) {
checkParseStatement(t, "let x = 42", "(let nil x 42)")
checkParseStatement(t, "let x: int = 42", "(let int x 42)")
} | explode_data.jsonl/33526 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
14463,
10061,
93122,
1155,
353,
8840,
836,
8,
341,
25157,
14463,
8636,
1155,
11,
330,
1149,
856,
284,
220,
19,
17,
497,
11993,
1149,
2092,
856,
220,
19,
17,
19107,
25157,
14463,
8636,
1155,
11,
330,
1149,
856,
25,
526,
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 |
func TestFailGracefullyBadMACAddress(t *testing.T) {
err := add("netboot", []string{"dhcpv6", "test"})
if err.Error() != "address test: invalid MAC address" {
t.Errorf(`err.Error() = %q, want "error message should be: address test: invalid MAC address"`, err.Error())
}
} | explode_data.jsonl/25077 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
19524,
86543,
3641,
17082,
25788,
4286,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
912,
445,
4711,
4619,
497,
3056,
917,
4913,
96220,
85,
21,
497,
330,
1944,
23625,
743,
1848,
6141,
368,
961,
330,
4995,
1273,
25,
8318,
2288... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPClientFailureHead400(t *testing.T) {
client := newHTTPClientFailureClient()
result, err := client.Head400(context.Background(), nil)
if err != nil {
t.Fatal(err)
}
if result.Success {
t.Fatal("Expected a false result")
}
} | explode_data.jsonl/54924 | {
"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,
9230,
2959,
17507,
12346,
19,
15,
15,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
9230,
2959,
17507,
2959,
741,
9559,
11,
1848,
1669,
2943,
90478,
19,
15,
15,
5378,
19047,
1507,
2092,
340,
743,
1848,
961,
2092,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTrippableBreakerManualBreak(t *testing.T) {
c := clock.NewMock()
cb := NewBreaker()
cb.Clock = c
cb.Break()
c.Add(cb.nextBackOff + 1)
if cb.Ready() {
t.Fatal("expected breaker to still be tripped")
}
cb.Reset()
cb.Trip()
c.Add(cb.nextBackOff + 1)
if !cb.Ready() {
t.Fatal("expected breaker to be ready")
}
} | explode_data.jsonl/60799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
21884,
602,
480,
22524,
261,
52092,
22524,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
8866,
7121,
11571,
741,
63810,
1669,
1532,
22524,
261,
741,
63810,
79248,
284,
272,
198,
63810,
1785,
1108,
741,
1444,
1904,
35653,
4529,
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 TestPing(t *testing.T) {
testutils.WithTestServer(t, nil, func(t testing.TB, ts *testutils.TestServer) {
ctx, cancel := NewContext(time.Second)
defer cancel()
errFrame := getErrorFrame(t)
var returnErr bool
frameRelay, close := testutils.FrameRelay(t, ts.HostPort(), func(outgoing bool, f *Frame) *Frame {
if !outgoing && returnErr {
errFrame.Header.ID = f.Header.ID
f = errFrame
}
return f
})
defer close()
clientCh := ts.NewClient(nil)
defer clientCh.Close()
require.NoError(t, clientCh.Ping(ctx, frameRelay))
conn, err := clientCh.RootPeers().GetOrAdd(frameRelay).GetConnection(ctx)
require.NoError(t, err, "Failed to get connection")
returnErr = true
require.Error(t, conn.Ping(ctx), "Expect error from error frame")
require.True(t, conn.IsActive(), "Connection should still be active after error frame")
returnErr = false
require.NoError(t, conn.Ping(ctx), "Ping should succeed")
})
} | explode_data.jsonl/78179 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
69883,
1155,
353,
8840,
836,
8,
341,
18185,
6031,
26124,
2271,
5475,
1155,
11,
2092,
11,
2915,
1155,
7497,
836,
33,
11,
10591,
353,
1944,
6031,
8787,
5475,
8,
341,
197,
20985,
11,
9121,
1669,
1532,
1972,
9730,
32435,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCreateNewSessionWithDefaultRegion(t *testing.T) {
// TODO Refactor for encapsulation
oldHome, err := testutils.SwitchAWSHome()
defer testutils.RestoreHome(oldHome)
os.Setenv("AWS_REGION", "")
os.Setenv("AWS_DEFAULT_REGION", "")
os.Setenv("AWS_PROFILE", "")
sess, err := session.NewAwsSessionWithoutOptions()
assert.Nil(t, err)
assert.Equal(t, "us-west-2", *sess.Config.Region)
} | explode_data.jsonl/68827 | {
"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,
4021,
3564,
5283,
2354,
3675,
14091,
1155,
353,
8840,
836,
8,
341,
197,
322,
5343,
8550,
5621,
369,
42569,
2914,
198,
61828,
7623,
11,
1848,
1669,
1273,
6031,
808,
5539,
36136,
7623,
741,
16867,
1273,
6031,
31129,
460,
7623,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIAMTokenSource(t *testing.T) {
tests := []struct {
name string
givenIAMErr bool
wantErr bool
}{
{
name: "normal success",
},
{
name: "iam error",
givenIAMErr: true,
wantErr: true,
},
}
for _, test := range tests {
const tokenValue = "iam-signed-jwt"
t.Run(test.name, func(t *testing.T) {
iamSvr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(iam.SignJwtResponse{
SignedJwt: tokenValue,
})
}))
if test.givenIAMErr {
iamSvr.Close()
} else {
defer iamSvr.Close()
}
defaultTokenSource = func(ctx context.Context, scopes ...string) (oauth2.TokenSource, error) {
return nil, nil
}
defer func() {
defaultTokenSource = google.DefaultTokenSource
}()
cfg := IAMConfig{
IAMAddress: iamSvr.URL,
}
ctx := context.Background()
src, err := NewIAMTokenSource(ctx, cfg)
if (err != nil) != test.wantErr {
t.Errorf("expected error? %t but got %s", test.wantErr, err)
}
if src == nil {
return
}
got, err := src.Token()
if (err != nil) != test.wantErr {
t.Errorf("expected error? %t but got %s", test.wantErr, err)
}
if got.AccessToken != tokenValue {
t.Errorf("expected access token value of %s, got %s",
tokenValue, got.AccessToken)
}
csrc, err := NewContextIAMTokenSource(ctx, cfg)
if (err != nil) != test.wantErr {
t.Errorf("expected error? %t but got %s", test.wantErr, err)
}
if csrc == nil {
return
}
got, err = csrc.ContextToken(ctx)
if (err != nil) != test.wantErr {
t.Errorf("expected error? %t but got %s", test.wantErr, err)
}
if got.AccessToken != tokenValue {
t.Errorf("expected access token value of %s, got %s",
tokenValue, got.AccessToken)
}
})
}
} | explode_data.jsonl/44402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 842
} | [
2830,
3393,
73707,
3323,
3608,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
3174,
2071,
40,
2729,
634,
1807,
271,
197,
50780,
7747,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEntryAddBatchTimerWithPoolAlloc(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
timerValPool := pool.NewFloatsPool([]pool.Bucket{
{Capacity: 16, Count: 1},
}, nil)
timerValPool.Init()
// Consume the element in the pool.
input := timerValPool.Get(10)
input = append(input, []float64{1.0, 3.5, 2.2, 6.5, 4.8}...)
bt := unaggregated.MetricUnion{
Type: metric.TimerType,
ID: testBatchTimerID,
BatchTimerVal: input,
TimerValPool: timerValPool,
}
e, _, _ := testEntry(ctrl, testEntryOptions{})
require.NoError(t, e.AddUntimed(bt, testDefaultStagedMetadatas))
// Assert the timer values have been returned to pool.
vals := timerValPool.Get(10)
require.Equal(t, []float64{1.0, 3.5, 2.2, 6.5, 4.8}, vals[:5])
} | explode_data.jsonl/24207 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
5874,
2212,
21074,
10105,
2354,
10551,
25154,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
51534,
2208,
10551,
1669,
7314,
7121,
5442,
82,
10551,
10556,
1028... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCSINodeService(t *testing.T) {
RegisterFailHandler(Fail)
junitReporter := reporters.NewJUnitReporter("node-svc.xml")
RunSpecsWithDefaultAndCustomReporters(t, "CSINodeService testing suite", []Reporter{junitReporter})
} | explode_data.jsonl/5884 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
6412,
687,
534,
1860,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
340,
12428,
3843,
52766,
1669,
19040,
7121,
56248,
52766,
445,
3509,
1331,
7362,
9028,
1138,
85952,
8327,
16056,
3675,
3036,
10268,
10361,
388,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEvalTakesStructD(t *testing.T) {
var values = strings.Split("a.C.D", ".")
var strNode = ArgNode{
value: "a.C.D",
values: values,
valuesLen: len(values),
}
var m = A{B: "B", C: C{D: "D"}}
var r, _ = EvalTakes(strNode, m)
fmt.Println(r)
} | explode_data.jsonl/52557 | {
"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,
54469,
51,
2050,
9422,
35,
1155,
353,
8840,
836,
8,
341,
2405,
2750,
284,
9069,
19823,
445,
64,
727,
909,
497,
5933,
1138,
2405,
607,
1955,
284,
7638,
1955,
515,
197,
16309,
25,
257,
330,
64,
727,
909,
756,
197,
45939,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_service_CreateEventLog(t *testing.T) {
tests := []struct {
name string
eventLog *EventLog
calls int
wantErr bool
}{
{
name: "simple",
eventLog: &EventLog{
Loc: &Coordinates{
DetectorId: "my-detector-id",
},
Events: []*DetectionEvent{
{
DeviceId: &DetectionEvent_Bluetooth{
Bluetooth: "my-bt-device-id",
},
Time: []*timestamp.Timestamp{
{Seconds: 100, Nanos: 200},
{Seconds: 200, Nanos: 300},
},
},
{
DeviceId: &DetectionEvent_Wifi{
Wifi: "my-wifi-device-id",
},
Time: []*timestamp.Timestamp{
{Seconds: 100, Nanos: 200},
{Seconds: 200, Nanos: 300},
},
},
{
DeviceId: &DetectionEvent_Mobile{
Mobile: "my-mobile-device-id",
},
Time: []*timestamp.Timestamp{
{Seconds: 100, Nanos: 200},
{Seconds: 200, Nanos: 300},
},
},
},
},
calls: 6,
wantErr: false,
},
}
for _, test := range tests {
tt := test
t.Run(tt.name, func(t *testing.T) {
logger := log15.New("test", "collector")
repoMock := &mocks.Repository{}
mockResultFn := func(_ context.Context, detectorID string, deviceID string, timestamp time.Time) error {
// Confirm existence of arguments in original event.
if detectorID != tt.eventLog.Loc.DetectorId {
return fmt.Errorf("wrong value of detector ID want=%v, got=%v", tt.eventLog.Loc.DetectorId, detectorID)
}
for _, ev := range tt.eventLog.Events {
evdID, err := decodeDeviceID(ev)
if err != nil {
return err
}
if evdID == deviceID {
for _, ts := range ev.Time {
t := time.Unix(ts.Seconds, int64(ts.Nanos))
if t == timestamp {
return nil
}
}
}
}
return fmt.Errorf("failed to find device detection event")
}
repoMock.On("CreateDetectionEvent",
mock.Anything, mock.AnythingOfType("string"), mock.AnythingOfType("string"), mock.AnythingOfType("time.Time")).
Return(mockResultFn, nil)
s := NewCollectorService(repoMock, logger)
_, err := s.CreateEventLog(context.Background(), tt.eventLog)
if (err != nil) != tt.wantErr {
t.Errorf("service.CreateEventLog() error = %v, wantErr %v", err, tt.wantErr)
return
}
repoMock.AssertNumberOfCalls(t, "CreateDetectionEvent", tt.calls)
})
}
} | explode_data.jsonl/23267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1139
} | [
2830,
3393,
12267,
34325,
1556,
2201,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
28302,
2201,
353,
1556,
2201,
198,
197,
1444,
5583,
262,
526,
198,
197,
50780,
7747,
220,
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... | 7 |
func TestUserCloneNil(t *testing.T) {
user := (*User)(nil)
clone := user.clone()
if clone != nil {
t.Fatalf("Expected nil, got: %+v", clone)
}
} | explode_data.jsonl/75602 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
1474,
37677,
19064,
1155,
353,
8840,
836,
8,
341,
19060,
1669,
4609,
1474,
2376,
8385,
340,
197,
19982,
1669,
1196,
15997,
741,
743,
14715,
961,
2092,
341,
197,
3244,
30762,
445,
18896,
2092,
11,
2684,
25,
68524,
85,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestReconciler_TaintedNode_RollingUpgrade(t *testing.T) {
job := mock.Job()
job.TaskGroups[0].Update = noCanaryUpdate
// Create an existing deployment that has some placed allocs
d := structs.NewDeployment(job)
d.TaskGroups[job.TaskGroups[0].Name] = &structs.DeploymentState{
Promoted: true,
DesiredTotal: 10,
PlacedAllocs: 7,
}
// Create 2 allocations from the old job
var allocs []*structs.Allocation
for i := 8; i < 10; i++ {
alloc := mock.Alloc()
alloc.Job = job
alloc.JobID = job.ID
alloc.NodeID = uuid.Generate()
alloc.Name = structs.AllocName(job.ID, job.TaskGroups[0].Name, uint(i))
alloc.TaskGroup = job.TaskGroups[0].Name
allocs = append(allocs, alloc)
}
// Create the healthy replacements
handled := make(map[string]allocUpdateType)
for i := 0; i < 8; i++ {
new := mock.Alloc()
new.Job = job
new.JobID = job.ID
new.NodeID = uuid.Generate()
new.Name = structs.AllocName(job.ID, job.TaskGroups[0].Name, uint(i))
new.TaskGroup = job.TaskGroups[0].Name
new.DeploymentID = d.ID
new.DeploymentStatus = &structs.AllocDeploymentStatus{
Healthy: helper.BoolToPtr(true),
}
allocs = append(allocs, new)
handled[new.ID] = allocUpdateFnIgnore
}
// Build a map of tainted nodes
tainted := make(map[string]*structs.Node, 3)
for i := 0; i < 3; i++ {
n := mock.Node()
n.ID = allocs[2+i].NodeID
if i == 0 {
n.Status = structs.NodeStatusDown
} else {
n.Drain = true
}
tainted[n.ID] = n
}
mockUpdateFn := allocUpdateFnMock(handled, allocUpdateFnDestructive)
reconciler := NewAllocReconciler(testLogger(), mockUpdateFn, false, job.ID, job, d, allocs, tainted)
r := reconciler.Compute()
// Assert the correct results
assertResults(t, r, &resultExpectation{
createDeployment: nil,
deploymentUpdates: nil,
place: 2,
destructive: 2,
stop: 2,
followupEvalWait: 31 * time.Second,
desiredTGUpdates: map[string]*structs.DesiredUpdates{
job.TaskGroups[0].Name: {
Place: 1, // Place the lost
Stop: 1, // Stop the lost
Migrate: 1, // Migrate the tainted
DestructiveUpdate: 2,
Ignore: 6,
},
},
})
assertNamesHaveIndexes(t, intRange(8, 9), destructiveResultsToNames(r.destructiveUpdate))
assertNamesHaveIndexes(t, intRange(0, 1), placeResultsToNames(r.place))
assertNamesHaveIndexes(t, intRange(0, 1), stopResultsToNames(r.stop))
} | explode_data.jsonl/67269 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1039
} | [
2830,
3393,
693,
40446,
5769,
1139,
30229,
1955,
2568,
965,
287,
43861,
1155,
353,
8840,
836,
8,
341,
68577,
1669,
7860,
45293,
741,
68577,
28258,
22173,
58,
15,
936,
4289,
284,
902,
6713,
658,
4289,
271,
197,
322,
4230,
458,
6350,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestConformanceTests(t *testing.T) {
const dir = "testdata"
fis, err := ioutil.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
wtid := watchTargetID
watchTargetID = conformanceTestWatchTargetID
defer func() { watchTargetID = wtid }()
n := 0
for _, fi := range fis {
if strings.HasSuffix(fi.Name(), ".textproto") {
runTestFromFile(t, filepath.Join(dir, fi.Name()))
n++
}
}
t.Logf("ran %d conformance tests", n)
} | explode_data.jsonl/34234 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
1109,
11795,
18200,
1155,
353,
8840,
836,
8,
341,
4777,
5419,
284,
330,
92425,
698,
1166,
285,
11,
1848,
1669,
43144,
6503,
6184,
14161,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
6692,
24449,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObjectGetSet(t *testing.T) {
const SCRIPT = `
input.test++;
input;
`
r := New()
o := r.NewObject()
o.Set("test", 42)
r.Set("input", o)
v, err := r.RunString(SCRIPT)
if err != nil {
t.Fatal(err)
}
if o1, ok := v.(*Object); ok {
if v1 := o1.Get("test"); v1.Export() != int64(43) {
t.Fatalf("Unexpected test value: %v (%T)", v1, v1.Export())
}
}
} | explode_data.jsonl/10461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
1190,
1949,
1649,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
197,
22427,
5958,
3507,
197,
22427,
280,
197,
3989,
7000,
1669,
1532,
741,
22229,
1669,
435,
7121,
1190,
741,
22229,
4202,
445,
1944,
497,
220,
19,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestConvertToUTF8String(t *testing.T) {
var testTable = []struct {
charset string
input []byte
want string
}{
{"utf-8", []byte("abcABC\u2014"), "abcABC\u2014"},
{"windows-1250", []byte{'a', 'Z', 0x96}, "aZ\u2013"},
{"big5", []byte{0xa1, 0x5d, 0xa1, 0x61, 0xa1, 0x71}, "\uff08\uff5b\u3008"},
}
// Success Conditions
for _, v := range testTable {
s, err := coding.ConvertToUTF8String(v.charset, v.input)
if err != nil {
t.Error("UTF-8 conversion failed")
}
if s != v.want {
t.Errorf("Got %s, but wanted %s", s, v.want)
}
}
// Fail for unsupported charset
_, err := coding.ConvertToUTF8String("123", []byte("there is no 123 charset"))
if err == nil {
t.Error("Charset 123 should not exist")
}
} | explode_data.jsonl/69515 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
12012,
1249,
8561,
23,
703,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
2556,
284,
3056,
1235,
341,
197,
7450,
746,
914,
198,
197,
22427,
256,
3056,
3782,
198,
197,
50780,
262,
914,
198,
197,
59403,
197,
197,
4913,
4762,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDockerError(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mockDocker := mock_docker.NewMockDocker(mockCtrl)
fs := newFakeFileSystem(testCgroupEntries)
p := newTestPlugin(
t,
withMockDocker(mockDocker),
withFileSystem(fs),
withDisabledRetryer(),
)
mockDocker.EXPECT().
ContainerInspect(gomock.Any(), testContainerID).
Return(types.ContainerJSON{}, errors.New("docker error"))
res, err := doAttest(t, p, &workloadattestor.AttestRequest{Pid: 123})
require.Error(t, err)
require.Contains(t, err.Error(), "docker error")
require.Nil(t, res)
} | explode_data.jsonl/27998 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
35,
13659,
1454,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
741,
77333,
35,
13659,
1669,
7860,
814,
13659,
7121,
11571,
35,
13659,
30389,
15001,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.