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 TestNormalize(t *testing.T) {
var (
doc Doc
tests = []struct {
name, apiResponse string
expected *blockatlas.Tx
}{
{"transfer", transferSrc, &transferDst},
{"token transfer", tokenTransferSrc, &tokenTransferDst},
{"contract call", contractCallSrc, &contractCallDst},
{"failed transaction", failedSrc, &failedDst},
}
)
t.Run("TestNormalize", func(t *testing.T) {
for _, tt := range tests {
err := json.Unmarshal([]byte(tt.apiResponse), &doc)
if err != nil {
t.Error(err)
return
}
res := AppendTxs(nil, &doc, coin.ETH)
resJSON, err := json.Marshal(res)
if err != nil {
t.Fatal(err)
}
dstJSON, err := json.Marshal([]blockatlas.Tx{*tt.expected})
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(resJSON, dstJSON) {
println("\n", "Test failed ", tt.name)
println("resJSON", string(resJSON))
println("dstJSON", string(dstJSON))
t.Error(tt.name + ": tx don't equal")
}
}
})
} | explode_data.jsonl/5196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 446
} | [
2830,
3393,
87824,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
59536,
256,
21709,
198,
197,
78216,
284,
3056,
1235,
341,
298,
11609,
11,
6330,
2582,
914,
198,
298,
42400,
688,
353,
4574,
266,
14493,
81362,
198,
197,
197,
59403,
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... | 6 |
func TestClosedWakeUp(t *testing.T) {
events := &testClosedWakeUpServer{
tester: t,
BuiltinEventEngine: &BuiltinEventEngine{}, network: "tcp", addr: ":8888", protoAddr: "tcp://:8888",
clientClosed: make(chan struct{}),
serverClosed: make(chan struct{}),
wakeup: make(chan struct{}),
}
err := Run(events, events.protoAddr)
assert.NoError(t, err)
} | explode_data.jsonl/52052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
26884,
90748,
2324,
1155,
353,
8840,
836,
8,
341,
90873,
1669,
609,
1944,
26884,
90748,
2324,
5475,
515,
197,
18185,
261,
25,
1797,
259,
345,
197,
12791,
25628,
1556,
4571,
25,
609,
33,
25628,
1556,
4571,
22655,
3922,
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 TestFailureBadBinaryTags(t *testing.T) {
badTagESSpan, err := loadESSpanFixture(1)
require.NoError(t, err)
badTagESSpan.Tags = []KeyValue{
{
Key: "zzzz",
Value: "zzzz",
Type: "binary",
},
}
failingSpanTransformAnyMsg(t, &badTagESSpan)
} | explode_data.jsonl/5145 | {
"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,
17507,
17082,
21338,
15930,
1155,
353,
8840,
836,
8,
341,
2233,
329,
5668,
9996,
848,
11,
1848,
1669,
2795,
9996,
848,
18930,
7,
16,
340,
17957,
35699,
1155,
11,
1848,
692,
2233,
329,
5668,
9996,
848,
73522,
284,
3056,
720... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLinuxConnReceiveInvalidSockaddr(t *testing.T) {
c, s := testLinuxConn(t, nil)
s.recvmsg.from = &unix.SockaddrInet4{}
_, got := c.Receive()
if want := errInvalidSockaddr; want != got {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v", want, got)
}
} | explode_data.jsonl/33487 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
46324,
9701,
14742,
7928,
79812,
6214,
1155,
353,
8840,
836,
8,
341,
1444,
11,
274,
1669,
1273,
46324,
9701,
1155,
11,
2092,
692,
1903,
40433,
3236,
6387,
284,
609,
56646,
808,
1176,
6214,
641,
295,
19,
31483,
197,
6878,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMakeIDsFromAPIAssigneesToAdd(t *testing.T) {
IDs, err := MakeIDsFromAPIAssigneesToAdd("", []string{""})
assert.NoError(t, err)
assert.Equal(t, []int64{}, IDs)
IDs, err = MakeIDsFromAPIAssigneesToAdd("", []string{"none_existing_user"})
assert.Error(t, err)
IDs, err = MakeIDsFromAPIAssigneesToAdd("user1", []string{"user1"})
assert.NoError(t, err)
assert.Equal(t, []int64{1}, IDs)
IDs, err = MakeIDsFromAPIAssigneesToAdd("user2", []string{""})
assert.NoError(t, err)
assert.Equal(t, []int64{2}, IDs)
IDs, err = MakeIDsFromAPIAssigneesToAdd("", []string{"user1", "user2"})
assert.NoError(t, err)
assert.Equal(t, []int64{1, 2}, IDs)
} | explode_data.jsonl/42483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
8078,
30466,
3830,
7082,
28933,
5516,
52113,
1155,
353,
8840,
836,
8,
341,
29580,
82,
11,
1848,
1669,
7405,
30466,
3830,
7082,
28933,
5516,
52113,
19814,
3056,
917,
90,
3014,
3518,
6948,
35699,
1155,
11,
1848,
340,
6948,
128... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPerCallLimit(t *testing.T) {
limiters := NewFakeLimiters()
m := PerCallLimit(1)
// Exceeds burst size.
err := m.RateLimit(context.Background(), 2)
spiretest.RequireGRPCStatus(t, err, codes.ResourceExhausted, "rate (2) exceeds burst size (1)")
// Within burst size.
require.NoError(t, m.RateLimit(context.Background(), 1))
// There should be a single rate limiter. WaitN should have only been
// called once for the call that didn't exceed the burst size.
assert.Equal(t, 1, limiters.Count)
assert.Equal(t, []WaitNEvent{
{ID: 1, Count: 1},
}, limiters.WaitNEvents)
} | explode_data.jsonl/5206 | {
"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,
3889,
7220,
16527,
1155,
353,
8840,
836,
8,
341,
8810,
67645,
1669,
1532,
52317,
16527,
388,
2822,
2109,
1669,
3616,
7220,
16527,
7,
16,
692,
197,
322,
1374,
4635,
82,
20524,
1379,
624,
9859,
1669,
296,
2013,
349,
16527,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTimeoutHandlerRaceHeader(t *testing.T) {
defer afterTest(t)
delay204 := HandlerFunc(func(w ResponseWriter, r *Request) {
w.WriteHeader(204)
})
ts := httptest.NewServer(TimeoutHandler(delay204, time.Nanosecond, ""))
defer ts.Close()
var wg sync.WaitGroup
gate := make(chan bool, 50)
n := 500
if testing.Short() {
n = 10
}
for i := 0; i < n; i++ {
gate <- true
wg.Add(1)
go func() {
defer wg.Done()
defer func() { <-gate }()
res, err := Get(ts.URL)
if err != nil {
t.Error(err)
return
}
defer res.Body.Close()
io.Copy(ioutil.Discard, res.Body)
}()
}
wg.Wait()
} | explode_data.jsonl/22424 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
7636,
3050,
55991,
4047,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
692,
55174,
17,
15,
19,
1669,
19954,
9626,
18552,
3622,
5949,
6492,
11,
435,
353,
1900,
8,
341,
197,
6692,
69794,
7,
17,
15,
19,
340,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCountEntries(t *testing.T) {
for _, tt := range []struct {
name string
count int32
resp *entryv1.CountEntriesResponse
code codes.Code
dsError error
err string
expectLogs []spiretest.LogEntry
}{
{
name: "0 entries",
count: 0,
resp: &entryv1.CountEntriesResponse{Count: 0},
},
{
name: "1 entries",
count: 1,
resp: &entryv1.CountEntriesResponse{Count: 1},
},
{
name: "2 entries",
count: 2,
resp: &entryv1.CountEntriesResponse{Count: 2},
},
{
name: "3 entries",
count: 3,
resp: &entryv1.CountEntriesResponse{Count: 3},
},
{
name: "ds error",
err: "failed to count entries: ds error",
code: codes.Internal,
dsError: status.Error(codes.Internal, "ds error"),
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Failed to count entries",
Data: logrus.Fields{
logrus.ErrorKey: "rpc error: code = Internal desc = ds error",
},
},
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
ds := fakedatastore.New(t)
test := setupServiceTest(t, ds)
defer test.Cleanup()
for i := 0; i < int(tt.count); i++ {
_, err := test.ds.CreateRegistrationEntry(ctx, &datastore.CreateRegistrationEntryRequest{
Entry: &common.RegistrationEntry{
ParentId: td.NewID(fmt.Sprintf("parent%d", i)).String(),
SpiffeId: td.NewID(fmt.Sprintf("child%d", i)).String(),
Selectors: []*common.Selector{
{Type: "unix", Value: "uid:1000"},
{Type: "unix", Value: "gid:1000"},
},
},
})
require.NoError(t, err)
}
ds.SetNextError(tt.dsError)
resp, err := test.client.CountEntries(context.Background(), &entryv1.CountEntriesRequest{})
spiretest.AssertLogs(t, test.logHook.AllEntries(), tt.expectLogs)
if tt.err != "" {
spiretest.RequireGRPCStatusContains(t, err, tt.code, tt.err)
require.Nil(t, resp)
return
}
require.NoError(t, err)
require.NotNil(t, resp)
spiretest.AssertProtoEqual(t, tt.resp, resp)
require.Equal(t, tt.count, resp.Count)
})
}
} | explode_data.jsonl/65672 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1018
} | [
2830,
3393,
2507,
24533,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
18032,
414,
526,
18,
17,
198,
197,
34653,
981,
353,
4085,
85,
16,
6134,
24533,
2582,
198,
197,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRootMappingFsDirnames(t *testing.T) {
c := qt.New(t)
fs := NewBaseFileDecorator(afero.NewMemMapFs())
testfile := "myfile.txt"
c.Assert(fs.Mkdir("f1t", 0755), qt.IsNil)
c.Assert(fs.Mkdir("f2t", 0755), qt.IsNil)
c.Assert(fs.Mkdir("f3t", 0755), qt.IsNil)
c.Assert(afero.WriteFile(fs, filepath.Join("f2t", testfile), []byte("some content"), 0755), qt.IsNil)
rfs, err := NewRootMappingFsFromFromTo(fs, "static/bf1", "f1t", "static/cf2", "f2t", "static/af3", "f3t")
c.Assert(err, qt.IsNil)
fif, err := rfs.Stat(filepath.Join("static/cf2", testfile))
c.Assert(err, qt.IsNil)
c.Assert(fif.Name(), qt.Equals, "myfile.txt")
fifm := fif.(FileMetaInfo).Meta()
c.Assert(fifm.Filename(), qt.Equals, filepath.FromSlash("f2t/myfile.txt"))
root, err := rfs.Open(filepathSeparator)
c.Assert(err, qt.IsNil)
dirnames, err := root.Readdirnames(-1)
c.Assert(err, qt.IsNil)
c.Assert(dirnames, qt.DeepEquals, []string{"bf1", "cf2", "af3"})
} | explode_data.jsonl/13725 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 457
} | [
2830,
3393,
8439,
6807,
48300,
6184,
11400,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
38949,
7121,
1155,
340,
53584,
1669,
1532,
3978,
1703,
47951,
2877,
802,
78,
7121,
18816,
2227,
48300,
12367,
18185,
1192,
1669,
330,
94921,
3909,
698,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFromLoadersWithErrors(t *testing.T) {
c := FromLoaders([]BackingLoader{BackingLoaderFunc(func() (Reader, error) {
return nil, errors.New("nope")
})})
assert.Equal(t, 0, len(c.readers))
} | explode_data.jsonl/72635 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
3830,
5879,
388,
2354,
13877,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
5542,
5879,
388,
10556,
40332,
9181,
90,
40332,
9181,
9626,
18552,
368,
320,
5062,
11,
1465,
8,
341,
197,
853,
2092,
11,
5975,
7121,
445,
2152,
375,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeply(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragB }
fragment fragB on Dog { ...fragC }
fragment fragC on Dog { ...fragO }
fragment fragX on Dog { ...fragY }
fragment fragY on Dog { ...fragZ }
fragment fragZ on Dog { ...fragO }
fragment fragO on Dog { ...fragP }
fragment fragP on Dog { ...fragA, ...fragX }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself via fragB, fragC, fragO, fragP.`,
2, 31,
3, 31,
4, 31,
8, 31,
9, 31),
testutil.RuleError(`Cannot spread fragment "fragO" within itself via fragP, fragX, fragY, fragZ.`,
8, 31,
9, 41,
5, 31,
6, 31,
7, 31),
})
} | explode_data.jsonl/30375 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
17926,
36989,
82440,
9488,
6406,
30358,
36989,
6406,
6154,
2132,
721,
33464,
398,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
81893,
37,
6209,
11337,
1155,
11,
48865,
16766,
9488,
34,
15805,
11337,
11,
22074,
414,
12289,
8343,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStateLockNoPOL(t *testing.T) {
cs1, vss := randState(2)
vs2 := vss[1]
height, round := cs1.Height, cs1.Round
partSize := types.BlockPartSizeBytes
timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose)
timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait)
voteCh := subscribeUnBuffered(cs1.eventBus, types.EventQueryVote)
proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal)
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound)
/*
Round1 (cs1, B) // B B // B B2
*/
// start round and wait for prevote
cs1.enterNewRound(height, round)
cs1.startRoutines(0)
ensureNewRound(newRoundCh, height, round)
ensureNewProposal(proposalCh, height, round)
roundState := cs1.GetRoundState()
theBlockHash := roundState.ProposalBlock.Hash()
thePartSetHeader := roundState.ProposalBlockParts.Header()
ensurePrevote(voteCh, height, round) // prevote
// we should now be stuck in limbo forever, waiting for more prevotes
// prevote arrives from vs2:
signAddVotes(cs1, types.PrevoteType, theBlockHash, thePartSetHeader, vs2)
ensurePrevote(voteCh, height, round) // prevote
ensurePrecommit(voteCh, height, round) // precommit
// the proposed block should now be locked and our precommit added
validatePrecommit(t, cs1, round, round, vss[0], theBlockHash, theBlockHash)
// we should now be stuck in limbo forever, waiting for more precommits
// lets add one for a different block
hash := make([]byte, len(theBlockHash))
copy(hash, theBlockHash)
hash[0] = (hash[0] + 1) % 255
signAddVotes(cs1, types.PrecommitType, hash, thePartSetHeader, vs2)
ensurePrecommit(voteCh, height, round) // precommit
// (note we're entering precommit for a second time this round)
// but with invalid args. then we enterPrecommitWait, and the timeout to new round
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
///
round++ // moving to the next round
ensureNewRound(newRoundCh, height, round)
t.Log("#### ONTO ROUND 1")
/*
Round2 (cs1, B) // B B2
*/
incrementRound(vs2)
// now we're on a new round and not the proposer, so wait for timeout
ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
rs := cs1.GetRoundState()
if rs.ProposalBlock != nil {
panic("Expected proposal block to be nil")
}
// wait to finish prevote
ensurePrevote(voteCh, height, round)
// we should have prevoted our locked block
validatePrevote(t, cs1, round, vss[0], rs.LockedBlock.Hash())
// add a conflicting prevote from the other validator
signAddVotes(cs1, types.PrevoteType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2)
ensurePrevote(voteCh, height, round)
// now we're going to enter prevote again, but with invalid args
// and then prevote wait, which should timeout. then wait for precommit
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
ensurePrecommit(voteCh, height, round) // precommit
// the proposed block should still be locked and our precommit added
// we should precommit nil and be locked on the proposal
validatePrecommit(t, cs1, round, 0, vss[0], nil, theBlockHash)
// add conflicting precommit from vs2
signAddVotes(cs1, types.PrecommitType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2)
ensurePrecommit(voteCh, height, round)
// (note we're entering precommit for a second time this round, but with invalid args
// then we enterPrecommitWait and timeout into NewRound
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
round++ // entering new round
ensureNewRound(newRoundCh, height, round)
t.Log("#### ONTO ROUND 2")
/*
Round3 (vs2, _) // B, B2
*/
incrementRound(vs2)
ensureNewProposal(proposalCh, height, round)
rs = cs1.GetRoundState()
// now we're on a new round and are the proposer
if !bytes.Equal(rs.ProposalBlock.Hash(), rs.LockedBlock.Hash()) {
panic(fmt.Sprintf(
"Expected proposal block to be locked block. Got %v, Expected %v",
rs.ProposalBlock,
rs.LockedBlock))
}
ensurePrevote(voteCh, height, round) // prevote
validatePrevote(t, cs1, round, vss[0], rs.LockedBlock.Hash())
signAddVotes(cs1, types.PrevoteType, hash, rs.ProposalBlock.MakePartSet(partSize).Header(), vs2)
ensurePrevote(voteCh, height, round)
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
ensurePrecommit(voteCh, height, round) // precommit
validatePrecommit(t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but be locked on proposal
signAddVotes(
cs1,
types.PrecommitType,
hash,
rs.ProposalBlock.MakePartSet(partSize).Header(),
vs2) // NOTE: conflicting precommits at same height
ensurePrecommit(voteCh, height, round)
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
cs2, _ := randState(2) // needed so generated block is different than locked block
// before we time out into new round, set next proposal block
prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1)
if prop == nil || propBlock == nil {
t.Fatal("Failed to create proposal block with vs2")
}
incrementRound(vs2)
round++ // entering new round
ensureNewRound(newRoundCh, height, round)
t.Log("#### ONTO ROUND 3")
/*
Round4 (vs2, C) // B C // B C
*/
// now we're on a new round and not the proposer
// so set the proposal block
if err := cs1.SetProposalAndBlock(prop, propBlock, propBlock.MakePartSet(partSize), ""); err != nil {
t.Fatal(err)
}
ensureNewProposal(proposalCh, height, round)
ensurePrevote(voteCh, height, round) // prevote
// prevote for locked block (not proposal)
validatePrevote(t, cs1, 3, vss[0], cs1.LockedBlock.Hash())
// prevote for proposed block
signAddVotes(cs1, types.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
ensurePrevote(voteCh, height, round)
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
ensurePrecommit(voteCh, height, round)
validatePrecommit(t, cs1, round, 0, vss[0], nil, theBlockHash) // precommit nil but locked on proposal
signAddVotes(
cs1,
types.PrecommitType,
propBlock.Hash(),
propBlock.MakePartSet(partSize).Header(),
vs2) // NOTE: conflicting precommits at same height
ensurePrecommit(voteCh, height, round)
} | explode_data.jsonl/81648 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2189
} | [
2830,
3393,
1397,
11989,
2753,
49303,
1155,
353,
8840,
836,
8,
341,
71899,
16,
11,
348,
778,
1669,
10382,
1397,
7,
17,
340,
5195,
82,
17,
1669,
348,
778,
58,
16,
921,
30500,
11,
4778,
1669,
10532,
16,
17743,
11,
10532,
16,
37646,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateConfig(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
Client := th.Client
cfg, resp := th.SystemAdminClient.GetConfig()
CheckNoError(t, resp)
_, resp = Client.UpdateConfig(cfg)
CheckForbiddenStatus(t, resp)
SiteName := th.App.Config().TeamSettings.SiteName
cfg.TeamSettings.SiteName = "MyFancyName"
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
CheckNoError(t, resp)
if len(cfg.TeamSettings.SiteName) == 0 {
t.Fatal()
} else {
if cfg.TeamSettings.SiteName != "MyFancyName" {
t.Log("It should update the SiteName")
t.Fatal()
}
}
//Revert the change
cfg.TeamSettings.SiteName = SiteName
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
CheckNoError(t, resp)
if len(cfg.TeamSettings.SiteName) == 0 {
t.Fatal()
} else {
if cfg.TeamSettings.SiteName != SiteName {
t.Log("It should update the SiteName")
t.Fatal()
}
}
t.Run("Should not be able to modify PluginSettings.EnableUploads", func(t *testing.T) {
oldEnableUploads := *th.App.GetConfig().PluginSettings.EnableUploads
*cfg.PluginSettings.EnableUploads = !oldEnableUploads
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
CheckNoError(t, resp)
assert.Equal(t, oldEnableUploads, *cfg.PluginSettings.EnableUploads)
assert.Equal(t, oldEnableUploads, *th.App.GetConfig().PluginSettings.EnableUploads)
cfg.PluginSettings.EnableUploads = nil
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
CheckNoError(t, resp)
assert.Equal(t, oldEnableUploads, *cfg.PluginSettings.EnableUploads)
assert.Equal(t, oldEnableUploads, *th.App.GetConfig().PluginSettings.EnableUploads)
})
} | explode_data.jsonl/10679 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 607
} | [
2830,
3393,
4289,
2648,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
50286,
11,
9039,
1669,
270,
16620,
7210,
2959,
2234... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRstOnCloseWithUnreadDataFinConvertRst(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.CreateConnected(context.TestInitialSequenceNumber, 30000, -1 /* epRcvBuf */)
we, ch := waiter.NewChannelEntry(nil)
c.WQ.EventRegister(&we, waiter.ReadableEvents)
defer c.WQ.EventUnregister(&we)
ept := endpointTester{c.EP}
ept.CheckReadError(t, &tcpip.ErrWouldBlock{})
data := []byte{1, 2, 3}
iss := seqnum.Value(context.TestInitialSequenceNumber).Add(1)
c.SendPacket(data, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: iss,
AckNum: c.IRS.Add(1),
RcvWnd: 30000,
})
// Wait for receive to be notified.
select {
case <-ch:
case <-time.After(3 * time.Second):
t.Fatalf("Timed out waiting for data to arrive")
}
// Check that ACK is received, this happens regardless of the read.
checker.IPv4(t, c.GetPacket(),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS)+1),
checker.TCPAckNum(uint32(iss)+uint32(len(data))),
checker.TCPFlags(header.TCPFlagAck),
),
)
// Cause a FIN to be generated.
c.EP.Shutdown(tcpip.ShutdownWrite)
// Make sure we get the FIN but DON't ACK IT.
checker.IPv4(t, c.GetPacket(),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPFlags(header.TCPFlagAck|header.TCPFlagFin),
checker.TCPSeqNum(uint32(c.IRS)+1),
))
if got, want := tcp.EndpointState(c.EP.State()), tcp.StateFinWait1; got != want {
t.Errorf("unexpected endpoint state: want %s, got %s", want, got)
}
// Cause a RST to be generated by closing the read end now since we have
// unread data.
c.EP.Shutdown(tcpip.ShutdownRead)
// Make sure we get the RST
checker.IPv4(t, c.GetPacket(),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPFlags(header.TCPFlagAck|header.TCPFlagRst),
// RST is always generated with sndNxt which if the FIN
// has been sent will be 1 higher than the sequence
// number of the FIN itself.
checker.TCPSeqNum(uint32(c.IRS)+2),
))
// The RST puts the endpoint into an error state.
if got, want := tcp.EndpointState(c.EP.State()), tcp.StateError; got != want {
t.Errorf("unexpected endpoint state: want %s, got %s", want, got)
}
// The ACK to the FIN should now be rejected since the connection has been
// closed by a RST.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: iss.Add(seqnum.Size(len(data))),
AckNum: c.IRS.Add(seqnum.Size(2)),
RcvWnd: 30000,
})
} | explode_data.jsonl/75951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1073
} | [
2830,
3393,
49,
267,
1925,
7925,
2354,
1806,
878,
1043,
9134,
12012,
49,
267,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
1444,
7251,
21146,
5378,
8787,
6341,
1407... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRule(t *testing.T) {
if rule, err := Default.Rule(0, 284, "Proxy-Host"); err != nil {
t.Fatal(err)
} else if !rule.Required {
t.Errorf("Unexpected rule %#v", rule)
}
} | explode_data.jsonl/9076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
11337,
1155,
353,
8840,
836,
8,
341,
743,
5912,
11,
1848,
1669,
7899,
63961,
7,
15,
11,
220,
17,
23,
19,
11,
330,
16219,
12,
9296,
5038,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
92,
770,
421,
753,
12937,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUserNameContain(t *testing.T) {
var users []User
filter.
Contains("Farcha", "name", "AND").
ToSql().
Find(&users)
assert.Equal(t, 2, len(users))
filter.Clear()
} | explode_data.jsonl/80102 | {
"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,
1949,
18856,
46522,
1155,
353,
8840,
836,
8,
341,
2405,
3847,
3056,
1474,
198,
50108,
624,
197,
197,
23805,
445,
37,
1113,
64,
497,
330,
606,
497,
330,
3976,
38609,
197,
197,
1249,
8269,
25829,
197,
197,
9885,
2099,
4218,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmoji(t *testing.T) {
const input = `{"utf8":"Example emoji, KO: \ud83d\udd13, \ud83c\udfc3 ` +
`OK: \u2764\ufe0f "}`
value := Get(input, "utf8")
var s string
json.Unmarshal([]byte(value.Raw), &s)
if value.String() != s {
t.Fatalf("expected '%v', got '%v'", s, value.String())
}
} | explode_data.jsonl/43413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
92731,
1155,
353,
8840,
836,
8,
341,
4777,
1946,
284,
1565,
4913,
4762,
23,
3252,
13314,
42365,
11,
37512,
25,
1124,
661,
23,
18,
67,
3770,
631,
16,
18,
11,
1124,
661,
23,
18,
66,
59,
661,
8316,
18,
1565,
3610,
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 TestStrArray_PushAndPop(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
expect := []string{"0", "1", "2", "3"}
array := garray.NewStrArrayFrom(expect)
t.Assert(array.Slice(), expect)
v, ok := array.PopLeft()
t.Assert(v, "0")
t.Assert(ok, true)
v, ok = array.PopRight()
t.Assert(v, "3")
t.Assert(ok, true)
v, ok = array.PopRand()
t.AssertIN(v, []string{"1", "2"})
t.Assert(ok, true)
v, ok = array.PopRand()
t.AssertIN(v, []string{"1", "2"})
t.Assert(ok, true)
v, ok = array.PopRand()
t.Assert(v, "")
t.Assert(ok, false)
t.Assert(array.Len(), 0)
array.PushLeft("1").PushRight("2")
t.Assert(array.Slice(), []string{"1", "2"})
})
} | explode_data.jsonl/53084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 340
} | [
2830,
3393,
2580,
1857,
1088,
1116,
3036,
11598,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
24952,
1669,
3056,
917,
4913,
15,
497,
330,
16,
497,
330,
17,
497,
330,
18,
16707,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConn_DisconnectNotify_EOF(t *testing.T) {
c := jsonrpc2.NewConn(context.Background(), jsonrpc2.NewBufferedStream(&readWriteCloser{eof, eof}, jsonrpc2.VarintObjectCodec{}), nil)
select {
case <-c.DisconnectNotify():
case <-time.After(200 * time.Millisecond):
t.Fatal("no disconnect notification")
}
} | explode_data.jsonl/50184 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
9701,
45525,
6459,
28962,
89287,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2951,
29414,
17,
7121,
9701,
5378,
19047,
1507,
2951,
29414,
17,
7121,
4095,
291,
3027,
2099,
878,
7985,
51236,
799,
90,
77594,
11,
76760,
2137,
2951... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseFloat64(t *testing.T) {
if GOLANG_NUMBER_PARSING {
t.Skip()
}
for i := 0; i < len(atoftests); i++ {
test := &atoftests[i]
found_minus := false
if test.in[0] == '-' {
found_minus = true
}
succes, is_double, d, _ := parse_number_simd([]byte(fmt.Sprintf(`%s:`, test.in)), found_minus)
if !succes {
// Ignore intentionally bad syntactical errors
if !reflect.DeepEqual(test.err, strconv.ErrSyntax) {
t.Errorf("TestParseFloat64: got: %v want: %v", succes, true)
}
continue // skip testing the rest for this test case
}
if !is_double {
t.Errorf("TestParseFloat64: got: %v want: %v", is_double, true)
}
outs := strconv.FormatFloat(d, 'g', -1, 64)
if outs != test.out {
t.Errorf("TestParseFloat64: got: %v want: %v", d, test.out)
}
}
} | explode_data.jsonl/74555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 359
} | [
2830,
3393,
14463,
5442,
21,
19,
1155,
353,
8840,
836,
8,
1476,
743,
479,
1930,
5218,
19364,
1088,
17048,
1718,
341,
197,
3244,
57776,
741,
197,
630,
2023,
600,
1669,
220,
15,
26,
600,
366,
2422,
7,
4330,
723,
17966,
1215,
600,
1027... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetPortfolioByExchange(t *testing.T) {
newbase := Base{}
newbase.AddExchangeAddress("ANX", "LTC", 0.07)
newbase.AddExchangeAddress("Bitfinex", "LTC", 0.05)
newbase.AddAddress("someaddress", "LTC", PortfolioAddressPersonal, 0.03)
portfolio := GetPortfolio()
portfolio.SeedPortfolio(newbase)
value := portfolio.GetPortfolioByExchange("ANX")
result, ok := value["LTC"]
if !ok {
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange error")
}
if result != 0.07 {
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange result != 0.10")
}
value = portfolio.GetPortfolioByExchange("Bitfinex")
result, ok = value["LTC"]
if !ok {
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange error")
}
if result != 0.05 {
t.Error("Test Failed - portfolio_test.go - GetPortfolioByExchange result != 0.05")
}
} | explode_data.jsonl/33743 | {
"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,
1949,
66675,
1359,
31564,
1155,
353,
8840,
836,
8,
341,
8638,
3152,
1669,
5351,
16094,
8638,
3152,
1904,
31564,
4286,
445,
1093,
55,
497,
330,
43,
7749,
497,
220,
15,
13,
15,
22,
340,
8638,
3152,
1904,
31564,
4286,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestShouldAddResponseFilters(t *testing.T) {
configs, err := gzipParse(caddy.NewTestController("http", `gzip { min_length 654 }`))
if err != nil {
t.Errorf("Test expected no error but found: %v", err)
}
filters := 0
for _, config := range configs {
for _, filter := range config.ResponseFilters {
switch filter.(type) {
case SkipCompressedFilter:
filters++
case LengthFilter:
filters++
if filter != LengthFilter(654) {
t.Errorf("Expected LengthFilter to have length 654, got: %v", filter)
}
}
}
if filters != 2 {
t.Errorf("Expected 2 response filters to be registered, got: %v", filters)
}
}
} | explode_data.jsonl/69623 | {
"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,
14996,
2212,
2582,
28351,
1155,
353,
8840,
836,
8,
341,
25873,
82,
11,
1848,
1669,
57795,
14463,
1337,
22478,
7121,
2271,
2051,
445,
1254,
497,
1565,
70996,
314,
1308,
5118,
220,
21,
20,
19,
335,
63,
4390,
743,
1848,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestIllegalSubstrings(t *testing.T) {
cases := []struct {
errorcase.Error
Name string
BucketName string
}{
{
Name: "Empty name is OK",
BucketName: "",
},
{
Name: "Standard name is OK",
BucketName: "foo",
},
{
Name: "Prefix 'goog' returns error",
BucketName: "googfoo",
Error: errorcase.NewErrorAny(),
},
}
for _, td := range cases {
err := IllegalSubstrings(td.BucketName)
_ = errorcase.Eval(t, err, td.Error) // No more test output to evaluate
}
} | explode_data.jsonl/71159 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
33713,
3136,
18594,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
18290,
5638,
6141,
198,
197,
21297,
981,
914,
198,
197,
12791,
11152,
675,
914,
198,
197,
59403,
197,
197,
515,
298,
21297,
25,
981,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEcPointAddNeg(t *testing.T) {
curve := btcec.S256()
num := big.NewInt(-1)
p1, _ := NewScalarBaseMult(curve, num)
num.Abs(num)
p2, _ := NewScalarBaseMult(curve, num)
p3, err := p1.Add(p2)
if err != nil {
t.Errorf("EcPoint.Add failed: %v", err)
}
zero := make([]byte, 64)
if !bytes.Equal(zero, p3.Bytes()) {
t.Errorf("Expected value to be zero, found: %v", p3)
}
} | explode_data.jsonl/75666 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
50730,
2609,
2212,
47800,
1155,
353,
8840,
836,
8,
341,
33209,
586,
1669,
19592,
68955,
808,
17,
20,
21,
741,
22431,
1669,
2409,
7121,
1072,
4080,
16,
692,
3223,
16,
11,
716,
1669,
1532,
20639,
3978,
40404,
17591,
586,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestVerifyStructure(t *testing.T) {
key, err := GeneratePrivateKey(1024)
assert.Nil(t, err)
selfSigned, err := GetSelfSignedCertificate(1, 0, "", "", "", "test", key)
assert.Nil(t, err)
cert, err := PEMToCertificate(selfSigned)
assert.Nil(t, err)
s := TestStructure{
FieldA: 5,
FieldB: []byte{0x01, 0x02},
FieldC: &TestStructure{},
}
res, _ := SignStructure(key, s)
valid, err := VerifyStructure(cert, s, res)
assert.Nil(t, err)
assert.True(t, valid)
s.FieldB[1] = 0x42
valid, _ = VerifyStructure(cert, s, res)
assert.False(t, valid)
} | explode_data.jsonl/3522 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
32627,
22952,
1155,
353,
8840,
836,
8,
341,
23634,
11,
1848,
1669,
19813,
75981,
7,
16,
15,
17,
19,
340,
6948,
59678,
1155,
11,
1848,
692,
5200,
49312,
11,
1848,
1669,
2126,
12092,
49312,
33202,
7,
16,
11,
220,
15,
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 TestIsPrecertificate(t *testing.T) {
var tests = []struct {
desc string
cert *x509.Certificate
wantPrecert bool
wantErr bool
}{
{
desc: "valid-precert",
cert: pemToCert(t, testonly.PrecertPEMValid),
wantPrecert: true,
},
{
desc: "valid-cert",
cert: pemToCert(t, testonly.CACertPEM),
wantPrecert: false,
},
{
desc: "remove-exts-from-precert",
cert: wipeExtensions(pemToCert(t, testonly.PrecertPEMValid)),
wantPrecert: false,
},
{
desc: "poison-non-critical",
cert: makePoisonNonCritical(pemToCert(t, testonly.PrecertPEMValid)),
wantPrecert: false,
wantErr: true,
},
{
desc: "poison-non-null",
cert: makePoisonNonNull(pemToCert(t, testonly.PrecertPEMValid)),
wantPrecert: false,
wantErr: true,
},
}
for _, test := range tests {
gotPrecert, err := IsPrecertificate(test.cert)
t.Run(test.desc, func(t *testing.T) {
if err != nil {
if !test.wantErr {
t.Errorf("IsPrecertificate()=%v,%v; want %v,nil", gotPrecert, err, test.wantPrecert)
}
return
}
if test.wantErr {
t.Errorf("IsPrecertificate()=%v,%v; want _,%v", gotPrecert, err, test.wantErr)
}
if gotPrecert != test.wantPrecert {
t.Errorf("IsPrecertificate()=%v,%v; want %v,nil", gotPrecert, err, test.wantPrecert)
}
})
}
} | explode_data.jsonl/13638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 710
} | [
2830,
3393,
3872,
68833,
20962,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
41653,
286,
914,
198,
197,
1444,
529,
286,
353,
87,
20,
15,
24,
727,
20962,
198,
197,
50780,
68833,
529,
1807,
198,
197,
50780,
774... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsInt(t *testing.T) {
var v *Value
v = &Value{data: int(1)}
assert.True(t, v.IsInt())
v = &Value{data: []int{int(1)}}
assert.True(t, v.IsIntSlice())
} | explode_data.jsonl/23418 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
3872,
1072,
1155,
353,
8840,
836,
8,
1476,
2405,
348,
353,
1130,
271,
5195,
284,
609,
1130,
90,
691,
25,
526,
7,
16,
10569,
6948,
32443,
1155,
11,
348,
4506,
1072,
12367,
5195,
284,
609,
1130,
90,
691,
25,
3056,
396,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestGain(t *testing.T) {
signal, err := newInput("TestGain", 1, 16)
if err != nil {
t.Fatalf("error setting up test; %s", err)
}
for _, tc := range []struct {
desc string
ok bool
rfErr error // MockReadFile error.
spiValue int // Current SPI value.
gain uint
}{
// Supported values.
{"13 dB", true, nil, 4, 13},
{"21 dB", true, nil, 12, 21},
{"34 dB", true, nil, 25, 34},
{"55 dB", true, nil, 46, 55},
// Error states.
{desc: "spi value too low", spiValue: 0},
{desc: "spi value too high", spiValue: 52},
{desc: "readfile error", rfErr: fmt.Errorf("mock ReadFile error")},
} {
t.Run(fmt.Sprintf("Gain() %s", tc.desc), func(t *testing.T) {
helpers.ResetMockReadWrite()
helpers.PrepareMockReadFile([]byte{}, tc.rfErr)
signal.Pad().spi.Write(tc.spiValue)
got, err := signal.Gain().Value()
if err != nil && tc.ok {
t.Fatalf("unexpected error %q", err)
}
if err == nil && !tc.ok {
t.Fatalf("expected an error")
}
if !tc.ok {
return
}
if want := tc.gain; got != want {
t.Errorf("= %d, want %d", got, want)
}
})
}
} | explode_data.jsonl/34842 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 517
} | [
2830,
3393,
58611,
1155,
353,
8840,
836,
8,
341,
81319,
11,
1848,
1669,
501,
2505,
445,
2271,
58611,
497,
220,
16,
11,
220,
16,
21,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
6243,
705,
1273,
26,
1018,
82,
497,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSubscribeGettingMatches(t *testing.T) {
cache := newSyncMapCache(t)
defer closeCache(t, cache)
// create a subscription
s, err := cache.NewSubscription("ITB-1101")
if err != nil {
t.Fatalf("failed to create subscription: %s", err)
}
defer s.Stop()
// set something on the cache that matches our prefix
kv := &KeyValue{
Key: "ITB-1101-CP1",
Data: randData(t, 300),
Timestamp: ptypes.TimestampNow(),
}
_, err = cache.Set(context.Background(), kv)
if err != nil {
t.Fatalf("failed to set: %s", err)
}
for {
select {
case <-time.After(1 * time.Second):
t.Fatalf("timed out waiting for value")
case <-s.Done():
t.Fatalf("subscription stopped before I received any values")
case nkv := <-s.Changes():
// should match kv
checkValueEqual(t, kv.GetKey(), &Value{Data: kv.GetData(), Timestamp: kv.GetTimestamp()}, &Value{Data: nkv.GetData(), Timestamp: nkv.GetTimestamp()})
// if we didn't just fail, then it worked
return
}
}
} | explode_data.jsonl/35588 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 396
} | [
2830,
3393,
28573,
28655,
42470,
1155,
353,
8840,
836,
8,
341,
52680,
1669,
501,
12154,
2227,
8233,
1155,
340,
16867,
3265,
8233,
1155,
11,
6500,
692,
197,
322,
1855,
264,
15142,
198,
1903,
11,
1848,
1669,
6500,
7121,
33402,
445,
952,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHealthCheck(t *testing.T) {
t.Parallel()
pint64 := func(x int64) *int64 { return &x }
pstring := func(x string) *string { return &x }
for _, tc := range []struct {
desc string
beConfig *backendconfig.BackendConfig
want *backendconfig.HealthCheckConfig
}{
{
desc: "override healthcheck with IG",
beConfig: fuzz.NewBackendConfigBuilder("", "backendconfig-1").Build(),
want: &backendconfig.HealthCheckConfig{
CheckIntervalSec: pint64(7),
TimeoutSec: pint64(3),
HealthyThreshold: pint64(3),
UnhealthyThreshold: pint64(5),
RequestPath: pstring("/my-path"),
},
},
{
desc: "override healthcheck and port with NEG",
beConfig: fuzz.NewBackendConfigBuilder("", "backendconfig-1").Build(),
want: &backendconfig.HealthCheckConfig{
RequestPath: pstring("/my-path"),
Port: pint64(8080), // Matches the targetPort
},
},
} {
tc := tc // Capture tc as we are running this in parallel.
Framework.RunWithSandbox(tc.desc, t, func(t *testing.T, s *e2e.Sandbox) {
t.Parallel()
ctx := context.Background()
backendConfigAnnotation := map[string]string{
annotations.BackendConfigKey: `{"default":"backendconfig-1"}`,
}
tc.beConfig.Spec.HealthCheck = tc.want
becrud := adapter.BackendConfigCRUD{C: Framework.BackendConfigClient}
tc.beConfig.Namespace = s.Namespace
if _, err := becrud.Create(tc.beConfig); err != nil {
t.Fatalf("error creating BackendConfig: %v", err)
}
t.Logf("BackendConfig created (%s/%s) ", s.Namespace, tc.beConfig.Name)
svc, err := e2e.CreateEchoService(s, "service-1", backendConfigAnnotation)
if err != nil {
t.Fatalf("error creating echo service: %v", err)
}
t.Logf("Echo service created (%s/%s)", s.Namespace, "service-1")
// Update service for NEG
if tc.want.Port != nil {
svc.Annotations[annotations.NEGAnnotationKey] = `{"ingress":true}`
if _, err := Framework.Clientset.CoreV1().Services(s.Namespace).Update(ctx, svc, v1.UpdateOptions{}); err != nil {
t.Fatalf("error updating port on svc: %v", err)
}
}
ing := fuzz.NewIngressBuilder(s.Namespace, "ingress-1", "").
DefaultBackend("service-1", intstr.FromInt(80)).
Build()
crud := adapter.IngressCRUD{C: Framework.Clientset}
if _, err := crud.Create(ing); err != nil {
t.Fatalf("error creating Ingress spec: %v", err)
}
t.Logf("Ingress created (%s/%s)", s.Namespace, ing.Name)
ing, err = e2e.WaitForIngress(s, ing, nil)
if err != nil {
t.Fatalf("error waiting for Ingress to stabilize: %v", err)
}
t.Logf("GCLB resources created (%s/%s)", s.Namespace, ing.Name)
vip := ing.Status.LoadBalancer.Ingress[0].IP
t.Logf("Ingress %s/%s VIP = %s", s.Namespace, ing.Name, vip)
params := &fuzz.GCLBForVIPParams{VIP: vip, Validators: fuzz.FeatureValidators(features.All)}
gclb, err := fuzz.GCLBForVIP(context.Background(), Framework.Cloud, params)
if err != nil {
t.Fatalf("Error getting GCP resources for LB with IP = %q: %v", vip, err)
}
if err := verifyHealthCheck(t, gclb, tc.want); err != nil {
t.Fatal(err)
}
// Change the configuration and wait for stabilization.
if err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
newBEConfig, err := becrud.Get(s.Namespace, tc.beConfig.Name)
if err != nil {
t.Fatalf("becrud.Get(%q, %q) = %v, want nil", s.Namespace, tc.beConfig.Name, err)
}
newBEConfig.Spec.HealthCheck.RequestPath = pstring("/other-path")
if _, err := becrud.Update(newBEConfig); err != nil {
return err
}
t.Logf("BackendConfig updated (%s/%s) ", s.Namespace, tc.beConfig.Name)
return nil
}); err != nil {
t.Fatalf("error updating BackendConfig %s/%s: %v", s.Namespace, tc.beConfig.Name, err)
}
if err := wait.Poll(transitionPollInterval, transitionPollTimeout, func() (bool, error) {
err := verifyHealthCheck(t, gclb, tc.want)
if err == nil {
return true, nil
}
t.Logf("Waiting for healthcheck to be updated: %v", err)
return false, nil
}); err != nil {
t.Fatal(err)
}
// Wait for GCLB resources to be deleted.
if err := crud.Delete(s.Namespace, ing.Name); err != nil {
t.Errorf("Delete(%q) = %v, want nil", ing.Name, err)
}
deleteOptions := &fuzz.GCLBDeleteOptions{
SkipDefaultBackend: true,
}
t.Logf("Waiting for GCLB resources to be deleted (%s/%s)", s.Namespace, ing.Name)
if err := e2e.WaitForGCLBDeletion(ctx, Framework.Cloud, gclb, deleteOptions); err != nil {
t.Errorf("e2e.WaitForGCLBDeletion(...) = %v, want nil", err)
}
t.Logf("GCLB resources deleted (%s/%s)", s.Namespace, ing.Name)
})
}
} | explode_data.jsonl/60926 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1997
} | [
2830,
3393,
14542,
3973,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3223,
396,
21,
19,
1669,
2915,
2075,
526,
21,
19,
8,
353,
396,
21,
19,
314,
470,
609,
87,
456,
3223,
917,
1669,
2915,
2075,
914,
8,
353,
917,
314,
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 TestPreAuthorizeHappyPath(t *testing.T) {
runPreAuthorizeHandler(
t, nil, "/authorize",
regexp.MustCompile(`/authorize\z`),
&api.Response{},
200, 201)
} | explode_data.jsonl/2400 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
4703,
37483,
32847,
1820,
1155,
353,
8840,
836,
8,
341,
56742,
4703,
37483,
3050,
1006,
197,
3244,
11,
2092,
11,
3521,
52022,
756,
197,
37013,
4580,
98626,
31813,
52022,
59,
89,
89746,
197,
197,
5,
2068,
12574,
38837,
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 |
func TestAdaptPipelineForCompatibility(t *testing.T) {
cases := []struct {
name string
esVersion *common.Version
content map[string]interface{}
expected map[string]interface{}
isErrExpected bool
}{
{
name: "ES < 6.7.0",
esVersion: common.MustNewVersion("6.6.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"user_agent": map[string]interface{}{
"field": "foo.http_user_agent",
},
},
}},
isErrExpected: true,
},
{
name: "ES == 6.7.0",
esVersion: common.MustNewVersion("6.7.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"rename": map[string]interface{}{
"field": "foo.src_ip",
"target_field": "source.ip",
},
},
map[string]interface{}{
"user_agent": map[string]interface{}{
"field": "foo.http_user_agent",
},
},
},
},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"rename": map[string]interface{}{
"field": "foo.src_ip",
"target_field": "source.ip",
},
},
map[string]interface{}{
"user_agent": map[string]interface{}{
"field": "foo.http_user_agent",
"ecs": true,
},
},
},
},
isErrExpected: false,
},
{
name: "ES >= 7.0.0",
esVersion: common.MustNewVersion("7.0.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"rename": map[string]interface{}{
"field": "foo.src_ip",
"target_field": "source.ip",
},
},
map[string]interface{}{
"user_agent": map[string]interface{}{
"field": "foo.http_user_agent",
},
},
},
},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"rename": map[string]interface{}{
"field": "foo.src_ip",
"target_field": "source.ip",
},
},
map[string]interface{}{
"user_agent": map[string]interface{}{
"field": "foo.http_user_agent",
},
},
},
},
isErrExpected: false,
},
}
for _, test := range cases {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
err := AdaptPipelineForCompatibility(*test.esVersion, "foo-pipeline", test.content, logp.NewLogger(logName))
if test.isErrExpected {
assert.Error(t, err)
} else {
require.NoError(t, err)
assert.Equal(t, test.expected, test.content)
}
})
}
} | explode_data.jsonl/61777 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1330
} | [
2830,
3393,
2589,
2689,
34656,
2461,
85880,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
78966,
5637,
257,
353,
5464,
35842,
198,
197,
27751,
981,
2415,
14032,
31344,
16094,
197,
42400... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoggerFromContext(t *testing.T) {
expected := NopLogger()
ctx := WithLoggerContext(context.Background(), expected)
actual := From(ctx)
assert.True(t, actual == expected, "unexpected logger instance from context")
} | explode_data.jsonl/66893 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
7395,
3830,
1972,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
451,
453,
7395,
741,
20985,
1669,
3085,
7395,
1972,
5378,
19047,
1507,
3601,
340,
88814,
1669,
5542,
7502,
340,
6948,
32443,
1155,
11,
5042,
621,
3601,
11,
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 |
func TestBuildSuggestions(t *testing.T) {
tests := []struct {
in *reviewdog.Comment
want string
}{
{
in: &reviewdog.Comment{
ToolName: "tool-name",
Result: &filter.FilteredDiagnostic{
Diagnostic: &rdf.Diagnostic{
Message: "no suggestion",
},
},
},
want: "",
},
{
in: buildTestComment(
"one suggestion",
[]*rdf.Suggestion{
buildTestsSuggestion("line1-fixed\nline2-fixed", 10, 10),
},
),
want: strings.Join([]string{
"```suggestion:-0+0",
"line1-fixed",
"line2-fixed",
"```",
"",
}, "\n"),
},
{
in: buildTestComment(
"two suggestions",
[]*rdf.Suggestion{
buildTestsSuggestion("line1-fixed\nline2-fixed", 10, 11),
buildTestsSuggestion("line3-fixed\nline4-fixed", 20, 21),
},
),
want: strings.Join([]string{
"```suggestion:-0+1",
"line1-fixed",
"line2-fixed",
"```",
"```suggestion:-0+1",
"line3-fixed",
"line4-fixed",
"```",
"",
}, "\n"),
},
{
in: buildTestComment(
"a suggestion that has fenced code block",
[]*rdf.Suggestion{
buildTestsSuggestion("```shell\ngit config --global receive.advertisepushoptions true\n```", 10, 12),
},
),
want: strings.Join([]string{
"````suggestion:-0+2",
"```shell",
"git config --global receive.advertisepushoptions true",
"```",
"````",
"",
}, "\n"),
},
}
for _, tt := range tests {
suggestion := buildSuggestions(tt.in)
if suggestion != tt.want {
t.Errorf("got unexpected suggestion.\ngot:\n%s\nwant:\n%s", suggestion, tt.want)
}
}
} | explode_data.jsonl/1734 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 788
} | [
2830,
3393,
11066,
98846,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
353,
19417,
18457,
56730,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
17430,
25,
609,
19417,
18457,
56730,
515,
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... | 3 |
func TestPVCControlUpdatePVCFailed(t *testing.T) {
g := NewGomegaWithT(t)
tc := newTidbCluster()
pvc := newPVC(tc)
fakeClient, pvcLister, _, recorder := newFakeClientAndRecorder()
control := NewRealPVCControl(fakeClient, recorder, pvcLister)
fakeClient.AddReactor("update", "persistentvolumeclaims", func(action core.Action) (bool, runtime.Object, error) {
return true, nil, apierrors.NewInternalError(errors.New("API server down"))
})
_, err := control.UpdatePVC(tc, pvc)
g.Expect(err).To(HaveOccurred())
} | explode_data.jsonl/66724 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
47,
11287,
3273,
4289,
47,
11287,
9408,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
340,
78255,
1669,
501,
51,
307,
65,
28678,
741,
3223,
7362,
1669,
501,
47,
11287,
44415,
340,
1166,
726,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSlashWithRedelegation(t *testing.T) {
app, ctx, addrDels, addrVals := bootstrapSlashTest(t, 10)
consAddr := sdk.ConsAddress(PKs[0].Address())
fraction := sdk.NewDecWithPrec(5, 1)
bondDenom := app.StakingKeeper.BondDenom(ctx)
// set a redelegation
rdTokens := sdk.TokensFromConsensusPower(6)
rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11,
time.Unix(0, 0), rdTokens, rdTokens.ToDec())
app.StakingKeeper.SetRedelegation(ctx, rd)
// set the associated delegation
del := types.NewDelegation(addrDels[0], addrVals[1], rdTokens.ToDec())
app.StakingKeeper.SetDelegation(ctx, del)
// update bonded tokens
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
rdCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, rdTokens.MulRaw(2)))
balances := app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())
err := app.BankKeeper.SetBalances(ctx, bondedPool.GetAddress(), balances.Add(rdCoins...))
require.NoError(t, err)
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
oldBonded := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
oldNotBonded := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount
// slash validator
ctx = ctx.WithBlockHeight(12)
validator, found := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction) })
burnAmount := sdk.TokensFromConsensusPower(10).ToDec().Mul(fraction).TruncateInt()
bondedPool = app.StakingKeeper.GetBondedPool(ctx)
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
// burn bonded tokens from only from delegations
bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance))
notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance))
oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
// read updating redelegation
rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1])
require.True(t, found)
require.Len(t, rd.Entries, 1)
// read updated validator
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
// power decreased by 2 - 4 stake originally bonded at the time of infraction
// was still bonded at the time of discovery and was slashed by half, 4 stake
// bonded at the time of discovery hadn't been bonded at the time of infraction
// and wasn't slashed
require.Equal(t, int64(8), validator.GetConsensusPower())
// slash the validator again
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, sdk.OneDec()) })
burnAmount = sdk.TokensFromConsensusPower(7)
// read updated pool
bondedPool = app.StakingKeeper.GetBondedPool(ctx)
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
// seven bonded tokens burned
bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance))
require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance))
bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance))
notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance))
oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
// read updating redelegation
rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1])
require.True(t, found)
require.Len(t, rd.Entries, 1)
// read updated validator
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
// power decreased by 4
require.Equal(t, int64(4), validator.GetConsensusPower())
// slash the validator again, by 100%
ctx = ctx.WithBlockHeight(12)
validator, found = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, sdk.OneDec()) })
burnAmount = sdk.TokensFromConsensusPower(10).ToDec().Mul(sdk.OneDec()).TruncateInt()
burnAmount = burnAmount.Sub(sdk.OneDec().MulInt(rdTokens).TruncateInt())
// read updated pool
bondedPool = app.StakingKeeper.GetBondedPool(ctx)
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance))
notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance))
oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
// read updating redelegation
rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1])
require.True(t, found)
require.Len(t, rd.Entries, 1)
// apply TM updates
app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
// read updated validator
// validator decreased to zero power, should be in unbonding period
validator, _ = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.Equal(t, validator.GetStatus(), sdk.Unbonding)
// slash the validator again, by 100%
// no stake remains to be slashed
ctx = ctx.WithBlockHeight(12)
// validator still in unbonding period
validator, _ = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.Equal(t, validator.GetStatus(), sdk.Unbonding)
require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, sdk.OneDec()) })
// read updated pool
bondedPool = app.StakingKeeper.GetBondedPool(ctx)
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldBonded, bondedPoolBalance))
notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount
require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance))
// read updating redelegation
rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1])
require.True(t, found)
require.Len(t, rd.Entries, 1)
// read updated validator
// power still zero, still in unbonding period
validator, _ = app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr)
require.Equal(t, validator.GetStatus(), sdk.Unbonding)
} | explode_data.jsonl/25504 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2547
} | [
2830,
3393,
88004,
2354,
6033,
68,
87566,
1155,
353,
8840,
836,
8,
341,
28236,
11,
5635,
11,
10789,
35,
2010,
11,
10789,
52452,
1669,
26925,
88004,
2271,
1155,
11,
220,
16,
15,
340,
197,
6254,
13986,
1669,
45402,
94594,
4286,
5304,
42... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTraceExporter_WithShutdown(t *testing.T) {
shutdownCalled := false
shutdown := func(context.Context) error { shutdownCalled = true; return nil }
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil), WithShutdown(shutdown))
assert.NotNil(t, te)
assert.NoError(t, err)
assert.Nil(t, te.Shutdown(context.Background()))
assert.True(t, shutdownCalled)
} | explode_data.jsonl/70314 | {
"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,
6550,
88025,
62,
2354,
62004,
1155,
353,
8840,
836,
8,
341,
36196,
18452,
20960,
1669,
895,
198,
36196,
18452,
1669,
2915,
5378,
9328,
8,
1465,
314,
23766,
20960,
284,
830,
26,
470,
2092,
555,
197,
665,
11,
1848,
1669,
153... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnqueueIn(t *testing.T) {
pool := newTestPool(t)
ns := "work"
cleanKeyspace(ns, pool)
enqueuer := NewEnqueuer(ns, pool)
// Set to expired value to make sure we update the set of known jobs
enqueuer.knownJobs["wat"] = 4
job, err := enqueuer.EnqueueIn("wat", 300, Q{"a": 1, "b": "cool"})
assert.Nil(t, err)
if assert.NotNil(t, job) {
assert.Equal(t, "wat", job.Name)
assert.True(t, len(job.ID) > 10) // Something is in it
assert.True(t, job.EnqueuedAt > (time.Now().Unix()-10)) // Within 10 seconds
assert.True(t, job.EnqueuedAt < (time.Now().Unix()+10)) // Within 10 seconds
assert.Equal(t, "cool", job.ArgString("b"))
assert.EqualValues(t, 1, job.ArgInt64("a"))
assert.NoError(t, job.ArgError())
assert.EqualValues(t, job.EnqueuedAt+300, job.RunAt)
}
// Make sure "wat" is in the known jobs
assert.EqualValues(t, []string{"wat"}, knownJobs(pool, redisKeyKnownJobs(ns)))
// Make sure the cache is set
expiresAt := enqueuer.knownJobs["wat"]
assert.True(t, expiresAt > (time.Now().Unix()+290))
// Make sure the length of the scheduled job queue is 1
assert.EqualValues(t, 1, zsetSize(pool, redisKeyScheduled(ns)))
// Get the job
score, j := jobOnZset(pool, redisKeyScheduled(ns))
assert.True(t, score > time.Now().Unix()+290)
assert.True(t, score <= time.Now().Unix()+300)
assert.Equal(t, "wat", j.Name)
assert.True(t, len(j.ID) > 10) // Something is in it
assert.True(t, j.EnqueuedAt > (time.Now().Unix()-10)) // Within 10 seconds
assert.True(t, j.EnqueuedAt < (time.Now().Unix()+10)) // Within 10 seconds
assert.Equal(t, "cool", j.ArgString("b"))
assert.EqualValues(t, 1, j.ArgInt64("a"))
assert.NoError(t, j.ArgError())
} | explode_data.jsonl/40371 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 719
} | [
2830,
3393,
1702,
4584,
641,
1155,
353,
8840,
836,
8,
341,
85273,
1669,
501,
2271,
10551,
1155,
340,
84041,
1669,
330,
1778,
698,
1444,
2675,
8850,
1306,
39417,
11,
7314,
340,
81848,
591,
8801,
1669,
1532,
1702,
591,
8801,
39417,
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... | 2 |
func TestPrintIfErrorf_WithoutError(t *testing.T) {
t.Run("PrintIfErrorf_WithoutError", func(t *testing.T) {
result := captureStdout(func(w io.Writer) {
pterm.PrintOnErrorf("", nil)
})
testza.AssertZero(t, result)
})
} | explode_data.jsonl/49145 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
8994,
2679,
1454,
69,
62,
26040,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
8994,
2679,
1454,
69,
62,
26040,
1454,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
9559,
1669,
12322,
22748,
411,
18552,
3622,
6399,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDuplicates(t *testing.T) {
b1 := blocks.NewBlock([]byte("1"))
b2 := blocks.NewBlock([]byte("2"))
n := New()
defer n.Shutdown()
ch := n.Subscribe(context.Background(), b1.Cid(), b2.Cid())
n.Publish(b1)
blockRecvd, ok := <-ch
if !ok {
t.Fail()
}
assertBlocksEqual(t, b1, blockRecvd)
n.Publish(b1) // ignored duplicate
n.Publish(b2)
blockRecvd, ok = <-ch
if !ok {
t.Fail()
}
assertBlocksEqual(t, b2, blockRecvd)
} | explode_data.jsonl/8954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
76851,
1155,
353,
8840,
836,
8,
341,
2233,
16,
1669,
10010,
7121,
4713,
10556,
3782,
445,
16,
5455,
2233,
17,
1669,
10010,
7121,
4713,
10556,
3782,
445,
17,
28075,
9038,
1669,
1532,
741,
16867,
308,
10849,
18452,
741,
23049,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTaskUpdateKnownStatusToPendingWithEssentialContainerStopped(t *testing.T) {
testTask := &Task{
KnownStatusUnsafe: apitaskstatus.TaskStatusNone,
Containers: []*apicontainer.Container{
{
KnownStatusUnsafe: apicontainerstatus.ContainerCreated,
Essential: true,
},
{
KnownStatusUnsafe: apicontainerstatus.ContainerStopped,
Essential: true,
},
{
KnownStatusUnsafe: apicontainerstatus.ContainerCreated,
},
},
}
newStatus := testTask.updateTaskKnownStatus()
assert.Equal(t, apitaskstatus.TaskCreated, newStatus)
assert.Equal(t, apitaskstatus.TaskCreated, testTask.GetKnownStatus())
} | explode_data.jsonl/37211 | {
"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,
6262,
4289,
48206,
2522,
1249,
32027,
2354,
37438,
2283,
4502,
59803,
1155,
353,
8840,
836,
8,
341,
18185,
6262,
1669,
609,
6262,
515,
197,
39340,
4169,
2522,
78770,
25,
1443,
275,
1073,
2829,
28258,
2522,
4064,
345,
197,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSQLJobQueue_Integration_RepopulateNewJobs(t *testing.T) {
dbName := "state___reindex_queue___repopulate_jobs"
queue := initSQLTest(t, dbName)
// Empty to start
j, err := queue.ClaimAvailableJob()
assert.NoError(t, err)
assert.Nil(t, j)
// Populate indexers
populated, err := queue.PopulateJobs()
assert.NoError(t, err)
assert.True(t, populated)
// Claim all idxs
jobX, err := queue.ClaimAvailableJob()
assert.NoError(t, err)
jobY, err := queue.ClaimAvailableJob()
assert.NoError(t, err)
jobZ, err := queue.ClaimAvailableJob()
assert.NoError(t, err)
// No jobs left
j, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
assert.Nil(t, j)
// Extract jobs/indexers to properly keep track by number
jobs := map[string]*Job{}
jobs[jobX.Idx.GetID()] = jobX
jobs[jobY.Idx.GetID()] = jobY
jobs[jobZ.Idx.GetID()] = jobZ
job0, job1, job2 := jobs[id0], jobs[id1], jobs[id2]
// Complete all idxs
// Complete with success idx0, idx2
err = queue.CompleteJob(job0, nil)
assert.NoError(t, err)
err = queue.CompleteJob(job2, nil)
assert.NoError(t, err)
// Complete with fail idx1
err = queue.CompleteJob(job1, someErr)
assert.NoError(t, err)
_, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
err = queue.CompleteJob(job1, someErr)
assert.NoError(t, err)
errVal, err := GetError(queue, job1.Idx.GetID())
assert.NoError(t, err)
assert.Equal(t, someErr.Error(), errVal)
// No jobs left
j, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
assert.Nil(t, j)
// Update version of indexer 0 -- previously succeeded
indexer.RegisterForTest(t, indexer0a)
updated, err := queue.PopulateJobs()
assert.NoError(t, err)
assert.True(t, updated)
// Update version of indexer 1 -- previously failed
indexer.RegisterForTest(t, indexer1a)
updated, err = queue.PopulateJobs()
assert.NoError(t, err)
assert.True(t, updated)
// Claim jobs -- idx0 and idx1 should both be present, across repopulations
jobZ, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
jobY, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
// No jobs remaining
j, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
assert.Nil(t, j)
// Extract jobs/indexers to properly keep track by number
jobs = map[string]*Job{}
jobs[jobZ.Idx.GetID()] = jobZ
jobs[jobY.Idx.GetID()] = jobY
job0, job1 = jobs[id0], jobs[id1]
idx0, idx1 := job0.Idx, job1.Idx
// Check idx0 version -- previously succeeded
assert.Equal(t, indexer0a.GetID(), idx0.GetID())
assert.Equal(t, version0, job0.From)
assert.Equal(t, version0a, job0.To)
// Check idx1 version -- previously failed
assert.Equal(t, indexer1a.GetID(), idx1.GetID())
assert.Equal(t, zero, job1.From)
assert.Equal(t, version1a, job1.To)
// Complete job for indexer 0
err = queue.CompleteJob(job0, nil)
assert.NoError(t, err)
// Complete job for indexer 1
err = queue.CompleteJob(job1, nil)
assert.NoError(t, err)
// No jobs remaining
j, err = queue.ClaimAvailableJob()
assert.NoError(t, err)
assert.Nil(t, j)
// All jobs succeeded
statuses, err := GetAllStatuses(queue)
assert.NoError(t, err)
for _, st := range statuses {
assert.Equal(t, StatusComplete, st)
}
} | explode_data.jsonl/25317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1247
} | [
2830,
3393,
6688,
12245,
7554,
32054,
17376,
50693,
47721,
3564,
40667,
1155,
353,
8840,
836,
8,
341,
20939,
675,
1669,
330,
2454,
5973,
265,
1252,
10841,
5973,
265,
47721,
37247,
698,
46993,
1669,
2930,
6688,
2271,
1155,
11,
75564,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCompare(t *testing.T) {
_, c := New(0, 3)
now := c.Now()
cmp := Compare(c, &now)
if cmp != 0 {
t.Fatal("Timestamps should be equal")
}
c.AddTicks(1)
cmp = Compare(c, &now)
if cmp < 1 {
t.Fatal("Original timestamp now must be higher than it's copy")
}
_, c1 := New(1, 3)
c1.AddTicks(1)
cmp = Compare(c, c1)
if cmp != 0 {
t.Fatalf("Timestamps must be concurrent: %v != %v", c, c1)
}
} | explode_data.jsonl/76175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
27374,
1155,
353,
8840,
836,
8,
341,
197,
6878,
272,
1669,
1532,
7,
15,
11,
220,
18,
340,
80922,
1669,
272,
13244,
741,
1444,
1307,
1669,
23768,
1337,
11,
609,
3328,
340,
743,
26089,
961,
220,
15,
341,
197,
3244,
26133,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerWriter(t *testing.T) {
{
size := size
c := NewController(2 * 1024 * 1024)
defer c.Close()
b1 := new(bytes.Buffer)
b2 := new(bytes.Buffer)
w1 := c.Writer(b1)
w2 := c.Writer(b2)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
n, err := io.Copy(w1, bytes.NewReader(b))
assert.NoError(t, err)
assert.Equal(t, size, int(n))
wg.Done()
}()
go func() {
time.Sleep(1 * time.Second)
n, err := io.Copy(w2, bytes.NewReader(b))
assert.NoError(t, err)
assert.Equal(t, size, int(n))
wg.Done()
}()
now := time.Now()
wg.Wait()
elapsed := time.Since(now).Seconds()
log.Println(elapsed)
assert.True(t, math.Abs(4-elapsed) < 0.5)
assert.Equal(t, b, b1.Bytes())
assert.Equal(t, b, b2.Bytes())
}
} | explode_data.jsonl/72807 | {
"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,
2051,
6492,
1155,
353,
8840,
836,
8,
341,
197,
515,
197,
13832,
1669,
1379,
198,
197,
1444,
1669,
1532,
2051,
7,
17,
353,
220,
16,
15,
17,
19,
353,
220,
16,
15,
17,
19,
340,
197,
16867,
272,
10421,
2822,
197,
2233,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReleaseIPInIPAM(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ecscniClient := NewClient(&Config{})
libcniClient := mock_libcni.NewMockCNI(ctrl)
ecscniClient.(*cniClient).libcni = libcniClient
libcniClient.EXPECT().DelNetwork(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
err := ecscniClient.ReleaseIPResource(context.TODO(), &Config{}, time.Second)
assert.NoError(t, err)
} | explode_data.jsonl/30401 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
16077,
3298,
641,
3298,
1402,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
757,
2388,
7751,
2959,
1669,
1532,
2959,
2099,
2648,
37790,
197,
55576,
775... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNCIPNetNotReserved(t *testing.T) {
inputPath := "NCValidIPNet.pem"
expected := lint.Pass
out := test.TestLint("e_ext_nc_intersects_reserved_ip", inputPath)
if out.Status != expected {
t.Errorf("%s: expected %s, got %s", inputPath, expected, out.Status)
}
} | explode_data.jsonl/77522 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
9949,
3298,
6954,
2623,
53003,
1155,
353,
8840,
836,
8,
341,
22427,
1820,
1669,
330,
9949,
4088,
3298,
6954,
49373,
698,
42400,
1669,
57920,
87768,
198,
13967,
1669,
1273,
8787,
47556,
445,
68,
9927,
52382,
15318,
54429,
74913... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpendJournalErrors(t *testing.T) {
t.Parallel()
tests := []struct {
name string
blockTxns []*wire.MsgTx
serialized []byte
errType error
}{
// Adapted from block 170 in main blockchain.
{
name: "Force assertion due to missing stxos",
blockTxns: []*wire.MsgTx{{ // Coinbase omitted.
Version: 1,
TxIn: []*wire.TxIn{{
PreviousOutPoint: wire.OutPoint{
Hash: *newHashFromStr("0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9"),
Index: 0,
},
SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"),
Sequence: 0xffffffff,
}},
LockTime: 0,
}},
serialized: hexToBytes(""),
errType: AssertError(""),
},
{
name: "Force deserialization error in stxos",
blockTxns: []*wire.MsgTx{{ // Coinbase omitted.
Version: 1,
TxIn: []*wire.TxIn{{
PreviousOutPoint: wire.OutPoint{
Hash: *newHashFromStr("0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9"),
Index: 0,
},
SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"),
Sequence: 0xffffffff,
}},
LockTime: 0,
}},
serialized: hexToBytes("1301320511db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a"),
errType: errDeserialize(""),
},
}
for _, test := range tests {
// Ensure the expected error type is returned and the returned slice is nil.
stxos, err := deserializeSpendJournalEntry(test.serialized,
test.blockTxns)
if reflect.TypeOf(err) != reflect.TypeOf(test.errType) {
t.Errorf("deserializeSpendJournalEntry (%s): expected "+
"error type does not match - got %T, want %T",
test.name, err, test.errType)
continue
}
if stxos != nil {
t.Errorf("deserializeSpendJournalEntry (%s): returned "+
"slice of spent transaction outputs is not nil",
test.name)
continue
}
}
} | explode_data.jsonl/59829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1000
} | [
2830,
3393,
50,
3740,
43494,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
47996,
31584,
4412,
220,
29838,
35531,
30365,
31584,
198,
197,
197,
75277,
3056,
378... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBeginOnReplica(t *testing.T) {
db, tsv := setupTabletServerTest(t, "")
defer tsv.StopService()
defer db.Close()
db.AddQueryPattern(".*", &sqltypes.Result{})
target := querypb.Target{TabletType: topodatapb.TabletType_REPLICA}
err := tsv.SetServingType(topodatapb.TabletType_REPLICA, time.Time{}, true, "")
require.NoError(t, err)
options := querypb.ExecuteOptions{
TransactionIsolation: querypb.ExecuteOptions_CONSISTENT_SNAPSHOT_READ_ONLY,
}
txID, alias, err := tsv.Begin(ctx, &target, &options)
require.NoError(t, err, "failed to create read only tx on replica")
assert.Equal(t, tsv.alias, alias, "Wrong tablet alias from Begin")
_, err = tsv.Rollback(ctx, &target, txID)
require.NoError(t, err, "failed to rollback read only tx")
// test that we can still create transactions even in read-only mode
options = querypb.ExecuteOptions{}
txID, _, err = tsv.Begin(ctx, &target, &options)
require.NoError(t, err, "expected write tx to be allowed")
_, err = tsv.Rollback(ctx, &target, txID)
require.NoError(t, err)
} | explode_data.jsonl/79980 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
11135,
1925,
18327,
15317,
1155,
353,
8840,
836,
8,
341,
20939,
11,
259,
3492,
1669,
6505,
2556,
83,
5475,
2271,
1155,
11,
14676,
16867,
259,
3492,
30213,
1860,
741,
16867,
2927,
10421,
2822,
20939,
1904,
2859,
15760,
445,
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 TestMarshalCustomMultiline(t *testing.T) {
type TypeA struct {
AttrA []int `toml:"int_slice" mltln:"true"`
}
config := TypeA{AttrA: []int{1, 2, 3}}
var buf bytes.Buffer
err := NewEncoder(&buf).ArraysWithOneElementPerLine(true).SetTagMultiline("mltln").Encode(config)
if err != nil {
t.Fatal(err)
}
expected := customMultilineTagTestToml
result := buf.Bytes()
if !bytes.Equal(result, expected) {
t.Errorf("Bad marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result)
}
} | explode_data.jsonl/46336 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
55438,
10268,
40404,
26560,
1155,
353,
8840,
836,
8,
341,
13158,
3990,
32,
2036,
341,
197,
197,
13371,
32,
3056,
396,
1565,
37401,
75,
2974,
396,
26488,
1,
296,
4832,
2261,
2974,
1866,
8805,
197,
630,
25873,
1669,
3990,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCancelAllExchangeOrders(t *testing.T) {
b.SetDefaults()
TestSetup(t)
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
currencyPair := currency.NewPairWithDelimiter(currency.BTC.String(),
currency.USD.String(),
"-")
var orderCancellation = &exchange.OrderCancellation{
OrderID: "1",
WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB",
AccountID: "1",
CurrencyPair: currencyPair,
}
resp, err := b.CancelAllOrders(orderCancellation)
if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
if areTestAPIKeysSet() && err != nil {
t.Errorf("Could not cancel orders: %v", err)
}
if len(resp.OrderStatus) > 0 {
t.Errorf("%v orders failed to cancel", len(resp.OrderStatus))
}
} | explode_data.jsonl/14547 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
9269,
2403,
31564,
24898,
1155,
353,
8840,
836,
8,
341,
2233,
4202,
16273,
741,
73866,
21821,
1155,
692,
743,
525,
2271,
7082,
8850,
1649,
368,
1009,
753,
4814,
92876,
6334,
12768,
24898,
341,
197,
3244,
57776,
445,
7082,
68... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestConvertTrace(t *testing.T) {
record := convertAndDrill(&entry.Entry{
TraceId: []byte{
0x48, 0x01, 0x40, 0xf3, 0xd7, 0x70, 0xa5, 0xae, 0x32, 0xf0, 0xa2, 0x2b, 0x6a, 0x81, 0x2c, 0xff,
},
SpanId: []byte{
0x32, 0xf0, 0xa2, 0x2b, 0x6a, 0x81, 0x2c, 0xff,
},
TraceFlags: []byte{
0x01,
}})
require.Equal(t, pdata.NewTraceID(
[16]byte{
0x48, 0x01, 0x40, 0xf3, 0xd7, 0x70, 0xa5, 0xae, 0x32, 0xf0, 0xa2, 0x2b, 0x6a, 0x81, 0x2c, 0xff,
}), record.TraceID())
require.Equal(t, pdata.NewSpanID(
[8]byte{
0x32, 0xf0, 0xa2, 0x2b, 0x6a, 0x81, 0x2c, 0xff,
}), record.SpanID())
require.Equal(t, uint32(0x01), record.Flags())
} | explode_data.jsonl/61131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
12012,
6550,
1155,
353,
8840,
836,
8,
341,
71952,
1669,
5508,
3036,
8847,
483,
2099,
4085,
22330,
515,
197,
197,
6550,
764,
25,
3056,
3782,
515,
298,
197,
15,
87,
19,
23,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
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 TestAccKeycloakOpenidClientOptionalScopes_noImportNeeded(t *testing.T) {
realm := "terraform-realm-" + acctest.RandString(10)
client := "terraform-client-" + acctest.RandString(10)
clientScope := "terraform-client-scope-" + acctest.RandString(10)
clientScopes := append(preAssignedOptionalClientScopes, clientScope)
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
Steps: []resource.TestStep{
{
Config: testKeycloakOpenidClientOptionalScopes_noOptionalScopes(realm, client, clientScope),
Check: testAccCheckKeycloakOpenidClientOptionalScopeIsNotAttached("keycloak_openid_client.client", clientScope),
},
{
PreConfig: func() {
keycloakClient := testAccProvider.Meta().(*keycloak.KeycloakClient)
openidClient, err := keycloakClient.GetOpenidClientByClientId(realm, client)
if err != nil {
t.Fatal(err)
}
err = keycloakClient.AttachOpenidClientOptionalScopes(realm, openidClient.Id, clientScopes)
if err != nil {
t.Fatal(err)
}
},
Config: testKeycloakOpenidClientOptionalScopes_basic(realm, client, clientScope),
Check: testAccCheckKeycloakOpenidClientHasOptionalScopes("keycloak_openid_client_optional_scopes.optional_scopes", clientScopes),
},
},
})
} | explode_data.jsonl/31490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 509
} | [
2830,
3393,
14603,
1592,
88751,
5002,
307,
2959,
15309,
3326,
18523,
6536,
11511,
56706,
1155,
353,
8840,
836,
8,
341,
17200,
7673,
1669,
330,
61385,
5504,
7673,
27651,
488,
1613,
67880,
2013,
437,
703,
7,
16,
15,
340,
25291,
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... | 1 |
func TestMainOutput(t *testing.T) {
var buf bytes.Buffer
out = &buf
main()
expected := `a:2
b:1
`
actual := buf.String()
assert.Equalf(t, expected, actual,
"Input does not match expected buffer output.")
} | explode_data.jsonl/18205 | {
"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,
6202,
5097,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
5820,
22622,
198,
13967,
284,
609,
5909,
271,
36641,
741,
42400,
1669,
1565,
64,
25,
17,
198,
65,
25,
16,
198,
3989,
88814,
1669,
6607,
6431,
2822,
6948,
12808,
69,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRandomUUID(t *testing.T) {
m := make(map[string]bool)
for x := 1; x < 32; x++ {
uuid := NewRandom()
s := uuid.String()
if m[s] {
t.Errorf("NewRandom returned duplicated UUID %s", s)
}
m[s] = true
if v, _ := uuid.Version(); v != 4 {
t.Errorf("Random UUID of version %s", v)
}
if uuid.Variant() != RFC4122 {
t.Errorf("Random UUID is variant %d", uuid.Variant())
}
}
} | explode_data.jsonl/31938 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
13999,
24754,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1281,
9147,
14032,
96436,
340,
2023,
856,
1669,
220,
16,
26,
856,
366,
220,
18,
17,
26,
856,
1027,
341,
197,
10676,
2423,
1669,
1532,
13999,
741,
197,
1903,
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... | 5 |
func TestDeadlineExceeded_ForMember(t *testing.T) {
expected := &discordgo.Member{User: &discordgo.User{Username: mockconstants.TestUser}}
mnr := &callbacks.DeadlineExceeded{Member: expected}
actual := mnr.ForMember()
err := deepEqual(actual, expected)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/56105 | {
"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,
83593,
840,
94206,
84368,
9366,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
609,
42579,
3346,
46404,
90,
1474,
25,
609,
42579,
3346,
7344,
90,
11115,
25,
7860,
15763,
8787,
1474,
11248,
2109,
19618,
1669,
609,
68311,
909,
314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStartAndWaitTimeout(t *testing.T) {
fakeRuntime := &mock.Runtime{}
fakeRuntime.StartStub = func(_ string, _ *ccintf.PeerConnection) error {
time.Sleep(time.Second)
return nil
}
launcher := &RuntimeLauncher{
Runtime: fakeRuntime,
Registry: NewHandlerRegistry(false),
StartupTimeout: 500 * time.Millisecond,
Metrics: NewLaunchMetrics(&disabled.Provider{}),
}
fakeStreamHandler := &mock.ChaincodeStreamHandler{}
//the actual test - timeout 1000 > 500
err := launcher.Launch("testcc:0", fakeStreamHandler)
if err == nil {
t.Fatalf("expected error but succeeded")
}
} | explode_data.jsonl/58387 | {
"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,
3479,
92812,
7636,
1155,
353,
8840,
836,
8,
341,
1166,
726,
15123,
1669,
609,
16712,
16706,
16094,
1166,
726,
15123,
12101,
33838,
284,
2915,
2490,
914,
11,
716,
353,
638,
396,
69,
1069,
34756,
4526,
8,
1465,
341,
197,
219... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewSearchResult(t *testing.T) {
assert := assert.New(t)
s1 := newSearchresult(SampleSearchResults[0])
assert.Equal(s1.name, "GoBook.pdf")
assert.Equal(s1.fullpath, SampleSearchResults[0])
s2 := newSearchresult(SampleSearchResults[1])
assert.Equal(s2.name, "Dive_into_Python3.pdf")
assert.Equal(s2.fullpath, SampleSearchResults[1])
} | explode_data.jsonl/33979 | {
"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,
3564,
5890,
2077,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
1903,
16,
1669,
501,
5890,
1382,
3759,
1516,
5890,
9801,
58,
15,
2546,
6948,
12808,
1141,
16,
2644,
11,
330,
10850,
7134,
15995,
1138,
6948... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBasicPolicy(t *testing.T) {
tests := map[string]struct {
Name string
Policy *Policy
Src addr.IA
Dst addr.IA
ExpPathNum int
}{
"Empty policy": {
Policy: &Policy{},
Src: xtest.MustParseIA("2-ff00:0:212"),
Dst: xtest.MustParseIA("2-ff00:0:211"),
ExpPathNum: 2,
},
}
ctrl := gomock.NewController(t)
defer ctrl.Finish()
pp := NewPathProvider(ctrl)
for name, test := range tests {
t.Run(name, func(t *testing.T) {
paths := pp.GetPaths(test.Src, test.Dst)
outPaths := test.Policy.Filter(paths)
assert.Equal(t, test.ExpPathNum, len(outPaths))
})
}
} | explode_data.jsonl/19160 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
15944,
13825,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
21297,
981,
914,
198,
197,
10025,
8018,
257,
353,
13825,
198,
197,
7568,
1287,
286,
10789,
2447,
32,
198,
197,
10957,
267,
286,
1078... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChannelArbitratorCommitFailure(t *testing.T) {
testCases := []struct {
// closeType is the type of channel close we want ot test.
closeType channeldb.ClosureType
// sendEvent is a function that will send the event
// corresponding to this test's closeType to the passed
// ChannelArbitrator.
sendEvent func(chanArb *ChannelArbitrator)
// expectedStates is the states we expect the state machine to
// go through after a restart and successful log commit.
expectedStates []ArbitratorState
}{
{
closeType: channeldb.CooperativeClose,
sendEvent: func(chanArb *ChannelArbitrator) {
closeInfo := &CooperativeCloseInfo{
&channeldb.ChannelCloseSummary{},
}
chanArb.cfg.ChainEvents.CooperativeClosure <- closeInfo
},
expectedStates: []ArbitratorState{StateFullyResolved},
},
{
closeType: channeldb.RemoteForceClose,
sendEvent: func(chanArb *ChannelArbitrator) {
commitSpend := &chainntnfs.SpendDetail{
SpenderTxHash: &chainhash.Hash{},
}
uniClose := &lnwallet.UnilateralCloseSummary{
SpendDetail: commitSpend,
HtlcResolutions: &lnwallet.HtlcResolutions{},
}
chanArb.cfg.ChainEvents.RemoteUnilateralClosure <- &RemoteUnilateralCloseInfo{
UnilateralCloseSummary: uniClose,
}
},
expectedStates: []ArbitratorState{StateContractClosed, StateFullyResolved},
},
{
closeType: channeldb.LocalForceClose,
sendEvent: func(chanArb *ChannelArbitrator) {
chanArb.cfg.ChainEvents.LocalUnilateralClosure <- &LocalUnilateralCloseInfo{
SpendDetail: &chainntnfs.SpendDetail{},
LocalForceCloseSummary: &lnwallet.LocalForceCloseSummary{
CloseTx: &wire.MsgTx{},
HtlcResolutions: &lnwallet.HtlcResolutions{},
},
ChannelCloseSummary: &channeldb.ChannelCloseSummary{},
}
},
expectedStates: []ArbitratorState{StateContractClosed, StateFullyResolved},
},
}
for _, test := range testCases {
test := test
log := &mockArbitratorLog{
state: StateDefault,
newStates: make(chan ArbitratorState, 5),
failCommit: true,
// Set the log to fail on the first expected state
// after state machine progress for this test case.
failCommitState: test.expectedStates[0],
}
chanArbCtx, err := createTestChannelArbitrator(t, log)
if err != nil {
t.Fatalf("unable to create ChannelArbitrator: %v", err)
}
chanArb := chanArbCtx.chanArb
if err := chanArb.Start(); err != nil {
t.Fatalf("unable to start ChannelArbitrator: %v", err)
}
// It should start in StateDefault.
chanArbCtx.AssertState(StateDefault)
closed := make(chan struct{})
chanArb.cfg.MarkChannelClosed = func(
*channeldb.ChannelCloseSummary,
...channeldb.ChannelStatus) error {
close(closed)
return nil
}
// Send the test event to trigger the state machine.
test.sendEvent(chanArb)
select {
case <-closed:
case <-time.After(defaultTimeout):
t.Fatalf("channel was not marked closed")
}
// Since the channel was marked closed in the database, but the
// commit to the next state failed, the state should still be
// StateDefault.
time.Sleep(100 * time.Millisecond)
if log.state != StateDefault {
t.Fatalf("expected to stay in StateDefault, instead "+
"has %v", log.state)
}
chanArb.Stop()
// Start the arbitrator again, with IsPendingClose reporting
// the channel closed in the database.
log.failCommit = false
chanArbCtx, err = chanArbCtx.Restart(func(c *chanArbTestCtx) {
c.chanArb.cfg.IsPendingClose = true
c.chanArb.cfg.ClosingHeight = 100
c.chanArb.cfg.CloseType = test.closeType
})
if err != nil {
t.Fatalf("unable to create ChannelArbitrator: %v", err)
}
// Since the channel is marked closed in the database, it
// should advance to the expected states.
chanArbCtx.AssertStateTransitions(test.expectedStates...)
// It should also mark the channel as resolved.
select {
case <-chanArbCtx.resolvedChan:
// Expected.
case <-time.After(defaultTimeout):
t.Fatalf("contract was not resolved")
}
}
} | explode_data.jsonl/3699 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1533
} | [
2830,
3393,
9629,
6953,
4489,
81,
850,
33441,
17507,
1155,
353,
8840,
836,
8,
1476,
18185,
37302,
1669,
3056,
1235,
1476,
197,
197,
322,
3265,
929,
374,
279,
943,
315,
5496,
3265,
582,
1366,
14147,
1273,
624,
197,
27873,
929,
521,
102... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListeners(t *testing.T) {
// Setup a connection manager with a couple of mock listeners that
// notify a channel when they receive mock connections.
receivedConns := make(chan net.Conn)
listener1 := newMockListener("127.0.0.1:8333")
listener2 := newMockListener("127.0.0.1:9333")
listeners := []net.Listener{listener1, listener2}
cmgr, err := New(&Config{
Listeners: listeners,
OnAccept: func(conn net.Conn) {
receivedConns <- conn
},
Dial: mockDialer,
})
if err != nil {
t.Fatalf("New error: %v", err)
}
cmgr.Start()
// Fake a couple of mock connections to each of the listeners.
go func() {
for i, listener := range listeners {
l := listener.(*mockListener)
l.Connect("127.0.0.1", 10000+i*2)
l.Connect("127.0.0.1", 10000+i*2+1)
}
}()
// Tally the receive connections to ensure the expected number are
// received. Also, fail the test after a timeout so it will not hang
// forever should the test not work.
expectedNumConns := len(listeners) * 2
var numConns int
out:
for {
select {
case <-receivedConns:
numConns++
if numConns == expectedNumConns {
break out
}
case <-time.After(time.Millisecond * 50):
t.Fatalf("Timeout waiting for %d expected connections",
expectedNumConns)
}
}
cmgr.Stop()
cmgr.Wait()
} | explode_data.jsonl/53954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
31570,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
264,
3633,
6645,
448,
264,
5625,
315,
7860,
23562,
429,
198,
197,
322,
15456,
264,
5496,
979,
807,
5258,
7860,
13234,
624,
17200,
8771,
1109,
4412,
1669,
1281,
35190,
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 TestEnqueueMultiple(t *testing.T) {
finite_tests.EnqueueMultiple(t, func(size int) interface {
goqueue.Owner
goqueue.Enqueuer
} {
return finite.New(size)
})
} | explode_data.jsonl/54507 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
1702,
4584,
32089,
1155,
353,
8840,
836,
8,
341,
1166,
15856,
32509,
65625,
32089,
1155,
11,
2915,
6856,
526,
8,
3749,
341,
197,
30680,
4584,
49920,
198,
197,
30680,
4584,
22834,
591,
8801,
198,
197,
92,
341,
197,
853,
342... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImageRef_HasAlpha__False(t *testing.T) {
Startup(nil)
img, err := NewImageFromFile(resources + "png-24bit.png")
require.NoError(t, err)
defer img.Close()
assert.False(t, img.HasAlpha())
} | explode_data.jsonl/38820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
1906,
3945,
2039,
300,
19384,
563,
4049,
1155,
353,
8840,
836,
8,
341,
197,
39076,
27907,
692,
39162,
11,
1848,
1669,
1532,
1906,
43633,
52607,
488,
330,
14066,
12,
17,
19,
4489,
3508,
1138,
17957,
35699,
1155,
11,
1848,
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 |
func TestCountClaimedOneTimeCodes(t *testing.T) {
db, mock, _ := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual))
defer db.Close()
row := sqlmock.NewRows([]string{"count"}).AddRow(100)
mock.ExpectQuery(`SELECT COUNT(*) FROM encryption_keys WHERE one_time_code IS NULL`).WillReturnRows(row)
expectedResult := int64(100)
receivedResult, receivedErr := countClaimedOneTimeCodes(db)
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled expectations: %s", err)
}
assert.Equal(t, expectedResult, receivedResult, "Expected to receive count of 100")
assert.Nil(t, receivedErr, "Expected nil if query ran")
} | explode_data.jsonl/64743 | {
"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,
2507,
45544,
291,
3966,
1462,
20871,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
716,
1669,
5704,
16712,
7121,
13148,
16712,
15685,
37554,
5341,
13148,
16712,
15685,
37554,
2993,
1171,
16867,
2927,
10421,
2822,
33967,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClose(t *testing.T) {
channel := ws.NewChannel()
go func() {
closed := <-channel.Closed
assert.True(t, closed, "channel closed stayed open")
}()
channel.Close()
} | explode_data.jsonl/48245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
7925,
1155,
353,
8840,
836,
8,
341,
71550,
1669,
17624,
7121,
9629,
741,
30680,
2915,
368,
341,
197,
1444,
9259,
1669,
9119,
10119,
95163,
198,
197,
6948,
32443,
1155,
11,
7877,
11,
330,
10119,
7877,
19613,
1787,
1138,
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 |
func TestHandlerName(t *testing.T) {
cases := map[string]rpcID{
"": {},
"foo": {'f', 'o', 'o'},
"foobarbaz": {'f', 'o', 'o', 'b', 'a', 'r', 'b', 'a'},
}
for s, id := range cases {
if hid := handlerName(s); hid != id {
t.Errorf("handlerName mismatch: expected %v, got %v", id, hid)
}
}
} | explode_data.jsonl/74445 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
3050,
675,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
29414,
915,
515,
197,
197,
28796,
688,
14573,
197,
197,
1,
7975,
788,
981,
5360,
69,
516,
364,
78,
516,
364,
78,
11688,
197,
197,
1,
50267,
42... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchedulerCreation(t *testing.T) {
client := clientsetfake.NewSimpleClientset()
informerFactory := informers.NewSharedInformerFactory(client, 0)
testSource := "testProvider"
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(t.Logf).Stop()
defaultBindTimeout := int64(30)
factory.RegisterFitPredicate("PredicateOne", PredicateOne)
factory.RegisterPriorityFunction("PriorityOne", PriorityOne, 1)
factory.RegisterAlgorithmProvider(testSource, sets.NewString("PredicateOne"), sets.NewString("PriorityOne"))
_, err := New(client,
informerFactory.Core().V1().Nodes(),
factory.NewPodInformer(client, 0),
informerFactory.Core().V1().PersistentVolumes(),
informerFactory.Core().V1().PersistentVolumeClaims(),
informerFactory.Core().V1().ReplicationControllers(),
informerFactory.Apps().V1().ReplicaSets(),
informerFactory.Apps().V1().StatefulSets(),
informerFactory.Core().V1().Services(),
informerFactory.Policy().V1beta1().PodDisruptionBudgets(),
informerFactory.Storage().V1().StorageClasses(),
eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: "scheduler"}),
kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &testSource},
WithBindTimeoutSeconds(defaultBindTimeout))
if err != nil {
t.Fatalf("Failed to create scheduler: %v", err)
}
} | explode_data.jsonl/41721 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 444
} | [
2830,
3393,
38878,
32701,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
2943,
746,
30570,
7121,
16374,
2959,
746,
741,
17430,
34527,
4153,
1669,
6051,
388,
7121,
16997,
641,
34527,
4153,
12805,
11,
220,
15,
692,
18185,
3608,
1669,
330,
194... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue29513(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustQuery("select '123' union select cast(45678 as char);").Sort().Check(testkit.Rows("123", "45678"))
tk.MustQuery("select '123' union select cast(45678 as char(2));").Sort().Check(testkit.Rows("123", "45"))
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int);")
tk.MustExec("insert into t values(45678);")
tk.MustQuery("select '123' union select cast(a as char) from t;").Sort().Check(testkit.Rows("123", "45678"))
tk.MustQuery("select '123' union select cast(a as char(2)) from t;").Sort().Check(testkit.Rows("123", "45"))
} | explode_data.jsonl/65617 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
42006,
17,
24,
20,
16,
18,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDescribeBuildDuration(t *testing.T) {
type testBuild struct {
build *buildv1.Build
output string
}
// now a minute ago
now := metav1.Now()
minuteAgo := metav1.Unix(now.Rfc3339Copy().Time.Unix()-60, 0)
twoMinutesAgo := metav1.Unix(now.Rfc3339Copy().Time.Unix()-120, 0)
threeMinutesAgo := metav1.Unix(now.Rfc3339Copy().Time.Unix()-180, 0)
tests := []testBuild{
{ // 0 - build new
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: minuteAgo},
Status: buildv1.BuildStatus{
Phase: buildv1.BuildPhaseNew,
},
},
"waiting for 1m",
},
{ // 1 - build pending
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: minuteAgo},
Status: buildv1.BuildStatus{
Phase: buildv1.BuildPhasePending,
},
},
"waiting for 1m",
},
{ // 2 - build running
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: twoMinutesAgo},
Status: buildv1.BuildStatus{
StartTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseRunning,
},
},
"running for 1m",
},
{ // 3 - build completed
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
StartTimestamp: &twoMinutesAgo,
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseComplete,
},
},
"1m",
},
{ // 4 - build failed
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
StartTimestamp: &twoMinutesAgo,
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseFailed,
},
},
"1m",
},
{ // 5 - build error
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
StartTimestamp: &twoMinutesAgo,
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseError,
},
},
"1m",
},
{ // 6 - build cancelled before running, start time wasn't set yet
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseCancelled,
},
},
"waited for 2m",
},
{ // 7 - build cancelled while running, start time is set already
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
StartTimestamp: &twoMinutesAgo,
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseCancelled,
},
},
"1m",
},
{ // 8 - build failed before running, start time wasn't set yet
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseFailed,
},
},
"waited for 2m",
},
{ // 9 - build error before running, start time wasn't set yet
&buildv1.Build{
ObjectMeta: metav1.ObjectMeta{CreationTimestamp: threeMinutesAgo},
Status: buildv1.BuildStatus{
CompletionTimestamp: &minuteAgo,
Phase: buildv1.BuildPhaseError,
},
},
"waited for 2m",
},
}
for i, tc := range tests {
if actual, expected := describeBuildDuration(tc.build), tc.output; !strings.Contains(actual, expected) {
t.Errorf("(%d) expected duration output %s, got %s", i, expected, actual)
}
}
} | explode_data.jsonl/6485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1605
} | [
2830,
3393,
74785,
11066,
12945,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
11066,
2036,
341,
197,
69371,
220,
353,
5834,
85,
16,
25212,
198,
197,
21170,
914,
198,
197,
630,
197,
322,
1431,
264,
9383,
4134,
198,
80922,
1669,
77520,
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... | 3 |
func TestExecForEach_ErrorsOnUnbalancedQuotes(t *testing.T) {
t.Parallel()
p := script.Echo("a\nb\nc\n").ExecForEach("echo \"{{.}}")
p.Wait()
if p.Error() == nil {
t.Error("want error with unbalanced quotes in command line")
}
} | explode_data.jsonl/51468 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
10216,
91392,
93623,
1087,
1925,
1806,
58402,
43780,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
5316,
5142,
958,
445,
64,
1699,
65,
59,
1016,
1699,
1827,
10216,
91392,
445,
3047,
7245,
2979,
13,
3417,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckPubKeyEncoding(t *testing.T) {
t.Parallel()
tests := []struct {
name string
key []byte
isValid bool
}{
{
name: "uncompressed ok",
key: decodeHex("0411db93e1dcdb8a016b49840f8c53bc1eb68" +
"a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf" +
"9744464f82e160bfa9b8b64f9d4c03f999b8643f656b" +
"412a3"),
isValid: true,
},
{
name: "compressed ok",
key: decodeHex("02ce0b14fb842b1ba549fdd675c98075f12e9" +
"c510f8ef52bd021a9a1f4809d3b4d"),
isValid: true,
},
{
name: "compressed ok",
key: decodeHex("032689c7c2dab13309fb143e0e8fe39634252" +
"1887e976690b6b47f5b2a4b7d448e"),
isValid: true,
},
{
name: "hybrid",
key: decodeHex("0679be667ef9dcbbac55a06295ce870b07029" +
"bfcdb2dce28d959f2815b16f81798483ada7726a3c46" +
"55da4fbfc0e1108a8fd17b448a68554199c47d08ffb1" +
"0d4b8"),
isValid: false,
},
{
name: "empty",
key: nil,
isValid: false,
},
}
flags := txscript.ScriptVerifyStrictEncoding
for _, test := range tests {
err := txscript.TstCheckPubKeyEncoding(test.key, flags)
if err != nil && test.isValid {
t.Errorf("checkSignatureEncoding test '%s' failed "+
"when it should have succeeded: %v", test.name,
err)
} else if err == nil && !test.isValid {
t.Errorf("checkSignatureEncooding test '%s' succeeded "+
"when it should have failed", test.name)
}
}
} | explode_data.jsonl/24201 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 730
} | [
2830,
3393,
3973,
29162,
1592,
14690,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
23634,
257,
3056,
3782,
198,
197,
19907,
4088,
1807,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestInterfaceSet(t *testing.T) {
p := &Point{3, 4}
var s struct {
I interface{}
P interface {
Dist(int) int
}
}
sv := ValueOf(&s).Elem()
sv.Field(0).Set(ValueOf(p))
if q := s.I.(*Point); q != p {
t.Errorf("i: have %p want %p", q, p)
}
pv := sv.Field(1)
pv.Set(ValueOf(p))
if q := s.P.(*Point); q != p {
t.Errorf("i: have %p want %p", q, p)
}
i := pv.Method(0).Call([]Value{ValueOf(10)})[0].Int()
if i != 250 {
t.Errorf("Interface Method returned %d; want 250", i)
}
} | explode_data.jsonl/29560 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
5051,
1649,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
609,
2609,
90,
18,
11,
220,
19,
630,
2405,
274,
2036,
341,
197,
24486,
3749,
16094,
197,
10025,
3749,
341,
298,
10957,
380,
1548,
8,
526,
198,
197,
197,
532,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFSMsgRemovedWhileBuffered(t *testing.T) {
// Test is irrelevant if no buffering used
if testFSDisableBufferWriters {
t.SkipNow()
}
cleanupFSDatastore(t)
defer cleanupFSDatastore(t)
fs := createDefaultFileStore(t)
defer fs.Close()
limits := DefaultStoreLimits
limits.MaxMsgs = 10
if err := fs.SetLimits(&limits); err != nil {
t.Fatalf("Error setting limits: %v", &limits)
}
total := 1000
msg := []byte("msg")
cs := storeCreateChannel(t, fs, "foo")
for i := 0; i < total; i++ {
storeMsg(t, cs, "foo", uint64(i+1), msg)
}
fs.Close()
fs, state := newFileStore(t, testFSDefaultDatastore, &limits)
defer fs.Close()
if state == nil {
t.Fatal("Expected to recover a state")
}
} | explode_data.jsonl/7771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
8485,
6611,
42642,
7983,
4095,
291,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
374,
39715,
421,
902,
87139,
1483,
198,
743,
1273,
8485,
25479,
4095,
54,
31829,
341,
197,
3244,
57776,
7039,
741,
197,
532,
1444,
60639,
84... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBrokerV1Beta1DataPlaneIngress(t *testing.T) {
helpers.BrokerV1Beta1IngressDataPlaneTestHelper(context.Background(), t, brokerClass, brokerTestRunner, helpers.BrokerDataPlaneNamespaceSetupOption(context.Background(), brokerTestRunner.ComponentNamespace))
} | explode_data.jsonl/48643 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
65545,
53,
16,
64811,
16,
1043,
34570,
641,
2483,
1155,
353,
8840,
836,
8,
341,
197,
21723,
1785,
45985,
53,
16,
64811,
16,
641,
2483,
1043,
34570,
2271,
5511,
5378,
19047,
1507,
259,
11,
22316,
1957,
11,
22316,
2271,
1948... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPushRegistryTag(t *testing.T) {
r := spawnTestRegistrySession(t)
err := r.PushRegistryTag("foo42/bar", imageID, "stable", makeURL("/v1/"))
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/13110 | {
"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,
16644,
15603,
5668,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
18042,
2271,
15603,
5283,
1155,
340,
9859,
1669,
435,
34981,
15603,
5668,
445,
7975,
19,
17,
49513,
497,
2168,
915,
11,
330,
27992,
497,
1281,
3144,
4283,
85,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestLoadConfigFrom(t *testing.T) {
assert := assertlib.New(t)
appenv.SetDefaultEnvToTest() // to ensure it tries to find the config.test file
// create a temp config file
tmpDir := os.TempDir()
tmpFile, err := ioutil.TempFile(tmpDir, "config-*.yaml")
assert.NoError(err)
defer func() {
_ = os.Remove(tmpFile.Name())
_ = tmpFile.Close()
}()
text := []byte("server:\n port: 1234\n")
_, err = tmpFile.Write(text)
assert.NoError(err)
// change default config values
fileName := filepath.Base(tmpFile.Name())
configName := fileName[:len(fileName)-5] // strip the ".yaml"
tmpTestFileName := tmpDir + "/" + configName + ".test.yaml"
err = ioutil.WriteFile(tmpTestFileName, []byte("server:\n rootpath: '/test/'"), 0644)
assert.NoError(err)
defer func() {
_ = os.Remove(tmpTestFileName)
}()
_ = os.Setenv("ALGOREA_SERVER__WRITETIMEOUT", "999")
defer func() { _ = os.Unsetenv("ALGOREA_SERVER__WRITETIMEOUT") }()
conf := loadConfigFrom(configName, tmpDir)
// test config override
assert.EqualValues(1234, conf.Sub(serverConfigKey).GetInt("port"))
// test env variables
assert.EqualValues(999, conf.GetInt("server.WriteTimeout")) // does not work with Sub!
// test 'test' section
assert.EqualValues("/test/", conf.Sub(serverConfigKey).GetString("rootPath"))
// test live env changes
_ = os.Setenv("ALGOREA_SERVER__WRITETIMEOUT", "777")
defer func() { _ = os.Unsetenv("ALGOREA_SERVER__WRITETIMEOUT") }()
assert.EqualValues(777, conf.GetInt("server.WriteTimeout"))
} | explode_data.jsonl/61933 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 563
} | [
2830,
3393,
5879,
2648,
3830,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
2740,
7121,
1155,
340,
28236,
3160,
4202,
3675,
14359,
1249,
2271,
368,
442,
311,
5978,
432,
16297,
311,
1477,
279,
2193,
5958,
1034,
271,
197,
322,
1855,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestACLReplication(t *testing.T) {
dir1, s1 := testServerWithConfig(t, func(c *Config) {
c.ACLDatacenter = "dc1"
c.ACLMasterToken = "root"
})
defer os.RemoveAll(dir1)
defer s1.Shutdown()
client := rpcClient(t, s1)
defer client.Close()
dir2, s2 := testServerWithConfig(t, func(c *Config) {
c.Datacenter = "dc2"
c.ACLDatacenter = "dc1"
c.ACLReplicationToken = "root"
c.ACLReplicationInterval = 0
c.ACLReplicationApplyLimit = 1000000
})
defer os.RemoveAll(dir2)
defer s2.Shutdown()
// Try to join.
addr := fmt.Sprintf("127.0.0.1:%d",
s1.config.SerfWANConfig.MemberlistConfig.BindPort)
if _, err := s2.JoinWAN([]string{addr}); err != nil {
t.Fatalf("err: %v", err)
}
testutil.WaitForLeader(t, s1.RPC, "dc1")
testutil.WaitForLeader(t, s1.RPC, "dc2")
// Create a bunch of new tokens.
var id string
for i := 0; i < 1000; i++ {
arg := structs.ACLRequest{
Datacenter: "dc1",
Op: structs.ACLSet,
ACL: structs.ACL{
Name: "User token",
Type: structs.ACLTypeClient,
Rules: testACLPolicy,
},
WriteRequest: structs.WriteRequest{Token: "root"},
}
if err := s1.RPC("ACL.Apply", &arg, &id); err != nil {
t.Fatalf("err: %v", err)
}
}
checkSame := func() (bool, error) {
index, remote, err := s1.fsm.State().ACLList()
if err != nil {
return false, err
}
_, local, err := s2.fsm.State().ACLList()
if err != nil {
return false, err
}
if len(remote) != len(local) {
return false, nil
}
for i, acl := range remote {
if !acl.IsSame(local[i]) {
return false, nil
}
}
var status structs.ACLReplicationStatus
s2.aclReplicationStatusLock.RLock()
status = s2.aclReplicationStatus
s2.aclReplicationStatusLock.RUnlock()
if !status.Enabled || !status.Running ||
status.ReplicatedIndex != index ||
status.SourceDatacenter != "dc1" {
return false, nil
}
return true, nil
}
// Wait for the replica to converge.
testutil.WaitForResult(checkSame, func(err error) {
t.Fatalf("ACLs didn't converge")
})
// Create more new tokens.
for i := 0; i < 1000; i++ {
arg := structs.ACLRequest{
Datacenter: "dc1",
Op: structs.ACLSet,
ACL: structs.ACL{
Name: "User token",
Type: structs.ACLTypeClient,
Rules: testACLPolicy,
},
WriteRequest: structs.WriteRequest{Token: "root"},
}
var dontCare string
if err := s1.RPC("ACL.Apply", &arg, &dontCare); err != nil {
t.Fatalf("err: %v", err)
}
}
// Wait for the replica to converge.
testutil.WaitForResult(checkSame, func(err error) {
t.Fatalf("ACLs didn't converge")
})
// Delete a token.
arg := structs.ACLRequest{
Datacenter: "dc1",
Op: structs.ACLDelete,
ACL: structs.ACL{
ID: id,
},
WriteRequest: structs.WriteRequest{Token: "root"},
}
var dontCare string
if err := s1.RPC("ACL.Apply", &arg, &dontCare); err != nil {
t.Fatalf("err: %v", err)
}
// Wait for the replica to converge.
testutil.WaitForResult(checkSame, func(err error) {
t.Fatalf("ACLs didn't converge")
})
} | explode_data.jsonl/34825 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1339
} | [
2830,
3393,
55393,
18327,
1693,
1155,
353,
8840,
836,
8,
341,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
2354,
2648,
1155,
11,
2915,
1337,
353,
2648,
8,
341,
197,
1444,
875,
3140,
1043,
3057,
284,
330,
7628,
16,
698,
197,
1444,
875,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateProviders(t *testing.T) {
t.Run("test error from create new couchdb", func(t *testing.T) {
err := startOrbServices(&orbParameters{dbParameters: &dbParameters{databaseType: databaseTypeCouchDBOption}})
require.Error(t, err)
require.Contains(t, err.Error(), "failed to ping couchDB: url can't be blank")
})
t.Run("test error from create new kms secrets couchdb", func(t *testing.T) {
err := startOrbServices(&orbParameters{
dbParameters: &dbParameters{
databaseType: databaseTypeMemOption,
kmsSecretsDatabaseType: databaseTypeCouchDBOption,
},
})
require.Error(t, err)
require.Contains(t, err.Error(), "failed to ping couchDB: url can't be blank")
})
t.Run("test invalid database type", func(t *testing.T) {
err := startOrbServices(&orbParameters{dbParameters: &dbParameters{databaseType: "data1"}})
require.Error(t, err)
require.Contains(t, err.Error(), "database type not set to a valid type")
})
t.Run("test invalid kms secrets database type", func(t *testing.T) {
err := startOrbServices(&orbParameters{
dbParameters: &dbParameters{
databaseType: databaseTypeMemOption,
kmsSecretsDatabaseType: "data1",
},
})
require.Error(t, err)
require.Contains(t, err.Error(), "database type not set to a valid type")
})
} | explode_data.jsonl/57247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 474
} | [
2830,
3393,
4021,
37351,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
1465,
504,
1855,
501,
26148,
1999,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
9859,
1669,
1191,
2195,
65,
11025,
2099,
29886,
9706,
90,
1999,
9706,
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 TestIntegrationTCPConnectUnknownDNS(t *testing.T) {
ctx := context.Background()
results := TCPConnect(ctx, TCPConnectConfig{
Address: "ooni.io:443",
DNSServerNetwork: "antani",
})
if !strings.HasSuffix(results.Error.Error(), "unsupported network value") {
t.Fatal("not the error that we expected")
}
} | explode_data.jsonl/53546 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
52464,
49896,
14611,
13790,
61088,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
55497,
1669,
26656,
14611,
7502,
11,
26656,
14611,
2648,
515,
197,
98090,
25,
688,
330,
9009,
72,
4245,
25,
19,
19,
18,
756,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_getVMExtensionCannotReadCurrentSeqNo(t *testing.T) {
ctx := log.NewSyncLogger(log.NewLogfmtLogger(os.Stdout))
mm := createMockVMExtensionEnvironmentManager()
mm.getCurrentSequenceNumberError = errors.New("the current sequence number is beyond our comprehension")
ii, _ := GetInitializationInfo("yaba", "5.0", true, testEnableCallback)
_, err := getVMExtensionInternal(ctx, ii, mm)
require.Error(t, err)
} | explode_data.jsonl/18578 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
3062,
11187,
12049,
17444,
4418,
5405,
20183,
2753,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1487,
7121,
12154,
7395,
12531,
7121,
2201,
12501,
7395,
9638,
83225,
1171,
2109,
76,
1669,
1855,
11571,
11187,
12049,
12723,
2043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidResource(t *testing.T) {
client := &invalidResourceClient{}
stopCh := make(chan struct{})
defer close(stopCh)
tif := &duck.TypedInformerFactory{
Client: client,
Type: &duckv1alpha1.AddressableType{},
ResyncPeriod: 1 * time.Second,
StopChannel: stopCh,
}
_, _, got := tif.Get(context.Background(), SchemeGroupVersion.WithResource("resources"))
if got != errTest {
t.Errorf("Error = %v, want: %v", got, errTest)
}
} | explode_data.jsonl/51697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
7928,
4783,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
609,
11808,
4783,
2959,
16094,
62644,
1143,
1669,
1281,
35190,
2036,
37790,
16867,
3265,
60170,
1143,
692,
3244,
333,
1669,
609,
72970,
98152,
641,
34527,
4153,
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 TestPromNullByteHandling(t *testing.T) {
cases := []struct {
input string
err string
}{
{
input: "null_byte_metric{a=\"abc\x00\"} 1",
err: "",
},
{
input: "a{b=\"\x00ss\"} 1\n",
err: "",
},
{
input: "a{b=\"\x00\"} 1\n",
err: "",
},
{
input: "a{b=\"\x00\"} 1\n",
err: "",
},
{
input: "a{b=\x00\"ssss\"} 1\n",
err: "expected label value, got \"INVALID\"",
},
{
input: "a{b=\"\x00",
err: "expected label value, got \"INVALID\"",
},
{
input: "a{b\x00=\"hiih\"} 1",
err: "expected equal, got \"INVALID\"",
},
{
input: "a\x00{b=\"ddd\"} 1",
err: "expected value after metric, got \"MNAME\"",
},
}
for i, c := range cases {
p := NewPromParser([]byte(c.input))
var err error
for err == nil {
_, err = p.Next()
}
if c.err == "" {
require.Equal(t, io.EOF, err, "test %d", i)
continue
}
require.Error(t, err)
require.Equal(t, c.err, err.Error(), "test %d", i)
}
} | explode_data.jsonl/65246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 527
} | [
2830,
3393,
35186,
3280,
7153,
38606,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
22427,
914,
198,
197,
9859,
256,
914,
198,
197,
59403,
197,
197,
515,
298,
22427,
25,
330,
2921,
19737,
41294,
90,
64,
4070,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTaskUpdate(t *testing.T) {
gd, err := startDispatcher(DefaultConfig())
assert.NoError(t, err)
defer gd.Close()
var (
expectedSessionID string
nodeID string
)
{
stream, err := gd.Clients[0].Session(context.Background(), &api.SessionRequest{})
assert.NoError(t, err)
defer stream.CloseSend()
resp, err := stream.Recv()
assert.NoError(t, err)
assert.NotEmpty(t, resp.SessionID)
expectedSessionID = resp.SessionID
nodeID = resp.Node.ID
}
// testTask1 and testTask2 are advanced from NEW to ASSIGNED.
testTask1 := &api.Task{
ID: "testTask1",
NodeID: nodeID,
}
testTask2 := &api.Task{
ID: "testTask2",
NodeID: nodeID,
}
// testTask3 is used to confirm that status updates for a task not
// assigned to the node sending the update are rejected.
testTask3 := &api.Task{
ID: "testTask3",
NodeID: "differentnode",
}
// testTask4 is used to confirm that a task's state is not allowed to
// move backwards.
testTask4 := &api.Task{
ID: "testTask4",
NodeID: nodeID,
Status: api.TaskStatus{
State: api.TaskStateShutdown,
},
}
err = gd.Store.Update(func(tx store.Tx) error {
assert.NoError(t, store.CreateTask(tx, testTask1))
assert.NoError(t, store.CreateTask(tx, testTask2))
assert.NoError(t, store.CreateTask(tx, testTask3))
assert.NoError(t, store.CreateTask(tx, testTask4))
return nil
})
assert.NoError(t, err)
testTask1.Status = api.TaskStatus{State: api.TaskStateAssigned}
testTask2.Status = api.TaskStatus{State: api.TaskStateAssigned}
testTask3.Status = api.TaskStatus{State: api.TaskStateAssigned}
testTask4.Status = api.TaskStatus{State: api.TaskStateRunning}
updReq := &api.UpdateTaskStatusRequest{
Updates: []*api.UpdateTaskStatusRequest_TaskStatusUpdate{
{
TaskID: testTask1.ID,
Status: &testTask1.Status,
},
{
TaskID: testTask2.ID,
Status: &testTask2.Status,
},
{
TaskID: testTask4.ID,
Status: &testTask4.Status,
},
},
}
{
// without correct SessionID should fail
resp, err := gd.Clients[0].UpdateTaskStatus(context.Background(), updReq)
assert.Nil(t, resp)
assert.Error(t, err)
assert.Equal(t, grpc.Code(err), codes.InvalidArgument)
}
updReq.SessionID = expectedSessionID
_, err = gd.Clients[0].UpdateTaskStatus(context.Background(), updReq)
assert.NoError(t, err)
{
// updating a task not assigned to us should fail
updReq.Updates = []*api.UpdateTaskStatusRequest_TaskStatusUpdate{
{
TaskID: testTask3.ID,
Status: &testTask3.Status,
},
}
resp, err := gd.Clients[0].UpdateTaskStatus(context.Background(), updReq)
assert.Nil(t, resp)
assert.Error(t, err)
assert.Equal(t, grpc.Code(err), codes.PermissionDenied)
}
gd.dispatcherServer.processUpdates()
gd.Store.View(func(readTx store.ReadTx) {
storeTask1 := store.GetTask(readTx, testTask1.ID)
assert.NotNil(t, storeTask1)
storeTask2 := store.GetTask(readTx, testTask2.ID)
assert.NotNil(t, storeTask2)
assert.Equal(t, storeTask1.Status.State, api.TaskStateAssigned)
assert.Equal(t, storeTask2.Status.State, api.TaskStateAssigned)
storeTask3 := store.GetTask(readTx, testTask3.ID)
assert.NotNil(t, storeTask3)
assert.Equal(t, storeTask3.Status.State, api.TaskStateNew)
// The update to task4's state should be ignored because it
// would have moved backwards.
storeTask4 := store.GetTask(readTx, testTask4.ID)
assert.NotNil(t, storeTask4)
assert.Equal(t, storeTask4.Status.State, api.TaskStateShutdown)
})
} | explode_data.jsonl/13855 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1412
} | [
2830,
3393,
6262,
4289,
1155,
353,
8840,
836,
8,
341,
3174,
67,
11,
1848,
1669,
1191,
21839,
87874,
2648,
2398,
6948,
35699,
1155,
11,
1848,
340,
16867,
32630,
10421,
2822,
2405,
2399,
197,
42400,
5283,
915,
914,
198,
197,
20831,
915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestChargeGet(t *testing.T) {
chargeParams := &stripe.ChargeParams{
Amount: 1001,
Currency: currency.USD,
Card: &stripe.CardParams{
Number: "378282246310005",
Month: "06",
Year: "20",
},
}
res, _ := New(chargeParams)
target, err := Get(res.ID, nil)
if err != nil {
t.Error(err)
}
if target.ID != res.ID {
t.Errorf("Charge id %q does not match expected id %q\n", target.ID, res.ID)
}
} | explode_data.jsonl/73934 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
55363,
1949,
1155,
353,
8840,
836,
8,
341,
7450,
709,
4870,
1669,
609,
61233,
6353,
2744,
4870,
515,
197,
197,
10093,
25,
256,
220,
16,
15,
15,
16,
345,
197,
6258,
5088,
25,
11413,
13,
26749,
345,
197,
197,
5770,
25,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestWatchFile(t *testing.T) {
if runtime.GOOS == "linux" {
// TODO(bep) FIX ME
t.Skip("Skip test on Linux ...")
}
t.Run("file content changed", func(t *testing.T) {
// given a `config.yaml` file being watched
v, configFile, cleanup := newViperWithConfigFile(t)
defer cleanup()
_, err := os.Stat(configFile)
require.NoError(t, err)
t.Logf("test config file: %s\n", configFile)
wg := sync.WaitGroup{}
wg.Add(1)
v.OnConfigChange(func(in fsnotify.Event) {
t.Logf("config file changed")
wg.Done()
})
v.WatchConfig()
// when overwriting the file and waiting for the custom change notification handler to be triggered
err = ioutil.WriteFile(configFile, []byte("foo: baz\n"), 0640)
wg.Wait()
// then the config value should have changed
require.Nil(t, err)
assert.Equal(t, "baz", v.Get("foo"))
})
t.Run("link to real file changed (à la Kubernetes)", func(t *testing.T) {
// skip if not executed on Linux
if runtime.GOOS != "linux" {
t.Skipf("Skipping test as symlink replacements don't work on non-linux environment...")
}
v, watchDir, _, _ := newViperWithSymlinkedConfigFile(t)
// defer cleanup()
wg := sync.WaitGroup{}
v.WatchConfig()
v.OnConfigChange(func(in fsnotify.Event) {
t.Logf("config file changed")
wg.Done()
})
wg.Add(1)
// when link to another `config.yaml` file
dataDir2 := path.Join(watchDir, "data2")
err := os.Mkdir(dataDir2, 0777)
require.Nil(t, err)
configFile2 := path.Join(dataDir2, "config.yaml")
err = ioutil.WriteFile(configFile2, []byte("foo: baz\n"), 0640)
require.Nil(t, err)
// change the symlink using the `ln -sfn` command
err = exec.Command("ln", "-sfn", dataDir2, path.Join(watchDir, "data")).Run()
require.Nil(t, err)
wg.Wait()
// then
require.Nil(t, err)
assert.Equal(t, "baz", v.Get("foo"))
})
} | explode_data.jsonl/9925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 763
} | [
2830,
3393,
14247,
1703,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
14210,
1,
341,
197,
197,
322,
5343,
1883,
747,
8,
20151,
16292,
198,
197,
3244,
57776,
445,
35134,
1273,
389,
14340,
2503,
1138,
197,
630,
3244,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFilesFile(t *testing.T) {
// want := "Awesome File Content."
got := fakeWriteCloser{}
err := stubWorker.fileFetch(defaultConf.Items[0], &got)
if err == nil {
t.Errorf("Unexpected success when opening %s from filesystem", defaultConf.Items[0].Source.String())
}
// if !cmp.Equal(want, got.String()) {
// t.Errorf("Expected %s to be written to output file, but got %s", want, got.String())
// }
} | explode_data.jsonl/10362 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
10809,
1703,
1155,
353,
8840,
836,
8,
341,
197,
322,
1366,
1669,
330,
26899,
2887,
8883,
10040,
3174,
354,
1669,
12418,
7985,
51236,
799,
16094,
9859,
1669,
13633,
21936,
9715,
20714,
18978,
15578,
12054,
58,
15,
1125,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestKustomizeUnsetOverride(t *testing.T) {
Given(t).
Path("kustomize").
When().
Create().
AppSet("--namesuffix", "-suf").
Then().
And(func(app *Application) {
assert.Contains(t, app.Spec.Source.Kustomize.NameSuffix, "-suf")
}).
When().
AppUnSet("--namesuffix").
Then().
And(func(app *Application) {
assert.Nil(t, app.Spec.Source.Kustomize)
}).
When().
AppSet("--kustomize-image", "alpine:foo", "--kustomize-image", "alpine:bar").
Then().
And(func(app *Application) {
assert.Contains(t, app.Spec.Source.Kustomize.Images, KustomizeImage("alpine:bar"))
}).
When().
//AppUnSet("--kustomize-image=alpine").
AppUnSet("--kustomize-image", "alpine", "--kustomize-image", "alpine").
Then().
And(func(app *Application) {
assert.Nil(t, app.Spec.Source.Kustomize)
})
} | explode_data.jsonl/37138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
42,
1450,
551,
1806,
746,
2177,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
69640,
445,
74,
1450,
551,
38609,
197,
197,
4498,
25829,
197,
75569,
25829,
197,
59557,
1649,
21549,
11400,
13554,
497,
6523,
82,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQueryShardsByOrgWhenAppsAuthIsEnabledOnly(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
usesGitHubAppsAuth bool
prs map[string][]PullRequest
expectedNumberOfApiCalls int
}{
{
name: "Apps auth is used, one call per org",
usesGitHubAppsAuth: true,
prs: map[string][]PullRequest{
"org": {testPR("org", "repo", "A", 5, githubql.MergeableStateMergeable)},
"other-org": {testPR("other-org", "repo", "A", 5, githubql.MergeableStateMergeable)},
},
expectedNumberOfApiCalls: 2,
},
{
name: "Apps auth is unused, one call for all orgs",
usesGitHubAppsAuth: false,
prs: map[string][]PullRequest{"": {
testPR("org", "repo", "A", 5, githubql.MergeableStateMergeable),
testPR("other-org", "repo", "A", 5, githubql.MergeableStateMergeable),
}},
expectedNumberOfApiCalls: 1,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
c := &Controller{
logger: logrus.WithField("test", tc.name),
config: func() *config.Config {
return &config.Config{ProwConfig: config.ProwConfig{Tide: config.Tide{Queries: []config.TideQuery{{Orgs: []string{"org", "other-org"}}}}}}
},
ghc: &fgc{prs: tc.prs},
usesGitHubAppsAuth: tc.usesGitHubAppsAuth,
}
prs, err := c.query()
if err != nil {
t.Fatalf("query() failed: %v", err)
}
if n := len(prs); n != 2 {
t.Errorf("expected to get two prs back, got %d", n)
}
if diff := cmp.Diff(tc.expectedNumberOfApiCalls, c.ghc.(*fgc).queryCalls); diff != "" {
t.Errorf("expectedNumberOfApiCallsByOrg differs from actual: %s", diff)
}
})
}
} | explode_data.jsonl/42802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 817
} | [
2830,
3393,
2859,
2016,
2347,
1359,
42437,
4498,
53602,
5087,
3872,
5462,
7308,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
3824,
914,
198,
197,
197,
4776,
75615,
53602,
5087,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCopyChunkStreamInvalid(t *testing.T) {
var r io.Reader
var c chan []*string
var err error
r = strings.NewReader("oops")
c = make(chan []*string, 1)
err = copyChunkStream(r, c)
if err == nil {
t.Fatalf("should fail to retrieve data. err: %v", err)
}
r = strings.NewReader(`[["foo"], ["bar"]]`)
c = make(chan []*string, 1)
err = copyChunkStream(r, c)
if err == nil {
t.Fatalf("should fail to retrieve data. err: %v", err)
}
r = strings.NewReader(`{"foo": "bar"}`)
c = make(chan []*string, 1)
err = copyChunkStream(r, c)
if err == nil {
t.Fatalf("should fail to retrieve data. err: %v", err)
}
} | explode_data.jsonl/23256 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
12106,
28304,
3027,
7928,
1155,
353,
8840,
836,
8,
341,
2405,
435,
6399,
47431,
198,
2405,
272,
26023,
29838,
917,
198,
2405,
1848,
1465,
271,
7000,
284,
9069,
68587,
445,
64562,
1138,
1444,
284,
1281,
35190,
29838,
917,
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... | 4 |
func TestPullerRetries(t *testing.T) {
// Scenario: p1 pulls from p2, p3, p4 and p5.
// Only p3 considers p1 to be eligible to receive the data.
// The rest consider p1 as not eligible.
gn := &gossipNetwork{}
factoryMock1 := &mocks.CollectionAccessFactory{}
accessPolicyMock1 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock1, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p2")) || bytes.Equal(data.Identity, []byte("p3")) ||
bytes.Equal(data.Identity, []byte("p4")) ||
bytes.Equal(data.Identity, []byte("p5"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock1.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock1, nil)
// p1
policyStore := newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p2", "p3", "p4", "p5")
p1 := gn.newPuller("p1", policyStore, factoryMock1, membership(peerData{"p2", uint64(1)},
peerData{"p3", uint64(1)}, peerData{"p4", uint64(1)}, peerData{"p5", uint64(1)})...)
// p2, p3, p4, and p5 have the same transient store
transientStore := &util.PrivateRWSetWithConfig{
RWSet: newPRWSet(),
CollectionConfig: &peer.CollectionConfig{
Payload: &peer.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &peer.StaticCollectionConfig{
Name: "col1",
},
},
},
}
dig := &proto.PvtDataDigest{
TxId: "txID1",
Collection: "col1",
Namespace: "ns1",
}
store := Dig2PvtRWSetWithConfig{
privdatacommon.DigKey{
TxId: "txID1",
Collection: "col1",
Namespace: "ns1",
}: transientStore,
}
// p2
policyStore = newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p2")
factoryMock2 := &mocks.CollectionAccessFactory{}
accessPolicyMock2 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock2, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p2"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock2.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock2, nil)
p2 := gn.newPuller("p2", policyStore, factoryMock2)
p2.PrivateDataRetriever.(*dataRetrieverMock).On("CollectionRWSet", mock.MatchedBy(protoMatcher(dig)), uint64(0)).Return(store, true, nil)
// p3
policyStore = newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p1")
factoryMock3 := &mocks.CollectionAccessFactory{}
accessPolicyMock3 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock3, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p1"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock3.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock3, nil)
p3 := gn.newPuller("p3", policyStore, factoryMock3)
p3.PrivateDataRetriever.(*dataRetrieverMock).On("CollectionRWSet", mock.MatchedBy(protoMatcher(dig)), uint64(0)).Return(store, true, nil)
// p4
policyStore = newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p4")
factoryMock4 := &mocks.CollectionAccessFactory{}
accessPolicyMock4 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock4, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p4"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock4.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock4, nil)
p4 := gn.newPuller("p4", policyStore, factoryMock4)
p4.PrivateDataRetriever.(*dataRetrieverMock).On("CollectionRWSet", mock.MatchedBy(protoMatcher(dig)), uint64(0)).Return(store, true, nil)
// p5
policyStore = newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p5")
factoryMock5 := &mocks.CollectionAccessFactory{}
accessPolicyMock5 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock5, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p5"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock5.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock5, nil)
p5 := gn.newPuller("p5", policyStore, factoryMock5)
p5.PrivateDataRetriever.(*dataRetrieverMock).On("CollectionRWSet", mock.MatchedBy(protoMatcher(dig)), uint64(0)).Return(store, true, nil)
// Fetch from someone
dasf := &digestsAndSourceFactory{}
fetchedMessages, err := p1.fetch(dasf.mapDigest(toDigKey(dig)).toSources().create())
assert.NoError(t, err)
rws1 := util.PrivateRWSet(fetchedMessages.AvailableElements[0].Payload[0])
rws2 := util.PrivateRWSet(fetchedMessages.AvailableElements[0].Payload[1])
fetched := []util.PrivateRWSet{rws1, rws2}
assert.NoError(t, err)
assert.Equal(t, transientStore.RWSet, fetched)
} | explode_data.jsonl/53266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1773
} | [
2830,
3393,
36068,
261,
12020,
4019,
1155,
353,
8840,
836,
8,
341,
197,
322,
58663,
25,
281,
16,
33045,
504,
281,
17,
11,
281,
18,
11,
281,
19,
323,
281,
20,
624,
197,
322,
8278,
281,
18,
31138,
281,
16,
311,
387,
17013,
311,
52... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoveOrgUser(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
testSuccess := func(orgID, userID int64) {
org := AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
expectedNumMembers := org.NumMembers
if BeanExists(t, &OrgUser{OrgID: orgID, UID: userID}) {
expectedNumMembers--
}
assert.NoError(t, RemoveOrgUser(orgID, userID))
AssertNotExistsBean(t, &OrgUser{OrgID: orgID, UID: userID})
org = AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
}
testSuccess(3, 4)
testSuccess(3, 4)
err := RemoveOrgUser(7, 5)
assert.Error(t, err)
assert.True(t, IsErrLastOrgOwner(err))
AssertExistsAndLoadBean(t, &OrgUser{OrgID: 7, UID: 5})
CheckConsistencyFor(t, &User{}, &Team{})
} | explode_data.jsonl/71071 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 321
} | [
2830,
3393,
13021,
42437,
1474,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
2271,
5988,
2398,
18185,
7188,
1669,
2915,
36246,
915,
11,
35204,
526,
21,
19,
8,
341,
197,
87625,
1669,
5319,
15575,
3036,
5879,
10437,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScalarBls12377G1Add(t *testing.T) {
bls12377G1 := BLS12377G1()
nine := bls12377G1.Scalar.New(9)
six := bls12377G1.Scalar.New(6)
fifteen := nine.Add(six)
require.NotNil(t, fifteen)
expected := bls12377G1.Scalar.New(15)
require.Equal(t, expected.Cmp(fifteen), 0)
n := new(big.Int).Set(bls12377modulus)
n.Sub(n, big.NewInt(3))
upper, err := bls12377G1.Scalar.SetBigInt(n)
require.NoError(t, err)
actual := upper.Add(nine)
require.NotNil(t, actual)
require.Equal(t, actual.Cmp(six), 0)
} | explode_data.jsonl/15755 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
20639,
33,
4730,
16,
17,
18,
22,
22,
38,
16,
2212,
1155,
353,
8840,
836,
8,
341,
96421,
82,
16,
17,
18,
22,
22,
38,
16,
1669,
425,
7268,
16,
17,
18,
22,
22,
38,
16,
741,
9038,
482,
1669,
1501,
82,
16,
17,
18,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExpandPublicReleaseAddressInput(t *testing.T) {
rd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"ip_type": false,
"public_ip": "192.0.2.1",
})
rd.SetId("192.0.2.1")
tests := []struct {
name string
args *schema.ResourceData
want *computing.ReleaseAddressInput
}{
{
name: "expands the resource data",
args: rd,
want: &computing.ReleaseAddressInput{
PublicIp: nifcloud.String("192.0.2.1"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := expandReleaseAddressInput(tt.args)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/35519 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 271
} | [
2830,
3393,
38946,
12676,
16077,
4286,
2505,
1155,
353,
8840,
836,
8,
341,
92356,
1669,
10802,
8787,
4783,
1043,
20015,
1155,
11,
501,
8632,
1507,
2415,
14032,
31344,
67066,
197,
197,
1,
573,
1819,
788,
256,
895,
345,
197,
197,
1,
888... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQueueEach(t *testing.T) {
q := nonEmptyQueue()
i := 1
q.Each(func(item int) {
if item != i {
t.Errorf("got %v, want %v", item, i)
}
i++
})
} | explode_data.jsonl/52732 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
7554,
4854,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
2477,
3522,
7554,
2822,
8230,
1669,
220,
16,
198,
18534,
13,
4854,
18552,
5393,
526,
8,
341,
197,
743,
1509,
961,
600,
341,
298,
3244,
13080,
445,
22390,
1018,
85,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestUserUsageStatistics_None(t *testing.T) {
db := setupForTest(t)
want := &types.UserUsageStatistics{
UserID: 42,
}
got, err := GetByUserID(context.Background(), db, 42)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(want, got) {
t.Fatalf("got %+v != %+v", got, want)
}
} | explode_data.jsonl/66473 | {
"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,
1474,
14783,
38599,
52523,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
6505,
2461,
2271,
1155,
692,
50780,
1669,
609,
9242,
7344,
14783,
38599,
515,
197,
31672,
915,
25,
220,
19,
17,
345,
197,
532,
3174,
354,
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... | 3 |
func TestBidderSyncAllowedVendorException(t *testing.T) {
noPurposeOrVendorConsentAndPubRestrictsP1 := "CPF_61ePF_61eFxAAAENAiCAAAAAAAAAAAAAAQAAAAAAAAAAIIACACA"
noPurposeOrVendorConsentAndPubRestrictsNone := "CPF_61ePF_61eFxAAAENAiCAAAAAAAAAAAAAACEAAAAA"
testDefs := []struct {
description string
p1VendorExceptionMap map[openrtb_ext.BidderName]struct{}
bidder openrtb_ext.BidderName
consent string
allowSync bool
}{
{
description: "Sync blocked by no consent - p1 enabled, no p1 vendor exception, pub restricts none",
p1VendorExceptionMap: map[openrtb_ext.BidderName]struct{}{},
bidder: openrtb_ext.BidderAppnexus,
consent: noPurposeOrVendorConsentAndPubRestrictsNone,
allowSync: false,
},
{
description: "Sync blocked by publisher - p1 enabled with p1 vendor exception, pub restricts p1 for vendor",
p1VendorExceptionMap: map[openrtb_ext.BidderName]struct{}{openrtb_ext.BidderAppnexus: {}},
bidder: openrtb_ext.BidderAppnexus,
consent: noPurposeOrVendorConsentAndPubRestrictsP1,
allowSync: false,
},
{
description: "Sync allowed by vendor exception - p1 enabled with p1 vendor exception, pub restricts none",
p1VendorExceptionMap: map[openrtb_ext.BidderName]struct{}{openrtb_ext.BidderAppnexus: {}},
bidder: openrtb_ext.BidderAppnexus,
consent: noPurposeOrVendorConsentAndPubRestrictsNone,
allowSync: true,
},
}
for _, td := range testDefs {
vendorListData := MarshalVendorList(buildVendorList34())
perms := permissionsImpl{
cfg: config.GDPR{
HostVendorID: 2,
TCF2: config.TCF2{
Enabled: true,
Purpose1: config.TCF2Purpose{Enabled: true, VendorExceptionMap: td.p1VendorExceptionMap},
},
},
vendorIDs: map[openrtb_ext.BidderName]uint16{
openrtb_ext.BidderAppnexus: 32,
},
fetchVendorList: map[uint8]func(ctx context.Context, id uint16) (vendorlist.VendorList, error){
tcf2SpecVersion: listFetcher(map[uint16]vendorlist.VendorList{
34: parseVendorListDataV2(t, vendorListData),
}),
},
}
perms.purposeConfigs = map[consentconstants.Purpose]config.TCF2Purpose{
consentconstants.Purpose(1): perms.cfg.TCF2.Purpose1,
}
allowSync, err := perms.BidderSyncAllowed(context.Background(), td.bidder, SignalYes, td.consent)
assert.NoErrorf(t, err, "Error processing BidderSyncAllowed for %s", td.description)
assert.EqualValuesf(t, td.allowSync, allowSync, "AllowSync failure on %s", td.description)
}
} | explode_data.jsonl/31104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1176
} | [
2830,
3393,
65452,
1107,
12154,
35382,
44691,
1354,
1155,
353,
8840,
836,
8,
341,
72104,
74033,
2195,
44691,
15220,
306,
3036,
29162,
50360,
29995,
47,
16,
1669,
330,
73830,
62,
21,
16,
68,
19701,
62,
21,
16,
68,
81856,
50107,
953,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContextLockTargets(t *testing.T) {
t.Parallel()
authContext := &Context{
Identity: BuiltinRole{
Role: types.RoleNode,
ClusterName: "cluster",
Identity: tlsca.Identity{
Username: "node.cluster",
Groups: []string{"role1", "role2"},
},
},
UnmappedIdentity: WrapIdentity(tlsca.Identity{
Username: "node.cluster",
Groups: []string{"mapped-role"},
}),
}
expected := []types.LockTarget{
{Node: "node"},
{Node: "node.cluster"},
{User: "node.cluster"},
{Role: "role1"},
{Role: "role2"},
{Role: "mapped-role"},
}
require.ElementsMatch(t, authContext.LockTargets(), expected)
} | explode_data.jsonl/10802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
1972,
11989,
49030,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
78011,
1972,
1669,
609,
1972,
515,
197,
197,
18558,
25,
425,
25628,
9030,
515,
298,
197,
9030,
25,
286,
4494,
35955,
1955,
345,
298,
197,
28678,
675... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestActivityService_GetRepositorySubscription_true(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"subscribed":true}`)
})
ctx := context.Background()
sub, _, err := client.Activity.GetRepositorySubscription(ctx, "o", "r")
if err != nil {
t.Errorf("Activity.GetRepositorySubscription returned error: %v", err)
}
want := &Subscription{Subscribed: Bool(true)}
if !reflect.DeepEqual(sub, want) {
t.Errorf("Activity.GetRepositorySubscription returned %+v, want %+v", sub, want)
}
const methodName = "GetRepositorySubscription"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Activity.GetRepositorySubscription(ctx, "\n", "\n")
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Activity.GetRepositorySubscription(ctx, "o", "r")
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
} | explode_data.jsonl/50050 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
4052,
1860,
13614,
4624,
33402,
16082,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
68354,
20271,
7382,
14,
34404,
497,
2915,
3622,
1758,
37508,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigureVolumesAndMounts(t *testing.T) {
env := Environment{
Integration: &v1alpha1.Integration{
ObjectMeta: metav1.ObjectMeta{
Name: TestDeploymentName,
Namespace: "ns",
},
Spec: v1alpha1.IntegrationSpec{
Resources: []v1alpha1.ResourceSpec{
{
DataSpec: v1alpha1.DataSpec{
Name: "res1.txt",
ContentRef: "my-cm1",
ContentKey: "my-key1",
},
Type: "data",
MountPath: "/etc/m1",
},
{
DataSpec: v1alpha1.DataSpec{
Name: "res2.txt",
ContentRef: "my-cm2",
},
Type: "data",
},
{
DataSpec: v1alpha1.DataSpec{
Name: "res3.txt",
ContentKey: "my-key3",
},
Type: "data",
},
{
DataSpec: v1alpha1.DataSpec{
Name: "res4.txt",
},
Type: "data",
},
},
Configuration: []v1alpha1.ConfigurationSpec{
{
Type: "configmap",
Value: "test-configmap",
},
{
Type: "secret",
Value: "test-secret",
},
{
Type: "volume",
Value: "testvolume:/foo/bar",
},
{
Type: "volume",
Value: "an-invalid-volume-spec",
},
},
},
},
}
vols := make([]corev1.Volume, 0)
mnts := make([]corev1.VolumeMount, 0)
env.ConfigureVolumesAndMounts(&vols, &mnts)
assert.Len(t, vols, 8)
assert.Len(t, mnts, 8)
v := findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm1" })
assert.NotNil(t, v)
assert.NotNil(t, v.VolumeSource.ConfigMap)
assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
assert.Equal(t, "my-key1", v.VolumeSource.ConfigMap.Items[0].Key)
assert.Equal(t, "res1.txt", v.VolumeSource.ConfigMap.Items[0].Path)
m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-000" })
assert.NotNil(t, m)
assert.Equal(t, "/etc/m1", m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm2" })
assert.NotNil(t, v)
assert.NotNil(t, v.VolumeSource.ConfigMap)
assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
assert.Equal(t, "content", v.VolumeSource.ConfigMap.Items[0].Key)
assert.Equal(t, "res2.txt", v.VolumeSource.ConfigMap.Items[0].Path)
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-001" })
assert.NotNil(t, m)
assert.Equal(t, "/etc/camel/resources/i-resource-001", m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == TestDeploymentName+"-resource-002" })
assert.NotNil(t, v)
assert.NotNil(t, v.VolumeSource.ConfigMap)
assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
assert.Equal(t, "my-key3", v.VolumeSource.ConfigMap.Items[0].Key)
assert.Equal(t, "res3.txt", v.VolumeSource.ConfigMap.Items[0].Path)
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-002" })
assert.NotNil(t, m)
assert.Equal(t, "/etc/camel/resources/i-resource-002", m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == TestDeploymentName+"-resource-003" })
assert.NotNil(t, v)
assert.NotNil(t, v.VolumeSource.ConfigMap)
assert.Len(t, v.VolumeSource.ConfigMap.Items, 1)
assert.Equal(t, "content", v.VolumeSource.ConfigMap.Items[0].Key)
assert.Equal(t, "res4.txt", v.VolumeSource.ConfigMap.Items[0].Path)
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-003" })
assert.NotNil(t, m)
assert.Equal(t, "/etc/camel/resources/i-resource-003", m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "test-configmap" })
assert.NotNil(t, v)
assert.NotNil(t, v.VolumeSource.ConfigMap)
assert.NotNil(t, v.VolumeSource.ConfigMap.LocalObjectReference)
assert.Equal(t, "test-configmap", v.VolumeSource.ConfigMap.LocalObjectReference.Name)
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-configmap" })
assert.NotNil(t, m)
assert.Equal(t, "/etc/camel/conf.d/integration-cm-test-configmap", m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "test-secret" })
assert.NotNil(t, v)
assert.NotNil(t, v.Secret)
assert.Equal(t, "test-secret", v.Secret.SecretName)
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-secret" })
assert.NotNil(t, m)
assert.Equal(t, "/etc/camel/conf.d/integration-secret-test-secret", m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "testvolume-data" })
assert.NotNil(t, v)
assert.NotNil(t, v.VolumeSource)
assert.NotNil(t, v.VolumeSource.PersistentVolumeClaim)
assert.Equal(t, "testvolume", v.VolumeSource.PersistentVolumeClaim.ClaimName)
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "testvolume-data" })
assert.NotNil(t, m)
assert.Equal(t, "/foo/bar", m.MountPath)
} | explode_data.jsonl/54529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2208
} | [
2830,
3393,
28560,
96325,
3036,
16284,
82,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
11586,
515,
197,
197,
52464,
25,
609,
85,
16,
7141,
16,
7371,
17376,
515,
298,
23816,
12175,
25,
77520,
16,
80222,
515,
571,
21297,
25,
414,
3393,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDockerConfigEntryJSONDecode(t *testing.T) {
tests := []struct {
input []byte
expect DockerConfigEntry
fail bool
}{
// simple case, just decode the fields
{
input: []byte(`{"username": "foo", "password": "bar", "email": "foo@example.com"}`),
expect: DockerConfigEntry{
Username: "foo",
Password: "bar",
Email: "foo@example.com",
},
fail: false,
},
// auth field decodes to username & password
{
input: []byte(`{"auth": "Zm9vOmJhcg==", "email": "foo@example.com"}`),
expect: DockerConfigEntry{
Username: "foo",
Password: "bar",
Email: "foo@example.com",
},
fail: false,
},
// auth field overrides username & password
{
input: []byte(`{"username": "foo", "password": "bar", "auth": "cGluZzpwb25n", "email": "foo@example.com"}`),
expect: DockerConfigEntry{
Username: "ping",
Password: "pong",
Email: "foo@example.com",
},
fail: false,
},
// poorly-formatted auth causes failure
{
input: []byte(`{"auth": "pants", "email": "foo@example.com"}`),
expect: DockerConfigEntry{
Username: "",
Password: "",
Email: "foo@example.com",
},
fail: true,
},
// invalid JSON causes failure
{
input: []byte(`{"email": false}`),
expect: DockerConfigEntry{
Username: "",
Password: "",
Email: "",
},
fail: true,
},
}
for i, tt := range tests {
var output DockerConfigEntry
err := json.Unmarshal(tt.input, &output)
if (err != nil) != tt.fail {
t.Errorf("case %d: expected fail=%t, got err=%v", i, tt.fail, err)
}
if !reflect.DeepEqual(tt.expect, output) {
t.Errorf("case %d: expected output %#v, got %#v", i, tt.expect, output)
}
}
} | explode_data.jsonl/40711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 844
} | [
2830,
3393,
35,
13659,
2648,
5874,
5370,
32564,
1155,
353,
8840,
836,
8,
972,
78216,
1669,
3056,
1235,
972,
197,
22427,
220,
3056,
3782,
319,
197,
24952,
40549,
2648,
5874,
319,
197,
63052,
256,
1807,
319,
197,
92,
1666,
197,
197,
322... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDescribeLoadBalancerOnGet(t *testing.T) {
awsServices := newMockedFakeAWSServices(TestClusterId)
c, _ := newAWSCloud(strings.NewReader("[global]"), awsServices)
awsServices.elb.(*MockedFakeELB).expectDescribeLoadBalancers("aid")
c.GetLoadBalancer(context.TODO(), TestClusterName, &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "myservice", UID: "id"}})
} | explode_data.jsonl/29218 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
74785,
5879,
93825,
1925,
1949,
1155,
353,
8840,
836,
8,
341,
197,
8635,
11025,
1669,
501,
11571,
291,
52317,
14419,
1220,
2161,
31159,
28678,
764,
340,
1444,
11,
716,
1669,
501,
14419,
3540,
52178,
51442,
68587,
10937,
9752,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.