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 TestIssue138(t *testing.T) {
env := map[string]interface{}{}
_, err := expr.Compile(`1 / (1 - 1)`, expr.Env(env))
require.Error(t, err)
require.Equal(t, "integer divide by zero (1:3)\n | 1 / (1 - 1)\n | ..^", err.Error())
_, err = expr.Compile(`1 % 0`, expr.Env(env))
require.Error(t, err)
} | explode_data.jsonl/36919 | {
"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,
42006,
16,
18,
23,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
2415,
14032,
31344,
6257,
31483,
197,
6878,
1848,
1669,
15169,
89323,
5809,
16,
608,
320,
16,
481,
220,
16,
8,
7808,
15169,
81214,
16978,
1171,
17957,
6141,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubChainState(t *testing.T) {
t.Parallel()
sc1 := SubChain{
ChainID: 2,
SecurityDeposit: big.NewInt(1),
OperationDeposit: big.NewInt(2),
StartHeight: 100,
ParentHeightOffset: 10,
OwnerPublicKey: testaddress.Addrinfo["producer"].PublicKey,
CurrentHeight: 200,
DepositCount: 300,
}
data, err := sc1.Serialize()
require.NoError(t, err)
var sc2 SubChain
require.NoError(t, sc2.Deserialize(data))
require.Equal(t, sc1, sc2)
} | explode_data.jsonl/38130 | {
"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,
3136,
18837,
1397,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
29928,
16,
1669,
3719,
18837,
515,
197,
197,
18837,
915,
25,
310,
220,
17,
345,
197,
7568,
18429,
78982,
25,
262,
2409,
7121,
1072,
7,
16,
1326,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApps(t *testing.T) {
apps := Default.Apps()
if len(apps) != 5 {
t.Fatalf("Unexpected # of apps. Want 5, have %d", len(apps))
}
// Base protocol.
if apps[0].ID != 0 {
t.Fatalf("Unexpected app.ID. Want 0, have %d", apps[0].ID)
}
// Base accounting
if apps[1].ID != 3 {
t.Fatalf("Unexpected app.ID. Want 3, have %d", apps[1].ID)
}
// Credit-Control applications.
if apps[2].ID != 4 {
t.Fatalf("Unexpected app.ID. Want 4, have %d", apps[2].ID)
}
// NASREQ applications
if apps[3].ID != 1 {
t.Fatalf("Unexpected app.ID. Want 1, have %d", apps[3].ID)
}
} | explode_data.jsonl/9069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
53602,
1155,
353,
8840,
836,
8,
341,
197,
27635,
1669,
7899,
5105,
82,
741,
743,
2422,
11462,
82,
8,
961,
220,
20,
341,
197,
3244,
30762,
445,
29430,
671,
315,
10500,
13,
23252,
220,
20,
11,
614,
1018,
67,
497,
2422,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLatestStableRelease(t *testing.T) {
testcases := []struct {
versions []string
want string
}{{
versions: []string{"1.7", "1.6"},
want: "1.7",
}, {
versions: []string{"1.6", "nightly"},
want: "1.6",
}, {
versions: []string{"1.7-RC0", "1.7", "nightly"},
want: "1.7",
}, {
versions: []string{"nightly", "nightly-20180201"},
want: "",
}, {
versions: []string{"1.7-RC0", "1.6", "1.5", "nightly", "nightly-20180201"},
want: "1.6",
}}
for _, testcase := range testcases {
input := make([]parsedVersion, 0, len(testcase.versions))
for _, version := range testcase.versions {
parsed, err := parseVersion(version)
if err != nil {
t.Fatalf("Could not parse version %q", version)
}
if parsed.versionString() != version {
t.Fatalf("parsedVersion(%q).versionString() = %q, want: %q", version, parsed.versionString(), version)
}
input = append(input, parsed)
}
output, err := sortedParsedVersions(input).LatestStableRelease()
if len(testcase.want) > 0 && err != nil {
t.Errorf("sortedParsedVersions(%#v).LatestStableRelease() = %v, want: nil", testcase.versions, err)
}
if testcase.want != output {
t.Errorf("sortedParsedVersions(%#v).LatestStableRelease() = %q, want: %q", testcase.versions, output, testcase.want)
}
}
} | explode_data.jsonl/35512 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 557
} | [
2830,
3393,
31992,
623,
480,
16077,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
197,
28290,
3056,
917,
198,
197,
50780,
257,
914,
198,
197,
15170,
515,
197,
197,
28290,
25,
3056,
917,
4913,
16,
13,
22,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTabletserverSetRollback(t *testing.T) {
_, tsv, db := newTestTxExecutor(t)
defer tsv.StopService()
defer db.Close()
target := querypb.Target{TabletType: topodatapb.TabletType_PRIMARY}
rollbackTransition := fmt.Sprintf("update _vt.dt_state set state = %d where dtid = 'aa' and state = %d", int(querypb.TransactionState_ROLLBACK), int(querypb.TransactionState_PREPARE))
db.AddQuery(rollbackTransition, &sqltypes.Result{RowsAffected: 1})
txid := newTxForPrep(tsv)
err := tsv.SetRollback(ctx, &target, "aa", txid)
require.NoError(t, err)
db.AddQuery(rollbackTransition, &sqltypes.Result{})
txid = newTxForPrep(tsv)
err = tsv.SetRollback(ctx, &target, "aa", txid)
assert.EqualError(t, err, "could not transition to ROLLBACK: aa", "Prepare err")
} | explode_data.jsonl/79985 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
2556,
83,
4030,
1649,
32355,
1419,
1155,
353,
8840,
836,
8,
341,
197,
6878,
259,
3492,
11,
2927,
1669,
501,
2271,
31584,
25255,
1155,
340,
16867,
259,
3492,
30213,
1860,
741,
16867,
2927,
10421,
741,
28861,
1669,
3239,
16650... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckSwarmPorts_Name(t *testing.T) {
e := &event.Mock{}
f := &docker.FactoryMock{}
task := NewCheckSwarmPorts(e, f)
assert.Equal(t, "CheckSwarmPorts", task.Name())
e.M.AssertExpectations(t)
f.AssertExpectations(t)
} | explode_data.jsonl/82250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
3973,
13218,
2178,
68273,
19015,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
609,
3087,
24664,
16094,
1166,
1669,
609,
28648,
51008,
11571,
31483,
49115,
1669,
1532,
3973,
13218,
2178,
68273,
2026,
11,
282,
692,
6948,
12808,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFavoritesListFailsDuringAddAsync(t *testing.T) {
mockCtrl, config, ctx := favTestInit(t, false)
// Only one task at a time
f := newFavoritesWithChan(config, make(chan *favReq, 1))
f.InitForTest()
defer favTestShutdown(t, mockCtrl, config, f)
// Call Add twice in a row, but only get one Add KBPKI call
fav1 := favorites.ToAdd{
Folder: favorites.Folder{
Name: "test",
Type: tlf.Public,
},
Data: favorites.Data{},
Created: false,
}
config.mockClock.EXPECT().Now().Return(time.Unix(0, 0)).Times(2)
// Cancel the first list request
config.mockKbpki.EXPECT().FavoriteList(gomock.Any()).Return(keybase1.
FavoritesResult{}, context.Canceled)
f.AddAsync(ctx, fav1) // this will fail
// Wait so the next one doesn't get batched together with this one
if err := f.wg.Wait(context.Background()); err != nil {
t.Fatalf("Couldn't wait on favorites: %v", err)
}
// Now make sure the second time around, the favorites get listed
// and one gets added, even if its context gets added
c := make(chan struct{})
config.mockKbpki.EXPECT().FavoriteList(gomock.Any()).Return(keybase1.FavoritesResult{}, nil)
config.mockKbpki.EXPECT().FavoriteAdd(gomock.Any(), fav1.ToKBFolder()).
Do(func(_ context.Context, _ keybase1.Folder) {
c <- struct{}{}
}).Return(nil)
f.AddAsync(ctx, fav1) // should work
<-c
} | explode_data.jsonl/14684 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 501
} | [
2830,
3393,
85221,
852,
37,
6209,
16014,
2212,
6525,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
11,
2193,
11,
5635,
1669,
9244,
2271,
3803,
1155,
11,
895,
340,
197,
322,
8278,
825,
3383,
518,
264,
882,
198,
1166,
1669,
501,
85221,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestErrorStatusCode404(t *testing.T) {
setupServer()
defer teardownServer()
mux.HandleFunc("/url", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
})
req := URL("http://example.com/url")
err := req.Get()
e, ok := err.(StatusError)
if !ok {
t.Errorf("Error %v doesn't implement StatusError", err)
}
if e.Code != 404 {
t.Errorf("Expected error code to be 404, got %v instead", e.Code)
}
var want = "404 Not Found"
var got = e.Error()
if got != want {
t.Errorf("Wanted %v, got %v instead", want, got)
}
assertTextualBody(t, "", req.Response.Body)
assertStatusCode(t, 404, req.Response.StatusCode)
} | explode_data.jsonl/24744 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
1454,
15872,
19,
15,
19,
1155,
353,
8840,
836,
8,
341,
84571,
5475,
741,
16867,
49304,
5475,
2822,
2109,
2200,
63623,
4283,
1085,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
69794,
7,
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... | 1 |
func TestResourcePermissionsCreate_conflicting_fields(t *testing.T) {
_, err := qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{},
Resource: ResourcePermissions(),
Create: true,
State: map[string]interface{}{
"cluster_id": "abc",
"notebook_path": "/Init",
"access_control": []interface{}{
map[string]interface{}{
"user_name": TestingUser,
"permission_level": "CAN_READ",
},
},
},
}.Apply(t)
qa.AssertErrorStartsWith(t, err, "invalid config supplied. cluster_id: conflicts with notebook_path. notebook_path: conflicts with cluster_id")
} | explode_data.jsonl/50877 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
4783,
23851,
4021,
16059,
78208,
12132,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
88496,
20766,
18930,
515,
197,
12727,
941,
18513,
25,
3056,
15445,
27358,
18930,
38837,
197,
79487,
25,
11765,
23851,
3148,
197,
7556... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventEmitter(t *testing.T) {
emitter := newEventEmitter()
go emitter.run()
done := make(chan struct{})
maxCalls := 12
nRecvdEvents := 0
emitter.on(ReconnectingEvent, func(str string) {
nRecvdEvents++
if nRecvdEvents == maxCalls {
close(done)
}
})
go func() {
for i := 0; i < maxCalls; i++ {
emitter.emit(ReconnectingEvent, "I am reconnecting!")
}
}()
select {
case <-time.After(1 * time.Second):
t.Fail()
case <-done:
}
emitter.close()
} | explode_data.jsonl/2031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
1556,
21971,
1155,
353,
8840,
836,
8,
341,
66204,
3248,
1669,
501,
1556,
21971,
741,
30680,
47263,
7634,
2822,
40495,
1669,
1281,
35190,
2036,
37790,
22543,
55292,
1669,
220,
16,
17,
198,
9038,
3820,
16598,
7900,
1669,
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... | 2 |
func TestMapSliceToInt(t *testing.T) {
assert := assert.New(t)
g := &Group{
People: []*Person{
{0, "George", 42.42, true},
{1, "Jeff", 0, true},
{2, "Ted", 50, true},
{3, "Luda", 100, false},
},
}
s, err := slices.ToInts(g.People, "ID")
assert.Nil(err)
assert.NotEmpty(s)
assert.Equal(s[0], 0)
assert.Equal(s[1], 1)
assert.Equal(s[2], 2)
assert.Equal(s[3], 3)
s, err = slices.ToInts(g.People, "Money")
assert.Equal(slices.ErrNotInt, err)
} | explode_data.jsonl/18824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
2227,
33236,
38544,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
3174,
1669,
609,
2808,
515,
197,
10025,
68,
1164,
25,
29838,
10680,
515,
298,
197,
90,
15,
11,
330,
38952,
497,
220,
19,
17,
13,
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 TestContainerManifestNaming(t *testing.T) {
verifyPackUnpack(t, "file", "manifest1234", "container5678")
verifyPackUnpack(t, "file", "manifest--", "container__")
verifyPackUnpack(t, "file", "--manifest", "__container")
verifyPackUnpack(t, "", "m___anifest_", "container-_-")
verifyPackUnpack(t, "other", "_m___anifest", "-_-container")
container := &api.Container{Name: "container"}
pod := &Pod{Name: "foo", Namespace: "test"}
name := fmt.Sprintf("k8s--%s--%s.%s--12345", container.Name, pod.Name, pod.Namespace)
podFullName := fmt.Sprintf("%s.%s", pod.Name, pod.Namespace)
returnedPodFullName, returnedContainerName, hash := parseDockerName(name)
if returnedPodFullName != podFullName || returnedContainerName != container.Name || hash != 0 {
t.Errorf("unexpected parse: %s %s %d", returnedPodFullName, returnedContainerName, hash)
}
} | explode_data.jsonl/2823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
4502,
38495,
85410,
1155,
353,
8840,
836,
8,
341,
93587,
30684,
1806,
4748,
1155,
11,
330,
1192,
497,
330,
42315,
16,
17,
18,
19,
497,
330,
3586,
20,
21,
22,
23,
1138,
93587,
30684,
1806,
4748,
1155,
11,
330,
1192,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestApp_VisibleCategories(t *testing.T) {
app := &App{
Name: "visible-categories",
HideHelp: true,
Commands: []*Command{
{
Name: "command1",
Category: "1",
HelpName: "foo command1",
Hidden: true,
},
{
Name: "command2",
Category: "2",
HelpName: "foo command2",
},
{
Name: "command3",
Category: "3",
HelpName: "foo command3",
},
},
}
expected := []CommandCategory{
&commandCategory{
name: "2",
commands: []*Command{
app.Commands[1],
},
},
&commandCategory{
name: "3",
commands: []*Command{
app.Commands[2],
},
},
}
app.Setup()
expect(t, expected, app.VisibleCategories())
app = &App{
Name: "visible-categories",
HideHelp: true,
Commands: []*Command{
{
Name: "command1",
Category: "1",
HelpName: "foo command1",
Hidden: true,
},
{
Name: "command2",
Category: "2",
HelpName: "foo command2",
Hidden: true,
},
{
Name: "command3",
Category: "3",
HelpName: "foo command3",
},
},
}
expected = []CommandCategory{
&commandCategory{
name: "3",
commands: []*Command{
app.Commands[2],
},
},
}
app.Setup()
expect(t, expected, app.VisibleCategories())
app = &App{
Name: "visible-categories",
HideHelp: true,
Commands: []*Command{
{
Name: "command1",
Category: "1",
HelpName: "foo command1",
Hidden: true,
},
{
Name: "command2",
Category: "2",
HelpName: "foo command2",
Hidden: true,
},
{
Name: "command3",
Category: "3",
HelpName: "foo command3",
Hidden: true,
},
},
}
app.Setup()
expect(t, []CommandCategory{}, app.VisibleCategories())
} | explode_data.jsonl/52591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 892
} | [
2830,
3393,
2164,
2334,
23066,
20970,
1155,
353,
8840,
836,
8,
341,
28236,
1669,
609,
2164,
515,
197,
21297,
25,
257,
330,
12601,
95099,
756,
197,
13292,
577,
12689,
25,
830,
345,
197,
197,
30479,
25,
29838,
4062,
515,
298,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCronSuite(t *testing.T) {
// To ensure consistency, always start at the next 30 second mark
_, _, sec := time.Now().Clock()
var toWait time.Duration
if sec <= 30 {
toWait = time.Duration(30-sec) * time.Second
} else {
toWait = time.Duration(90-sec) * time.Second
}
logrus.Infof("Waiting %s to start", humanize.Duration(toWait))
time.Sleep(toWait)
suite.Run(t, new(CronSuite))
} | explode_data.jsonl/63486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
34,
2248,
28000,
1155,
353,
8840,
836,
8,
341,
197,
322,
2014,
5978,
28137,
11,
2677,
1191,
518,
279,
1790,
220,
18,
15,
2086,
1868,
198,
197,
6878,
8358,
5701,
1669,
882,
13244,
1005,
26104,
741,
2405,
311,
14190,
882,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSellCoinTxBaseToCustomBaseCommission(t *testing.T) {
// sell_coin: MNT
// buy_coin: TEST
// gas_coin: MNT
coinToSell := types.GetBaseCoin()
coinToBuy := types.StrToCoinSymbol("TEST")
gasCoin := types.GetBaseCoin()
initialBalance := helpers.NoahToQNoah(big.NewInt(10000000))
toSell := helpers.NoahToQNoah(big.NewInt(100))
cState := getState()
initialVolume, initialReserve, crr := createTestCoinWithSymbol(cState, coinToBuy)
privateKey, addr := getAccount()
cState.Accounts.AddBalance(addr, coinToSell, initialBalance)
tx := createSellCoinTx(coinToSell, coinToBuy, gasCoin, toSell, 1)
if err := tx.Sign(privateKey); err != nil {
t.Fatal(err)
}
encodedTx, err := rlp.EncodeToBytes(tx)
if err != nil {
t.Fatal(err)
}
// check response
response := RunTx(cState, false, encodedTx, big.NewInt(0), 0, &sync.Map{}, 0)
if response.Code != code.OK {
t.Fatalf("Response code is not 0. Error %s", response.Log)
}
// check received coins
buyCoinBalance := cState.Accounts.GetBalance(addr, coinToBuy)
estimatedBuyBalance := formula.CalculatePurchaseReturn(initialVolume, initialReserve, crr, toSell)
if buyCoinBalance.Cmp(estimatedBuyBalance) != 0 {
t.Fatalf("Buy coin balance is not correct. Expected %s, got %s", estimatedBuyBalance.String(), buyCoinBalance.String())
}
// check sold coins + commission
sellCoinBalance := cState.Accounts.GetBalance(addr, coinToSell)
estimatedSellCoinBalance := big.NewInt(0).Set(initialBalance)
estimatedSellCoinBalance.Sub(estimatedSellCoinBalance, tx.CommissionInBaseCoin())
estimatedSellCoinBalance.Sub(estimatedSellCoinBalance, toSell)
if sellCoinBalance.Cmp(estimatedSellCoinBalance) != 0 {
t.Fatalf("Sell coin balance is not correct")
}
// check reserve and supply
coinData := cState.Coins.GetCoin(coinToBuy)
estimatedReserve := big.NewInt(0).Set(initialReserve)
estimatedReserve.Add(estimatedReserve, toSell)
if coinData.Reserve().Cmp(estimatedReserve) != 0 {
t.Fatalf("Wrong coin reserve")
}
estimatedSupply := big.NewInt(0).Set(initialVolume)
estimatedSupply.Add(estimatedSupply, formula.CalculatePurchaseReturn(initialVolume, initialReserve, crr, toSell))
if coinData.Volume().Cmp(estimatedSupply) != 0 {
t.Fatalf("Wrong coin supply")
}
} | explode_data.jsonl/21871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 804
} | [
2830,
3393,
68533,
41180,
31584,
3978,
1249,
10268,
3978,
73750,
1155,
353,
8840,
836,
8,
341,
197,
322,
4559,
75718,
25,
386,
6408,
198,
197,
322,
3695,
75718,
25,
13602,
198,
197,
322,
6819,
75718,
25,
386,
6408,
271,
197,
7160,
124... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateWithEmptyPdAddress(t *testing.T) {
cmd := new(cobra.Command)
o := newOptions()
o.addFlags(cmd)
require.Nil(t, cmd.ParseFlags([]string{"--pd="}))
err := o.complete(cmd)
require.Nil(t, err)
err = o.validate()
require.Regexp(t, ".*empty PD address.*", err.Error())
} | explode_data.jsonl/41627 | {
"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,
17926,
2354,
3522,
47,
67,
4286,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
501,
1337,
28856,
12714,
340,
22229,
1669,
501,
3798,
741,
22229,
1364,
9195,
14160,
692,
17957,
59678,
1155,
11,
5439,
8937,
9195,
10556,
917,
4913... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOrderingServiceStreamFailure(t *testing.T) {
testOrderingServiceStreamFailure(t, blockDelivererConsumerWithRecv)
testOrderingServiceStreamFailure(t, blockDelivererConsumerWithSend)
assert.Equal(t, 0, connNumber)
} | explode_data.jsonl/38312 | {
"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,
4431,
287,
1860,
3027,
17507,
1155,
353,
8840,
836,
8,
341,
18185,
4431,
287,
1860,
3027,
17507,
1155,
11,
2504,
16532,
1524,
261,
29968,
2354,
63483,
340,
18185,
4431,
287,
1860,
3027,
17507,
1155,
11,
2504,
16532,
1524,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBadComments(t *testing.T) {
t.Parallel()
const src = `
// first comment - text and position changed by test
package p
import "fmt"
const pi = 3.14 // rough circle
var (
x, y, z int = 1, 2, 3
u, v float64
)
func fibo(n int) {
if n < 2 {
return n /* seed values */
}
return fibo(n-1) + fibo(n-2)
}
`
f, err := parser.ParseFile(fset, "", src, parser.ParseComments)
if err != nil {
t.Error(err) // error in test
}
comment := f.Comments[0].List[0]
pos := comment.Pos()
if fset.PositionFor(pos, false /* absolute position */).Offset != 1 {
t.Error("expected offset 1") // error in test
}
testComment(t, f, len(src), &ast.Comment{Slash: pos, Text: "//-style comment"})
testComment(t, f, len(src), &ast.Comment{Slash: pos, Text: "/*-style comment */"})
testComment(t, f, len(src), &ast.Comment{Slash: pos, Text: "/*-style \n comment */"})
testComment(t, f, len(src), &ast.Comment{Slash: pos, Text: "/*-style comment \n\n\n */"})
} | explode_data.jsonl/64598 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
17082,
17373,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
4777,
2286,
284,
22074,
322,
1156,
3980,
481,
1467,
323,
2309,
5497,
553,
1273,
198,
1722,
281,
198,
474,
330,
12501,
698,
1024,
8938,
284,
220,
18,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_GetLatestAvailableMasterHash(t *testing.T) {
h, err := getLatestAvailableMasterHash(&stepMocks.Step{}, 5)
require.NoError(t, err)
require.True(t, isHex(h))
} | explode_data.jsonl/64706 | {
"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,
13614,
31992,
16485,
18041,
6370,
1155,
353,
8840,
836,
8,
341,
9598,
11,
1848,
1669,
633,
31992,
16485,
18041,
6370,
2099,
9520,
72577,
68402,
22655,
220,
20,
340,
17957,
35699,
1155,
11,
1848,
340,
17957,
32443,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCollectorServiceLinks(t *testing.T) {
c := NewCollector(v1.NewJaeger(types.NamespacedName{Name: "my-instance"}))
dep := c.Get()
falseVar := false
assert.Equal(t, &falseVar, dep.Spec.Template.Spec.EnableServiceLinks)
} | explode_data.jsonl/59539 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
53694,
1860,
24089,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
53694,
3747,
16,
7121,
52445,
1878,
52613,
98932,
68552,
675,
63121,
25,
330,
2408,
73655,
9207,
1171,
197,
14891,
1669,
272,
2234,
741,
36012,
3962,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestUpdate(t *testing.T) {
t.Parallel()
funcOK := Option{
name: "ok",
f: func(*Config) error {
return nil
},
}
funcNG := Option{
name: "ok",
f: func(*Config) error {
return errForTest
},
}
tests := []struct {
name string
options []Option
expect error
}{
{"success(nil)", nil, nil},
{"success(New)", []Option{funcOK}, nil},
{"success(Option)", []Option{funcNG}, errForTest},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
l := Must(NewWithConfig(io.Discard, NewConfig()))
expect := tt.expect
_, actual := l.Renew(tt.options...)
FailIfNotErrorIs(t, expect, actual)
})
}
} | explode_data.jsonl/71321 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
4289,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
29244,
3925,
1669,
6959,
515,
197,
11609,
25,
330,
562,
756,
197,
1166,
25,
2915,
4071,
2648,
8,
1465,
341,
298,
853,
2092,
198,
197,
197,
1583,
197,
532,
2924... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWatch(t *testing.T) {
var table = []struct {
t watch.EventType
obj runtime.Object
}{
{watch.Added, &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "first"}}},
{watch.Modified, &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "second"}}},
{watch.Deleted, &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "last"}}},
}
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
flusher, ok := w.(http.Flusher)
if !ok {
panic("need flusher!")
}
w.Header().Set("Transfer-Encoding", "chunked")
w.WriteHeader(http.StatusOK)
flusher.Flush()
encoder := restclientwatch.NewEncoder(streaming.NewEncoder(w, scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion)), scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion))
for _, item := range table {
if err := encoder.Encode(&watch.Event{Type: item.t, Object: item.obj}); err != nil {
panic(err)
}
flusher.Flush()
}
}))
defer testServer.Close()
s := testRESTClient(t, testServer)
watching, err := s.Get().Prefix("path/to/watch/thing").Watch()
if err != nil {
t.Fatalf("Unexpected error")
}
for _, item := range table {
got, ok := <-watching.ResultChan()
if !ok {
t.Fatalf("Unexpected early close")
}
if e, a := item.t, got.Type; e != a {
t.Errorf("Expected %v, got %v", e, a)
}
if e, a := item.obj, got.Object; !apiequality.Semantic.DeepDerivative(e, a) {
t.Errorf("Expected %v, got %v", e, a)
}
}
_, ok := <-watching.ResultChan()
if ok {
t.Fatal("Unexpected non-close")
}
} | explode_data.jsonl/13283 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 646
} | [
2830,
3393,
14247,
1155,
353,
8840,
836,
8,
341,
2405,
1965,
284,
3056,
1235,
341,
197,
3244,
256,
3736,
89879,
198,
197,
22671,
15592,
8348,
198,
197,
59403,
197,
197,
90,
14321,
1904,
291,
11,
609,
85,
16,
88823,
90,
1190,
12175,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDelete(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixtures.HandleDeleteSuccessfully(t)
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
err := Delete(client.ServiceClient(), serverId, aId).ExtractErr()
th.AssertNoErr(t, err)
} | explode_data.jsonl/34616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
6435,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
1166,
941,
18513,
31421,
6435,
35959,
1155,
340,
11323,
764,
1669,
330,
64,
17,
21,
23,
23,
22,
66,
21,
1786,
19,
22,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntArray_Remove(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []int{1, 2, 3, 5, 4}
array1 := garray.NewIntArrayFrom(a1)
v, ok := array1.Remove(1)
t.Assert(v, 2)
t.Assert(ok, true)
t.Assert(array1.Len(), 4)
v, ok = array1.Remove(0)
t.Assert(v, 1)
t.Assert(ok, true)
t.Assert(array1.Len(), 3)
v, ok = array1.Remove(2)
t.Assert(v, 4)
t.Assert(ok, true)
t.Assert(array1.Len(), 2)
})
} | explode_data.jsonl/47623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
95338,
66843,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11,
220,
19,
532,
197,
11923... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractJWK(t *testing.T) {
wfe, _ := setupWFE(t)
keyIDJWS, _, _ := signRequestKeyID(t, 1, nil, "", "", wfe.nonceService)
goodJWS, goodJWK, _ := signRequestEmbed(t, nil, "", "", wfe.nonceService)
testCases := []struct {
Name string
JWS *jose.JSONWebSignature
ExpectedKey *jose.JSONWebKey
ExpectedProblem *probs.ProblemDetails
}{
{
Name: "JWS with wrong auth type (Key ID vs embedded JWK)",
JWS: keyIDJWS,
ExpectedProblem: &probs.ProblemDetails{
Type: probs.MalformedProblem,
Detail: "No embedded JWK in JWS header",
HTTPStatus: http.StatusBadRequest,
},
},
{
Name: "Valid JWS with embedded JWK",
JWS: goodJWS,
ExpectedKey: goodJWK,
},
}
for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
jwk, prob := wfe.extractJWK(tc.JWS)
if tc.ExpectedProblem == nil && prob != nil {
t.Fatal(fmt.Sprintf("Expected nil problem, got %#v\n", prob))
} else if tc.ExpectedProblem == nil {
test.AssertMarshaledEquals(t, jwk, tc.ExpectedKey)
} else {
test.AssertMarshaledEquals(t, prob, tc.ExpectedProblem)
}
})
}
} | explode_data.jsonl/15354 | {
"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,
28959,
41,
68316,
1155,
353,
8840,
836,
8,
341,
6692,
1859,
11,
716,
1669,
6505,
54,
11419,
1155,
692,
23634,
915,
41,
7433,
11,
8358,
716,
1669,
1841,
1900,
1592,
915,
1155,
11,
220,
16,
11,
2092,
11,
7342,
7342,
289,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCertExpiration(t *testing.T) {
// Scenario: In this test we make sure that a peer may not expire
// its own identity.
// This is important because the only way identities are gossiped
// transitively is via the pull mechanism.
// If a peer's own identity disappears from the pull mediator,
// it will never be sent to peers transitively.
// The test ensures that self identities don't expire
// in the following manner:
// It starts a peer and then sleeps twice the identity usage threshold,
// in order to make sure that its own identity should be expired.
// Then, it starts another peer, and listens to the messages sent
// between both peers, and looks for a few identity digests of the first peer.
// If such identity digest are detected, it means that the peer
// didn't expire its own identity.
// Backup original usageThreshold value
idUsageThreshold := identity.GetIdentityUsageThreshold()
identity.SetIdentityUsageThreshold(time.Second)
// Restore original usageThreshold value
defer identity.SetIdentityUsageThreshold(idUsageThreshold)
port0, grpc0, certs0, secDialOpts0, _ := util.CreateGRPCLayer()
port1, grpc1, certs1, secDialOpts1, _ := util.CreateGRPCLayer()
g1 := newGossipInstanceWithGRPC(0, port0, grpc0, certs0, secDialOpts0, 0, port1)
defer g1.Stop()
time.Sleep(identity.GetIdentityUsageThreshold() * 2)
g2 := newGossipInstanceWithGRPC(0, port1, grpc1, certs1, secDialOpts1, 0)
defer g2.Stop()
identities2Detect := 3
// Make the channel bigger than needed so goroutines won't get stuck
identitiesGotViaPull := make(chan struct{}, identities2Detect+100)
acceptIdentityPullMsgs := func(o interface{}) bool {
m := o.(proto.ReceivedMessage).GetGossipMessage()
if m.IsPullMsg() && m.IsDigestMsg() {
for _, dig := range m.GetDataDig().Digests {
if bytes.Equal(dig, []byte(fmt.Sprintf("127.0.0.1:%d", port0))) {
identitiesGotViaPull <- struct{}{}
}
}
}
return false
}
g1.Accept(acceptIdentityPullMsgs, true)
for i := 0; i < identities2Detect; i++ {
select {
case <-identitiesGotViaPull:
case <-time.After(time.Second * 15):
assert.Fail(t, "Didn't detect an identity gossiped via pull in a timely manner")
return
}
}
} | explode_data.jsonl/52303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 735
} | [
2830,
3393,
36934,
66301,
1155,
353,
8840,
836,
8,
341,
197,
322,
58663,
25,
758,
419,
1273,
582,
1281,
2704,
429,
264,
14397,
1231,
537,
32563,
198,
197,
322,
1181,
1828,
9569,
624,
197,
322,
1096,
374,
2989,
1576,
279,
1172,
1616,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDaoPingRedis(t *testing.T) {
var (
c = context.Background()
)
convey.Convey("PingRedis", t, func(ctx convey.C) {
err := d.PingRedis(c)
ctx.Convey("Then err should be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
})
})
} | explode_data.jsonl/61958 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
12197,
69883,
48137,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
1444,
284,
2266,
19047,
741,
197,
340,
37203,
5617,
4801,
5617,
445,
69883,
48137,
497,
259,
11,
2915,
7502,
20001,
727,
8,
341,
197,
9859,
1669,
294,
106... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandshakeClientCertRSA(t *testing.T) {
config := *testConfig
cert, _ := X509KeyPair([]byte(clientCertificatePEM), []byte(clientKeyPEM))
config.Certificates = []Certificate{cert}
test := &clientTest{
name: "ClientCert-RSA-RSA",
command: []string{"openssl", "s_server", "-cipher", "RC4-SHA", "-verify", "1"},
config: &config,
}
runClientTestTLS10(t, test)
runClientTestTLS12(t, test)
test = &clientTest{
name: "ClientCert-RSA-ECDSA",
command: []string{"openssl", "s_server", "-cipher", "ECDHE-ECDSA-AES128-SHA", "-verify", "1"},
config: &config,
cert: testECDSACertificate,
key: testECDSAPrivateKey,
}
runClientTestTLS10(t, test)
runClientTestTLS12(t, test)
test = &clientTest{
name: "ClientCert-RSA-AES256-GCM-SHA384",
command: []string{"openssl", "s_server", "-cipher", "ECDHE-RSA-AES256-GCM-SHA384", "-verify", "1"},
config: &config,
cert: testRSACertificate,
key: testRSAPrivateKey,
}
runClientTestTLS12(t, test)
} | explode_data.jsonl/19951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 433
} | [
2830,
3393,
2314,
29661,
2959,
36934,
73564,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
353,
1944,
2648,
198,
1444,
529,
11,
716,
1669,
1599,
20,
15,
24,
1592,
12443,
10556,
3782,
12805,
33202,
1740,
44,
701,
3056,
3782,
12805,
1592,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBackoffMessage(t *testing.T) {
cancel, controller := newController()
defer cancel()
assert.NotNil(t, controller)
wf := unmarshalWF(backoffMessage)
assert.NotNil(t, wf)
woc := newWorkflowOperationCtx(wf, controller)
assert.NotNil(t, woc)
retryNode := woc.wf.GetNodeByName("retry-backoff-s69z6")
// Simulate backoff of 4 secods
firstNode := getChildNodeIndex(retryNode, woc.wf.Status.Nodes, 0)
firstNode.StartedAt = metav1.Time{Time: time.Now().Add(-8 * time.Second)}
firstNode.FinishedAt = metav1.Time{Time: time.Now().Add(-6 * time.Second)}
woc.wf.Status.Nodes[firstNode.ID] = *firstNode
lastNode := getChildNodeIndex(retryNode, woc.wf.Status.Nodes, -1)
lastNode.StartedAt = metav1.Time{Time: time.Now().Add(-3 * time.Second)}
lastNode.FinishedAt = metav1.Time{Time: time.Now().Add(-1 * time.Second)}
woc.wf.Status.Nodes[lastNode.ID] = *lastNode
newRetryNode, proceed, err := woc.processNodeRetries(retryNode, *woc.wf.Spec.Templates[0].RetryStrategy, &executeTemplateOpts{})
assert.NoError(t, err)
assert.False(t, proceed)
assert.Equal(t, "Backoff for 4 seconds", newRetryNode.Message)
// Advance time one second
firstNode.StartedAt = metav1.Time{Time: time.Now().Add(-9 * time.Second)}
firstNode.FinishedAt = metav1.Time{Time: time.Now().Add(-7 * time.Second)}
woc.wf.Status.Nodes[firstNode.ID] = *firstNode
lastNode.StartedAt = metav1.Time{Time: time.Now().Add(-4 * time.Second)}
lastNode.FinishedAt = metav1.Time{Time: time.Now().Add(-2 * time.Second)}
woc.wf.Status.Nodes[lastNode.ID] = *lastNode
newRetryNode, proceed, err = woc.processNodeRetries(retryNode, *woc.wf.Spec.Templates[0].RetryStrategy, &executeTemplateOpts{})
assert.NoError(t, err)
assert.False(t, proceed)
// Message should not change
assert.Equal(t, "Backoff for 4 seconds", newRetryNode.Message)
// Advance time 3 seconds
firstNode.StartedAt = metav1.Time{Time: time.Now().Add(-12 * time.Second)}
firstNode.FinishedAt = metav1.Time{Time: time.Now().Add(-10 * time.Second)}
woc.wf.Status.Nodes[firstNode.ID] = *firstNode
lastNode.StartedAt = metav1.Time{Time: time.Now().Add(-7 * time.Second)}
lastNode.FinishedAt = metav1.Time{Time: time.Now().Add(-5 * time.Second)}
woc.wf.Status.Nodes[lastNode.ID] = *lastNode
newRetryNode, proceed, err = woc.processNodeRetries(retryNode, *woc.wf.Spec.Templates[0].RetryStrategy, &executeTemplateOpts{})
assert.NoError(t, err)
assert.True(t, proceed)
// New node is started, message should be clear
assert.Equal(t, "", newRetryNode.Message)
} | explode_data.jsonl/70956 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 981
} | [
2830,
3393,
3707,
1847,
2052,
1155,
353,
8840,
836,
8,
341,
84441,
11,
6461,
1669,
501,
2051,
741,
16867,
9121,
741,
6948,
93882,
1155,
11,
6461,
340,
6692,
69,
1669,
650,
27121,
32131,
58092,
1847,
2052,
340,
6948,
93882,
1155,
11,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExchangeCorpus(t *testing.T) {
privateKey := PrivateKey{
RSA: testutil.RSAPrivateKey(),
}
for i, seed := range []string{
"\xef\x00\x04",
} {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
dc := 2
reader := testutil.Rand([]byte(seed))
log := zaptest.NewLogger(t)
i := transport.Intermediate
client, server := i.Pipe()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
g, gctx := errgroup.WithContext(ctx)
g.Go(func() error {
_, err := NewExchanger(client, dc).
WithLogger(log.Named("client")).
WithRand(reader).
Client([]PublicKey{privateKey.Public()}).
Run(gctx)
if err != nil {
cancel()
}
return err
})
g.Go(func() error {
_, err := NewExchanger(server, dc).
WithLogger(log.Named("server")).
WithRand(reader).
Server(privateKey).
Run(gctx)
if err != nil {
cancel()
}
return err
})
require.NoError(t, g.Wait())
})
}
} | explode_data.jsonl/81853 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 473
} | [
2830,
3393,
31564,
10580,
17820,
1155,
353,
8840,
836,
8,
341,
2455,
1592,
1669,
9679,
1592,
515,
197,
11143,
7778,
25,
1273,
1314,
2013,
50,
2537,
81,
731,
1592,
3148,
197,
630,
2023,
600,
11,
10320,
1669,
2088,
3056,
917,
515,
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 TestReaderToBuffer(t *testing.T) {
urlToGet := "https://github.com/schollz/croc/releases/download/v4.1.4/croc_v4.1.4_Windows-64bit_GUI.zip"
req, err := http.NewRequest("GET", urlToGet, nil)
assert.Nil(t, err)
resp, err := http.DefaultClient.Do(req)
assert.Nil(t, err)
defer resp.Body.Close()
var out io.Writer
/// setup buffer
var buf bytes.Buffer
f := bufio.NewWriter(&buf)
out = f
bar := NewOptions(int(resp.ContentLength), OptionSetBytes(int(resp.ContentLength)))
out = io.MultiWriter(out, bar)
_, err = io.Copy(out, resp.Body)
assert.Nil(t, err)
// if reading to buffer, write buffer bytes
f.Flush()
err = ioutil.WriteFile("croc_v4.1.4_Windows-64bit_GUI.zip", buf.Bytes(), 0644)
assert.Nil(t, err)
md5, err := md5sum("croc_v4.1.4_Windows-64bit_GUI.zip")
assert.Nil(t, err)
assert.Equal(t, "1e496ef2beba6e2a5e4200cba72a5ad6", md5)
assert.Nil(t, os.Remove("croc_v4.1.4_Windows-64bit_GUI.zip"))
} | explode_data.jsonl/52764 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 408
} | [
2830,
3393,
5062,
1249,
4095,
1155,
353,
8840,
836,
8,
341,
19320,
1249,
1949,
1669,
330,
2428,
1110,
5204,
905,
2687,
331,
965,
89,
2899,
27687,
58187,
33630,
5457,
19,
13,
16,
13,
19,
2899,
27687,
2273,
19,
13,
16,
13,
19,
2763,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRemoveManifests(t *testing.T) {
// Load up the registry.
count := 3
for i := 0; i < count; i++ {
ii, err := random.Index(1024, int64(count), int64(count))
if err != nil {
t.Fatal(err)
}
// test removing the first layer, second layer or the third layer
manifest, err := ii.IndexManifest()
if err != nil {
t.Fatal(err)
}
if len(manifest.Manifests) != count {
t.Fatalf("mismatched manifests on setup, had %d, expected %d", len(manifest.Manifests), count)
}
digest := manifest.Manifests[i].Digest
ii = mutate.RemoveManifests(ii, match.Digests(digest))
manifest, err = ii.IndexManifest()
if err != nil {
t.Fatal(err)
}
if len(manifest.Manifests) != (count - 1) {
t.Fatalf("mismatched manifests after removal, had %d, expected %d", len(manifest.Manifests), count-1)
}
for j, m := range manifest.Manifests {
if m.Digest == digest {
t.Fatalf("unexpectedly found removed hash %v at position %d", digest, j)
}
}
}
} | explode_data.jsonl/3100 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 400
} | [
2830,
3393,
13021,
38495,
82,
1155,
353,
8840,
836,
8,
341,
197,
322,
8893,
705,
279,
19424,
624,
18032,
1669,
220,
18,
198,
2023,
600,
1669,
220,
15,
26,
600,
366,
1760,
26,
600,
1027,
341,
197,
197,
3808,
11,
1848,
1669,
4194,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func Test_GetSchemaInfo_EmptyDir(t *testing.T) {
var directory = "../fixtures/datafeeds/documents/docs_emptyDir"
os.Mkdir(directory, 0700)
files, err := ioutil.ReadDir(directory)
assert.NoError(t, err, fmt.Sprintf("Test: %s failed, should read file with no error", "Error when directory has no files"))
fs := &Service{&MockSftpClient{files, nil}, "", "../fixtures/datafeeds"}
_, err = fs.GetSchemaInfo(pkg)
assert.Error(t, err, "Test failed, directory should be empty")
assert.Contains(t, err.Error(), "No schema found in: ", "Test failed, unexpected error was returned")
defer os.Remove(directory)
} | explode_data.jsonl/57083 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
13614,
8632,
1731,
76060,
1595,
6184,
1155,
353,
8840,
836,
8,
341,
2405,
6220,
284,
7005,
45247,
13167,
64542,
97090,
25967,
15124,
6184,
698,
25078,
1321,
12438,
38608,
11,
220,
15,
22,
15,
15,
340,
74075,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStructCodec(t *testing.T) {
type oStruct struct {
O int
}
type pStruct struct {
P int
Q int
}
type rStruct struct {
R int
S pStruct
T oStruct
oStruct
}
type uStruct struct {
U int
v int
}
type vStruct struct {
V string `datastore:",noindex"`
}
oStructCodec := &structCodec{
fields: map[string]fieldCodec{
"O": {path: []int{0}},
},
complete: true,
}
pStructCodec := &structCodec{
fields: map[string]fieldCodec{
"P": {path: []int{0}},
"Q": {path: []int{1}},
},
complete: true,
}
rStructCodec := &structCodec{
fields: map[string]fieldCodec{
"R": {path: []int{0}},
"S": {path: []int{1}, structCodec: pStructCodec},
"T": {path: []int{2}, structCodec: oStructCodec},
"O": {path: []int{3, 0}},
},
complete: true,
}
uStructCodec := &structCodec{
fields: map[string]fieldCodec{
"U": {path: []int{0}},
},
complete: true,
}
vStructCodec := &structCodec{
fields: map[string]fieldCodec{
"V": {path: []int{0}, noIndex: true},
},
complete: true,
}
testCases := []struct {
desc string
structValue interface{}
want *structCodec
}{
{
"oStruct",
oStruct{},
oStructCodec,
},
{
"pStruct",
pStruct{},
pStructCodec,
},
{
"rStruct",
rStruct{},
rStructCodec,
},
{
"uStruct",
uStruct{},
uStructCodec,
},
{
"non-basic fields",
struct {
B appengine.BlobKey
K *Key
T time.Time
}{},
&structCodec{
fields: map[string]fieldCodec{
"B": {path: []int{0}},
"K": {path: []int{1}},
"T": {path: []int{2}},
},
complete: true,
},
},
{
"struct tags with ignored embed",
struct {
A int `datastore:"a,noindex"`
B int `datastore:"b"`
C int `datastore:",noindex"`
D int `datastore:""`
E int
I int `datastore:"-"`
J int `datastore:",noindex" json:"j"`
oStruct `datastore:"-"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"a": {path: []int{0}, noIndex: true},
"b": {path: []int{1}},
"C": {path: []int{2}, noIndex: true},
"D": {path: []int{3}},
"E": {path: []int{4}},
"J": {path: []int{6}, noIndex: true},
},
complete: true,
},
},
{
"unexported fields",
struct {
A int
b int
C int `datastore:"x"`
d int `datastore:"Y"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}},
"x": {path: []int{2}},
},
complete: true,
},
},
{
"nested and embedded structs",
struct {
A int
B int
CC oStruct
DDD rStruct
oStruct
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}},
"B": {path: []int{1}},
"CC": {path: []int{2}, structCodec: oStructCodec},
"DDD": {path: []int{3}, structCodec: rStructCodec},
"O": {path: []int{4, 0}},
},
complete: true,
},
},
{
"struct tags with nested and embedded structs",
struct {
A int `datastore:"-"`
B int `datastore:"w"`
C oStruct `datastore:"xx"`
D rStruct `datastore:"y"`
oStruct `datastore:"z"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"w": {path: []int{1}},
"xx": {path: []int{2}, structCodec: oStructCodec},
"y": {path: []int{3}, structCodec: rStructCodec},
"z.O": {path: []int{4, 0}},
},
complete: true,
},
},
{
"unexported nested and embedded structs",
struct {
a int
B int
c uStruct
D uStruct
uStruct
}{},
&structCodec{
fields: map[string]fieldCodec{
"B": {path: []int{1}},
"D": {path: []int{3}, structCodec: uStructCodec},
"U": {path: []int{4, 0}},
},
complete: true,
},
},
{
"noindex nested struct",
struct {
A oStruct `datastore:",noindex"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}, structCodec: oStructCodec, noIndex: true},
},
complete: true,
},
},
{
"noindex slice",
struct {
A []string `datastore:",noindex"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}, noIndex: true},
},
hasSlice: true,
complete: true,
},
},
{
"noindex embedded struct slice",
struct {
// vStruct has a single field, V, also with noindex.
A []vStruct `datastore:",noindex"`
}{},
&structCodec{
fields: map[string]fieldCodec{
"A": {path: []int{0}, structCodec: vStructCodec, noIndex: true},
},
hasSlice: true,
complete: true,
},
},
}
for _, tc := range testCases {
got, err := getStructCodec(reflect.TypeOf(tc.structValue))
if err != nil {
t.Errorf("%s: getStructCodec: %v", tc.desc, err)
continue
}
// can't reflect.DeepEqual b/c element order in fields map may differ
if !isEqualStructCodec(got, tc.want) {
t.Errorf("%s\ngot %+v\nwant %+v\n", tc.desc, got, tc.want)
}
}
} | explode_data.jsonl/60714 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2847
} | [
2830,
3393,
9422,
36913,
1155,
353,
8840,
836,
8,
972,
13158,
297,
9422,
2036,
972,
197,
48049,
526,
319,
197,
1771,
13158,
281,
9422,
2036,
972,
197,
10025,
526,
319,
197,
16995,
526,
319,
197,
1771,
13158,
435,
9422,
2036,
972,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_AddSetNoDuplicate(t *testing.T) {
a := makeSet([]int{7, 5, 3, 7})
if a.Cardinality() != 3 {
t.Error("AddSetNoDuplicate set should have 3 elements since 7 is a duplicate")
}
if !(a.Contains(7) && a.Contains(5) && a.Contains(3)) {
t.Error("AddSetNoDuplicate set should have a 7, 5, and 3 in it.")
}
} | explode_data.jsonl/170 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
21346,
1649,
2753,
53979,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1281,
1649,
10556,
396,
90,
22,
11,
220,
20,
11,
220,
18,
11,
220,
22,
8824,
743,
264,
48613,
80777,
368,
961,
220,
18,
341,
197,
3244,
6141,
445,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestClient_testInterface(t *testing.T) {
process := helperProcess("test-interface")
c := NewClient(&ClientConfig{
Cmd: process,
HandshakeConfig: testHandshake,
Plugins: testPluginMap,
})
defer c.Kill()
// Grab the RPC client
client, err := c.Client()
if err != nil {
t.Fatalf("err should be nil, got %s", err)
}
// Grab the impl
raw, err := client.Dispense("test")
if err != nil {
t.Fatalf("err should be nil, got %s", err)
}
impl, ok := raw.(testInterface)
if !ok {
t.Fatalf("bad: %#v", raw)
}
result := impl.Double(21)
if result != 42 {
t.Fatalf("bad: %#v", result)
}
// Kill it
c.Kill()
// Test that it knows it is exited
if !c.Exited() {
t.Fatal("should say client has exited")
}
if c.killed() {
t.Fatal("process failed to exit gracefully")
}
} | explode_data.jsonl/57835 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 337
} | [
2830,
3393,
2959,
4452,
5051,
1155,
353,
8840,
836,
8,
341,
53314,
1669,
13137,
7423,
445,
1944,
82954,
1138,
1444,
1669,
1532,
2959,
2099,
2959,
2648,
515,
197,
6258,
2277,
25,
1797,
1882,
345,
197,
197,
2314,
29661,
2648,
25,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSetBaseURL(t *testing.T) {
expectedBaseURL := "http://gitlab.local/foo/" + apiVersionPath
c := NewClient(nil, "")
err := c.SetBaseURL("http://gitlab.local/foo")
if err != nil {
t.Fatalf("Failed to SetBaseURL: %v", err)
}
if c.BaseURL().String() != expectedBaseURL {
t.Errorf("BaseURL is %s, want %s", c.BaseURL().String(), expectedBaseURL)
}
} | explode_data.jsonl/47240 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
1649,
3978,
3144,
1155,
353,
8840,
836,
8,
341,
42400,
3978,
3144,
1669,
330,
1254,
1110,
12882,
14380,
11033,
60555,
11225,
488,
6330,
5637,
1820,
198,
1444,
1669,
1532,
2959,
27907,
11,
14676,
9859,
1669,
272,
4202,
3978,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRestartMember(t *testing.T) {
defer testutil.AfterTest(t)
c := NewCluster(t, 3)
c.Launch(t)
defer c.Terminate(t)
for i := 0; i < 3; i++ {
c.Members[i].Stop(t)
membs := append([]*member{}, c.Members[:i]...)
membs = append(membs, c.Members[i+1:]...)
c.waitLeader(t, membs)
clusterMustProgress(t, membs)
err := c.Members[i].Restart(t)
if err != nil {
t.Fatal(err)
}
}
clusterMustProgress(t, c.Members)
} | explode_data.jsonl/723 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
59354,
9366,
1155,
353,
8840,
836,
8,
341,
16867,
1273,
1314,
36892,
2271,
1155,
340,
1444,
1669,
1532,
28678,
1155,
11,
220,
18,
340,
1444,
1214,
18423,
1155,
340,
16867,
272,
836,
261,
34016,
1155,
692,
2023,
600,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTraceKVStorePrefix(t *testing.T) {
store := newEmptyTraceKVStore(nil)
pStore := prefix.NewStore(store, []byte("trace_prefix"))
require.IsType(t, prefix.Store{}, pStore)
} | explode_data.jsonl/52009 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
6550,
82707,
6093,
14335,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
501,
3522,
6550,
82707,
6093,
27907,
340,
3223,
6093,
1669,
9252,
7121,
6093,
31200,
11,
3056,
3782,
445,
15067,
13974,
5455,
17957,
4506,
929,
1155,
11,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestAddFile(t *testing.T) {
testData := []byte("This test data should be part of the file.")
testName := "docker.com/notary/certificate"
testExt := "crt"
perms := os.FileMode(0755)
// Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-")
if err != nil {
t.Fatalf("failed to create a temporary directory: %v", err)
}
defer os.RemoveAll(tempBaseDir)
// Since we're generating this manually we need to add the extension '.'
expectedFilePath := filepath.Join(tempBaseDir, testName+"."+testExt)
// Create our SimpleFileStore
store := &SimpleFileStore{
baseDir: tempBaseDir,
fileExt: testExt,
perms: perms,
}
// Call the Add function
err = store.Add(testName, testData)
if err != nil {
t.Fatalf("failed to add file to store: %v", err)
}
// Check to see if file exists
b, err := ioutil.ReadFile(expectedFilePath)
if err != nil {
t.Fatalf("expected file not found: %v", err)
}
if !bytes.Equal(b, testData) {
t.Fatalf("unexpected content in the file: %s", expectedFilePath)
}
} | explode_data.jsonl/54571 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 383
} | [
2830,
3393,
2212,
1703,
1155,
353,
8840,
836,
8,
341,
18185,
1043,
1669,
3056,
3782,
445,
1986,
1273,
821,
1265,
387,
949,
315,
279,
1034,
13053,
18185,
675,
1669,
330,
28648,
905,
62441,
658,
2899,
20962,
698,
18185,
6756,
1669,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestClient_UpdateUser_validation(t *testing.T) {
var err error
_, err = testClient.UpdateUser(&UpdateUserInput{
ID: "",
})
if err != ErrMissingID {
t.Errorf("bad error: %s", err)
}
} | explode_data.jsonl/26705 | {
"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,
2959,
47393,
1474,
19416,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
197,
6878,
1848,
284,
1273,
2959,
16689,
1474,
2099,
4289,
1474,
2505,
515,
197,
29580,
25,
8324,
197,
3518,
743,
1848,
961,
15495,
25080,
915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestGetAllRoutes(t *testing.T) {
router := RouterWindows{}
routes, err := router.GetAllRoutes()
if err != nil {
t.Fatal(err)
}
if len(routes) == 0 {
t.Fatal("len(routes) == 0")
}
} | explode_data.jsonl/67378 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
1949,
2403,
26653,
1155,
353,
8840,
836,
8,
341,
67009,
1669,
10554,
13164,
16094,
7000,
5495,
11,
1848,
1669,
9273,
45732,
26653,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
743,
2422,
44888,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShowCmd(t *testing.T) {
const routerID = "F022000000335"
const natID = "F052000000335"
testCases := []struct {
name string
clientError error
flags map[string]string
statusCode int
response string
output string
errorMsg string
}{
{
"success",
nil,
map[string]string{
"router": routerID,
},
http.StatusOK,
testdata.ShowResponse,
testdata.ShowOutput,
"",
},
{
"client auth error",
errors.New("client auth error"),
map[string]string{
"router": routerID,
},
0,
"",
"",
"creating FIC client:",
},
{
"resource not found",
nil,
map[string]string{
"router": routerID,
},
http.StatusNotFound,
"",
"",
"calling Show nat API:",
},
{
"router flag is not specified",
nil,
map[string]string{},
0,
"",
"",
"required flag(s) \"router\" not set",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.statusCode != 0 {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc(
fmt.Sprintf("/routers/%s/nats/%s", routerID, natID),
func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(tc.statusCode)
fmt.Fprintf(w, tc.response)
},
)
}
buf := new(bytes.Buffer)
cmd := newShowCmd(
func() (client *fic.ServiceClient, err error) {
return fakeClient.ServiceClient(), tc.clientError
},
buf,
)
cmd.SetArgs([]string{natID})
for key, value := range tc.flags {
cmd.Flags().Set(key, value)
}
err := cmd.Execute()
if tc.errorMsg == "" {
require.Nil(t, err)
} else {
require.NotNil(t, err)
require.Contains(t, err.Error(), tc.errorMsg)
}
require.Equal(t, strings.TrimPrefix(tc.output, "\n"), buf.String())
})
}
} | explode_data.jsonl/20477 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 921
} | [
2830,
3393,
7812,
15613,
1155,
353,
8840,
836,
8,
341,
4777,
9273,
915,
284,
330,
37,
15,
17,
17,
15,
15,
15,
15,
15,
15,
18,
18,
20,
698,
4777,
17588,
915,
284,
330,
37,
15,
20,
17,
15,
15,
15,
15,
15,
15,
18,
18,
20,
183... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRenderNoDHCPSimpleMacvlan(t *testing.T) {
g := NewGomegaWithT(t)
crd := NoDHCPConfigSimpleMacvlan.DeepCopy()
config := &crd.Spec
FillDefaults(config, nil)
objs, err := RenderMultus(config, manifestDir)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(objs).NotTo(ContainElement(HaveKubernetesID("DaemonSet", "openshift-multus", "dhcp-daemon")))
} | explode_data.jsonl/16738 | {
"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,
6750,
2753,
35,
22455,
5012,
6456,
19552,
89622,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
692,
1444,
6498,
1669,
2308,
51326,
7123,
2648,
16374,
19552,
89622,
55602,
12106,
741,
25873,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseCorrectPath(t *testing.T) {
testUrl, _ := url.Parse("http://example.com/wd/hub/firefox/42.0/test-process/3/session/uuid/url")
err, browserName, version, processName, priority, command := parsePath(testUrl)
AssertThat(t, err, Is{nil})
AssertThat(t, browserName, EqualTo{"firefox"})
AssertThat(t, version, EqualTo{"42.0"})
AssertThat(t, processName, EqualTo{"test-process"})
AssertThat(t, priority, EqualTo{3})
AssertThat(t, command, EqualTo{"session/uuid/url"})
} | explode_data.jsonl/65284 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
14463,
33092,
1820,
1155,
353,
8840,
836,
8,
341,
18185,
2864,
11,
716,
1669,
2515,
8937,
445,
1254,
1110,
8687,
905,
6324,
67,
7530,
392,
53010,
15011,
14,
19,
17,
13,
15,
12697,
50094,
14,
18,
54760,
14,
17128,
57254,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_AddColumn_Migration(t *testing.T) {
argsss := []string{"add", "ac", "test123", "new_column:int"}
fileName, mm, _ := generateMigration(argsss)
expectedString := `{"id":"` + getID(fileName) + `","up":{"addColumn":[{"tableName":"test123","columns":[{"fieldname":"new_column","datatype":"int"}]}]},"down":{"dropColumn":[{"tableName":"test123","columns":[{"fieldname":"new_column","datatype":"int"}]}]}}`
content1, _ := json.Marshal(mm)
checkError(t, expectedString, string(content1))
} | explode_data.jsonl/22629 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
21346,
2933,
1245,
5033,
1155,
353,
8840,
836,
8,
341,
47903,
84160,
1669,
3056,
917,
4913,
718,
497,
330,
580,
497,
330,
1944,
16,
17,
18,
497,
330,
931,
8744,
14337,
16707,
17661,
675,
11,
9465,
11,
716,
1669,
6923,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuffer(t *testing.T) {
buf := &Buffer{}
buf.WriteString("foo\n")
buf.WriteString("bar\n")
assert.Equal(t, []string{"foo", "bar"}, buf.Lines(), "Unexpected output from Lines.")
assert.Equal(t, "foo\nbar", buf.Stripped(), "Unexpected output from Stripped.")
} | explode_data.jsonl/5039 | {
"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,
4095,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
609,
4095,
16094,
26398,
44747,
445,
7975,
1699,
1138,
26398,
44747,
445,
2257,
1699,
1138,
6948,
12808,
1155,
11,
3056,
917,
4913,
7975,
497,
330,
2257,
14345,
6607,
90995,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnixSocketProxy(t *testing.T) {
if runtime.GOOS == "windows" {
return
}
trialMsg := "Is it working?"
var proxySuccess bool
// This is our fake "application" we want to proxy to
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Request was proxied when this is called
proxySuccess = true
fmt.Fprint(w, trialMsg)
}))
// Get absolute path for unix: socket
dir, err := ioutil.TempDir("", "caddy_proxytest")
if err != nil {
t.Fatalf("Failed to make temp dir to contain unix socket. %v", err)
}
defer os.RemoveAll(dir)
socketPath := filepath.Join(dir, "test_socket")
// Change httptest.Server listener to listen to unix: socket
ln, err := net.Listen("unix", socketPath)
if err != nil {
t.Fatalf("Unable to listen: %v", err)
}
ts.Listener = ln
ts.Start()
defer ts.Close()
url := strings.Replace(ts.URL, "http://", "unix:", 1)
p := newWebSocketTestProxy(url, false, 30*time.Second)
echoProxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
p.ServeHTTP(w, r)
}))
defer echoProxy.Close()
res, err := http.Get(echoProxy.URL)
if err != nil {
t.Fatalf("Unable to GET: %v", err)
}
greeting, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatalf("Unable to GET: %v", err)
}
actualMsg := fmt.Sprintf("%s", greeting)
if !proxySuccess {
t.Errorf("Expected request to be proxied, but it wasn't")
}
if actualMsg != trialMsg {
t.Errorf("Expected '%s' but got '%s' instead", trialMsg, actualMsg)
}
} | explode_data.jsonl/64234 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 601
} | [
2830,
3393,
55832,
10286,
16219,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
853,
198,
197,
630,
25583,
530,
6611,
1669,
330,
3872,
432,
3238,
11974,
2405,
13291,
7188,
1807,
271,
197,
322,
109... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGet(t *testing.T) {
server, etcdStorage := newEtcdTestStorage(t, etcd3testing.PathPrefix())
defer server.Terminate(t)
cacher, _, err := newTestCacher(etcdStorage)
if err != nil {
t.Fatalf("Couldn't create cacher: %v", err)
}
defer cacher.Stop()
podFoo := makeTestPod("foo")
fooCreated := updatePod(t, etcdStorage, podFoo, nil)
// We pass the ResourceVersion from the above Create() operation.
result := &example.Pod{}
if err := cacher.Get(context.TODO(), "pods/ns/foo", storage.GetOptions{IgnoreNotFound: true, ResourceVersion: fooCreated.ResourceVersion}, result); err != nil {
t.Errorf("Unexpected error: %v", err)
}
if e, a := *fooCreated, *result; !reflect.DeepEqual(e, a) {
t.Errorf("Expected: %#v, got: %#v", e, a)
}
if err := cacher.Get(context.TODO(), "pods/ns/bar", storage.GetOptions{ResourceVersion: fooCreated.ResourceVersion, IgnoreNotFound: true}, result); err != nil {
t.Errorf("Unexpected error: %v", err)
}
emptyPod := example.Pod{}
if e, a := emptyPod, *result; !reflect.DeepEqual(e, a) {
t.Errorf("Expected: %#v, got: %#v", e, a)
}
if err := cacher.Get(context.TODO(), "pods/ns/bar", storage.GetOptions{ResourceVersion: fooCreated.ResourceVersion}, result); !storage.IsNotFound(err) {
t.Errorf("Unexpected error: %v", err)
}
} | explode_data.jsonl/41356 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
1949,
1155,
353,
8840,
836,
8,
341,
41057,
11,
1842,
4385,
5793,
1669,
501,
31860,
4385,
2271,
5793,
1155,
11,
1842,
4385,
18,
8840,
17474,
14335,
2398,
16867,
3538,
836,
261,
34016,
1155,
340,
1444,
11007,
11,
8358,
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... | 7 |
func TestEventBeforeCallback(t *testing.T) {
var prevState string
OrderStateMachine.Event(OrderEventCheckout).To(OrderStatePaying).From(OrderStateDraft).Before(func(order interface{}, tx *gorm.DB) (err error) {
prevState = order.(*Order).State
return
})
order := &Order{}
order.State = OrderStateDraft
CreateOrderAndExecuteTransition(order, OrderEventCheckout, t, true)
if prevState != OrderStateDraft {
t.Errorf("Before callback triggered after state change")
}
} | explode_data.jsonl/44775 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
1556,
10227,
7494,
1155,
353,
8840,
836,
8,
341,
2405,
74946,
914,
198,
197,
4431,
94666,
6904,
39692,
1556,
55145,
568,
1249,
39692,
1397,
47,
17270,
568,
3830,
39692,
1397,
50086,
568,
10227,
18552,
19385,
3749,
22655,
9854,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnsetCol(t *testing.T) {
session := createSession(t)
defer session.Close()
if session.cfg.ProtoVersion < 4 {
t.Skip("Unset Values are not supported in protocol < 4")
}
if err := createTable(session, "CREATE TABLE gocql_test.testUnsetInsert (id int, my_int int, my_text text, PRIMARY KEY (id))"); err != nil {
t.Fatalf("failed to create table with error '%v'", err)
}
if err := session.Query("INSERT INTO testUnSetInsert (id,my_int,my_text) VALUES (?,?,?)", 1, 2, "3").Exec(); err != nil {
t.Fatalf("failed to insert with err: %v", err)
}
if err := session.Query("INSERT INTO testUnSetInsert (id,my_int,my_text) VALUES (?,?,?)", 1, UnsetValue, UnsetValue).Exec(); err != nil {
t.Fatalf("failed to insert with err: %v", err)
}
var id, mInt int
var mText string
if err := session.Query("SELECT id, my_int ,my_text FROM testUnsetInsert").Scan(&id, &mInt, &mText); err != nil {
t.Fatalf("failed to select with err: %v", err)
} else if id != 1 || mInt != 2 || mText != "3" {
t.Fatalf("Expected results: 1, 2, \"3\", got %v, %v, %v", id, mInt, mText)
}
} | explode_data.jsonl/11192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 414
} | [
2830,
3393,
1806,
746,
6127,
1155,
353,
8840,
836,
8,
341,
25054,
1669,
1855,
5283,
1155,
340,
16867,
3797,
10421,
2822,
743,
3797,
30481,
7763,
983,
5637,
366,
220,
19,
341,
197,
3244,
57776,
445,
1806,
746,
24979,
525,
537,
7248,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestEntityKeysToBigTable(t *testing.T) {
testCases := []struct {
desc string
project string
entityKeys []*spec.Entity
want string
}{
{
desc: "concatenation string of project and entityKeys less than 50 characters",
project: "default",
entityKeys: []*spec.Entity{
{
Name: "driver_id",
},
{
Name: "geohash",
},
},
want: "default__driver_id__geohash",
},
{
desc: "concatenation string of project and entityKeys more than 50 characters",
project: "default-project-mobility-nationwide",
entityKeys: []*spec.Entity{
{
Name: "driver_geohash",
},
{
Name: "driver_id",
},
},
want: "default-project-mobility-nationwide__drivede1619bb",
},
}
for _, tC := range testCases {
t.Run(tC.desc, func(t *testing.T) {
got := entityKeysToBigTable(tC.project, entitiesToEntityNames(tC.entityKeys))
assert.Equal(t, tC.want, got)
})
}
} | explode_data.jsonl/67217 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 430
} | [
2830,
3393,
3030,
8850,
1249,
15636,
2556,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
981,
914,
198,
197,
72470,
262,
914,
198,
197,
52987,
8850,
29838,
9535,
9899,
198,
197,
50780,
981,
914,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddRangeErrors(t *testing.T) {
for _, tc := range []struct {
id string
line string
expectedErr string
expectedRange struct {
age int
interval int
}
}{
{
id: "Negative age",
line: "RaNGe:-5s:0s",
expectedErr: "Line 0: Age values must be positive, got -5s",
},
{
id: "Negative interval",
line: "RaNGe:5s:-7s",
expectedErr: "Line 0: Interval values must be positive, got -7s",
},
} {
t.Logf("Testing case %q", tc.id)
p := parser{line: tc.line, fieldSep: ":"}
err := p.parseLine()
if tc.expectedErr == "" {
if err != nil {
t.Fatalf("Expected no error, got %q", err)
}
if len(p.ranges) != 1 {
t.Fatalf("Expected 1 parsed range, got %d", len(p.ranges))
}
expAge := time.Duration(tc.expectedRange.age)
expInterval := time.Duration(tc.expectedRange.interval)
if p.ranges[0].Age != expAge || p.ranges[0].Interval != expInterval {
t.Fatalf("Expected age/interval %v, got range %v", tc.expectedRange, p.ranges[0])
}
} else {
if err == nil {
t.Fatalf("Expected err %q, got nil", tc.expectedErr)
}
if tc.expectedErr != err.Error() {
t.Fatalf("Expected error %q, got %q", tc.expectedErr, err)
}
}
}
} | explode_data.jsonl/54252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
2212,
6046,
13877,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
15710,
310,
914,
198,
197,
27109,
688,
914,
198,
197,
42400,
7747,
256,
914,
198,
197,
42400,
6046,
2036,
341,
298,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestCompactionOutputSplitters(t *testing.T) {
var main, child0, child1 compactionOutputSplitter
pickSplitter := func(input string) *compactionOutputSplitter {
switch input {
case "main":
return &main
case "child0":
return &child0
case "child1":
return &child1
default:
t.Fatalf("invalid splitter slot: %s", input)
return nil
}
}
datadriven.RunTest(t, "testdata/compaction_output_splitters",
func(d *datadriven.TestData) string {
switch d.Cmd {
case "reset":
main = nil
child0 = nil
child1 = nil
case "init":
if len(d.CmdArgs) < 2 {
return "expected at least 2 args"
}
splitterToInit := pickSplitter(d.CmdArgs[0].Key)
switch d.CmdArgs[1].Key {
case "array":
*splitterToInit = &splitterGroup{
cmp: base.DefaultComparer.Compare,
splitters: []compactionOutputSplitter{child0, child1},
}
case "mock":
*splitterToInit = &mockSplitter{}
case "userkey":
*splitterToInit = &userKeyChangeSplitter{
cmp: base.DefaultComparer.Compare,
splitter: child0,
}
}
(*splitterToInit).onNewOutput(nil)
case "set-should-split":
if len(d.CmdArgs) < 2 {
return "expected at least 2 args"
}
splitterToSet := (*pickSplitter(d.CmdArgs[0].Key)).(*mockSplitter)
var val compactionSplitSuggestion
switch d.CmdArgs[1].Key {
case "split-now":
val = splitNow
case "no-split":
val = noSplit
default:
t.Fatalf("unexpected value for should-split: %s", d.CmdArgs[1].Key)
}
splitterToSet.shouldSplitVal = val
case "should-split-before":
if len(d.CmdArgs) < 1 {
return "expected at least 1 arg"
}
key := base.ParseInternalKey(d.CmdArgs[0].Key)
shouldSplit := main.shouldSplitBefore(&key, nil)
if shouldSplit == splitNow {
main.onNewOutput(&key)
}
return shouldSplit.String()
default:
return fmt.Sprintf("unknown command: %s", d.Cmd)
}
return "ok"
})
} | explode_data.jsonl/51416 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 890
} | [
2830,
3393,
13552,
1311,
5097,
94159,
28063,
1155,
353,
8840,
836,
8,
341,
2405,
1887,
11,
1682,
15,
11,
1682,
16,
1367,
1311,
5097,
20193,
465,
198,
3223,
865,
20193,
465,
1669,
2915,
5384,
914,
8,
353,
5689,
1311,
5097,
20193,
465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAsPathAs4TransInvalid1(t *testing.T) {
as := []uint16{65000, 4000, bgp.AS_TRANS, bgp.AS_TRANS, 40001}
params := []bgp.AsPathParamInterface{bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, as)}
aspath := bgp.NewPathAttributeAsPath(params)
as4 := []uint32{100000, 65000, 4000, 400000, 300000, 40001}
as4param1 := bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, as4)
param4s := []*bgp.As4PathParam{as4param1}
as4path := bgp.NewPathAttributeAs4Path(param4s)
msg := bgp.NewBGPUpdateMessage(nil, []bgp.PathAttributeInterface{aspath, as4path}, nil).Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(msg)
assert.Equal(t, len(msg.PathAttributes), 1)
assert.Equal(t, len(msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value), 1)
assert.Equal(t, len(msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS), 5)
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[0], uint32(65000))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[1], uint32(4000))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[2], uint32(bgp.AS_TRANS))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[3], uint32(bgp.AS_TRANS))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[4], uint32(40001))
} | explode_data.jsonl/29054 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 606
} | [
2830,
3393,
2121,
1820,
2121,
19,
3167,
7928,
16,
1155,
353,
8840,
836,
8,
341,
60451,
1669,
3056,
2496,
16,
21,
90,
21,
20,
15,
15,
15,
11,
220,
19,
15,
15,
15,
11,
8951,
79,
875,
50,
28953,
11,
8951,
79,
875,
50,
28953,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Arguments_Diff_DifferentNumberOfArgs(t *testing.T) {
var args = Arguments([]interface{}{"string", 123, true})
var diff string
var count int
diff, count = args.Diff([]interface{}{"string", 456, "false", "extra"})
assert.Equal(t, 3, count)
assert.Contains(t, diff, `extra != (Missing)`)
} | explode_data.jsonl/8615 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
87581,
2831,
1557,
3092,
1557,
18277,
40619,
4117,
1155,
353,
8840,
836,
8,
8022,
2405,
2827,
284,
27702,
10556,
4970,
6257,
4913,
917,
497,
220,
16,
17,
18,
11,
830,
35099,
2405,
3638,
914,
319,
2405,
1760,
526,
319,
8056... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGet(t *testing.T) {
msr := NewInMemoryTransactionStore(DummyMatcher{}, 10)
matches := []Transaction{
{Time: 1},
{Time: 2},
{Time: 3},
{Time: 4},
{Time: 5},
}
for _, m := range matches {
msr.Save(m)
}
tests := []struct {
msg string
limit int
offset int
expected []Transaction
}{
{"Zero limit and offset", 0, 0, []Transaction{}},
{"Zero limit and one offset", 0, 1, []Transaction{}},
{"Grab the first element", 1, 0, []Transaction{{Time: 1}}},
{"Grab second element", 1, 1, []Transaction{{Time: 2}}},
{"Grab first two elements", 2, 0, []Transaction{{Time: 1}, {Time: 2}}},
{"Grab the second and the third elements", 2, 1, []Transaction{{Time: 2}, {Time: 3}}},
{"Grab the last elements", 1, 4, []Transaction{{Time: 5}}},
{"Grab the last two elements", 2, 3, []Transaction{{Time: 4}, {Time: 5}}},
{"Out of bounds offset", 1, 5, []Transaction{}},
{"Out of bounds limit", 2, 4, []Transaction{{Time: 5}}},
}
for _, tt := range tests {
t.Run(tt.msg, func(t *testing.T) {
r := msr.Get(tt.limit, tt.offset)
if !reflect.DeepEqual(r, tt.expected) {
t.Errorf("Wrong definitions: got %v, want %v", r, tt.expected)
}
})
}
} | explode_data.jsonl/44242 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
1949,
1155,
353,
8840,
836,
8,
1476,
47691,
81,
1669,
1532,
641,
10642,
8070,
6093,
5432,
8574,
37554,
22655,
220,
16,
15,
692,
2109,
9118,
1669,
3056,
8070,
515,
197,
197,
90,
1462,
25,
220,
16,
1583,
197,
197,
90,
1462... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChannelQueue_Batch(t *testing.T) {
handleChan := make(chan *testData)
handle := func(data ...Data) []Data {
assert.True(t, len(data) == 2)
for _, datum := range data {
testDatum := datum.(*testData)
handleChan <- testDatum
}
return nil
}
nilFn := func(_ func()) {}
queue, err := NewChannelQueue(handle,
ChannelQueueConfiguration{
WorkerPoolConfiguration: WorkerPoolConfiguration{
QueueLength: 20,
BatchLength: 2,
BlockTimeout: 0,
BoostTimeout: 0,
BoostWorkers: 0,
MaxWorkers: 10,
},
Workers: 1,
}, &testData{})
assert.NoError(t, err)
go queue.Run(nilFn, nilFn)
test1 := testData{"A", 1}
test2 := testData{"B", 2}
queue.Push(&test1)
go queue.Push(&test2)
result1 := <-handleChan
assert.Equal(t, test1.TestString, result1.TestString)
assert.Equal(t, test1.TestInt, result1.TestInt)
result2 := <-handleChan
assert.Equal(t, test2.TestString, result2.TestString)
assert.Equal(t, test2.TestInt, result2.TestInt)
err = queue.Push(test1)
assert.Error(t, err)
} | explode_data.jsonl/17392 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 430
} | [
2830,
3393,
9629,
7554,
1668,
754,
1155,
353,
8840,
836,
8,
341,
53822,
46019,
1669,
1281,
35190,
353,
1944,
1043,
340,
53822,
1669,
2915,
2592,
2503,
1043,
8,
3056,
1043,
341,
197,
6948,
32443,
1155,
11,
2422,
2592,
8,
621,
220,
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... | 2 |
func TestString_IsZero(t *testing.T) {
tests := []struct {
name string
e String
want bool
}{
{name: "True", e: String{""}, want: true},
{name: "False", e: String{"abc"}, want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.e.IsZero(); got != tt.want {
t.Errorf("String.IsZero() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/34775 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
703,
31879,
17999,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
923,
198,
197,
50780,
1807,
198,
197,
59403,
197,
197,
47006,
25,
330,
2514,
497,
384,
25,
923,
90,
301... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAdmissionNamespaceExists(t *testing.T) {
namespace := "test"
mockClient := newMockClientForTest([]string{namespace})
handler, informerFactory, err := newHandlerForTest(mockClient)
if err != nil {
t.Errorf("unexpected error initializing handler: %v", err)
}
informerFactory.Start(wait.NeverStop)
pod := newPod(namespace)
err = handler.Admit(admission.NewAttributesRecord(&pod, nil, api.Kind("Pod").WithVersion("version"), pod.Namespace, pod.Name, api.Resource("pods").WithVersion("version"), "", admission.Create, nil))
if err != nil {
t.Errorf("unexpected error returned from admission handler")
}
} | explode_data.jsonl/13317 | {
"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,
2589,
2728,
22699,
15575,
1155,
353,
8840,
836,
8,
341,
56623,
1669,
330,
1944,
698,
77333,
2959,
1669,
501,
11571,
2959,
2461,
2271,
10556,
917,
90,
2231,
3518,
53326,
11,
6051,
261,
4153,
11,
1848,
1669,
501,
3050,
2461,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodeToString(t *testing.T) {
node := neo4j.Node{
Id: 2,
Labels: []string{`Something`},
Props: map[string]interface{}{
"Prop1": 2,
"Prop2": time.Date(2020, 1, 2, 3, 4, 5, 6, time.UTC),
},
}
actual := input.ToString(node)
expected := `(:Something {"Prop1":2,"Prop2":"2020-01-02T03:04:05.000000006Z"})`
if actual != expected {
t.Fatalf(`expected '%v' but got '%v'`, expected, actual)
}
} | explode_data.jsonl/7072 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
1955,
5870,
1155,
353,
8840,
836,
8,
341,
20831,
1669,
35082,
19,
73,
21714,
515,
197,
67211,
25,
257,
220,
17,
345,
197,
197,
23674,
25,
3056,
917,
90,
63,
23087,
63,
1583,
197,
197,
5992,
25,
2415,
14032,
31344,
67066,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCache(t *testing.T) {
processes := []process.Process{
{PID: 1, PPID: 0, Name: "init", Cmdline: "init"},
{PID: 2, PPID: 1, Name: "bash", Cmdline: "bash"},
{PID: 3, PPID: 1, Name: "apache", Threads: 2, Cmdline: "apache"},
{PID: 4, PPID: 2, Name: "ping", Cmdline: "ping foo.bar.local"},
}
walker := &mockWalker{
processes: processes,
}
cachingWalker := process.NewCachingWalker(walker)
err := cachingWalker.Tick()
if err != nil {
t.Fatal(err)
}
want, err := all(walker)
have, err := all(cachingWalker)
if err != nil || !reflect.DeepEqual(want, have) {
t.Errorf("%v (%v)", test.Diff(want, have), err)
}
walker.processes = []process.Process{}
have, err = all(cachingWalker)
if err != nil || !reflect.DeepEqual(want, have) {
t.Errorf("%v (%v)", test.Diff(want, have), err)
}
err = cachingWalker.Tick()
if err != nil {
t.Fatal(err)
}
have, err = all(cachingWalker)
want = map[process.Process]struct{}{}
if err != nil || !reflect.DeepEqual(want, have) {
t.Errorf("%v (%v)", test.Diff(want, have), err)
}
} | explode_data.jsonl/3084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
8233,
1155,
353,
8840,
836,
8,
341,
53314,
288,
1669,
3056,
4630,
29012,
515,
197,
197,
90,
33751,
25,
220,
16,
11,
29850,
915,
25,
220,
15,
11,
3988,
25,
330,
2327,
497,
40210,
1056,
25,
330,
2327,
7115,
197,
197,
90,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestManyProducersManyConsumers(t *testing.T) {
r := prodcons.Runner{}
m := map[int]struct{}{}
producerCount := 500
for i := 0; i < producerCount; i++ {
iC := i
m[iC] = struct{}{}
r.Producer(func() (interface{}, error) {
return iC, nil
})
}
producedVals := make(chan int, producerCount)
for i := 0; i < 10; i++ {
r.Consumer(func(i interface{}) error {
producedVals <- i.(int)
return nil
})
}
err := r.Run()
close(producedVals)
assert.NoError(t, err)
for val := range producedVals {
_, exists := m[val]
assert.True(t, exists)
delete(m, val)
}
assert.Len(t, m, 0)
} | explode_data.jsonl/75651 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
8441,
1336,
33375,
8441,
41966,
388,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
14475,
6254,
16708,
1194,
16094,
2109,
1669,
2415,
18640,
60,
1235,
6257,
31483,
197,
58912,
2507,
1669,
220,
20,
15,
15,
198,
2023,
600,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRemoveFieldSuffix(t *testing.T) {
tests := []struct {
input map[string]interface{}
want map[string]interface{}
}{
{
map[string]interface{}{
"foo_suffix": "bar",
},
map[string]interface{}{
"foo": "bar",
},
},
{
map[string]interface{}{
"kkk": "bar",
"nested": map[string]interface{}{
"foo_suffix": "bar",
},
},
map[string]interface{}{
"kkk": "bar",
"nested": map[string]interface{}{
"foo": "bar",
},
},
},
{
map[string]interface{}{
"foo_suffix": "bar",
"array": []map[string]interface{}{
{
"foo_suffix": "bar",
},
{
"foo_suffix": "bar",
},
},
},
map[string]interface{}{
"foo": "bar",
"array": []map[string]interface{}{
{
"foo": "bar",
},
{
"foo": "bar",
},
},
},
},
{
map[string]interface{}{
"foo_suffix": "bar",
"array": []interface{}{
map[string]interface{}{
"foo_suffix": "bar",
},
map[string]interface{}{
"foo_suffix": "bar",
},
},
},
map[string]interface{}{
"foo": "bar",
"array": []interface{}{
map[string]interface{}{
"foo": "bar",
},
map[string]interface{}{
"foo": "bar",
},
},
},
},
}
for k, tt := range tests {
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
removeFieldSuffix(tt.input, "_suffix")
assert.Equal(t, tt.want, tt.input)
})
}
} | explode_data.jsonl/59328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 801
} | [
2830,
3393,
13021,
1877,
40177,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
2415,
14032,
31344,
16094,
197,
50780,
220,
2415,
14032,
31344,
16094,
197,
59403,
197,
197,
515,
298,
19567,
14032,
31344,
67066,
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 TestTimeoutOptions(t *testing.T) {
opts := requestOptions{}
options := []RequestOption{WithTimeout(fab.PeerResponse, 20*time.Second),
WithTimeout(fab.ResMgmt, 25*time.Second), WithTimeout(fab.OrdererResponse, 30*time.Second),
WithTimeout(fab.PeerConnection, 35*time.Second), WithTimeout(fab.Execute, 40*time.Second),
WithTimeout(fab.Query, 45*time.Second)}
for _, option := range options {
option(nil, &opts)
}
assert.True(t, opts.Timeouts[fab.PeerResponse] == 20*time.Second, "timeout value by type didn't match with one supplied")
assert.True(t, opts.Timeouts[fab.ResMgmt] == 25*time.Second, "timeout value by type didn't match with one supplied")
assert.True(t, opts.Timeouts[fab.OrdererResponse] == 30*time.Second, "timeout value by type didn't match with one supplied")
assert.True(t, opts.Timeouts[fab.PeerConnection] == 35*time.Second, "timeout value by type didn't match with one supplied")
assert.True(t, opts.Timeouts[fab.Execute] == 40*time.Second, "timeout value by type didn't match with one supplied")
assert.True(t, opts.Timeouts[fab.Query] == 45*time.Second, "timeout value by type didn't match with one supplied")
} | explode_data.jsonl/64979 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 385
} | [
2830,
3393,
7636,
3798,
1155,
353,
8840,
836,
8,
1476,
64734,
1669,
91094,
31483,
35500,
1669,
3056,
1900,
5341,
90,
2354,
7636,
955,
370,
1069,
34756,
2582,
11,
220,
17,
15,
77053,
32435,
1326,
197,
197,
2354,
7636,
955,
370,
8377,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIndex_Success(t *testing.T) {
t.Log("Index should render the index template successfully.")
RegisterMockTestingT(t)
l := mocks.NewMockLocker()
// These are the locks that we expect to be rendered.
now := time.Now()
locks := map[string]models.ProjectLock{
"lkysow/atlantis-example/./default": {
Pull: models.PullRequest{
Num: 9,
},
Project: models.Project{
RepoFullName: "lkysow/atlantis-example",
},
Time: now,
},
}
When(l.List()).ThenReturn(locks, nil)
it := sMocks.NewMockTemplateWriter()
r := mux.NewRouter()
atlantisVersion := "0.3.1"
// Need to create a lock route since the server expects this route to exist.
r.NewRoute().Path("/lock").
Queries("id", "{id}").Name(server.LockViewRouteName)
u, err := url.Parse("https://example.com")
Ok(t, err)
s := server.Server{
Locker: l,
IndexTemplate: it,
Router: r,
AtlantisVersion: atlantisVersion,
AtlantisURL: u,
}
req, _ := http.NewRequest("GET", "", bytes.NewBuffer(nil))
w := httptest.NewRecorder()
s.Index(w, req)
it.VerifyWasCalledOnce().Execute(w, server.IndexData{
Locks: []server.LockIndexData{
{
LockPath: "/lock?id=lkysow%252Fatlantis-example%252F.%252Fdefault",
RepoFullName: "lkysow/atlantis-example",
PullNum: 9,
Time: now,
},
},
AtlantisVersion: atlantisVersion,
})
responseContains(t, w, http.StatusOK, "")
} | explode_data.jsonl/15317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 605
} | [
2830,
3393,
1552,
87161,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
445,
1552,
1265,
3141,
279,
1922,
3811,
7790,
13053,
79096,
11571,
16451,
51,
1155,
340,
8810,
1669,
68909,
7121,
11571,
87253,
741,
197,
322,
4220,
525,
279,
31676,
429... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubnet(t *testing.T) {
for i, c := range []struct {
desc string
service *v1.Service
expected *string
}{
{
desc: "No annotation should return nil",
service: &v1.Service{},
expected: nil,
},
{
desc: "annotation with subnet but no ILB should return nil",
service: &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
ServiceAnnotationLoadBalancerInternalSubnet: "subnet",
},
},
},
expected: nil,
},
{
desc: "annotation with subnet but ILB=false should return nil",
service: &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
ServiceAnnotationLoadBalancerInternalSubnet: "subnet",
ServiceAnnotationLoadBalancerInternal: "false",
},
},
},
expected: nil,
},
{
desc: "annotation with empty subnet should return nil",
service: &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
ServiceAnnotationLoadBalancerInternalSubnet: "",
ServiceAnnotationLoadBalancerInternal: "true",
},
},
},
expected: nil,
},
{
desc: "annotation with subnet and ILB should return subnet",
service: &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
ServiceAnnotationLoadBalancerInternalSubnet: "subnet",
ServiceAnnotationLoadBalancerInternal: "true",
},
},
},
expected: to.StringPtr("subnet"),
},
} {
real := subnet(c.service)
assert.Equal(t, c.expected, real, fmt.Sprintf("TestCase[%d]: %s", i, c.desc))
}
} | explode_data.jsonl/33994 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 697
} | [
2830,
3393,
3136,
4711,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
272,
1669,
2088,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
52934,
220,
353,
85,
16,
13860,
198,
197,
42400,
353,
917,
198,
197,
59403,
197,
197,
515,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPageWithFrontMatterConfig(t *testing.T) {
t.Parallel()
for _, dateHandler := range []string{":filename", ":fileModTime"} {
t.Run(fmt.Sprintf("dateHandler=%q", dateHandler), func(t *testing.T) {
assrt := require.New(t)
cfg, fs := newTestCfg()
pageTemplate := `
---
title: Page
weight: %d
lastMod: 2018-02-28
%s
---
Content
`
cfg.Set("frontmatter", map[string]interface{}{
"date": []string{dateHandler, "date"},
})
c1 := filepath.Join("content", "section", "2012-02-21-noslug.md")
c2 := filepath.Join("content", "section", "2012-02-22-slug.md")
writeSource(t, fs, c1, fmt.Sprintf(pageTemplate, 1, ""))
writeSource(t, fs, c2, fmt.Sprintf(pageTemplate, 2, "slug: aslug"))
c1fi, err := fs.Source.Stat(c1)
assrt.NoError(err)
c2fi, err := fs.Source.Stat(c2)
assrt.NoError(err)
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
assrt.Len(s.RegularPages(), 2)
noSlug := s.RegularPages()[0]
slug := s.RegularPages()[1]
assrt.Equal(28, noSlug.Lastmod().Day())
switch strings.ToLower(dateHandler) {
case ":filename":
assrt.False(noSlug.Date().IsZero())
assrt.False(slug.Date().IsZero())
assrt.Equal(2012, noSlug.Date().Year())
assrt.Equal(2012, slug.Date().Year())
assrt.Equal("noslug", noSlug.Slug())
assrt.Equal("aslug", slug.Slug())
case ":filemodtime":
assrt.Equal(c1fi.ModTime().Year(), noSlug.Date().Year())
assrt.Equal(c2fi.ModTime().Year(), slug.Date().Year())
fallthrough
default:
assrt.Equal("", noSlug.Slug())
assrt.Equal("aslug", slug.Slug())
}
})
}
} | explode_data.jsonl/60621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 739
} | [
2830,
3393,
2665,
2354,
23395,
44,
1650,
2648,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2023,
8358,
2400,
3050,
1669,
2088,
3056,
917,
90,
788,
8404,
497,
13022,
1192,
4459,
1462,
9207,
341,
197,
3244,
16708,
28197,
17305,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAzureDevOpsProject_CreateProject_PollsUntilOperationIsSuccessful(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
coreClient := azdosdkmocks.NewMockCoreClient(ctrl)
operationsClient := azdosdkmocks.NewMockOperationsClient(ctrl)
clients := &config.AggregatedClient{
CoreClient: coreClient,
OperationsClient: operationsClient,
Ctx: context.Background(),
}
expectedProjectCreateArgs := core.QueueCreateProjectArgs{ProjectToCreate: &testProject}
mockedOperationReference := operations.OperationReference{Id: &testID}
expectedOperationArgs := operations.GetOperationArgs{OperationId: &testID}
coreClient.
EXPECT().
QueueCreateProject(clients.Ctx, expectedProjectCreateArgs).
Return(&mockedOperationReference, nil).
Times(1)
firstStatus := operationWithStatus(operations.OperationStatusValues.InProgress)
firstPoll := operationsClient.
EXPECT().
GetOperation(clients.Ctx, expectedOperationArgs).
Return(&firstStatus, nil)
secondStatus := operationWithStatus(operations.OperationStatusValues.Succeeded)
secondPoll := operationsClient.
EXPECT().
GetOperation(clients.Ctx, expectedOperationArgs).
Return(&secondStatus, nil)
gomock.InOrder(firstPoll, secondPoll)
err := createProject(clients, &testProject, 5)
require.Equal(t, nil, err)
} | explode_data.jsonl/3731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
78107,
14592,
38904,
7849,
34325,
7849,
1088,
67878,
24493,
8432,
3872,
36374,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
71882,
2959,
1669,
12376,
40525,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWrite_fail(t *testing.T) {
dev, err := New(&gpiotest.Pin{}, &gpiotest.Pin{})
if err != nil {
t.Fatalf("failed to initialize tm1637: %v", err)
}
if n, err := dev.Write(make([]byte, 7)); n != 0 || err == nil {
t.Fatal("buffer too long")
}
} | explode_data.jsonl/32418 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
7985,
22121,
1155,
353,
8840,
836,
8,
341,
27302,
11,
1848,
1669,
1532,
2099,
70,
2493,
354,
477,
82939,
22655,
609,
70,
2493,
354,
477,
82939,
37790,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
16091,
311,
9468,
173... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNestedLists(t *testing.T) {
callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, `
package foo
// Blah is a test.
// +k8s:openapi-gen=true
// +k8s:openapi-gen=x-kubernetes-type-tag:type_test
type Blah struct {
// Nested list
NestedList [][]int64
}
`)
if callErr != nil {
t.Fatal(callErr)
}
if funcErr != nil {
t.Fatal(funcErr)
}
assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref),
`, callBuffer.String())
assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Blah is a test.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"NestedList": {
SchemaProps: spec.SchemaProps{
Description: "Nested list",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: 0,
Type: []string{"integer"},
Format: "int64",
},
},
},
},
},
},
},
},
},
Required: []string{"NestedList"},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-type-tag": "type_test",
},
},
},
}
}
`, funcBuffer.String())
} | explode_data.jsonl/3360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 519
} | [
2830,
3393,
71986,
37848,
1155,
353,
8840,
836,
8,
341,
67288,
7747,
11,
2915,
7747,
11,
2060,
11,
1618,
4095,
11,
2915,
4095,
1669,
1273,
5002,
7082,
929,
6492,
1155,
11,
22074,
1722,
15229,
271,
322,
2502,
1466,
374,
264,
1273,
624,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestQuerySM(t *testing.T) {
v := NewQuerySM().(*QuerySM)
require.True(t, v.CanResponse())
v.SequenceNumber = 13
validate(t,
v.GetResponse(),
"0000001480000003000000000000000d00000000",
data.QUERY_SM_RESP,
)
v.MessageID = "away"
_ = v.SourceAddr.SetAddress("Alicer")
v.SourceAddr.SetTon(28)
v.SourceAddr.SetNpi(29)
validate(t,
v,
"0000001e00000003000000000000000d61776179001c1d416c6963657200",
data.QUERY_SM,
)
} | explode_data.jsonl/37162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
2859,
9501,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
1532,
2859,
9501,
1005,
4071,
2859,
9501,
340,
17957,
32443,
1155,
11,
348,
53280,
2582,
2398,
5195,
63537,
2833,
284,
220,
16,
18,
271,
197,
7067,
1155,
345,
197,
5195... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigureSecurityGroupPermissionsOpenPortsSkipExisting(t *testing.T) {
driver := NewTestDriver()
group := securityGroup
group.IpPermissions = []*ec2.IpPermission{
{
IpProtocol: aws.String("tcp"),
FromPort: aws.Int64(8888),
ToPort: aws.Int64(testSSHPort),
},
{
IpProtocol: aws.String("tcp"),
FromPort: aws.Int64(8080),
ToPort: aws.Int64(testSSHPort),
},
}
driver.OpenPorts = []string{"8888/tcp", "8080/udp", "8080"}
perms, err := driver.configureSecurityGroupPermissions(group)
assert.NoError(t, err)
assert.Len(t, perms, 3)
assert.Equal(t, aws.Int64(int64(8080)), perms[2].ToPort)
assert.Equal(t, aws.String("udp"), perms[2].IpProtocol)
} | explode_data.jsonl/7409 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
28560,
15352,
2808,
23851,
5002,
68273,
35134,
53067,
1155,
353,
8840,
836,
8,
341,
33652,
1669,
1532,
2271,
11349,
741,
44260,
1669,
4763,
2808,
198,
44260,
2447,
79,
23851,
284,
29838,
757,
17,
2447,
79,
14966,
515,
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 TestGetrlimit(t *testing.T) {
var rlim unix.Rlimit
err := unix.Getrlimit(unix.RLIMIT_AS, &rlim)
if err != nil {
t.Fatalf("Getrlimit: %v", err)
}
} | explode_data.jsonl/35461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
1949,
2381,
2353,
1155,
353,
8840,
836,
8,
341,
2405,
435,
4659,
51866,
2013,
9506,
198,
9859,
1669,
51866,
2234,
2381,
2353,
18364,
941,
2013,
57100,
28028,
11,
609,
2381,
318,
340,
743,
1848,
961,
2092,
341,
197,
3244,
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
] | 2 |
func TestNewStringDecoder_ok(t *testing.T) {
decoder := NewStringDecoder(false)
message := "somewhere over the rainbow"
original := strings.NewReader(message)
var result map[string]interface{}
if err := decoder(original, &result); err != nil {
t.Error("Unexpected error: ", err.Error())
}
if len(result) != 1 {
t.Error("Unexpected result: ", result)
}
v, ok := result["content"]
if !ok {
t.Error("Wrong result: content not found ", result)
}
if v.(string) != message {
t.Error("Wrong result: ", v)
}
} | explode_data.jsonl/43263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
3564,
703,
20732,
19817,
1155,
353,
8840,
836,
8,
341,
197,
48110,
1669,
1532,
703,
20732,
3576,
340,
24753,
1669,
330,
56739,
60652,
916,
279,
47613,
698,
197,
9889,
1669,
9069,
68587,
7333,
340,
2405,
1102,
2415,
14032,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateStructErrors(t *testing.T) {
type update struct{ A int }
ctx := context.Background()
c, _ := newMock(t)
doc := c.Collection("C").Doc("d")
for _, test := range []struct {
desc string
fields []string
data interface{}
}{
{
desc: "data is not a struct or *struct",
data: map[string]interface{}{"a": 1},
},
{
desc: "no paths",
fields: nil,
data: update{},
},
{
desc: "empty",
fields: []string{""},
data: update{},
},
{
desc: "empty component",
fields: []string{"a.b..c"},
data: update{},
},
{
desc: "duplicate field",
fields: []string{"a", "b", "c", "a"},
data: update{},
},
{
desc: "invalid character",
fields: []string{"a", "b]"},
data: update{},
},
{
desc: "prefix",
fields: []string{"a", "b", "c", "b.c"},
data: update{},
},
} {
_, err := doc.UpdateStruct(ctx, test.fields, test.data)
if err == nil {
t.Errorf("%s: got nil, want error", test.desc)
}
}
} | explode_data.jsonl/15819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 477
} | [
2830,
3393,
4289,
9422,
13877,
1155,
353,
8840,
836,
8,
341,
13158,
2647,
2036,
90,
362,
526,
555,
20985,
1669,
2266,
19047,
741,
1444,
11,
716,
1669,
501,
11571,
1155,
340,
59536,
1669,
272,
28629,
445,
34,
1827,
9550,
445,
67,
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... | 3 |
func TestReuseListener(t *testing.T) {
t.Run("good to reuse", func(t *testing.T) {
top := &localconfig.TopLevel{General: localconfig.General{TLS: localconfig.TLS{Enabled: true}}}
require.True(t, reuseListener(top))
})
t.Run("reuse tls disabled", func(t *testing.T) {
top := &localconfig.TopLevel{}
require.PanicsWithValue(
t,
"TLS is required for running ordering nodes of cluster type.",
func() { reuseListener(top) },
)
})
t.Run("good not to reuse", func(t *testing.T) {
top := &localconfig.TopLevel{
General: localconfig.General{
Cluster: localconfig.Cluster{
ListenAddress: "127.0.0.1",
ListenPort: 5000,
ServerPrivateKey: "key",
ServerCertificate: "bad",
},
},
}
require.False(t, reuseListener(top))
})
t.Run("partial config", func(t *testing.T) {
top := &localconfig.TopLevel{
General: localconfig.General{
Cluster: localconfig.Cluster{
ListenAddress: "127.0.0.1",
ListenPort: 5000,
ServerCertificate: "bad",
},
},
}
require.PanicsWithValue(
t,
"Options: General.Cluster.ListenPort, General.Cluster.ListenAddress,"+
" General.Cluster.ServerCertificate, General.Cluster.ServerPrivateKey, should be defined altogether.",
func() { reuseListener(top) },
)
})
} | explode_data.jsonl/32659 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 538
} | [
2830,
3393,
38081,
2743,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
18536,
311,
25978,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
42118,
1669,
609,
2438,
1676,
17557,
4449,
90,
15415,
25,
2205,
1676,
75749,
90,
45439,
25,
2205... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSortOperation_Marshaling(t *testing.T) {
data := []byte(`{"id":"sort","kind":"sort","spec":{"columns":["t1","t2"],"desc":true}}`)
op := &flux.Operation{
ID: "sort",
Spec: &universe.SortOpSpec{
Columns: []string{"t1", "t2"},
Desc: true,
},
}
querytest.OperationMarshalingTestHelper(t, data, op)
} | explode_data.jsonl/76869 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
10231,
8432,
1245,
277,
927,
6132,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
5809,
4913,
307,
3252,
6860,
2198,
15314,
3252,
6860,
2198,
9535,
22317,
16369,
36799,
83,
16,
2198,
83,
17,
68882,
8614,
788,
1866,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExecuteOption(t *testing.T) {
testExecutor := &mockOptionsExecutor{}
assert := assert.New(t)
options := PkiInitOption{}
anyOpt, _, _ := NewPkiInitOption(options)
anyOpt.(*PkiInitOption).executor = testExecutor
exitCode, err := anyOpt.executeOptions(mockOption())
assert.Equal(normal, exitCode)
assert.Nil(err)
} | explode_data.jsonl/48135 | {
"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,
17174,
5341,
1155,
353,
8840,
836,
8,
341,
18185,
25255,
1669,
609,
16712,
3798,
25255,
16094,
6948,
1669,
2060,
7121,
1155,
692,
35500,
1669,
393,
6642,
3803,
5341,
16094,
197,
3767,
21367,
11,
8358,
716,
1669,
1532,
47,
66... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExplicitProvider(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: "explicit_provider",
Dependencies: []string{"@pulumi/pulumi"},
Quick: true,
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
assert.NotNil(t, stackInfo.Deployment)
latest := stackInfo.Deployment
// Expect one stack resource, two provider resources, and two custom resources.
assert.True(t, len(latest.Resources) == 5)
var defaultProvider *apitype.ResourceV3
var explicitProvider *apitype.ResourceV3
for _, res := range latest.Resources {
urn := res.URN
switch urn.Name() {
case "default":
assert.True(t, providers.IsProviderType(res.Type))
assert.Nil(t, defaultProvider)
prov := res
defaultProvider = &prov
case "p":
assert.True(t, providers.IsProviderType(res.Type))
assert.Nil(t, explicitProvider)
prov := res
explicitProvider = &prov
case "a":
prov, err := providers.ParseReference(res.Provider)
assert.NoError(t, err)
assert.NotNil(t, defaultProvider)
defaultRef, err := providers.NewReference(defaultProvider.URN, defaultProvider.ID)
assert.NoError(t, err)
assert.Equal(t, defaultRef.String(), prov.String())
case "b":
prov, err := providers.ParseReference(res.Provider)
assert.NoError(t, err)
assert.NotNil(t, explicitProvider)
explicitRef, err := providers.NewReference(explicitProvider.URN, explicitProvider.ID)
assert.NoError(t, err)
assert.Equal(t, explicitRef.String(), prov.String())
}
}
assert.NotNil(t, defaultProvider)
assert.NotNil(t, explicitProvider)
},
})
} | explode_data.jsonl/76364 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 680
} | [
2830,
3393,
98923,
5179,
1155,
353,
8840,
836,
8,
341,
2084,
17376,
80254,
2271,
1155,
11,
609,
60168,
80254,
2271,
3798,
515,
197,
197,
6184,
25,
688,
330,
93632,
29518,
756,
197,
197,
48303,
25,
3056,
917,
4913,
31,
79,
65482,
4322,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestComplex(t *testing.T) {
{
var v, r complex64
v = complex(1, 2)
if err := encdec(v, &r, func(code byte) bool {
return code == def.Fixext8
}); err != nil {
t.Error(err)
}
b, _ := msgpack.Marshal(v)
if int8(b[1]) != def.ComplexTypeCode() {
t.Errorf("complex type code is different %d, %d", int8(b[1]), def.ComplexTypeCode())
}
}
typeCode := int8(-100)
msgpack.SetComplexTypeCode(typeCode)
{
if def.ComplexTypeCode() != typeCode {
t.Errorf("complex type code not set %d, %d", typeCode, def.ComplexTypeCode())
}
var v, r complex128
v = complex(math.MaxFloat64, math.SmallestNonzeroFloat64)
if err := encdec(v, &r, func(code byte) bool {
return code == def.Fixext16
}); err != nil {
t.Error(err)
}
b, _ := msgpack.Marshal(v)
if int8(b[1]) != def.ComplexTypeCode() {
t.Errorf("complex type code is different %d, %d", int8(b[1]), def.ComplexTypeCode())
}
}
} | explode_data.jsonl/64213 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 407
} | [
2830,
3393,
31137,
1155,
353,
8840,
836,
8,
341,
197,
515,
197,
2405,
348,
11,
435,
6351,
21,
19,
198,
197,
5195,
284,
6351,
7,
16,
11,
220,
17,
340,
197,
743,
1848,
1669,
3209,
8169,
3747,
11,
609,
81,
11,
2915,
15842,
4922,
8,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_TX_GetOne(t *testing.T) {
table := createInitTable()
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
tx, err := db.Begin()
if err != nil {
gtest.Error(err)
}
if record, err := tx.GetOne(fmt.Sprintf("SELECT * FROM %s WHERE passport=?", table), "user_2"); err != nil {
gtest.Error(err)
} else {
if record == nil {
gtest.Error("FAIL")
}
t.Assert(record["nickname"].String(), "name_2")
}
if err := tx.Commit(); err != nil {
gtest.Error(err)
}
})
} | explode_data.jsonl/41314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
18819,
13614,
3966,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
1855,
3803,
2556,
741,
16867,
5943,
2556,
15761,
692,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
46237,
11,
1848,
1669,
2927,
28467,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatWithdrawPermissions(t *testing.T) {
// Arrange
y.SetDefaults()
expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.WithdrawFiatViaWebsiteOnlyText
// Act
withdrawPermissions := y.FormatWithdrawPermissions()
// Assert
if withdrawPermissions != expectedResult {
t.Errorf("Expected: %s, Recieved: %s", expectedResult, withdrawPermissions)
}
} | explode_data.jsonl/79875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
4061,
92261,
23851,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
14522,
4202,
16273,
741,
42400,
2077,
1669,
9289,
6477,
92261,
58288,
2354,
7082,
14966,
1178,
488,
330,
609,
330,
488,
9289,
26124,
7633,
37,
10358,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalUnmarshal(t *testing.T) {
testMarshalUnmarshal(t, None[int](), "null")
testMarshalUnmarshal(t, Some(3), "3")
testMarshalUnmarshal(t, Some(MyStruct{Prop: "x"}), `{"prop": "x"}`)
var ms Maybe[MyStruct]
assert.Error(t, ms.UnmarshalJSON([]byte(`malformed json`)))
assert.Error(t, ms.UnmarshalJSON([]byte(`{"prop": true}`)))
} | explode_data.jsonl/80922 | {
"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,
55438,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
18185,
55438,
1806,
27121,
1155,
11,
2240,
18640,
60,
1507,
330,
2921,
1138,
18185,
55438,
1806,
27121,
1155,
11,
4329,
7,
18,
701,
330,
18,
1138,
18185,
55438,
1806,
27121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocalKMS_getKeyTemplate(t *testing.T) {
keyTemplate, err := getKeyTemplate(kms.HMACSHA256Tag256Type)
require.NoError(t, err)
require.NotNil(t, keyTemplate)
require.Equal(t, "type.googleapis.com/google.crypto.tink.HmacKey", keyTemplate.TypeUrl)
} | explode_data.jsonl/33102 | {
"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,
7319,
42,
4826,
3062,
1592,
7275,
1155,
353,
8840,
836,
8,
341,
23634,
7275,
11,
1848,
1669,
74103,
7275,
5969,
1011,
3839,
25788,
33145,
17,
20,
21,
5668,
17,
20,
21,
929,
340,
17957,
35699,
1155,
11,
1848,
340,
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,
1... | 1 |
func TestCustomBuildImgNotFound(t *testing.T) {
f := newFakeCustomBuildFixture(t)
_, err := f.cb.Build(f.ctx, container.MustParseNamed("gcr.io/foo/bar"), "true")
// TODO(dmiller) better error message
assert.EqualError(t, err, "fake docker client error: object not found")
} | explode_data.jsonl/76331 | {
"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,
10268,
11066,
13033,
10372,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
52317,
10268,
11066,
18930,
1155,
692,
197,
6878,
1848,
1669,
282,
34757,
25212,
955,
30608,
11,
5476,
50463,
14463,
15810,
445,
70,
5082,
4245,
60555,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBasicControllerFlow(t *testing.T) {
stopChannel := make(chan struct{})
defer close(stopChannel)
received := make(chan bool)
caName, kubeclient, fakeWatch, _, controller, informerFactory := controllerSetup([]runtime.Object{}, stopChannel, t)
controller.syncHandler = func(serviceKey string) error {
defer func() { received <- true }()
err := controller.syncService(serviceKey)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
return err
}
informerFactory.Start(stopChannel)
go controller.Run(1, stopChannel)
expectedSecretName := "new-secret"
serviceName := "svc-name"
serviceUID := "some-uid"
expectedServiceAnnotations := map[string]string{ServingCertSecretAnnotation: expectedSecretName, ServingCertCreatedByAnnotation: caName}
expectedSecretAnnotations := map[string]string{ServiceUIDAnnotation: serviceUID, ServiceNameAnnotation: serviceName}
namespace := "ns"
serviceToAdd := &v1.Service{}
serviceToAdd.Name = serviceName
serviceToAdd.Namespace = namespace
serviceToAdd.UID = types.UID(serviceUID)
serviceToAdd.Annotations = map[string]string{ServingCertSecretAnnotation: expectedSecretName}
fakeWatch.Add(serviceToAdd)
t.Log("waiting to reach syncHandler")
select {
case <-received:
case <-time.After(time.Duration(30 * time.Second)):
t.Fatalf("failed to call into syncService")
}
foundSecret := false
foundServiceUpdate := false
for _, action := range kubeclient.Actions() {
switch {
case action.Matches("create", "secrets"):
createSecret := action.(clientgotesting.CreateAction)
newSecret := createSecret.GetObject().(*v1.Secret)
if newSecret.Name != expectedSecretName {
t.Errorf("expected %v, got %v", expectedSecretName, newSecret.Name)
continue
}
if newSecret.Namespace != namespace {
t.Errorf("expected %v, got %v", namespace, newSecret.Namespace)
continue
}
delete(newSecret.Annotations, ServingCertExpiryAnnotation)
if !reflect.DeepEqual(newSecret.Annotations, expectedSecretAnnotations) {
t.Errorf("expected %v, got %v", expectedSecretAnnotations, newSecret.Annotations)
continue
}
checkGeneratedCertificate(t, newSecret.Data["tls.crt"], serviceToAdd)
foundSecret = true
case action.Matches("update", "services"):
updateService := action.(clientgotesting.UpdateAction)
service := updateService.GetObject().(*v1.Service)
if !reflect.DeepEqual(service.Annotations, expectedServiceAnnotations) {
t.Errorf("expected %v, got %v", expectedServiceAnnotations, service.Annotations)
continue
}
foundServiceUpdate = true
}
}
if !foundSecret {
t.Errorf("secret wasn't created. Got %v\n", kubeclient.Actions())
}
if !foundServiceUpdate {
t.Errorf("service wasn't updated. Got %v\n", kubeclient.Actions())
}
} | explode_data.jsonl/49898 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 936
} | [
2830,
3393,
15944,
2051,
18878,
1155,
353,
8840,
836,
8,
341,
62644,
9629,
1669,
1281,
35190,
2036,
37790,
16867,
3265,
60170,
9629,
340,
17200,
8771,
1669,
1281,
35190,
1807,
692,
197,
924,
675,
11,
80958,
2972,
11,
12418,
14247,
11,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMSPIDMapping(t *testing.T) {
randString := func() string {
buff := make([]byte, 10)
rand.Read(buff)
return hex.EncodeToString(buff)
}
dir := filepath.Join(os.TempDir(), fmt.Sprintf("TestMSPIDMapping_%s", randString()))
os.Mkdir(dir, 0o700)
defer os.RemoveAll(dir)
cryptogen, err := gexec.Build("github.com/hechain20/hechain/cmd/cryptogen")
require.NoError(t, err)
defer os.Remove(cryptogen)
idemixgen, err := gexec.Build("github.com/IBM/idemix/tools/idemixgen", "-mod=mod")
require.NoError(t, err)
defer os.Remove(idemixgen)
cryptoConfigDir := filepath.Join(dir, "crypto-config")
b, err := exec.Command(cryptogen, "generate", fmt.Sprintf("--output=%s", cryptoConfigDir)).CombinedOutput()
require.NoError(t, err, string(b))
idemixConfigDir := filepath.Join(dir, "crypto-config", "idemix")
b, err = exec.Command(idemixgen, "ca-keygen", fmt.Sprintf("--output=%s", idemixConfigDir)).CombinedOutput()
require.NoError(t, err, string(b))
profileConfig := genesisconfig.Load("TwoOrgsChannel", "testdata/")
ordererConfig := genesisconfig.Load("TwoOrgsOrdererGenesis", "testdata/")
profileConfig.Orderer = ordererConfig.Orderer
// Override the MSP directory with our randomly generated and populated path
for _, org := range ordererConfig.Orderer.Organizations {
org.MSPDir = filepath.Join(cryptoConfigDir, "ordererOrganizations", "example.com", "msp")
org.Name = randString()
}
// Randomize organization names
for _, org := range profileConfig.Application.Organizations {
org.Name = randString()
// Non bccsp-msp orgs don't have the crypto material produced by cryptogen,
// we need to use the idemix crypto folder instead.
if org.MSPType != "bccsp" {
org.MSPDir = filepath.Join(idemixConfigDir)
continue
}
org.MSPDir = filepath.Join(cryptoConfigDir, "peerOrganizations", "org1.example.com", "msp")
}
channelGroup, err := encoder.NewChannelGroup(profileConfig)
require.NoError(t, err)
fakeConfigGetter := &mocks.ConfigGetter{}
fakeConfigGetter.GetCurrConfigReturnsOnCall(
0,
&common.Config{
ChannelGroup: channelGroup,
},
)
cs := config.NewDiscoverySupport(fakeConfigGetter)
res, err := cs.Config("mychannel")
require.NoError(t, err)
actualKeys := make(map[string]struct{})
for key := range res.Orderers {
actualKeys[key] = struct{}{}
}
for key := range res.Msps {
actualKeys[key] = struct{}{}
}
// Note that Org3MSP is an idemix org, but it shouldn't be listed here
// because peers can't have idemix credentials
expected := map[string]struct{}{
"OrdererMSP": {},
"Org1MSP": {},
"Org2MSP": {},
}
require.Equal(t, expected, actualKeys)
} | explode_data.jsonl/958 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 975
} | [
2830,
3393,
44,
4592,
915,
6807,
1155,
353,
8840,
836,
8,
341,
7000,
437,
703,
1669,
2915,
368,
914,
341,
197,
85696,
1669,
1281,
10556,
3782,
11,
220,
16,
15,
340,
197,
7000,
437,
6503,
39729,
340,
197,
853,
12371,
50217,
5870,
397... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConfigBuilderFunctions(t *testing.T) {
configTests := []struct {
name string
customName string
cfg *Config
wantReceiverConfig *prometheusreceiver.Config
wantSubprocessConfig *subprocessmanager.SubprocessConfig
wantErr bool
}{
{
name: "no command",
cfg: &Config{
ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)),
ScrapeInterval: 60 * time.Second,
ScrapeTimeout: 10 * time.Second,
Port: 9104,
SubprocessConfig: subprocessmanager.SubprocessConfig{
Command: "",
Env: []subprocessmanager.EnvConfig{},
},
},
wantReceiverConfig: &prometheusreceiver.Config{
ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)),
PrometheusConfig: &promconfig.Config{
ScrapeConfigs: []*promconfig.ScrapeConfig{
{
ScrapeInterval: model.Duration(60 * time.Second),
ScrapeTimeout: model.Duration(10 * time.Second),
Scheme: "http",
MetricsPath: "/metrics",
JobName: "prometheus_exec",
HonorLabels: false,
HonorTimestamps: true,
ServiceDiscoveryConfigs: discovery.Configs{
&discovery.StaticConfig{
{
Targets: []model.LabelSet{
{model.AddressLabel: model.LabelValue("localhost:9104")},
},
},
},
},
},
},
},
},
wantSubprocessConfig: &subprocessmanager.SubprocessConfig{
Env: []subprocessmanager.EnvConfig{},
},
wantErr: true,
},
{
name: "normal config",
cfg: &Config{
ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "mysqld")),
ScrapeInterval: 90 * time.Second,
ScrapeTimeout: 10 * time.Second,
Port: 9104,
SubprocessConfig: subprocessmanager.SubprocessConfig{
Command: "mysqld_exporter",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "password:username@(url:port)/dbname",
},
},
},
},
wantReceiverConfig: &prometheusreceiver.Config{
ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "mysqld")),
PrometheusConfig: &promconfig.Config{
ScrapeConfigs: []*promconfig.ScrapeConfig{
{
ScrapeInterval: model.Duration(90 * time.Second),
ScrapeTimeout: model.Duration(10 * time.Second),
Scheme: "http",
MetricsPath: "/metrics",
JobName: "mysqld",
HonorLabels: false,
HonorTimestamps: true,
ServiceDiscoveryConfigs: discovery.Configs{
&discovery.StaticConfig{
{
Targets: []model.LabelSet{
{model.AddressLabel: model.LabelValue("localhost:9104")},
},
},
},
},
},
},
},
},
wantSubprocessConfig: &subprocessmanager.SubprocessConfig{
Command: "mysqld_exporter",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "password:username@(url:port)/dbname",
},
},
},
wantErr: false,
},
{
name: "lots of defaults",
cfg: &Config{
ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "postgres/test")),
ScrapeInterval: 60 * time.Second,
ScrapeTimeout: 10 * time.Second,
SubprocessConfig: subprocessmanager.SubprocessConfig{
Command: "postgres_exporter",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "password:username@(url:port)/dbname",
},
},
},
},
wantReceiverConfig: &prometheusreceiver.Config{
ReceiverSettings: config.NewReceiverSettings(config.NewComponentIDWithName(typeStr, "postgres/test")),
PrometheusConfig: &promconfig.Config{
ScrapeConfigs: []*promconfig.ScrapeConfig{
{
ScrapeInterval: model.Duration(60 * time.Second),
ScrapeTimeout: model.Duration(10 * time.Second),
Scheme: "http",
MetricsPath: "/metrics",
JobName: "postgres/test",
HonorLabels: false,
HonorTimestamps: true,
ServiceDiscoveryConfigs: discovery.Configs{
&discovery.StaticConfig{
{
Targets: []model.LabelSet{
{model.AddressLabel: model.LabelValue("localhost:0")},
},
},
},
},
},
},
},
},
wantSubprocessConfig: &subprocessmanager.SubprocessConfig{
Command: "postgres_exporter",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "password:username@(url:port)/dbname",
},
},
},
wantErr: false,
},
}
for _, test := range configTests {
t.Run(test.name, func(t *testing.T) {
got := getPromReceiverConfig(test.cfg)
assert.Equal(t, test.wantReceiverConfig, got)
})
}
for _, test := range configTests {
t.Run(test.name, func(t *testing.T) {
got := getSubprocessConfig(test.cfg)
assert.Equal(t, test.wantSubprocessConfig, got)
})
}
} | explode_data.jsonl/1740 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2443
} | [
2830,
3393,
2648,
3297,
25207,
1155,
353,
8840,
836,
8,
341,
25873,
18200,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
1444,
1450,
675,
1843,
914,
198,
197,
50286,
1698,
353,
2648,
198,
197,
50780,
25436,
2648,
256,
353,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTopDownDefaultKeyword(t *testing.T) {
tests := []struct {
note string
rules []string
expected interface{}
}{
{"undefined", []string{`p = 1 { false }`, `default p = 0`, `p = 2 { false }`}, "0"},
{"defined", []string{`p = 1 { true }`, `default p = 0`, `p = 2 { false }`}, "1"},
{"array comprehension", []string{`p = 1 { false }`, `default p = [x | a[_] = x]`}, "[1,2,3,4]"},
{"object comprehension", []string{`p = 1 { false }`, `default p = {x: k | d[k][_] = x}`}, `{"bar": "e", "baz": "e"}`},
{"set comprehension", []string{`p = 1 { false }`, `default p = {x | a[_] = x}`}, `[1,2,3,4]`},
}
data := loadSmallTestData()
for _, tc := range tests {
runTopDownTestCase(t, data, tc.note, tc.rules, tc.expected)
}
} | explode_data.jsonl/25207 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
5366,
4454,
3675,
34481,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
9038,
1272,
257,
914,
198,
197,
7000,
2425,
262,
3056,
917,
198,
197,
42400,
3749,
16094,
197,
59403,
197,
197,
4913,
9614,
497,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomSpecModelUriInjection(t *testing.T) {
scenarios := map[string]struct {
original *appsv1.Deployment
expectedModelUriEnvVariable *v1.EnvVar
}{
"CustomSpecModelUriSet": {
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
constants.ModelInitializerSourceUriInternalAnnotationKey: "pvc://mypvcname/some/path/on/pvc",
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
v1.Container{
Name: "user-container",
Env: []v1.EnvVar{
v1.EnvVar{
Name: constants.CustomSpecModelUriEnvVarKey,
Value: "pvc://mypvcname/some/path/on/pvc",
},
},
},
},
},
},
},
},
expectedModelUriEnvVariable: &v1.EnvVar{
Name: constants.CustomSpecModelUriEnvVarKey,
Value: constants.DefaultModelLocalMountPath,
},
},
"CustomSpecModelUriEmpty": {
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
constants.ModelInitializerSourceUriInternalAnnotationKey: "pvc://mypvcname/some/path/on/pvc",
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
v1.Container{
Name: "user-container",
Env: []v1.EnvVar{
v1.EnvVar{
Name: constants.CustomSpecModelUriEnvVarKey,
Value: "",
},
},
},
},
},
},
},
},
expectedModelUriEnvVariable: &v1.EnvVar{
Name: constants.CustomSpecModelUriEnvVarKey,
Value: "",
},
},
"CustomSpecModelUriNotSet": {
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
constants.ModelInitializerSourceUriInternalAnnotationKey: "pvc://mypvcname/some/path/on/pvc",
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
v1.Container{
Name: "user-container",
Env: []v1.EnvVar{
v1.EnvVar{
Name: "TestRandom",
Value: "val",
},
},
},
},
},
},
},
},
expectedModelUriEnvVariable: nil,
},
}
for name, scenario := range scenarios {
injector := &ModelInitializerInjector{
credentialBuilder: credentials.NewCredentialBulder(c, &v1.ConfigMap{
Data: map[string]string{},
}),
}
if err := injector.InjectModelInitializer(scenario.original); err != nil {
t.Errorf("Test %q unexpected result: %s", name, err)
}
var originalEnvVar *v1.EnvVar
for _, envVar := range scenario.original.Spec.Template.Spec.Containers[0].Env {
if envVar.Name == constants.CustomSpecModelUriEnvVarKey {
originalEnvVar = &envVar
}
}
if diff := cmp.Diff(scenario.expectedModelUriEnvVariable, originalEnvVar); diff != "" {
t.Errorf("Test %q unexpected result (-want +got): %v", name, diff)
}
}
} | explode_data.jsonl/14728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1594
} | [
2830,
3393,
10268,
8327,
1712,
13899,
36653,
1155,
353,
8840,
836,
8,
341,
29928,
60494,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
9889,
503,
353,
676,
3492,
16,
34848,
39130,
198,
197,
42400,
1712,
13899,
14359,
7827,
353,
85,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestValSetUpdatesDuplicateEntries(t *testing.T) {
testCases := []valSetErrTestCase{
// Duplicate entries in changes
{ // first entry is duplicated change
testValSet(2, 10),
[]testVal{{"v1", 11}, {"v1", 22}},
},
{ // second entry is duplicated change
testValSet(2, 10),
[]testVal{{"v2", 11}, {"v2", 22}},
},
{ // change duplicates are separated by a valid change
testValSet(2, 10),
[]testVal{{"v1", 11}, {"v2", 22}, {"v1", 12}},
},
{ // change duplicates are separated by a valid change
testValSet(3, 10),
[]testVal{{"v1", 11}, {"v3", 22}, {"v1", 12}},
},
// Duplicate entries in remove
{ // first entry is duplicated remove
testValSet(2, 10),
[]testVal{{"v1", 0}, {"v1", 0}},
},
{ // second entry is duplicated remove
testValSet(2, 10),
[]testVal{{"v2", 0}, {"v2", 0}},
},
{ // remove duplicates are separated by a valid remove
testValSet(2, 10),
[]testVal{{"v1", 0}, {"v2", 0}, {"v1", 0}},
},
{ // remove duplicates are separated by a valid remove
testValSet(3, 10),
[]testVal{{"v1", 0}, {"v3", 0}, {"v1", 0}},
},
{ // remove and update same val
testValSet(2, 10),
[]testVal{{"v1", 0}, {"v2", 20}, {"v1", 30}},
},
{ // duplicate entries in removes + changes
testValSet(2, 10),
[]testVal{{"v1", 0}, {"v2", 20}, {"v2", 30}, {"v1", 0}},
},
{ // duplicate entries in removes + changes
testValSet(3, 10),
[]testVal{{"v1", 0}, {"v3", 5}, {"v2", 20}, {"v2", 30}, {"v1", 0}},
},
}
for i, tt := range testCases {
executeValSetErrTestCase(t, i, tt)
}
} | explode_data.jsonl/28328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 689
} | [
2830,
3393,
2208,
1649,
37091,
53979,
24533,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
831,
1649,
7747,
16458,
515,
197,
197,
322,
71071,
10695,
304,
4344,
198,
197,
197,
90,
442,
1156,
4343,
374,
54903,
2297,
198,
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 TestUpdatePods(t *testing.T) {
manager := NewReplicaSetController(fake.NewSimpleClientset(), controller.NoResyncPeriodFunc, BurstReplicas, 0)
manager.podStoreSynced = alwaysReady
received := make(chan string)
manager.syncHandler = func(key string) error {
obj, exists, err := manager.rsStore.Store.GetByKey(key)
if !exists || err != nil {
t.Errorf("Expected to find replica set under key %v", key)
}
received <- obj.(*extensions.ReplicaSet).Name
return nil
}
stopCh := make(chan struct{})
defer close(stopCh)
go wait.Until(manager.worker, 10*time.Millisecond, stopCh)
// Put 2 ReplicaSets and one pod into the controller's stores
labelMap1 := map[string]string{"foo": "bar"}
testRSSpec1 := newReplicaSet(1, labelMap1)
manager.rsStore.Store.Add(testRSSpec1)
testRSSpec2 := *testRSSpec1
labelMap2 := map[string]string{"bar": "foo"}
testRSSpec2.Spec.Selector = &unversioned.LabelSelector{MatchLabels: labelMap2}
testRSSpec2.Name = "barfoo"
manager.rsStore.Store.Add(&testRSSpec2)
// case 1: We put in the podStore a pod with labels matching testRSSpec1,
// then update its labels to match testRSSpec2. We expect to receive a sync
// request for both replica sets.
pod1 := newPodList(manager.podStore.Indexer, 1, api.PodRunning, labelMap1, testRSSpec1, "pod").Items[0]
pod2 := pod1
pod2.Labels = labelMap2
manager.updatePod(&pod1, &pod2)
expected := sets.NewString(testRSSpec1.Name, testRSSpec2.Name)
for _, name := range expected.List() {
t.Logf("Expecting update for %+v", name)
select {
case got := <-received:
if !expected.Has(got) {
t.Errorf("Expected keys %#v got %v", expected, got)
}
case <-time.After(wait.ForeverTestTimeout):
t.Errorf("Expected update notifications for replica sets within 100ms each")
}
}
// case 2: pod1 in the podStore has labels matching testRSSpec1. We update
// its labels to match no replica set. We expect to receive a sync request
// for testRSSpec1.
pod2.Labels = make(map[string]string)
manager.updatePod(&pod1, &pod2)
expected = sets.NewString(testRSSpec1.Name)
for _, name := range expected.List() {
t.Logf("Expecting update for %+v", name)
select {
case got := <-received:
if !expected.Has(got) {
t.Errorf("Expected keys %#v got %v", expected, got)
}
case <-time.After(wait.ForeverTestTimeout):
t.Errorf("Expected update notifications for replica sets within 100ms each")
}
}
} | explode_data.jsonl/10049 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 868
} | [
2830,
3393,
4289,
23527,
82,
1155,
353,
8840,
836,
8,
341,
92272,
1669,
1532,
18327,
15317,
1649,
2051,
74138,
7121,
16374,
2959,
746,
1507,
6461,
16766,
1061,
1721,
23750,
9626,
11,
77467,
18327,
52210,
11,
220,
15,
340,
92272,
556,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestApplicationEvaluationEvents(t *testing.T) {
tests := []struct {
want WebhookApplicationEvaluation
closer bool
}{
{WebhookApplicationEvaluation{Initiator: "dummy1", ID: "foobar1"}, false},
{WebhookApplicationEvaluation{Initiator: "dummy2", ID: "foobar2"}, true},
}
for _, test := range tests {
events, close := ApplicationEvaluationEvents()
if test.closer {
defer close()
}
sendApplicationEvaluationEvent(test.want)
got := <-events
if !reflect.DeepEqual(got, test.want) {
t.Error("Did not get expected event")
t.Error("got", got)
t.Error("want", test.want)
}
}
} | explode_data.jsonl/47923 | {
"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,
4988,
82363,
7900,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
50780,
256,
4895,
20873,
4988,
82363,
198,
197,
1444,
69215,
1807,
198,
197,
59403,
197,
197,
90,
5981,
20873,
4988,
82363,
90,
3803,
36122,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntRangeBand_Parse(t *testing.T) {
testCases := map[string]struct {
inRange string
wantedMin int
wantedMax int
wantedErr error
}{
"invalid format": {
inRange: "badRange",
wantedErr: fmt.Errorf("invalid range value badRange. Should be in format of ${min}-${max}"),
},
"invalid minimum": {
inRange: "a-100",
wantedErr: fmt.Errorf("cannot convert minimum value a to integer"),
},
"invalid maximum": {
inRange: "1-a",
wantedErr: fmt.Errorf("cannot convert maximum value a to integer"),
},
"success": {
inRange: "1-10",
wantedMin: 1,
wantedMax: 10,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
r := IntRangeBand(tc.inRange)
gotMin, gotMax, err := r.Parse()
if tc.wantedErr != nil {
require.EqualError(t, err, tc.wantedErr.Error())
} else {
require.NoError(t, err)
require.Equal(t, tc.wantedMin, gotMin)
require.Equal(t, tc.wantedMax, gotMax)
}
})
}
} | explode_data.jsonl/70115 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
1072,
6046,
33744,
77337,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
17430,
6046,
914,
271,
197,
6692,
7566,
6217,
526,
198,
197,
6692,
7566,
5974,
526,
198,
197,
6692,
7566,
7747,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPodSpecWithSecretsProvider(t *testing.T) {
coreops.SetInstance(coreops.New(fakek8sclient.NewSimpleClientset()))
nodeName := "testNode"
cluster := &corev1.StorageCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "px-cluster",
Namespace: "kube-system",
},
Spec: corev1.StorageClusterSpec{
SecretsProvider: stringPtr("k8s"),
},
}
driver := portworx{}
expectedArgs := []string{
"-c", "px-cluster",
"-x", "kubernetes",
"-secret_type", "k8s",
}
actual, err := driver.GetStoragePodSpec(cluster, nodeName)
require.NoError(t, err, "Unexpected error on GetStoragePodSpec")
assert.ElementsMatch(t, expectedArgs, actual.Containers[0].Args)
// Don't set the secrets provider if empty
cluster.Spec.SecretsProvider = stringPtr("")
expectedArgs = []string{
"-c", "px-cluster",
"-x", "kubernetes",
}
actual, _ = driver.GetStoragePodSpec(cluster, nodeName)
assert.ElementsMatch(t, expectedArgs, actual.Containers[0].Args)
// Don't set the secrets provider if nil
cluster.Spec.SecretsProvider = nil
actual, _ = driver.GetStoragePodSpec(cluster, nodeName)
assert.ElementsMatch(t, expectedArgs, actual.Containers[0].Args)
} | explode_data.jsonl/55445 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
23527,
8327,
2354,
19773,
82,
5179,
1155,
353,
8840,
836,
8,
341,
71882,
3721,
4202,
2523,
47867,
3721,
7121,
74138,
74,
23,
82,
2972,
7121,
16374,
2959,
746,
12145,
20831,
675,
1669,
330,
1944,
1955,
1837,
197,
18855,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseFormat(t *testing.T) {
var tests = []struct {
desc string
spec string
formatters []fabenc.Formatter
}{
{
desc: "empty spec",
spec: "",
formatters: []fabenc.Formatter{},
},
{
desc: "simple verb",
spec: "%{color}",
formatters: []fabenc.Formatter{
fabenc.ColorFormatter{},
},
},
{
desc: "with prefix",
spec: "prefix %{color}",
formatters: []fabenc.Formatter{
fabenc.StringFormatter{Value: "prefix "},
fabenc.ColorFormatter{},
},
},
{
desc: "with suffix",
spec: "%{color} suffix",
formatters: []fabenc.Formatter{
fabenc.ColorFormatter{},
fabenc.StringFormatter{Value: " suffix"}},
},
{
desc: "with prefix and suffix",
spec: "prefix %{color} suffix",
formatters: []fabenc.Formatter{
fabenc.StringFormatter{Value: "prefix "},
fabenc.ColorFormatter{},
fabenc.StringFormatter{Value: " suffix"},
},
},
{
desc: "with format",
spec: "%{level:.4s} suffix",
formatters: []fabenc.Formatter{
fabenc.LevelFormatter{FormatVerb: "%.4s"},
fabenc.StringFormatter{Value: " suffix"},
},
},
}
for _, tc := range tests {
t.Run(fmt.Sprintf(tc.desc), func(t *testing.T) {
formatters, err := fabenc.ParseFormat(tc.spec)
assert.NoError(t, err)
assert.Equal(t, tc.formatters, formatters)
})
}
} | explode_data.jsonl/10929 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 619
} | [
2830,
3393,
14463,
4061,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
41653,
981,
914,
198,
197,
98100,
981,
914,
198,
197,
37410,
10175,
3056,
36855,
954,
96291,
198,
197,
59403,
197,
197,
515,
298,
41653,
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 TestTypeSystem_UnionTypesMustBeArray_AcceptsAUnionTypeWithArrayTypes(t *testing.T) {
_, err := schemaWithFieldType(graphql.NewUnion(graphql.UnionConfig{
Name: "SomeUnion",
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
return nil
},
Types: []*graphql.Object{
someObjectType,
},
}))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
} | explode_data.jsonl/79152 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
929,
2320,
62,
32658,
4173,
31776,
3430,
1857,
1566,
66,
57771,
32,
32658,
929,
2354,
1857,
4173,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
10802,
2354,
63733,
24312,
1470,
7121,
32658,
24312,
1470,
10616,
290,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEvent_String(t *testing.T) {
v := Event{
Type: String(""),
Public: Bool(false),
Repo: &Repository{},
Actor: &User{},
Org: &Organization{},
ID: String(""),
}
want := `github.Event{Type:"", Public:false, Repo:github.Repository{}, Actor:github.User{}, Org:github.Organization{}, ID:""}`
if got := v.String(); got != want {
t.Errorf("Event.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33234 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 176
} | [
2830,
3393,
1556,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
3665,
515,
197,
27725,
25,
256,
923,
445,
4461,
197,
73146,
25,
12608,
3576,
1326,
197,
197,
25243,
25,
256,
609,
4624,
38837,
197,
197,
18870,
25,
220,
609,
1474,
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 TestPodUnset(t *testing.T) {
t.Parallel()
ms, ctrl, pod, executor := setup(t)
defer ctrl.Finish()
// Expectations
ms.EXPECT().GetPodFlag(pod, events.PodCreatePodResponse).Return(scenario.ResponseUnset, nil)
ms.EXPECT().GetNodeFlag(events.NodeCreatePodResponse).Return(scenario.ResponseUnset, nil)
// Run code under test
out, err := executor(events.PodCreatePodResponse)
// Assert
assert.NoError(t, err)
assert.Equal(t, tStr, out)
} | explode_data.jsonl/35141 | {
"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,
23527,
1806,
746,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
47691,
11,
23743,
11,
7509,
11,
31558,
1669,
6505,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
322,
32085,
804,
198,
47691,
22402,
7285,
1005,
1949... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.