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 TestCloudDatastoreWithRPCRetryAndChaosRPCTestSuite(t *testing.T) {
ctx := context.Background()
for name, test := range testsuite.TestSuite {
t.Run(name, func(t *testing.T) {
// Skip the flaky tests.
switch name {
case
"Filter_PropertyTranslaterMustError":
t.SkipNow()
}
defer cleanUp()
datastore, err := FromContext(ctx)
if err != nil {
t.Fatal(err)
}
rr := rpcretry.New(
rpcretry.WithRetryLimit(10),
rpcretry.WithMinBackoffDuration(1),
rpcretry.WithMaxBackoffDuration(1),
rpcretry.WithLogger(func(ctx context.Context, format string, args ...interface{}) {
t.Logf(format, args...)
}),
)
datastore.AppendMiddleware(rr)
seed := time.Now().UnixNano()
t.Logf("chaos seed: %d", seed)
cr := chaosrpc.New(rand.NewSource(seed))
datastore.AppendMiddleware(cr)
ctx = testsuite.WrapCloudFlag(ctx)
test(ctx, t, datastore)
})
}
} | explode_data.jsonl/22390 | {
"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,
16055,
1043,
4314,
2354,
29528,
51560,
3036,
1143,
64866,
21657,
76434,
28000,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
2023,
829,
11,
1273,
1669,
2088,
7032,
9302,
8787,
28000,
341,
197,
3244,
16708,
3153,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRename(t *testing.T) {
t.Run("should rename element", func(t *testing.T) {
tests := map[string]interface{}{
"struct": struct{ OldName string }{
OldName: "v",
},
"map": map[string]string{
"OldName": "v",
},
}
for name, object := range tests {
t.Run(name, func(t *testing.T) {
mapper := mapify.Mapper{
Rename: func(path string, e mapify.Element) (string, error) {
return "newName", nil
},
}
// when
v, err := mapper.MapAny(object)
// then
require.NoError(t, err)
expected := map[string]interface{}{
"newName": "v",
}
assert.Equal(t, expected, v)
})
}
})
t.Run("should return error when Rename returned error", func(t *testing.T) {
tests := map[string]interface{}{
"struct": struct{ Field string }{},
"map": map[string]string{"Field": ""},
}
for name, object := range tests {
t.Run(name, func(t *testing.T) {
givenError := stringError("err")
mapper := mapify.Mapper{
Rename: func(path string, e mapify.Element) (string, error) {
return e.Name(), givenError
},
}
// when
result, actualErr := mapper.MapAny(object)
// then
assert.Nil(t, result)
assert.ErrorIs(t, actualErr, givenError)
})
}
})
} | explode_data.jsonl/71714 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 573
} | [
2830,
3393,
88757,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5445,
29074,
2392,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
78216,
1669,
2415,
14032,
31344,
67066,
298,
197,
80575,
788,
2036,
90,
10621,
675,
914,
335,
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... | 1 |
func TestEntryAddUntimedWithNoRollup(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
pipelineNoRollup := metadata.PipelineMetadata{
Pipeline: applied.NewPipeline([]applied.OpUnion{
{
Type: pipeline.TransformationOpType,
Transformation: pipeline.TransformationOp{Type: transformation.Absolute},
},
}),
}
e, _, _ := testEntry(ctrl, testEntryOptions{})
metadatas := metadata.StagedMetadatas{
{Metadata: metadata.Metadata{Pipelines: []metadata.PipelineMetadata{pipelineNoRollup}}},
}
err := e.AddUntimed(testCounter, metadatas)
require.NoError(t, err)
} | explode_data.jsonl/24225 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
5874,
2212,
20250,
75485,
2354,
2753,
32355,
454,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
3223,
8790,
2753,
32355,
454,
1669,
11160,
1069,
8790,
14610,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFrameHitCount(t *testing.T) {
f := NewFrame(nil)
if f.HitCount() != 0 {
t.Errorf("The initial hit counts should be 0.")
}
f.IncHitCount()
if f.HitCount() != 1 {
t.Errorf("This should be 1.")
}
f.SetHitCount(0)
if f.HitCount() != 0 {
t.Errorf("This should be 0.")
}
} | explode_data.jsonl/52246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
4369,
19498,
2507,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
1532,
4369,
27907,
340,
743,
282,
85344,
2507,
368,
961,
220,
15,
341,
197,
3244,
13080,
445,
785,
2856,
4201,
14579,
1265,
387,
220,
15,
13053,
197,
532,
1166,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBatchPointGetLockIndex(t *testing.T) {
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk2.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1 (c1 int primary key, c2 int, c3 int, unique key uk(c2))")
tk.MustExec("insert into t1 values (1, 1, 1)")
tk.MustExec("insert into t1 values (5, 5, 5)")
tk.MustExec("insert into t1 values (10, 10, 10)")
tk.MustExec("begin pessimistic")
// the handle does not exist and the index key should be locked as point get executor did
tk.MustQuery("select * from t1 where c2 in (2, 3) for update").Check(testkit.Rows())
tk2.MustExec("set innodb_lock_wait_timeout = 1")
tk2.MustExec("begin pessimistic")
err := tk2.ExecToErr("insert into t1 values(2, 2, 2)")
require.Error(t, err)
require.True(t, storeerr.ErrLockWaitTimeout.Equal(err))
err = tk2.ExecToErr("select * from t1 where c2 = 3 for update nowait")
require.Error(t, err)
require.True(t, storeerr.ErrLockAcquireFailAndNoWaitSet.Equal(err))
tk.MustExec("rollback")
tk2.MustExec("rollback")
} | explode_data.jsonl/12478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 439
} | [
2830,
3393,
21074,
2609,
1949,
11989,
1552,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1855,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegrationTransactionRecordQueryCanExecute(t *testing.T) {
env := NewIntegrationTestEnv(t)
newKey, err := GeneratePrivateKey()
assert.NoError(t, err)
newBalance := NewHbar(2)
assert.Equal(t, 2*HbarUnits.Hbar._NumberOfTinybar(), newBalance.tinybar)
tx, err := NewAccountCreateTransaction().
SetKey(newKey.PublicKey()).
SetNodeAccountIDs(env.NodeAccountIDs).
SetInitialBalance(newBalance).
FreezeWith(env.Client)
assert.NoError(t, err)
tx, err = tx.SignWithOperator(env.Client)
assert.NoError(t, err)
resp, err := tx.Execute(env.Client)
assert.NoError(t, err)
_, err = NewTransactionReceiptQuery().
SetTransactionID(resp.TransactionID).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
Execute(env.Client)
assert.NoError(t, err)
record, err := NewTransactionRecordQuery().
SetTransactionID(resp.TransactionID).
SetNodeAccountIDs([]AccountID{resp.NodeID}).
Execute(env.Client)
assert.NoError(t, err)
accountID := *record.Receipt.AccountID
assert.NotNil(t, accountID)
transaction, err := NewAccountDeleteTransaction().
SetNodeAccountIDs([]AccountID{resp.NodeID}).
SetAccountID(accountID).
SetTransferAccountID(env.Client.GetOperatorAccountID()).
FreezeWith(env.Client)
assert.NoError(t, err)
resp, err = transaction.
Sign(newKey).
Execute(env.Client)
assert.NoError(t, err)
_, err = resp.GetReceipt(env.Client)
assert.NoError(t, err)
err = CloseIntegrationTestEnv(env, nil)
assert.NoError(t, err)
} | explode_data.jsonl/78871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 547
} | [
2830,
3393,
52464,
8070,
6471,
2859,
6713,
17174,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
1532,
52464,
2271,
14359,
1155,
692,
8638,
1592,
11,
1848,
1669,
19813,
75981,
741,
6948,
35699,
1155,
11,
1848,
692,
8638,
21190,
1669,
1532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgFilter_IsByBot(t *testing.T) {
var botID disgord.Snowflake = 123
messageFromBot := &disgord.Message{
Author: &disgord.User{Bot: true},
}
messageNotFromBot := &disgord.Message{
Author: &disgord.User{Bot: false},
}
testCases := []struct {
name string
evt interface{}
shouldPassThrough bool
}{
{"MessageCreate_FromBot", &disgord.MessageCreate{Message: messageFromBot}, true},
{"MessageUpdate_FromBot", &disgord.MessageUpdate{Message: messageFromBot}, true},
{"MessageCreate_NotBot", &disgord.MessageCreate{Message: messageNotFromBot}, false},
{"MessageUpdate_NotBot", &disgord.MessageUpdate{Message: messageNotFromBot}, false},
}
filter, _ := newMsgFilter(context.Background(), &clientRESTMock{id: botID})
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := filter.IsByBot(tc.evt)
if tc.shouldPassThrough && result == nil {
t.Error("expected to passthrough")
}
if !tc.shouldPassThrough && result != nil {
t.Error("expected a filter match")
}
})
}
} | explode_data.jsonl/1328 | {
"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,
6611,
5632,
31879,
1359,
23502,
1155,
353,
8840,
836,
8,
341,
2405,
10924,
915,
32183,
539,
808,
3328,
63456,
284,
220,
16,
17,
18,
271,
24753,
3830,
23502,
1669,
609,
4243,
70,
539,
8472,
515,
197,
197,
7133,
25,
609,
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... | 5 |
func TestTabContainer_RemoveIndex(t *testing.T) {
tabs := container.NewAppTabs(&container.TabItem{Text: "Test1", Content: widget.NewLabel("Test1")},
&container.TabItem{Text: "Test2", Content: widget.NewLabel("Test2")})
tabs.SelectTabIndex(1)
tabs.RemoveIndex(1)
assert.Equal(t, 0, tabs.CurrentTabIndex()) // check max item selection and no panic
tabs.SelectTabIndex(0)
tabs.RemoveIndex(0)
assert.Equal(t, -1, tabs.CurrentTabIndex()) // check deselection and no panic
} | explode_data.jsonl/32317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
8582,
4502,
66843,
1552,
1155,
353,
8840,
836,
8,
341,
3244,
3435,
1669,
5476,
7121,
2164,
36985,
2099,
3586,
4328,
1234,
90,
1178,
25,
330,
2271,
16,
497,
8883,
25,
9086,
7121,
2476,
445,
2271,
16,
79583,
197,
197,
5,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRename(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
t.Parallel()
// Create TurtleDexFileSet with TurtleDexFile
entry := newTestFile()
// Create new paths for the file.
oldTurtleDexFilePath := entry.TurtleDexFilePath()
newTurtleDexFilePath := strings.TrimSuffix(entry.TurtleDexFilePath(), modules.TurtleDexFileExtension) + "_renamed" + modules.TurtleDexFileExtension
// Rename file
if err := entry.Rename(newTurtleDexFilePath); err != nil {
t.Fatal("Failed to rename file", err)
}
// Check if the file was moved.
if _, err := os.Open(oldTurtleDexFilePath); !os.IsNotExist(err) {
t.Fatal("Expected a file doesn't exist error but got", err)
}
f, err := os.Open(newTurtleDexFilePath)
if err != nil {
t.Fatal("Failed to open file at new location", err)
}
if err := f.Close(); err != nil {
t.Fatal(err)
}
// Check the metadata.
if entry.siaFilePath != newTurtleDexFilePath {
t.Fatal("TurtleDexFilePath wasn't updated correctly")
}
if entry.TurtleDexFilePath() != newTurtleDexFilePath {
t.Fatal("TurtleDexPath wasn't updated correctly", entry.TurtleDexFilePath(), newTurtleDexFilePath)
}
} | explode_data.jsonl/14692 | {
"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,
88757,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
7039,
741,
197,
532,
3244,
41288,
7957,
2822,
197,
322,
4230,
66806,
35,
327,
1703,
1649,
448,
66806,
35,
327,
1703,
198,
48344,
1669,
501,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddJitterToChunkEndTime_ShouldHonorMaxVarianceAndMaxNextAt(t *testing.T) {
chunkMinTime := int64(10)
nextAt := int64(95)
maxNextAt := int64(100)
variance := 0.2
// Compute the expected max variance.
expectedMaxVariance := int64(float64(nextAt-chunkMinTime) * variance)
for seriesHash := uint64(0); seriesHash < 1000; seriesHash++ {
actual := addJitterToChunkEndTime(seriesHash, chunkMinTime, nextAt, maxNextAt, variance)
require.GreaterOrEqual(t, actual, nextAt-(expectedMaxVariance/2))
require.LessOrEqual(t, actual, maxNextAt)
}
} | explode_data.jsonl/60338 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
2212,
41,
3248,
1249,
28304,
55833,
36578,
616,
39,
54037,
5974,
53,
36905,
3036,
5974,
5847,
1655,
1155,
353,
8840,
836,
8,
341,
23049,
3122,
6217,
1462,
1669,
526,
21,
19,
7,
16,
15,
340,
28144,
1655,
1669,
526,
21,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSpanErrorNil(t *testing.T) {
assert := assert.New(t)
tracer := newTracer(withTransport(newDefaultTransport()))
span := tracer.newRootSpan("pylons.request", "pylons", "/")
// don't set the error if it's nil
nMeta := len(span.Meta)
span.SetTag(ext.Error, nil)
assert.Equal(int32(0), span.Error)
assert.Equal(nMeta, len(span.Meta))
} | explode_data.jsonl/42850 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
12485,
1454,
19064,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
25583,
9584,
1669,
501,
1282,
9584,
16980,
27560,
1755,
3675,
27560,
12145,
197,
1480,
1669,
64306,
4618,
8439,
12485,
445,
3288,
75,
2382,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMakeIdentifier(t *testing.T) {
t.Parallel()
id := makeIdentifier()
if len(id) < 10 {
t.Errorf("expected a string of length 10 at least")
}
} | explode_data.jsonl/5210 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 60
} | [
2830,
3393,
8078,
8714,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
15710,
1669,
1281,
8714,
741,
743,
2422,
3724,
8,
366,
220,
16,
15,
341,
197,
3244,
13080,
445,
7325,
264,
914,
315,
3084,
220,
16,
15,
518,
3245,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestNewClientWithSkipVerify(t *testing.T) {
assert := assert.New(t)
var druidOpts []ClientOption
druidOpts = append(druidOpts, WithSkipTLSVerify())
d, err := NewClient("localhost:8082", druidOpts...)
assert.Nil(err, "error should be nil")
assert.NotNil(d, "client should not be nil")
assert.True(d.http.HTTPClient.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify, "insecure skip verify should be true")
} | explode_data.jsonl/28557 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
3564,
2959,
2354,
35134,
32627,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
2405,
1353,
2423,
43451,
3056,
2959,
5341,
198,
2698,
81,
2423,
43451,
284,
8737,
30958,
2423,
43451,
11,
3085,
35134,
45439,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKafkaClient_decodeOffsetValueV0_Errors(t *testing.T) {
for _, values := range decodeOffsetValueV0Errors {
_, errorAt := decodeOffsetValueV0(bytes.NewBuffer(values.Bytes))
assert.Equalf(t, values.ErrorAt, errorAt, "Expected errorAt to be %v, not %v", values.ErrorAt, errorAt)
}
} | explode_data.jsonl/34268 | {
"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,
42,
21883,
2959,
15227,
6446,
1130,
53,
15,
93623,
1087,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
2750,
1669,
2088,
16895,
6446,
1130,
53,
15,
13877,
341,
197,
197,
6878,
1465,
1655,
1669,
16895,
6446,
1130,
53,
15,
23158... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHITS(t *testing.T) {
for i, test := range hitsTests {
g := simple.NewDirectedGraph()
for u, e := range test.g {
// Add nodes that are not defined by an edge.
if g.Node(int64(u)) == nil {
g.AddNode(simple.Node(u))
}
for v := range e {
g.SetEdge(simple.Edge{F: simple.Node(u), T: simple.Node(v)})
}
}
got := HITS(g, test.tol)
prec := 1 - int(math.Log10(test.wantTol))
for n := range test.g {
if !floats.EqualWithinAbsOrRel(got[int64(n)].Hub, test.want[int64(n)].Hub, test.wantTol, test.wantTol) {
t.Errorf("unexpected HITS result for test %d:\ngot: %v\nwant:%v",
i, orderedHubAuth(got, prec), orderedHubAuth(test.want, prec))
break
}
if !floats.EqualWithinAbsOrRel(got[int64(n)].Authority, test.want[int64(n)].Authority, test.wantTol, test.wantTol) {
t.Errorf("unexpected HITS result for test %d:\ngot: %v\nwant:%v",
i, orderedHubAuth(got, prec), orderedHubAuth(test.want, prec))
break
}
}
}
} | explode_data.jsonl/73757 | {
"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,
39,
14474,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
12983,
18200,
341,
197,
3174,
1669,
4285,
7121,
92669,
11212,
741,
197,
2023,
575,
11,
384,
1669,
2088,
1273,
1302,
341,
298,
197,
322,
2691,
7798,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEExact(t *testing.T) {
xsdvalidate.Init()
defer xsdvalidate.Cleanup()
xsdhandler, err := xsdvalidate.NewXsdHandlerUrl("docs/eExact-Schema.xsd", xsdvalidate.ParsErrDefault)
if err != nil {
panic(err)
}
defer xsdhandler.Free()
eExact := globe.EExact{
GLEntries: globe.GLEntries{
{
Description: "test",
FinEntryLines: globe.FinEntryLines{
{
Description: "test 1",
},
{
Description: "test 2",
},
},
},
},
Accounts: globe.Accounts{
{
Name: "Name 1",
},
{
Name: "Name 2",
},
},
}
inXML, err := xml.MarshalIndent(eExact, "", " ")
if err != nil {
t.Error(err)
}
log.Println(string(inXML))
err = xsdhandler.ValidateMem(inXML, xsdvalidate.ValidErrDefault)
if err != nil {
switch err.(type) {
case xsdvalidate.ValidationError:
fmt.Println(err)
fmt.Printf("Error in line: %d\n", err.(xsdvalidate.ValidationError).Errors[0].Line)
fmt.Println(err.(xsdvalidate.ValidationError).Errors[0].Message)
default:
fmt.Println(err)
}
}
} | explode_data.jsonl/77557 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 506
} | [
2830,
3393,
36,
57954,
1155,
353,
8840,
836,
8,
341,
10225,
13446,
7067,
26849,
741,
16867,
11943,
67,
7067,
727,
60639,
741,
10225,
13446,
17905,
11,
1848,
1669,
11943,
67,
7067,
7121,
55,
13446,
3050,
2864,
445,
14120,
16546,
57954,
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... | 5 |
func Test_preorderTraversal(t *testing.T) {
assert := assert.New(t)
assert.Equal([]int{1, 2, 3}, preorderTraversal(&TreeNode{Val: 1, Right: &TreeNode{Val: 2, Left: &TreeNode{Val: 3}}}))
} | explode_data.jsonl/32244 | {
"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,
10442,
1358,
76276,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
6948,
12808,
10556,
396,
90,
16,
11,
220,
17,
11,
220,
18,
2137,
71850,
76276,
2099,
26597,
90,
2208,
25,
220,
16,
11,
10083,
25,
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 |
func TestNilAttributeMap(t *testing.T) {
assert.EqualValues(t, 0, NewAttributeMap().Len())
val, exist := NewAttributeMap().Get("test_key")
assert.False(t, exist)
assert.EqualValues(t, AttributeValue{nil}, val)
insertMap := NewAttributeMap()
insertMap.Insert("k", NewAttributeValueString("v"))
assert.EqualValues(t, generateTestAttributeMap(), insertMap)
insertMapString := NewAttributeMap()
insertMapString.InsertString("k", "v")
assert.EqualValues(t, generateTestAttributeMap(), insertMapString)
insertMapNull := NewAttributeMap()
insertMapNull.InsertNull("k")
assert.EqualValues(t, generateTestNullAttributeMap(), insertMapNull)
insertMapInt := NewAttributeMap()
insertMapInt.InsertInt("k", 123)
assert.EqualValues(t, generateTestIntAttributeMap(), insertMapInt)
insertMapDouble := NewAttributeMap()
insertMapDouble.InsertDouble("k", 12.3)
assert.EqualValues(t, generateTestDoubleAttributeMap(), insertMapDouble)
insertMapBool := NewAttributeMap()
insertMapBool.InsertBool("k", true)
assert.EqualValues(t, generateTestBoolAttributeMap(), insertMapBool)
updateMap := NewAttributeMap()
updateMap.Update("k", NewAttributeValueString("v"))
assert.EqualValues(t, NewAttributeMap(), updateMap)
updateMapString := NewAttributeMap()
updateMapString.UpdateString("k", "v")
assert.EqualValues(t, NewAttributeMap(), updateMapString)
updateMapInt := NewAttributeMap()
updateMapInt.UpdateInt("k", 123)
assert.EqualValues(t, NewAttributeMap(), updateMapInt)
updateMapDouble := NewAttributeMap()
updateMapDouble.UpdateDouble("k", 12.3)
assert.EqualValues(t, NewAttributeMap(), updateMapDouble)
updateMapBool := NewAttributeMap()
updateMapBool.UpdateBool("k", true)
assert.EqualValues(t, NewAttributeMap(), updateMapBool)
upsertMap := NewAttributeMap()
upsertMap.Upsert("k", NewAttributeValueString("v"))
assert.EqualValues(t, generateTestAttributeMap(), upsertMap)
upsertMapString := NewAttributeMap()
upsertMapString.UpsertString("k", "v")
assert.EqualValues(t, generateTestAttributeMap(), upsertMapString)
upsertMapInt := NewAttributeMap()
upsertMapInt.UpsertInt("k", 123)
assert.EqualValues(t, generateTestIntAttributeMap(), upsertMapInt)
upsertMapDouble := NewAttributeMap()
upsertMapDouble.UpsertDouble("k", 12.3)
assert.EqualValues(t, generateTestDoubleAttributeMap(), upsertMapDouble)
upsertMapBool := NewAttributeMap()
upsertMapBool.UpsertBool("k", true)
assert.EqualValues(t, generateTestBoolAttributeMap(), upsertMapBool)
deleteMap := NewAttributeMap()
assert.False(t, deleteMap.Delete("k"))
assert.EqualValues(t, NewAttributeMap(), deleteMap)
// Test Sort
assert.EqualValues(t, NewAttributeMap(), NewAttributeMap().Sort())
} | explode_data.jsonl/38196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 867
} | [
2830,
3393,
19064,
3907,
2227,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
6227,
1155,
11,
220,
15,
11,
1532,
3907,
2227,
1005,
11271,
12367,
19302,
11,
3000,
1669,
1532,
3907,
2227,
1005,
1949,
445,
1944,
3097,
1138,
6948,
50757,
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... | 1 |
func TestStore_GetVulnerabilityMetadata_SetVulnerabilityMetadata(t *testing.T) {
dbTempFile, err := ioutil.TempFile("", "grype-db-test-store")
if err != nil {
t.Fatalf("could not create temp file: %+v", err)
}
defer os.Remove(dbTempFile.Name())
store, cleanupFn, err := New(dbTempFile.Name(), true)
defer cleanupFn()
if err != nil {
t.Fatalf("could not create store: %+v", err)
}
total := []v2.VulnerabilityMetadata{
{
ID: "my-cve",
RecordSource: "record-source",
Severity: "pretty bad",
Links: []string{"https://ancho.re"},
Description: "best description ever",
CvssV2: &v2.Cvss{
BaseScore: 1.1,
ExploitabilityScore: 2.2,
ImpactScore: 3.3,
Vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P--NOT",
},
CvssV3: &v2.Cvss{
BaseScore: 1.3,
ExploitabilityScore: 2.1,
ImpactScore: 3.2,
Vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P--NICE",
},
},
{
ID: "my-other-cve",
RecordSource: "record-source",
Severity: "pretty bad",
Links: []string{"https://ancho.re"},
Description: "worst description ever",
CvssV2: &v2.Cvss{
BaseScore: 4.1,
ExploitabilityScore: 5.2,
ImpactScore: 6.3,
Vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P--VERY",
},
CvssV3: &v2.Cvss{
BaseScore: 1.4,
ExploitabilityScore: 2.5,
ImpactScore: 3.6,
Vector: "AV:N/AC:L/Au:N/C:P/I:P/A:P--GOOD",
},
},
}
if err = store.AddVulnerabilityMetadata(total...); err != nil {
t.Fatalf("failed to set metadata: %+v", err)
}
var allEntries []model.VulnerabilityMetadataModel
store.db.Find(&allEntries)
if len(allEntries) != len(total) {
t.Fatalf("unexpected number of entries: %d", len(allEntries))
}
// gut check on reader
storeReader, othercleanfn, err := reader.New(dbTempFile.Name())
defer othercleanfn()
if err != nil {
t.Fatalf("could not open db reader: %+v", err)
}
assertVulnerabilityMetadataReader(t, storeReader, total[0].ID, total[0].RecordSource, total[0])
} | explode_data.jsonl/78503 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1079
} | [
2830,
3393,
6093,
13614,
53,
58401,
2897,
14610,
14812,
53,
58401,
2897,
14610,
1155,
353,
8840,
836,
8,
341,
20939,
12151,
1703,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
901,
499,
60399,
16839,
33252,
1138,
743,
1848,
961,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestLogoutCommand(t *testing.T) {
_, session := setupTest()
log := &logout{tag: "A00004"}
resp := log.execute(session)
if (resp.tag != "A00004") || (resp.message != "LOGOUT completed") || (resp.untagged[0] != "BYE IMAP4rev1 Server logging out") {
t.Error("Logout Failed - unexpected response.")
fmt.Println(resp)
}
} | explode_data.jsonl/9589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
27958,
4062,
1155,
353,
8840,
836,
8,
341,
197,
6878,
3797,
1669,
6505,
2271,
741,
6725,
1669,
609,
15937,
90,
4578,
25,
330,
32,
15,
15,
15,
15,
19,
16707,
34653,
1669,
1487,
7769,
16264,
340,
743,
320,
18243,
12399,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUserGroup(t *testing.T) {
userGroup := models.UserGroup{GroupName: "insert_group", GroupType: common.LDAPGroupType, LdapGroupDN: "ldap_dn_string"}
result, err := AddUserGroup(userGroup)
if err != nil {
t.Errorf("Error occurred when AddUserGroup: %v", err)
}
createdUserGroupID = result
type args struct {
id int
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{"Get User Group", args{id: result}, "insert_group", false},
{"Get User Group does not exist", args{id: 9999}, "insert_group", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetUserGroup(tt.args.id)
if (err != nil) != tt.wantErr {
t.Errorf("GetUserGroup() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != nil && got.GroupName != tt.want {
t.Errorf("GetUserGroup() = %v, want %v", got.GroupName, tt.want)
}
})
}
} | explode_data.jsonl/73816 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
1949,
1474,
2808,
1155,
353,
8840,
836,
8,
341,
19060,
2808,
1669,
4119,
7344,
2808,
90,
50569,
25,
330,
4208,
6288,
497,
5737,
929,
25,
4185,
1214,
35,
2537,
2808,
929,
11,
444,
91294,
2808,
31264,
25,
330,
38665,
69799,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAttachmentService_Human(t *testing.T) {
testCases := []struct {
name string
attachmentID string
mockFile string
wantHTTPMethod string
endpoint string
context context.Context
wantHTTPCodeReturn int
wantErr bool
}{
{
name: "GetHumanReadableAttachmentWhenTheAttachmentIDIsCorrect",
mockFile: "./mocks/get-attachment-human-view.json",
attachmentID: "10006",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: false,
},
{
name: "GetHumanReadableAttachmentWhenTheAttachmentIDIsNotSet",
mockFile: "./mocks/get-attachment-human-view.json",
attachmentID: "",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
{
name: "GetHumanReadableAttachmentWhenTheAttachmentIDIsIncorrect",
attachmentID: "10007",
mockFile: "./mocks/get-attachment-human-view.json",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
{
name: "GetHumanReadableAttachmentWhenTheAttachmentIDIsEmpty",
attachmentID: "",
mockFile: "./mocks/get-attachment-human-view.json",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
{
name: "GetHumanReadableAttachmentWhenTheAttachmentIDHasSpecialCharacters",
attachmentID: "((*^%%**",
mockFile: "./mocks/get-attachment-human-view.json",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
{
name: "GetHumanReadableAttachmentWhenTheContextIsNil",
attachmentID: "10006",
mockFile: "./mocks/get-attachment-human-view.json",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: nil,
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
{
name: "GetHumanReadableAttachmentWhenTheRequestMethodIsDifferent",
attachmentID: "10006",
mockFile: "./mocks/get-attachment-human-view.json",
wantHTTPMethod: http.MethodPost,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
{
name: "GetHumanReadableAttachmentWhenTheResponseBodyHasADifferentFormat",
mockFile: "./mocks/empty_json.json",
attachmentID: "10006",
wantHTTPMethod: http.MethodGet,
endpoint: "/rest/api/3/attachment/10006/expand/human",
context: context.Background(),
wantHTTPCodeReturn: http.StatusOK,
wantErr: true,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
//Init a new HTTP mock server
mockOptions := mockServerOptions{
Endpoint: testCase.endpoint,
MockFilePath: testCase.mockFile,
MethodAccepted: testCase.wantHTTPMethod,
ResponseCodeWanted: testCase.wantHTTPCodeReturn,
}
mockServer, err := startMockServer(&mockOptions)
if err != nil {
t.Fatal(err)
}
defer mockServer.Close()
//Init the library instance
mockClient, err := startMockClient(mockServer.URL)
if err != nil {
t.Fatal(err)
}
service := &AttachmentService{client: mockClient}
getResult, gotResponse, err := service.Human(testCase.context, testCase.attachmentID)
if testCase.wantErr {
if err != nil {
t.Logf("error returned: %v", err.Error())
}
assert.Error(t, err)
if gotResponse != nil {
t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.StatusCode)
}
} else {
assert.NoError(t, err)
assert.NotEqual(t, gotResponse, nil)
assert.NotEqual(t, getResult, nil)
apiEndpoint, err := url.Parse(gotResponse.Endpoint)
if err != nil {
t.Fatal(err)
}
var endpointToAssert string
if apiEndpoint.Query().Encode() != "" {
endpointToAssert = fmt.Sprintf("%v?%v", apiEndpoint.Path, apiEndpoint.Query().Encode())
} else {
endpointToAssert = apiEndpoint.Path
}
t.Logf("HTTP Endpoint Wanted: %v, HTTP Endpoint Returned: %v", testCase.endpoint, endpointToAssert)
assert.Equal(t, testCase.endpoint, endpointToAssert)
t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.StatusCode)
assert.Equal(t, gotResponse.StatusCode, testCase.wantHTTPCodeReturn)
}
})
}
} | explode_data.jsonl/50070 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2502
} | [
2830,
3393,
33569,
1860,
2039,
7136,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
2290,
914,
198,
197,
197,
21981,
915,
981,
914,
198,
197,
77333,
1703,
1843,
914,
198,
197,
50780,
9230,
3523,
257,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateRequestBody(t *testing.T) {
requiredReqBody := openapi3.NewRequestBody().
WithContent(openapi3.NewContentWithJSONSchema(openapi3.NewStringSchema())).
WithRequired(true)
plainTextContent := openapi3.NewContent()
plainTextContent["text/plain"] = openapi3.NewMediaType().WithSchema(openapi3.NewStringSchema())
testCases := []struct {
name string
body *openapi3.RequestBody
mime string
data io.Reader
wantErr error
}{
{
name: "non required empty",
body: openapi3.NewRequestBody().
WithContent(openapi3.NewContentWithJSONSchema(openapi3.NewStringSchema())),
},
{
name: "non required not empty",
body: openapi3.NewRequestBody().
WithContent(openapi3.NewContentWithJSONSchema(openapi3.NewStringSchema())),
mime: "application/json",
data: toJSON("foo"),
},
{
name: "required empty",
body: requiredReqBody,
wantErr: &openapi3filter.RequestError{RequestBody: requiredReqBody, Err: openapi3filter.ErrInvalidRequired},
},
{
name: "required not empty",
body: requiredReqBody,
mime: "application/json",
data: toJSON("foo"),
},
{
name: "not JSON data",
body: openapi3.NewRequestBody().WithContent(plainTextContent).WithRequired(true),
mime: "text/plain",
data: strings.NewReader("foo"),
},
{
name: "not declared content",
body: openapi3.NewRequestBody().WithRequired(true),
mime: "application/json",
data: toJSON("foo"),
},
{
name: "not declared schema",
body: openapi3.NewRequestBody().WithJSONSchemaRef(nil),
mime: "application/json",
data: toJSON("foo"),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
req := httptest.NewRequest(http.MethodPost, "/test", tc.data)
if tc.mime != "" {
req.Header.Set(http.CanonicalHeaderKey("Content-Type"), tc.mime)
}
inp := &openapi3filter.RequestValidationInput{Request: req}
err := openapi3filter.ValidateRequestBody(context.Background(), inp, tc.body)
if tc.wantErr == nil {
require.NoError(t, err)
return
}
require.True(t, matchReqBodyError(tc.wantErr, err), "got error:\n%s\nwant error\n%s", err, tc.wantErr)
})
}
} | explode_data.jsonl/41695 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 886
} | [
2830,
3393,
17926,
33334,
1155,
353,
8840,
836,
8,
341,
58183,
27234,
5444,
1669,
1787,
2068,
18,
7121,
33334,
25829,
197,
197,
2354,
2762,
30981,
2068,
18,
7121,
2762,
2354,
5370,
8632,
30981,
2068,
18,
7121,
703,
8632,
2140,
4292,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestValidateIgnoreHeadersFails(t *testing.T) {
ignoreHeaders := []string{
"Host",
"Connection",
}
allErrs := validateIgnoreHeaders(ignoreHeaders, field.NewPath("ignoreHeaders"))
if len(allErrs) == 0 {
t.Errorf("validateIgnoreHeaders(%v) returned no errors for invalid input", ignoreHeaders)
}
} | explode_data.jsonl/65905 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
17926,
12497,
10574,
37,
6209,
1155,
353,
8840,
836,
8,
341,
197,
13130,
10574,
1669,
3056,
917,
515,
197,
197,
1,
9296,
756,
197,
197,
1,
4526,
756,
197,
630,
50960,
7747,
82,
1669,
9593,
12497,
10574,
96426,
10574,
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 TestSyncToSignedCommitKeyWithKnownKey(t *testing.T) {
Given(t).
Project("gpg").
Path(guestbookPath).
GPGPublicKeyAdded().
Sleep(2).
When().
AddSignedFile("test.yaml", "null").
IgnoreErrors().
Create().
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy))
} | explode_data.jsonl/66665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
12154,
1249,
49312,
33441,
1592,
2354,
48206,
1592,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
197,
7849,
445,
70,
3517,
38609,
197,
69640,
3268,
3045,
2190,
1820,
4292,
197,
9600,
11383,
61822,
19337,
25829,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmailCallbackURL(t *testing.T) {
type args struct {
baseurl string
email string
secret string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
// TODO: Add test cases.
{
name: "Valid callback",
args: args{
baseurl: "https://example.com",
email: "hello@example.com",
secret: "secret with special chars!@to be encoded",
},
want: "https://example.com?email=hello%40example.com&secret=secret+with+special+chars%21%40to+be+encoded",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := EmailCallbackURL(tt.args.baseurl, tt.args.email, tt.args.secret)
if (err != nil) != tt.wantErr {
t.Errorf("EmailCallbackURL() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("EmailCallbackURL() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/58087 | {
"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,
4781,
7494,
3144,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
24195,
1085,
914,
198,
197,
57549,
256,
914,
198,
197,
197,
20474,
220,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFillKubeProxyDefaults(t *testing.T) {
g := NewGomegaWithT(t)
trueVar := true
falseVar := false
testcases := []struct {
in *operv1.NetworkSpec
out *operv1.NetworkSpec
}{
// no bind address and cluster CIDR is IPv4
{
in: &operv1.NetworkSpec{
ClusterNetwork: []operv1.ClusterNetworkEntry{
{
CIDR: "192.168.0.0/14",
HostPrefix: 23,
},
},
DeployKubeProxy: &trueVar,
},
out: &operv1.NetworkSpec{
ClusterNetwork: []operv1.ClusterNetworkEntry{
{
CIDR: "192.168.0.0/14",
HostPrefix: 23,
},
},
DeployKubeProxy: &trueVar,
KubeProxyConfig: &operv1.ProxyConfig{
BindAddress: "0.0.0.0",
},
},
},
// no bind address and cluster CIDR is IPv6
{
in: &operv1.NetworkSpec{
ClusterNetwork: []operv1.ClusterNetworkEntry{
{
CIDR: "fd00:1234::/64",
HostPrefix: 23,
},
},
DeployKubeProxy: &trueVar,
},
out: &operv1.NetworkSpec{
ClusterNetwork: []operv1.ClusterNetworkEntry{
{
CIDR: "fd00:1234::/64",
HostPrefix: 23,
},
},
DeployKubeProxy: &trueVar,
KubeProxyConfig: &operv1.ProxyConfig{
BindAddress: "::",
},
},
},
// no bind address and no deploy kube-proxy
{
in: &operv1.NetworkSpec{
ClusterNetwork: []operv1.ClusterNetworkEntry{
{
CIDR: "fd00:1234::/64",
HostPrefix: 23,
},
},
DeployKubeProxy: &falseVar,
},
out: &operv1.NetworkSpec{
ClusterNetwork: []operv1.ClusterNetworkEntry{
{
CIDR: "fd00:1234::/64",
HostPrefix: 23,
},
},
DeployKubeProxy: &falseVar,
},
},
}
for _, tc := range testcases {
fillKubeProxyDefaults(tc.in, nil)
g.Expect(tc.in).To(Equal(tc.out))
}
} | explode_data.jsonl/57156 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 951
} | [
2830,
3393,
14449,
42,
3760,
16219,
16273,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
692,
42808,
3962,
1669,
830,
198,
36012,
3962,
1669,
895,
271,
18185,
23910,
1669,
3056,
1235,
341,
197,
17430,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSpx2(t *testing.T) {
gopSpxTestEx(t, `
println("Hi")
`, `
func onMsg(msg string) {
}
`, `package main
import (
fmt "fmt"
spx2 "github.com/goplus/gop/cl/internal/spx2"
)
type Game struct {
spx2.Game
}
func (this *Game) MainEntry() {
fmt.Println("Hi")
}
func main() {
new(Game).Main()
}
type Kai struct {
spx2.Sprite
*Game
}
func (this *Kai) onMsg(msg string) {
}
`, "Game.t2gmx", "Kai.t2spx")
} | explode_data.jsonl/78668 | {
"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,
50,
1767,
17,
1155,
353,
8840,
836,
8,
341,
3174,
453,
50,
1767,
2271,
840,
1155,
11,
22074,
33655,
445,
13048,
1138,
7808,
22074,
2830,
389,
6611,
8119,
914,
8,
341,
532,
7808,
1565,
1722,
1887,
271,
474,
2399,
11009,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestModifyUser(t *testing.T) {
ts := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, modifyUserResponse)
}),
)
defer ts.Close()
duo := buildAdminClient(ts.URL, nil)
userToModify := User{
UserID: "DU3RP9I2WOC59VZX672N",
Email: "jsmith-new@example.com",
}
result, err := duo.ModifyUser(userToModify.UserID, userToModify)
if err != nil {
t.Errorf("Unexpected error from ModifyUser call %v", err.Error())
}
if result.Stat != "OK" {
t.Errorf("Expected OK, but got %s", result.Stat)
}
if result.Response.UserID != userToModify.UserID {
t.Errorf("Expected UserID to be %s, but got %s", userToModify.UserID, result.Response.UserID)
}
if result.Response.Email != userToModify.Email {
t.Errorf("Expected Email to be %s, but got %s", userToModify.Email, result.Response.Email)
}
} | explode_data.jsonl/61400 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
44427,
1474,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
1006,
197,
28080,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
298,
11009,
991,
33655,
3622,
11,
5602,
1474... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStepper_Date_After(t *testing.T) {
hourSt := Stepper{
N: 2,
U: Uhour,
}
daySt := Stepper{
N: 2,
U: Uday,
}
testTime := time.Date(2021, 1, 17, 17, 45, 04, 0, time.UTC)
hour, err := hourSt.After(testTime)
assert.NoError(t, err)
assert.Equal(t, 19, hour.(time.Time).Hour())
day, err := daySt.After(testTime)
assert.NoError(t, err)
assert.Equal(t, 19, day.(time.Time).Day())
} | explode_data.jsonl/78066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
20903,
6922,
39564,
1566,
1046,
1155,
353,
8840,
836,
8,
341,
9598,
413,
623,
1669,
3360,
6922,
515,
197,
18317,
25,
220,
17,
345,
197,
15980,
25,
547,
24677,
345,
197,
532,
98197,
623,
1669,
3360,
6922,
515,
197,
18317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyLast(t *testing.T) {
t.Parallel()
slice := ring.New(15)
last := slice.Last()
if last != nil {
t.Error("Non-nil last value returned for empty ring")
}
} | explode_data.jsonl/14677 | {
"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,
3522,
5842,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1903,
4754,
1669,
10058,
7121,
7,
16,
20,
340,
33096,
1669,
15983,
24682,
741,
743,
1537,
961,
2092,
341,
197,
3244,
6141,
445,
8121,
83248,
1537,
897,
592... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplyOldSavePath(t *testing.T) {
t.Parallel()
fName := "TestApplyOldSavePath"
defer cleanup(fName)
writeOldFile(fName, t)
oldfName := "OldSavePath"
err := Apply(bytes.NewReader(newFile), Options{
TargetPath: fName,
OldSavePath: oldfName,
})
validateUpdate(fName, err, t)
if _, err := os.Stat(oldfName); os.IsNotExist(err) {
t.Fatalf("Failed to find the old file: %v", err)
}
cleanup(oldfName)
} | explode_data.jsonl/73981 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
28497,
18284,
8784,
1820,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
675,
1669,
330,
2271,
28497,
18284,
8784,
1820,
698,
16867,
21290,
955,
675,
340,
24945,
18284,
1703,
955,
675,
11,
259,
692,
61828,
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... | 2 |
func TestReflect_struct(t *testing.T) {
var expected testStruct = testStruct{42, "hello", 12.5}
var actual testStruct
b := make([]byte, 18)
lex.PutInt(b, expected.A)
lex.PutString(b[8:], expected.B)
lex.PutFloat32(b[14:], expected.C)
lex.Reflect(b, &actual)
assert.Equal(t, expected, actual)
} | explode_data.jsonl/50152 | {
"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,
72789,
15126,
1155,
353,
8840,
836,
8,
341,
2405,
3601,
1273,
9422,
284,
1273,
9422,
90,
19,
17,
11,
330,
14990,
497,
220,
16,
17,
13,
20,
532,
2405,
5042,
1273,
9422,
271,
2233,
1669,
1281,
10556,
3782,
11,
220,
16,
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 TestObjectReference(t *testing.T) {
testConfig := []byte(`metrics:
- name: submatch
event_matcher:
- key: Type
expr: Normal
labels:
node: Object.Spec.NodeName
`)
config, err := NewConfig(bytes.NewBuffer(testConfig))
require.NoError(t, err, "There should be no error while unmarshaling config")
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pod",
Namespace: "test-namespace",
},
Spec: v1.PodSpec{NodeName: "test-node"},
}
fakeClient := fake.NewSimpleClientset(pod)
testEvent := v1.Event{
InvolvedObject: v1.ObjectReference{
Kind: "Pod",
Namespace: pod.Namespace,
Name: pod.Name,
APIVersion: "v1",
},
Type: "Normal",
}
matches := LogEvent(&testEvent, &EventRouter{Config: config, kubeClient: fakeClient})
require.Equal(t, []FilterMatch{
FilterMatch{Name: "submatch", Labels: map[string]string{"node": pod.Spec.NodeName}},
}, matches)
} | explode_data.jsonl/36670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 375
} | [
2830,
3393,
1190,
8856,
1155,
353,
8840,
836,
8,
341,
18185,
2648,
1669,
3056,
3782,
5809,
43262,
510,
12,
829,
25,
1186,
6347,
198,
220,
1538,
10708,
261,
510,
220,
481,
1376,
25,
3990,
198,
262,
15169,
25,
18437,
198,
220,
9201,
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 TestSimpleSend(t *testing.T) {
c := newTestContext(t, 20000, 1500, localLinkAddr)
defer c.cleanup()
// Prepare route.
r := stack.Route{
RemoteLinkAddress: remoteLinkAddr,
}
for iters := 1000; iters > 0; iters-- {
// Prepare and send packet.
n := rand.Intn(10000)
hdr := buffer.NewPrependable(n + int(c.ep.MaxHeaderLength()))
hdrBuf := hdr.Prepend(n)
randomFill(hdrBuf)
n = rand.Intn(10000)
buf := buffer.NewView(n)
randomFill(buf)
proto := tcpip.NetworkProtocolNumber(rand.Intn(0x10000))
err := c.ep.WritePacket(&r, &hdr, buf, proto)
if err != nil {
t.Fatalf("WritePacket failed: %v", err)
}
// Receive packet.
desc := c.txq.tx.Pull()
pi := queue.DecodeTxPacketHeader(desc)
contents := make([]byte, 0, pi.Size)
for i := 0; i < pi.BufferCount; i++ {
bi := queue.DecodeTxBufferHeader(desc, i)
contents = append(contents, c.txq.data[bi.Offset:][:bi.Size]...)
}
c.txq.tx.Flush()
if pi.Reserved != 0 {
t.Fatalf("Reserved value is non-zero: 0x%x", pi.Reserved)
}
// Check the thernet header.
ethTemplate := make(header.Ethernet, header.EthernetMinimumSize)
ethTemplate.Encode(&header.EthernetFields{
SrcAddr: localLinkAddr,
DstAddr: remoteLinkAddr,
Type: proto,
})
if got := contents[:header.EthernetMinimumSize]; !reflect.DeepEqual(got, []byte(ethTemplate)) {
t.Fatalf("Bad ethernet header in packet: got %x, want %x", got, ethTemplate)
}
// Compare contents skipping the ethernet header added by the
// endpoint.
merged := append(hdrBuf, buf...)
if uint32(len(contents)) < pi.Size {
t.Fatalf("Sum of buffers is less than packet size: %v < %v", len(contents), pi.Size)
}
contents = contents[:pi.Size][header.EthernetMinimumSize:]
if !reflect.DeepEqual(contents, merged) {
t.Fatalf("Buffers are different: got %x (%v bytes), want %x (%v bytes)", contents, len(contents), merged, len(merged))
}
// Tell the endpoint about the completion of the write.
b := c.txq.rx.Push(8)
queue.EncodeTxCompletion(b, pi.ID)
c.txq.rx.Flush()
}
} | explode_data.jsonl/4233 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 846
} | [
2830,
3393,
16374,
11505,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
501,
2271,
1972,
1155,
11,
220,
17,
15,
15,
15,
15,
11,
220,
16,
20,
15,
15,
11,
2205,
3939,
13986,
340,
16867,
272,
87689,
2822,
197,
322,
31166,
6021,
624,
7000... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateKeyToPath(t *testing.T) {
testCases := []struct {
kp core.KeyToPath
ok bool
errtype field.ErrorType
}{
{
kp: core.KeyToPath{Key: "k", Path: "p"},
ok: true,
},
{
kp: core.KeyToPath{Key: "k", Path: "p/p/p/p"},
ok: true,
},
{
kp: core.KeyToPath{Key: "k", Path: "p/..p/p../p..p"},
ok: true,
},
{
kp: core.KeyToPath{Key: "k", Path: "p", Mode: utilpointer.Int32Ptr(0644)},
ok: true,
},
{
kp: core.KeyToPath{Key: "", Path: "p"},
ok: false,
errtype: field.ErrorTypeRequired,
},
{
kp: core.KeyToPath{Key: "k", Path: ""},
ok: false,
errtype: field.ErrorTypeRequired,
},
{
kp: core.KeyToPath{Key: "k", Path: "..p"},
ok: false,
errtype: field.ErrorTypeInvalid,
},
{
kp: core.KeyToPath{Key: "k", Path: "../p"},
ok: false,
errtype: field.ErrorTypeInvalid,
},
{
kp: core.KeyToPath{Key: "k", Path: "p/../p"},
ok: false,
errtype: field.ErrorTypeInvalid,
},
{
kp: core.KeyToPath{Key: "k", Path: "p/.."},
ok: false,
errtype: field.ErrorTypeInvalid,
},
{
kp: core.KeyToPath{Key: "k", Path: "p", Mode: utilpointer.Int32Ptr(01000)},
ok: false,
errtype: field.ErrorTypeInvalid,
},
{
kp: core.KeyToPath{Key: "k", Path: "p", Mode: utilpointer.Int32Ptr(-1)},
ok: false,
errtype: field.ErrorTypeInvalid,
},
}
for i, tc := range testCases {
errs := validateKeyToPath(&tc.kp, field.NewPath("field"))
if tc.ok && len(errs) > 0 {
t.Errorf("[%d] unexpected errors: %v", i, errs)
} else if !tc.ok && len(errs) == 0 {
t.Errorf("[%d] expected error type %v", i, tc.errtype)
} else if len(errs) > 1 {
t.Errorf("[%d] expected only one error, got %d", i, len(errs))
} else if !tc.ok {
if errs[0].Type != tc.errtype {
t.Errorf("[%d] expected error type %v, got %v", i, tc.errtype, errs[0].Type)
}
}
}
} | explode_data.jsonl/1000 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1017
} | [
2830,
3393,
17926,
1592,
1249,
1820,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
16463,
79,
414,
6200,
9610,
1249,
1820,
198,
197,
59268,
414,
1807,
198,
197,
9859,
1313,
2070,
6141,
929,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestPoolError(t *testing.T) {
assert := assert.New(t)
var (
panicCount = uint32(0)
panicHandler = func(alias string, err interface{}) {
atomic.AddUint32(&panicCount, 1)
// Do work panic
assert.Equal(alias, fmt.Sprintf("%s-%d", poolName, 1))
}
pool = New(poolName, numWorkers, panicHandler)
executed uint32
)
pool.Submit(func() {
panic("Some erroneous job")
atomic.AddUint32(&executed, 1)
}, 1+rand.Float64())
pool.WaitGroup().Wait()
pool.ShutDown()
assert.Zero(atomic.LoadUint32(&executed))
assert.Greater(atomic.LoadUint32(&panicCount), uint32(0))
} | explode_data.jsonl/73114 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
10551,
1454,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
2405,
2399,
197,
30764,
2507,
256,
284,
2622,
18,
17,
7,
15,
340,
197,
30764,
3050,
284,
2915,
79965,
914,
11,
1848,
3749,
28875,
341,
298,
78... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLink_GetNewAddress(t *testing.T) {
InitTest()
add, err := Lin.GetNewAddress(TestSeed, 0)
if err != nil {
fmt.Println("GetNewAddress err ", err.Error())
} else {
for k, v := range add {
fmt.Println(k, " => ", v)
}
}
} | explode_data.jsonl/15327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
3939,
13614,
3564,
4286,
1155,
353,
8840,
836,
8,
341,
98762,
2271,
741,
12718,
11,
1848,
1669,
8564,
2234,
3564,
4286,
31159,
41471,
11,
220,
15,
340,
743,
1848,
961,
2092,
341,
197,
11009,
12419,
445,
1949,
3564,
4286,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPostUnmarshalTaskWithEFSVolumesThatUseECSVolumePlugin(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
testCreds := getACSIAMRoleCredentials()
credentialsIDInTask := aws.StringValue(testCreds.CredentialsId)
credentialsManager := mock_credentials.NewMockManager(ctrl)
taskCredentials := credentials.TaskIAMRoleCredentials{
IAMRoleCredentials: credentials.IAMRoleCredentials{CredentialsID: credentialsIDInTask},
}
expectedEndpoint := "/v2/credentials/" + credentialsIDInTask
credentialsManager.EXPECT().GetTaskCredentials(credentialsIDInTask).Return(taskCredentials, true)
taskFromACS := getACSEFSTask()
taskFromACS.RoleCredentials = testCreds
seqNum := int64(42)
task, err := TaskFromACS(taskFromACS, &ecsacs.PayloadMessage{SeqNum: &seqNum})
assert.Nil(t, err, "Should be able to handle acs task")
assert.Equal(t, 1, len(task.Containers))
task.SetCredentialsID(aws.StringValue(testCreds.CredentialsId))
cfg := &config.Config{}
cfg.VolumePluginCapabilities = []string{"efsAuth"}
require.NoError(t, task.PostUnmarshalTask(cfg, credentialsManager, nil, nil, nil))
assert.Equal(t, 1, len(task.Containers), "Should match the number of containers as before PostUnmarshalTask")
assert.Equal(t, 1, len(task.Volumes), "Should have 1 volume")
taskVol := task.Volumes[0]
assert.Equal(t, "efsvolume", taskVol.Name)
assert.Equal(t, "efs", taskVol.Type)
resources := task.GetResources()
assert.Len(t, resources, 1)
vol, ok := resources[0].(*taskresourcevolume.VolumeResource)
require.True(t, ok)
dockerVolName := vol.VolumeConfig.DockerVolumeName
b, err := json.Marshal(resources[0])
require.NoError(t, err)
assert.JSONEq(t, fmt.Sprintf(`{
"name": "efsvolume",
"dockerVolumeConfiguration": {
"scope": "task",
"autoprovision": false,
"mountPoint": "",
"driver": "amazon-ecs-volume-plugin",
"driverOpts": {
"device": "fs-12345:/tmp",
"o": "tls,tlsport=12345,iam,awscredsuri=%s,accesspoint=fsap-123",
"type": "efs"
},
"labels": {},
"dockerVolumeName": "%s"
},
"createdAt": "0001-01-01T00:00:00Z",
"desiredStatus": "NONE",
"knownStatus": "NONE"
}`, expectedEndpoint, dockerVolName), string(b))
} | explode_data.jsonl/37200 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 852
} | [
2830,
3393,
4133,
1806,
27121,
6262,
2354,
36,
8485,
96325,
4792,
10253,
36,
6412,
18902,
11546,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
741,
18185,
34,
53369,
1669,
63... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccLibvirtCloudInit_CreateCloudInitDiskAndUpdate(t *testing.T) {
var volume libvirt.StorageVol
randomResourceName := acctest.RandString(10)
// this structs are contents values we expect.
expectedContents := Expected{UserData: "#cloud-config", NetworkConfig: "network:", MetaData: "instance-id: bamboo"}
expectedContents2 := Expected{UserData: "#cloud-config2", NetworkConfig: "network2:", MetaData: "instance-id: bamboo2"}
expectedContentsEmpty := Expected{UserData: "#cloud-config2", NetworkConfig: "", MetaData: ""}
randomIsoName := acctest.RandString(10) + ".iso"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: func(s *terraform.State) error {
return nil
},
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
resource "libvirt_cloudinit_disk" "%s" {
name = "%s"
user_data = "#cloud-config"
meta_data = "instance-id: bamboo"
network_config = "network:"
}`, randomResourceName, randomIsoName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"libvirt_cloudinit_disk."+randomResourceName, "name", randomIsoName),
testAccCheckCloudInitVolumeExists("libvirt_cloudinit_disk."+randomResourceName, &volume),
expectedContents.testAccCheckCloudInitDiskFilesContent("libvirt_cloudinit_disk."+randomResourceName, &volume),
),
},
{
Config: fmt.Sprintf(`
resource "libvirt_cloudinit_disk" "%s" {
name = "%s"
user_data = "#cloud-config2"
meta_data = "instance-id: bamboo2"
network_config = "network2:"
}`, randomResourceName, randomIsoName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"libvirt_cloudinit_disk."+randomResourceName, "name", randomIsoName),
testAccCheckCloudInitVolumeExists("libvirt_cloudinit_disk."+randomResourceName, &volume),
expectedContents2.testAccCheckCloudInitDiskFilesContent("libvirt_cloudinit_disk."+randomResourceName, &volume),
),
},
{
Config: fmt.Sprintf(`
resource "libvirt_cloudinit_disk" "%s" {
name = "%s"
user_data = "#cloud-config2"
}`, randomResourceName, randomIsoName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"libvirt_cloudinit_disk."+randomResourceName, "name", randomIsoName),
testAccCheckCloudInitVolumeExists("libvirt_cloudinit_disk."+randomResourceName, &volume),
expectedContentsEmpty.testAccCheckCloudInitDiskFilesContent("libvirt_cloudinit_disk."+randomResourceName, &volume),
),
},
// when we apply 2 times with same conf, we should not have a diff. See bug:
// https://github.com/dmacvicar/terraform-provider-libvirt/issues/313
{
Config: fmt.Sprintf(`
resource "libvirt_cloudinit_disk" "%s" {
name = "%s"
user_data = "#cloud-config4"
}`, randomResourceName, randomIsoName),
ExpectNonEmptyPlan: true,
PlanOnly: true,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"libvirt_cloudinit_disk."+randomResourceName, "name", randomIsoName),
testAccCheckCloudInitVolumeExists("libvirt_cloudinit_disk."+randomResourceName, &volume),
expectedContentsEmpty.testAccCheckCloudInitDiskFilesContent("libvirt_cloudinit_disk."+randomResourceName, &volume),
),
},
},
})
} | explode_data.jsonl/32958 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1393
} | [
2830,
3393,
14603,
9194,
47381,
16055,
3803,
34325,
16055,
3803,
47583,
56365,
1155,
353,
8840,
836,
8,
341,
2405,
8123,
3051,
47381,
43771,
36361,
198,
83628,
4783,
675,
1669,
1613,
67880,
2013,
437,
703,
7,
16,
15,
340,
197,
322,
419,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResponseRouterNoResponse(t *testing.T) {
receiver := &fakeReceiver{
Responses: []rpcResponse{
{nil, errors.New("Some other error that will get ignored since we can't route it to anyone (ie: no message ID)")},
{nil, amqp.ErrConnClosed},
},
}
link := &Link{
responseMap: map[string]chan rpcResponse{},
receiver: receiver,
}
link.startResponseRouter()
require.Empty(t, receiver.Responses)
} | explode_data.jsonl/57205 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
2582,
9523,
2753,
2582,
1155,
353,
8840,
836,
8,
341,
17200,
12862,
1669,
609,
30570,
25436,
515,
197,
197,
70743,
25,
3056,
29414,
2582,
515,
298,
197,
90,
8385,
11,
5975,
7121,
445,
8373,
1008,
1465,
429,
686,
633,
12036... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPexpire(t *testing.T) {
s, err := Run()
ok(t, err)
defer s.Close()
c, err := proto.Dial(s.Addr())
ok(t, err)
defer c.Close()
t.Run("key exists", func(t *testing.T) {
ok(t, s.Set("foo", "bar"))
must1(t, c, "PEXPIRE", "foo", "12")
mustDo(t, c,
"PTTL", "foo",
proto.Int(12),
)
equals(t, 12*time.Millisecond, s.TTL("foo"))
})
t.Run("no such key", func(t *testing.T) {
must0(t, c, "PEXPIRE", "nosuch", "12")
mustDo(t, c,
"PTTL", "nosuch",
proto.Int(-2),
)
})
t.Run("no expire", func(t *testing.T) {
s.Set("aap", "noot")
mustDo(t, c,
"PTTL", "aap",
proto.Int(-1),
)
})
} | explode_data.jsonl/44813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
47,
52161,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
6452,
741,
59268,
1155,
11,
1848,
340,
16867,
274,
10421,
741,
1444,
11,
1848,
1669,
18433,
98462,
1141,
93626,
2398,
59268,
1155,
11,
1848,
340,
16867,
272,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCancelPipelineRun(t *testing.T) {
testCases := []struct {
name string
pipelineRun *v1alpha1.PipelineRun
pipelineState []*resources.ResolvedPipelineRunTask
taskRuns []*v1alpha1.TaskRun
}{{
name: "no-resolved-taskrun",
pipelineRun: tb.PipelineRun("test-pipeline-run-cancelled", "foo",
tb.PipelineRunSpec("test-pipeline",
tb.PipelineRunCancelled,
),
),
}, {
name: "1-of-resolved-taskrun",
pipelineRun: tb.PipelineRun("test-pipeline-run-cancelled", "foo",
tb.PipelineRunSpec("test-pipeline",
tb.PipelineRunCancelled,
),
),
pipelineState: []*resources.ResolvedPipelineRunTask{
{TaskRunName: "t1", TaskRun: tb.TaskRun("t1", "foo")},
{TaskRunName: "t2"},
},
taskRuns: []*v1alpha1.TaskRun{tb.TaskRun("t1", "foo")},
}, {
name: "resolved-taskruns",
pipelineRun: tb.PipelineRun("test-pipeline-run-cancelled", "foo",
tb.PipelineRunSpec("test-pipeline",
tb.PipelineRunCancelled,
),
),
pipelineState: []*resources.ResolvedPipelineRunTask{
{TaskRunName: "t1", TaskRun: tb.TaskRun("t1", "foo")},
{TaskRunName: "t2", TaskRun: tb.TaskRun("t2", "foo")},
},
taskRuns: []*v1alpha1.TaskRun{tb.TaskRun("t1", "foo"), tb.TaskRun("t2", "foo")},
}}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
d := test.Data{
PipelineRuns: []*v1alpha1.PipelineRun{tc.pipelineRun},
TaskRuns: tc.taskRuns,
}
c, _ := test.SeedTestData(t, d)
err := cancelPipelineRun(tc.pipelineRun, tc.pipelineState, c.Pipeline)
if err != nil {
t.Fatal(err)
}
// This PipelineRun should still be complete and false, and the status should reflect that
cond := tc.pipelineRun.Status.GetCondition(apis.ConditionSucceeded)
if cond.IsTrue() {
t.Errorf("Expected PipelineRun status to be complete and false, but was %v", cond)
}
l, err := c.Pipeline.TektonV1alpha1().TaskRuns("foo").List(metav1.ListOptions{})
if err != nil {
t.Fatal(err)
}
for _, tr := range l.Items {
if tr.Spec.Status != v1alpha1.TaskRunSpecStatusCancelled {
t.Errorf("expected task %q to be marked as cancelled, was %q", tr.Name, tr.Spec.Status)
}
}
})
}
} | explode_data.jsonl/45955 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1027
} | [
2830,
3393,
9269,
34656,
6727,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
3223,
8790,
6727,
256,
353,
85,
16,
7141,
16,
1069,
8790,
6727,
198,
197,
3223,
8790,
1397,
29838,
12745... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadSaveWithStruct(t *testing.T) {
type gopher struct {
Name string
Info string `search:"about"`
Legs float64 `search:",facet"`
Fuzz Atom `search:"Fur,facet"`
}
doc := gopher{"Gopher", "Likes slide rules.", 4, Atom("furry")}
pb := &pb.Document{
Field: []*pb.Field{
newStringValueField("Name", "Gopher", pb.FieldValue_TEXT),
newStringValueField("about", "Likes slide rules.", pb.FieldValue_TEXT),
},
Facet: []*pb.Facet{
newFacet("Legs", "4e+00", pb.FacetValue_NUMBER),
newFacet("Fur", "furry", pb.FacetValue_ATOM),
},
}
var gotDoc gopher
if err := loadDoc(&gotDoc, pb, nil); err != nil {
t.Fatalf("loadDoc: %v", err)
}
if !reflect.DeepEqual(gotDoc, doc) {
t.Errorf("loading doc\ngot %v\nwant %v", gotDoc, doc)
}
gotPB, err := saveDoc(&doc)
if err != nil {
t.Fatalf("saveDoc: %v", err)
}
gotPB.OrderId = nil // Don't test: it's time dependent.
if !proto.Equal(gotPB, pb) {
t.Errorf("saving doc\ngot %v\nwant %v", gotPB, pb)
}
} | explode_data.jsonl/27953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 442
} | [
2830,
3393,
5879,
8784,
2354,
9422,
1155,
353,
8840,
836,
8,
341,
13158,
342,
16940,
2036,
341,
197,
21297,
914,
198,
197,
197,
1731,
914,
220,
1565,
1836,
2974,
9096,
8805,
197,
15070,
791,
82,
2224,
21,
19,
1565,
1836,
12147,
83523,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreatePipeline(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/projects/1/pipeline", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testJSONBody(t, r, values{"ref": "master"})
fmt.Fprint(w, `{"id":1, "status":"pending"}`)
})
opt := &CreatePipelineOptions{Ref: String("master")}
pipeline, _, err := client.Pipelines.CreatePipeline(1, opt)
if err != nil {
t.Errorf("Pipelines.CreatePipeline returned error: %v", err)
}
want := &Pipeline{ID: 1, Status: "pending"}
if !reflect.DeepEqual(want, pipeline) {
t.Errorf("Pipelines.CreatePipeline returned %+v, want %+v", pipeline, want)
}
} | explode_data.jsonl/5215 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
4021,
34656,
1155,
353,
8840,
836,
8,
341,
2109,
2200,
11,
3538,
11,
2943,
1669,
6505,
741,
16867,
49304,
21421,
692,
2109,
2200,
63623,
4283,
17161,
14,
16,
4322,
8790,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPMetrics(t *testing.T) {
t.Parallel()
handler := New(nil, &Options{
RoutePrefix: "/",
ListenAddress: "somehost:9090",
ExternalURL: &url.URL{
Host: "localhost.localdomain:9090",
Scheme: "http",
},
})
getReady := func() int {
t.Helper()
w := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/-/ready", nil)
require.NoError(t, err)
handler.router.ServeHTTP(w, req)
return w.Code
}
code := getReady()
require.Equal(t, http.StatusServiceUnavailable, code)
counter := handler.metrics.requestCounter
require.Equal(t, 1, int(prom_testutil.ToFloat64(counter.WithLabelValues("/-/ready", strconv.Itoa(http.StatusServiceUnavailable)))))
handler.Ready()
for range [2]int{} {
code = getReady()
require.Equal(t, http.StatusOK, code)
}
require.Equal(t, 2, int(prom_testutil.ToFloat64(counter.WithLabelValues("/-/ready", strconv.Itoa(http.StatusOK)))))
require.Equal(t, 1, int(prom_testutil.ToFloat64(counter.WithLabelValues("/-/ready", strconv.Itoa(http.StatusServiceUnavailable)))))
} | explode_data.jsonl/46074 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 411
} | [
2830,
3393,
9230,
27328,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
53326,
1669,
1532,
27907,
11,
609,
3798,
515,
197,
47501,
14335,
25,
256,
3521,
756,
197,
10675,
268,
4286,
25,
330,
14689,
3790,
25,
24,
15,
24,
15,
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 |
func TestClientImplementation(t *testing.T) {
//given
cli := NewClient(context.Background(), baseURL, &http.Client{})
//then
assert.Implements(t, (*Client)(nil), cli, "Rest client implements Client interface")
} | explode_data.jsonl/17064 | {
"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,
2959,
36850,
1155,
353,
8840,
836,
8,
341,
197,
322,
41968,
198,
86448,
1669,
1532,
2959,
5378,
19047,
1507,
56741,
11,
609,
1254,
11716,
37790,
197,
322,
3391,
198,
6948,
26914,
4674,
1155,
11,
4609,
2959,
2376,
8385,
701,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListPods(t *testing.T) {
ns := api.NamespaceDefault
c := &testClient{
Request: testRequest{Method: "GET", Path: testapi.Default.ResourcePath("pods", ns, ""), Query: buildQueryValues(nil)},
Response: Response{StatusCode: http.StatusOK,
Body: &api.PodList{
Items: []api.Pod{
{
Status: api.PodStatus{
Phase: api.PodRunning,
},
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
"name": "baz",
},
},
},
},
},
},
}
receivedPodList, err := c.Setup(t).Pods(ns).List(unversioned.ListOptions{})
c.Validate(t, receivedPodList, err)
} | explode_data.jsonl/36091 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
852,
23527,
82,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
6330,
46011,
3675,
198,
1444,
1669,
609,
1944,
2959,
515,
197,
73806,
25,
1273,
1900,
90,
3523,
25,
330,
3806,
497,
7933,
25,
1273,
2068,
13275,
20766,
1820,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntExpressionPOW(t *testing.T) {
assertClauseSerialize(t, table1ColInt.POW(table2ColInt), "POW(table1.col_int, table2.col_int)")
assertClauseSerialize(t, table1ColInt.POW(Int(11)), "POW(table1.col_int, $1)", int64(11))
} | explode_data.jsonl/41460 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
1072,
9595,
2045,
54,
1155,
353,
8840,
836,
8,
341,
6948,
28482,
15680,
1155,
11,
1965,
16,
6127,
1072,
1069,
3307,
15761,
17,
6127,
1072,
701,
330,
2045,
54,
15761,
16,
13414,
4042,
11,
1965,
17,
13414,
4042,
19107,
6948,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContextSaveConfig(t *testing.T) {
ctx := newContext(&caddy.Instance{Storage: make(map[interface{}]interface{})}).(*httpContext)
ctx.saveConfig("foo", new(SiteConfig))
if _, ok := ctx.keysToSiteConfigs["foo"]; !ok {
t.Error("Expected config to be saved, but it wasn't")
}
if got, want := len(ctx.siteConfigs), 1; got != want {
t.Errorf("Expected len(siteConfigs) == %d, but was %d", want, got)
}
ctx.saveConfig("Foobar", new(SiteConfig))
if _, ok := ctx.keysToSiteConfigs["foobar"]; ok {
t.Error("Did not expect to get config with case-insensitive key, but did")
}
if got, want := len(ctx.siteConfigs), 2; got != want {
t.Errorf("Expected len(siteConfigs) == %d, but was %d", want, got)
}
} | explode_data.jsonl/26465 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
1972,
8784,
2648,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
501,
1972,
2099,
66,
22478,
12688,
90,
5793,
25,
1281,
9147,
58,
4970,
78134,
4970,
28875,
16630,
4071,
1254,
1972,
340,
20985,
5681,
2648,
445,
7975,
497,
501,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckErrorSuppression(t *testing.T) {
query := `arr = [1,2,3]; arr[0].deadbeef = 1`
_, errs := newTypeChecker().CheckBody(nil, MustParseBody(query))
if len(errs) != 1 {
t.Fatalf("Expected exactly one error but got: %v", errs)
}
_, ok := errs[0].Details.(*RefErrUnsupportedDetail)
if !ok {
t.Fatalf("Expected ref error but got: %v", errs)
}
query = `_ = [true | count(1)]`
_, errs = newTypeChecker().CheckBody(newTypeChecker().Env(BuiltinMap), MustParseBody(query))
if len(errs) != 1 {
t.Fatalf("Expected exactly one error but got: %v", errs)
}
_, ok = errs[0].Details.(*ArgErrDetail)
if !ok {
t.Fatalf("Expected arg error but got: %v", errs)
}
} | explode_data.jsonl/14560 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
3973,
1454,
10048,
4011,
1155,
353,
8840,
836,
8,
1476,
27274,
1669,
1565,
1118,
284,
508,
16,
11,
17,
11,
18,
5265,
2890,
58,
15,
936,
33754,
1371,
823,
284,
220,
16,
19324,
197,
6878,
70817,
1669,
501,
929,
35188,
1005... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestIsRed(t *testing.T) {
defer leaktest.AfterTest(t)
testCases := []struct {
node *proto.RangeTreeNode
expected bool
}{
// normal black node
{&proto.RangeTreeNode{Black: true}, false},
// normal red node
{&proto.RangeTreeNode{Black: false}, true},
// nil
{nil, false},
}
for i, test := range testCases {
node := test.node
actual := isRed(node)
if actual != test.expected {
t.Errorf("%d: %+v expect %v; got %v", i, node, test.expected, actual)
}
}
} | explode_data.jsonl/15490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
3872,
6033,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
340,
18185,
37302,
1669,
3056,
1235,
341,
197,
20831,
257,
353,
15110,
24783,
26597,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
322,
462... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTagInvalidUnprefixedRepo(t *testing.T) {
// skip this until we start blocking bad tags
t.Skip()
invalidRepos := []string{"-foo", "fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo", "f"}
for _, repo := range invalidRepos {
tagCmd := exec.Command(dockerBinary, "tag", "busybox", repo)
_, _, err := runCommandWithOutput(tagCmd)
if err == nil {
t.Errorf("tag busybox %v should have failed", repo)
continue
}
logMessage := fmt.Sprintf("tag - busybox %v --> must fail", repo)
logDone(logMessage)
}
} | explode_data.jsonl/77728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
5668,
7928,
1806,
30552,
3286,
25243,
1155,
353,
8840,
836,
8,
341,
197,
322,
10706,
419,
3080,
582,
1191,
22188,
3873,
9492,
198,
3244,
57776,
2822,
197,
11808,
693,
966,
1669,
3056,
917,
4913,
12,
7975,
497,
330,
824,
3,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCreateRouteForOneReserveRevision(t *testing.T) {
ctx, _, ctl, _, cf := newTestSetup(t)
defer cf()
fakeRecorder := controller.GetEventRecorder(ctx).(*record.FakeRecorder)
// An inactive revision
rev := getTestRevision("test-rev")
rev.Status.MarkActiveFalse("NoTraffic", "no message")
fakeservingclient.Get(ctx).ServingV1().Revisions(testNamespace).Create(rev)
fakerevisioninformer.Get(ctx).Informer().GetIndexer().Add(rev)
// A route targeting the revision
route := getTestRouteWithTrafficTargets(WithSpecTraffic(v1.TrafficTarget{
RevisionName: "test-rev",
ConfigurationName: "test-config",
Percent: ptr.Int64(100),
}))
fakeservingclient.Get(ctx).ServingV1().Routes(testNamespace).Create(route)
// Since Reconcile looks in the lister, we need to add it to the informer
fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route)
ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route))
ci := getRouteIngressFromClient(ctx, t, route)
// Check labels
expectedLabels := map[string]string{
serving.RouteLabelKey: route.Name,
serving.RouteNamespaceLabelKey: route.Namespace,
"route": "test-route",
}
if diff := cmp.Diff(expectedLabels, ci.Labels); diff != "" {
t.Errorf("Unexpected label diff (-want +got): %v", diff)
}
domain := strings.Join([]string{route.Name, route.Namespace, defaultDomainSuffix}, ".")
expectedSpec := netv1alpha1.IngressSpec{
TLS: []netv1alpha1.IngressTLS{},
Rules: []netv1alpha1.IngressRule{{
Hosts: []string{
"test-route.test.svc.cluster.local",
},
Visibility: netv1alpha1.IngressVisibilityClusterLocal,
HTTP: &netv1alpha1.HTTPIngressRuleValue{
Paths: []netv1alpha1.HTTPIngressPath{{
Splits: []netv1alpha1.IngressBackendSplit{{
IngressBackend: netv1alpha1.IngressBackend{
ServiceNamespace: testNamespace,
ServiceName: rev.Status.ServiceName,
ServicePort: intstr.FromInt(80),
},
Percent: 100,
AppendHeaders: map[string]string{
"Knative-Serving-Revision": "test-rev",
"Knative-Serving-Namespace": testNamespace,
},
}},
}},
},
}, {
Hosts: []string{
domain,
},
Visibility: netv1alpha1.IngressVisibilityExternalIP,
HTTP: &netv1alpha1.HTTPIngressRuleValue{
Paths: []netv1alpha1.HTTPIngressPath{{
Splits: []netv1alpha1.IngressBackendSplit{{
IngressBackend: netv1alpha1.IngressBackend{
ServiceNamespace: testNamespace,
ServiceName: rev.Status.ServiceName,
ServicePort: intstr.FromInt(80),
},
Percent: 100,
AppendHeaders: map[string]string{
"Knative-Serving-Revision": "test-rev",
"Knative-Serving-Namespace": testNamespace,
},
}},
}},
},
}},
}
if diff := cmp.Diff(expectedSpec, ci.Spec); diff != "" {
t.Errorf("Unexpected rule spec diff (-want +got): %s", diff)
}
// Update ingress loadbalancer to trigger placeholder service creation.
ci.Status = netv1alpha1.IngressStatus{
LoadBalancer: &netv1alpha1.LoadBalancerStatus{
Ingress: []netv1alpha1.LoadBalancerIngressStatus{{
DomainInternal: "test-domain",
}},
},
}
fakeingressinformer.Get(ctx).Informer().GetIndexer().Update(ci)
ctl.Reconciler.Reconcile(context.Background(), KeyOrDie(route))
// Look for the events. Events are delivered asynchronously so we need to use
// hooks here. Each hook tests for a specific event.
select {
case got := <-fakeRecorder.Events:
const want = `Normal Created Created placeholder service "test-route"`
if got != want {
t.Errorf("<-Events = %s, wanted %s", got, want)
}
case <-time.After(3 * time.Second):
t.Error("timed out waiting for expected events.")
}
select {
case got := <-fakeRecorder.Events:
const wantPrefix = `Normal Created Created Ingress`
if !strings.HasPrefix(got, wantPrefix) {
t.Errorf("<-Events = %s, wanted prefix %s", got, wantPrefix)
}
case <-time.After(3 * time.Second):
t.Error("timed out waiting for expected events.")
}
} | explode_data.jsonl/66129 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1641
} | [
2830,
3393,
4021,
4899,
2461,
3966,
1061,
5852,
33602,
1155,
353,
8840,
836,
8,
341,
20985,
11,
8358,
64935,
11,
8358,
24111,
1669,
501,
2271,
21821,
1155,
340,
16867,
24111,
2822,
1166,
726,
47023,
1669,
6461,
2234,
1556,
47023,
7502,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func Test_client_DownloadReleaseAsset(t *testing.T) {
tests := []struct {
name string
assetName string
responseContent string
wantErr bool
}{
{"ok", "abc", "true", false},
{"not found", "404", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if strings.HasSuffix(req.RequestURI, "/dummy/test/releases/download/v1.0/abc") {
res.WriteHeader(200)
} else {
res.WriteHeader(404)
}
_, e := res.Write([]byte(tt.responseContent))
assert.NoError(t, e)
}))
defer func() { testServer.Close() }()
c := &client{
apiHost: testServer.URL,
host: testServer.URL,
client: testServer.Client(),
}
_, err := c.DownloadReleaseAsset("dummy", "test", "v1.0", tt.assetName)
if (err != nil) != tt.wantErr {
t.Errorf("DownloadReleaseAsset() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
} | explode_data.jsonl/45922 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 467
} | [
2830,
3393,
8179,
1557,
37702,
16077,
16604,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
197,
9852,
675,
981,
914,
198,
197,
21735,
2762,
914,
198,
197,
50780,
7747,
260,
1807,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestOSSToObjectError(t *testing.T) {
testCases := []struct {
inputErr error
expectedErr error
bucket, object string
}{
{
inputErr: ossErrResponse("BucketAlreadyExists"),
expectedErr: minio.BucketAlreadyOwnedByYou{},
},
{
inputErr: ossErrResponse("BucketNotEmpty"),
expectedErr: minio.BucketNotEmpty{},
},
{
inputErr: ossErrResponse("InvalidBucketName"),
expectedErr: minio.BucketNameInvalid{},
},
{
inputErr: ossErrResponse("NoSuchBucket"),
expectedErr: minio.BucketNotFound{},
},
// with empty object, NoSuchKey is interpreted as BucketNotFound
{
inputErr: ossErrResponse("NoSuchKey"),
expectedErr: minio.BucketNotFound{},
},
{
inputErr: ossErrResponse("NoSuchUpload"),
expectedErr: minio.InvalidUploadID{},
},
{
inputErr: ossErrResponse("InvalidObjectName"),
expectedErr: minio.ObjectNameInvalid{},
},
{
inputErr: ossErrResponse("AccessDenied"),
expectedErr: minio.PrefixAccessDenied{},
},
{
inputErr: ossErrResponse("NoSuchUpload"),
expectedErr: minio.InvalidUploadID{},
},
{
inputErr: ossErrResponse("EntityTooSmall"),
expectedErr: minio.PartTooSmall{},
},
{
inputErr: nil,
expectedErr: nil,
},
// Special test case for NoSuchKey with object name
{
inputErr: ossErrResponse("NoSuchKey"),
expectedErr: minio.ObjectNotFound{Bucket: "bucket", Object: "object"},
bucket: "bucket",
object: "object",
},
// Special test case for error value that is not of
// type (*Error)
{
inputErr: fmt.Errorf("not a *Error"),
expectedErr: fmt.Errorf("not a *Error"),
},
}
for i, tc := range testCases {
actualErr := ossToObjectError(tc.inputErr, tc.bucket, tc.object)
if e, ok := actualErr.(*errors.Error); ok && e.Cause != tc.expectedErr {
t.Errorf("Test case %d: Expected error '%v' but received error '%v'", i+1, tc.expectedErr, e.Cause)
}
}
} | explode_data.jsonl/79131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 864
} | [
2830,
3393,
3126,
784,
78,
1190,
1454,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
22427,
7747,
981,
1465,
198,
197,
42400,
7747,
262,
1465,
198,
197,
2233,
11152,
11,
1633,
914,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestBuildToolComponent(t *testing.T) {
component := BuildTool{
Version: "19.1.0",
}
require.Equal(t, "build-tools;19.1.0", component.GetSDKStylePath())
require.Equal(t, "build-tools-19.1.0", component.GetLegacySDKStylePath())
require.Equal(t, "build-tools/19.1.0", component.InstallPathInAndroidHome())
} | explode_data.jsonl/15336 | {
"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,
11066,
7740,
2189,
1155,
353,
8840,
836,
8,
341,
52228,
1669,
7854,
7740,
515,
197,
77847,
25,
330,
16,
24,
13,
16,
13,
15,
756,
197,
630,
17957,
12808,
1155,
11,
330,
5834,
44646,
26,
16,
24,
13,
16,
13,
15,
497,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMul(t *testing.T) {
t.Parallel()
s1 := []float64{1, 2, 3}
s2 := []float64{1, 2, 3}
ans := []float64{1, 4, 9}
Mul(s1, s2)
if !EqualApprox(s1, ans, EqTolerance) {
t.Errorf("Mul doesn't give correct answer")
}
s1short := []float64{1}
if !Panics(func() { Mul(s1short, s2) }) {
t.Errorf("Did not panic with unequal lengths")
}
s2short := []float64{1}
if !Panics(func() { Mul(s1, s2short) }) {
t.Errorf("Did not panic with unequal lengths")
}
} | explode_data.jsonl/1230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
59155,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
16,
1669,
3056,
3649,
21,
19,
90,
16,
11,
220,
17,
11,
220,
18,
532,
1903,
17,
1669,
3056,
3649,
21,
19,
90,
16,
11,
220,
17,
11,
220,
18,
532,
435... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTarWithOptions(t *testing.T) {
// TODO Windows: Figure out how to fix this test.
if runtime.GOOS == "windows" {
t.Skip("Failing on Windows")
}
origin, err := ioutil.TempDir("", "docker-test-untar-origin")
if err != nil {
t.Fatal(err)
}
if _, err := ioutil.TempDir(origin, "folder"); err != nil {
t.Fatal(err)
}
defer os.RemoveAll(origin)
if err := ioutil.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil {
t.Fatal(err)
}
if err := ioutil.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700); err != nil {
t.Fatal(err)
}
cases := []struct {
opts *TarOptions
numChanges int
}{
{&TarOptions{IncludeFiles: []string{"1"}}, 2},
{&TarOptions{ExcludePatterns: []string{"2"}}, 1},
{&TarOptions{ExcludePatterns: []string{"1", "folder*"}}, 2},
{&TarOptions{IncludeFiles: []string{"1", "1"}}, 2},
{&TarOptions{IncludeFiles: []string{"1"}, RebaseNames: map[string]string{"1": "test"}}, 4},
}
for _, testCase := range cases {
changes, err := tarUntar(t, origin, testCase.opts)
if err != nil {
t.Fatalf("Error tar/untar when testing inclusion/exclusion: %s", err)
}
if len(changes) != testCase.numChanges {
t.Errorf("Expected %d changes, got %d for %+v:",
testCase.numChanges, len(changes), testCase.opts)
}
}
} | explode_data.jsonl/81996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
62733,
74238,
1155,
353,
8840,
836,
8,
341,
197,
322,
5343,
5515,
25,
19037,
700,
1246,
311,
5046,
419,
1273,
624,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
445,
37,
14277,
389,
5515,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestCatchClause(t *testing.T) {
data := []byte(`<?php
namespace App;
use Exception;
try {
} catch (\NotFoundException $ex) {
} catch (\HttpException | Exception $ex) {
} catch (\Throwable $ex) {
}`)
doc := NewDocument("test1", data)
doc.Load()
results := []*ClassAccess{}
tra := newTraverser()
tra.traverseDocument(doc, func(_ *traverser, symbol Symbol, _ []Symbol) {
if classAccess, ok := symbol.(*ClassAccess); ok {
results = append(results, classAccess)
}
})
cupaloy.SnapshotT(t, results)
} | explode_data.jsonl/4694 | {
"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,
57760,
28482,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
5809,
1316,
1208,
198,
2231,
1845,
401,
810,
4112,
401,
1539,
341,
92,
2287,
19788,
14578,
400,
327,
8,
341,
92,
2287,
19788,
58499,
760,
4112,
400,
327,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContainerCreate(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionAuth(t)
defer rollback()
err := c.ContainerCreate(ctx, CONTAINER, m1.ContainerHeaders())
if err != nil {
t.Fatal(err)
}
err = c.ContainerDelete(ctx, CONTAINER)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/12663 | {
"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,
4502,
4021,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
5087,
1155,
340,
16867,
60414,
741,
9859,
1669,
272,
33672,
4021,
7502,
11,
16120,
34521,
11,
296,
16,
33672,
10574,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnalogSensorDriverDefaultName(t *testing.T) {
d := NewAnalogSensorDriver(newAioTestAdaptor(), "1")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "AnalogSensor"), true)
} | explode_data.jsonl/912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
2082,
30951,
30752,
11349,
3675,
675,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
1532,
2082,
30951,
30752,
11349,
1755,
32,
815,
2271,
2589,
32657,
1507,
330,
16,
1138,
3174,
674,
1716,
477,
11711,
1155,
11,
9069,
94357,
1500... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnprovidedPositionalArg(t *testing.T) {
f := NewFixture(t, model.UserConfigState{})
f.File("Tiltfile", `
config.define_string_list('foo', args=True)
cfg = config.parse()
print("foo:",cfg['foo'])
`)
_, err := f.ExecFile("Tiltfile")
require.Error(t, err)
require.Contains(t, err.Error(), `key "foo" not in dict`)
} | explode_data.jsonl/65233 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
1806,
63425,
3812,
278,
2735,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
1532,
18930,
1155,
11,
1614,
7344,
2648,
1397,
37790,
1166,
8576,
445,
51,
2963,
1192,
497,
22074,
1676,
16756,
3904,
2019,
492,
7975,
516,
2827,
3618,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFlash(t *testing.T) {
store := sessions.NewMemoryStore()
defer func() {
err := store.Close()
if err != nil {
t.Fatal(err)
}
}()
ss := sessions.New(store, "myapp_session")
m := mux.New()
m.Use(ss.Middleware)
m.Get("/").ThenFunc(func(c context.Context, w http.ResponseWriter, r *http.Request) {
s := sessions.Session(c)
if flashes := s.Flashes(); 0 < len(flashes) {
fmt.Fprintf(w, "Flashes %v %v", flashes[0], flashes[1])
} else {
s.AddFlash("hoge")
s.AddFlash("fuga")
fmt.Fprintf(w, "AddFlash")
}
})
ts := httptest.NewServer(m)
defer ts.Close()
c := newClient(t)
re := regexp.MustCompile("myapp_session=([a-f0-9]{40})")
{
_, body, header := c.Get(t, ts.URL, "myapp_session")
assert.Equal(t, "AddFlash", body)
if ok := assert.Len(t, header["Set-Cookie"], 1); ok {
assert.Regexp(t, re, header["Set-Cookie"][0])
}
}
{
_, body, header := c.Get(t, ts.URL, "myapp_session")
assert.Equal(t, "Flashes hoge fuga", body)
assert.Len(t, header["Set-Cookie"], 0)
}
{
_, body, header := c.Get(t, ts.URL, "myapp_session")
assert.Equal(t, "AddFlash", body)
assert.Len(t, header["Set-Cookie"], 0)
}
{
_, body, header := c.Get(t, ts.URL, "myapp_session")
assert.Equal(t, "Flashes hoge fuga", body)
assert.Len(t, header["Set-Cookie"], 0)
}
} | explode_data.jsonl/45595 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
23876,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
15704,
7121,
10642,
6093,
741,
16867,
2915,
368,
341,
197,
9859,
1669,
3553,
10421,
741,
197,
743,
1848,
961,
2092,
341,
298,
3244,
26133,
3964,
340,
197,
197,
532,
197,
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... | 2 |
func TestSend(t *testing.T) {
var url = "1https://oapi.dingtalk.com/robot/send?access_token=468470912f6c1241b1d804292794523940a9763eed0b04bf379469ee2163a103"
ddBot := &DingDingBot{url, url, "ddBot"}
//一般文本消息
//a := &DingDingTextMessage{Text: "hello"}
//链接消息
//a := &DingDingLinkMessage{"Hello Title", "Hello", "", "http://www.20dot.com"}
//markdown消息
//a := &DingDingMarkDownMessage{"杭州天气", "#### 杭州天气 \n > 9度,@1825718XXXX 西北风1级,空气良89,相对温度73%\n\n > \n > ###### 10点20分发布 [天气](http://www.thinkpage.cn/)", []string{"18500153794"}, true}
//ActionCard跳转消息
// a := &DingDingActionCardMessage{"乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
// " \n\n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划",
// 1, 1, "阅读全文", "https://20dot.com", nil}
// a := &DingDingActionCardMessage{"乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
// " \n\n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划",
// 1, 0, "", "",
// []DingDingActionCardBtnType{DingDingActionCardBtnType{"赞成", "https://baidu.com"}, DingDingActionCardBtnType{"反对", "https://baidu.com"}}}
//FeedCard类型消息
a := &DingDingFeedCardMessage{
[]DingDingFeedCardItem{
DingDingFeedCardItem{"时代的火车向前开", "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI", "https://www.dingtalk.com/"},
DingDingFeedCardItem{"时代的火车向前开2", "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI", "https://www.dingtalk.com/"}}}
returnMsg, err := ddBot.Send(a)
log.Println("结果:", returnMsg)
log.Println("err:", err)
} | explode_data.jsonl/52856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1438
} | [
2830,
3393,
11505,
1155,
353,
8840,
836,
8,
341,
2405,
2515,
284,
330,
16,
2428,
1110,
78,
2068,
950,
287,
35241,
905,
14,
18247,
69736,
30,
5211,
6458,
28,
19,
21,
23,
19,
22,
15,
24,
16,
17,
69,
21,
66,
16,
17,
19,
16,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResourceWithOwnerReferenceTemplate(t *testing.T) {
controller := newController()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
// operate the workflow. it should create a pod.
wf := unmarshalWF(resourceWithOwnerReferenceTemplate)
wf, err := wfcset.Create(wf)
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
woc.operate()
wf, err = wfcset.Get(wf.ObjectMeta.Name, metav1.GetOptions{})
assert.NoError(t, err)
assert.Equal(t, wfv1.NodeRunning, wf.Status.Phase)
pods, err := controller.kubeclientset.CoreV1().Pods("").List(metav1.ListOptions{})
if !assert.NoError(t, err) {
t.Fatal(err)
}
objectMetas := map[string]metav1.ObjectMeta{}
for _, pod := range pods.Items {
tmplStr := pod.Annotations[common.AnnotationKeyTemplate]
tmpl := wfv1.Template{}
err = yaml.Unmarshal([]byte(tmplStr), &tmpl)
if !assert.NoError(t, err) {
t.Fatal(err)
}
cm := apiv1.ConfigMap{}
err = yaml.Unmarshal([]byte(tmpl.Resource.Manifest), &cm)
if !assert.NoError(t, err) {
t.Fatal(err)
}
objectMetas[cm.Name] = cm.ObjectMeta
}
if assert.Equal(t, 1, len(objectMetas["resource-cm-1"].OwnerReferences)) {
assert.Equal(t, "manual-ref-name", objectMetas["resource-cm-1"].OwnerReferences[0].Name)
}
if assert.Equal(t, 1, len(objectMetas["resource-cm-2"].OwnerReferences)) {
assert.Equal(t, "resource-with-ownerreference-template", objectMetas["resource-cm-2"].OwnerReferences[0].Name)
}
if assert.Equal(t, 2, len(objectMetas["resource-cm-3"].OwnerReferences)) {
assert.Equal(t, "manual-ref-name", objectMetas["resource-cm-3"].OwnerReferences[0].Name)
assert.Equal(t, "resource-with-ownerreference-template", objectMetas["resource-cm-3"].OwnerReferences[1].Name)
}
} | explode_data.jsonl/54385 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 706
} | [
2830,
3393,
4783,
2354,
13801,
8856,
7275,
1155,
353,
8840,
836,
8,
341,
61615,
1669,
501,
2051,
741,
6692,
8316,
746,
1669,
6461,
1418,
69,
2972,
746,
18979,
45926,
73,
53,
16,
7141,
16,
1005,
6776,
38140,
445,
5130,
197,
322,
14476,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPanicBreakpointOnContinue(t *testing.T) {
runTest(t, "panic", func(client *daptest.Client, fixture protest.Fixture) {
runDebugSessionWithBPs(t, client, "launch",
// Launch
func() {
client.LaunchRequest("exec", fixture.Path, !stopOnEntry)
},
// Set breakpoints
fixture.Source, []int{5},
[]onBreakpoint{{
execute: func() {
checkStop(t, client, 1, "main.main", 5)
client.ContinueRequest(1)
client.ExpectContinueResponse(t)
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != 1 || se.Body.Reason != "exception" || se.Body.Description != "panic" {
t.Errorf("\ngot %#v\nwant ThreadId=1 Reason=\"exception\" Description=\"panic\"", se)
}
client.ExceptionInfoRequest(1)
eInfo := client.ExpectExceptionInfoResponse(t)
if eInfo.Body.ExceptionId != "panic" || eInfo.Body.Description != "\"BOOM!\"" {
t.Errorf("\ngot %#v\nwant ExceptionId=\"panic\" Description=\"\"BOOM!\"\"", eInfo)
}
client.StackTraceRequest(se.Body.ThreadId, 0, 20)
st := client.ExpectStackTraceResponse(t)
for i, frame := range st.Body.StackFrames {
if strings.HasPrefix(frame.Name, "runtime.") {
if frame.Source.PresentationHint != "deemphasize" {
t.Errorf("\ngot Body.StackFrames[%d]=%#v\nwant Source.PresentationHint=\"deemphasize\"", i, frame)
}
} else if frame.Source.PresentationHint != "" {
t.Errorf("\ngot Body.StackFrames[%d]=%#v\nwant Source.PresentationHint=\"\"", i, frame)
}
}
},
disconnect: true,
}})
})
} | explode_data.jsonl/17342 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 675
} | [
2830,
3393,
47,
31270,
22524,
2768,
1925,
23526,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
1155,
11,
330,
19079,
497,
2915,
12805,
353,
91294,
1944,
11716,
11,
12507,
8665,
991,
12735,
8,
341,
197,
56742,
7939,
5283,
2354,
33,
20420,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNUsersBootstrap(t *testing.T) {
if os.Getenv("SKIP_FOLDERSYNC") != "" {
t.Skip("Skipping foldersync tests")
}
tests := []struct {
totalClients int
totalCorePeers int
syncTimeout time.Duration
randFilesGen int
randFileSize int
checkSyncedFiles bool
}{
{totalClients: 2, totalCorePeers: 1, syncTimeout: time.Second * 10},
{totalClients: 3, totalCorePeers: 1, syncTimeout: time.Second * 30},
{totalClients: 3, totalCorePeers: 2, syncTimeout: time.Second * 30},
{totalClients: 2, totalCorePeers: 1, syncTimeout: time.Second * 20, randFilesGen: 4, randFileSize: 10},
{totalClients: 3, totalCorePeers: 2, syncTimeout: time.Second * 30, randFilesGen: 4, randFileSize: 10},
}
for _, tt := range tests {
tt := tt
t.Run(fmt.Sprintf("Total%dCore%d", tt.totalClients, tt.totalCorePeers), func(t *testing.T) {
var clients []*client
client0, clean0 := createRootClient(t, fmt.Sprintf("client%d", 0))
defer clean0()
clients = append(clients, client0)
addr, key, err := client0.getDBInfo()
checkErr(t, err)
for i := 1; i < tt.totalCorePeers; i++ {
client, clean := createJoinerClient(t, fmt.Sprintf("client%d", i), addr, key)
defer clean()
clients = append(clients, client)
}
for i := tt.totalCorePeers; i < tt.totalClients; i++ {
addr, key, err := clients[i%tt.totalCorePeers].getDBInfo()
checkErr(t, err)
client, clean := createJoinerClient(t, fmt.Sprintf("client%d", i), addr, key)
defer clean()
clients = append(clients, client)
}
for i := 0; i < tt.totalClients; i++ {
err := clients[i].start()
checkErr(t, err)
}
blk := make([]byte, tt.randFileSize)
for i := 0; i < tt.randFilesGen; i++ {
for j, c := range clients {
rf, err := ioutil.TempFile(path.Join(c.folderPath, c.name), fmt.Sprintf("client%d-", j))
checkErr(t, err)
_, err = rand.Read(blk)
checkErr(t, err)
_, err = rf.Write(blk)
checkErr(t, err)
time.Sleep(time.Millisecond * time.Duration(rand.Intn(300)))
}
}
time.Sleep(tt.syncTimeout)
assertClientsEqualTrees(t, clients)
})
}
} | explode_data.jsonl/21833 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 941
} | [
2830,
3393,
45,
7137,
45511,
1155,
353,
8840,
836,
8,
341,
743,
2643,
64883,
445,
91799,
1400,
7863,
4321,
71401,
899,
961,
1591,
341,
197,
3244,
57776,
445,
85945,
29242,
1721,
7032,
1138,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestValidateDmsReplicationInstanceId(t *testing.T) {
validIds := []string{
"tf-test-replication-instance-1",
"tfTestReplicaitonInstance",
}
for _, s := range validIds {
_, errors := validateDmsReplicationInstanceId(s, "replicaiton_instance_id")
if len(errors) > 0 {
t.Fatalf("%q should be a valid replication instance id: %v", s, errors)
}
}
invalidIds := []string{
"tf_test_replication-instance_1",
"tf.test.replication.instance.1",
"tf test replication instance 1",
"tf-test-replication-instance-1!",
"tf-test-replication-instance-1-",
"tf-test-replication-instance--1",
"tf-test-replication-instance-1tf-test-replication-instance-1tf-test-replication-instance-1",
}
for _, s := range invalidIds {
_, errors := validateDmsReplicationInstanceId(s, "replication_instance_id")
if len(errors) == 0 {
t.Fatalf("%q should not be a valid replication instance id: %v", s, errors)
}
}
} | explode_data.jsonl/78605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 356
} | [
2830,
3393,
17926,
35,
1011,
18327,
1693,
65918,
1155,
353,
8840,
836,
8,
341,
56322,
12701,
1669,
3056,
917,
515,
197,
197,
1,
8935,
16839,
5504,
79,
1693,
73655,
12,
16,
756,
197,
197,
1,
8935,
2271,
18327,
415,
1315,
263,
2523,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestStateStoreKeys(t *testing.T) {
address := common.HexToAddress("0xabcd")
expected := "swap_cashout_000000000000000000000000000000000000abcd"
if chequebook.CashoutActionKey(address) != expected {
t.Fatalf("wrong cashout action key. wanted %s, got %s", expected, chequebook.CashoutActionKey(address))
}
expected = "swap_chequebook_last_issued_cheque_000000000000000000000000000000000000abcd"
if chequebook.LastIssuedChequeKey(address) != expected {
t.Fatalf("wrong last issued cheque key. wanted %s, got %s", expected, chequebook.LastIssuedChequeKey(address))
}
expected = "swap_chequebook_last_received_cheque__000000000000000000000000000000000000abcd"
if chequebook.LastReceivedChequeKey(address) != expected {
t.Fatalf("wrong last received cheque key. wanted %s, got %s", expected, chequebook.LastReceivedChequeKey(address))
}
} | explode_data.jsonl/41448 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
1397,
6093,
8850,
1155,
353,
8840,
836,
8,
341,
63202,
1669,
4185,
91538,
1249,
4286,
445,
15,
52616,
4385,
5130,
42400,
1669,
330,
25741,
64363,
411,
62,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRolesGet(t *testing.T) {
clients.RequireAdmin(t)
client, err := clients.NewIdentityV3Client()
th.AssertNoErr(t, err)
role, err := FindRole(t, client)
th.AssertNoErr(t, err)
p, err := roles.Get(client, role.ID).Extract()
th.AssertNoErr(t, err)
tools.PrintResource(t, p)
} | explode_data.jsonl/57722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
25116,
1949,
1155,
353,
8840,
836,
8,
341,
197,
31869,
81288,
7210,
1155,
692,
25291,
11,
1848,
1669,
8239,
7121,
18558,
53,
18,
2959,
741,
70479,
11711,
2753,
7747,
1155,
11,
1848,
692,
197,
5778,
11,
1848,
1669,
7379,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMCR_createResourcesFromTemplates(t *testing.T) {
testcases := []struct {
name string
data templateData
templates []resourceTemplate
resourceName string
create bool
}{
{
name: "Create objects from precacheDependenciesCreateTemplates",
data: templateData{
Cluster: "test",
},
templates: precacheDependenciesCreateTemplates,
},
{
name: "Create objects from precacheDependenciesViewTemplates",
data: templateData{
Cluster: "test",
},
templates: precacheDependenciesViewTemplates,
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
r := &ClusterGroupUpgradeReconciler{
Client: fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects().Build(),
Log: logr.Discard(),
Scheme: scheme.Scheme,
}
err := r.createResourcesFromTemplates(context.TODO(), &tc.data, tc.templates)
if err != nil {
t.Errorf("error returned from createResourcesFromTemplates: %v", err)
}
for _, item := range tc.templates {
var obj = &unstructured.Unstructured{}
var kind string
var group string
if strings.Contains(item.resourceName, "view") {
group = "view.open-cluster-management.io"
kind = "ManagedClusterView"
} else {
group = "action.open-cluster-management.io"
kind = "ManagedClusterAction"
}
obj.SetGroupVersionKind(schema.GroupVersionKind{
Group: group,
Kind: kind,
Version: "v1beta1",
})
err = r.Get(context.TODO(), types.NamespacedName{
Name: item.resourceName,
Namespace: tc.data.Cluster,
}, obj)
assert.Equal(t, err, nil)
}
})
}
} | explode_data.jsonl/47901 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 707
} | [
2830,
3393,
44,
8973,
8657,
11277,
3830,
51195,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
8924,
260,
3811,
1043,
198,
197,
197,
15463,
262,
3056,
9233,
7275,
198,
197,
50346,
67... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestIotaGetNodeInfo(t *testing.T) {
InitTest()
info, err := Lin.API.GetNodeInfo()
if err != nil {
fmt.Println("GetNodeInfo err ", err.Error())
} else {
fmt.Printf("INFO IS \n %+v \n", info)
//fmt.Println("Info Time", info.Time)
//fmt.Println("Info NodeAlias", info.NodeAlias)
//fmt.Println("Info AutopeeringID", info.AutopeeringID)
//fmt.Println("Info Uptime", info.Uptime)
//fmt.Println("Info AppName", info.AppName)
//fmt.Println("Info IsHealthy", info.IsHealthy)
//fmt.Println("Info Duration", info.Duration)
//fmt.Println("Info TransactionsToRequest", info.TransactionsToRequest)
//fmt.Println("Info Tips", info.Tips)
//fmt.Println("Info Neighbors", info.Neighbors)
//fmt.Println("Info LatestMilestone", info.LatestMilestone)
//fmt.Println("Info LatestMilestoneIndex", info.LatestMilestoneIndex)
//fmt.Println("Info LatestSolidSubtangleMilestone", info.LatestSolidSubtangleMilestone)
//fmt.Println("Info LatestSolidSubtangleMilestoneIndex", info.LatestSolidSubtangleMilestoneIndex)
}
} | explode_data.jsonl/15328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 389
} | [
2830,
3393,
40,
6089,
1949,
1955,
1731,
1155,
353,
8840,
836,
8,
341,
98762,
2271,
741,
27043,
11,
1848,
1669,
8564,
24922,
2234,
1955,
1731,
741,
743,
1848,
961,
2092,
341,
197,
11009,
12419,
445,
1949,
1955,
1731,
1848,
3670,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDeleteOwnerRefPatch(t *testing.T) {
original := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "100",
OwnerReferences: []metav1.OwnerReference{
{UID: "1"},
{UID: "2"},
{UID: "3"},
},
},
}
originalData := serilizeOrDie(t, original)
expected := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "100",
OwnerReferences: []metav1.OwnerReference{
{UID: "1"},
},
},
}
patch := deleteOwnerRefPatch("100", "2", "3")
patched, err := strategicpatch.StrategicMergePatch(originalData, patch, v1.Pod{})
if err != nil {
t.Fatal(err)
}
var got v1.Pod
if err := json.Unmarshal(patched, &got); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(expected, got) {
t.Errorf("expected: %#v,\ngot: %#v", expected, got)
}
} | explode_data.jsonl/1193 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
6435,
13801,
3945,
43622,
1155,
353,
8840,
836,
8,
341,
197,
9889,
1669,
348,
16,
88823,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
197,
6463,
25,
330,
16,
15,
15,
756,
298,
197,
13801,
31712,
25,
3056,
4059... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParse(test *testing.T) {
parseBadRDL(test, `type Contact Struct { String foo; String foo; }`)
parseBadRDL(test, `type Foo Struct { String foo; } type Bar Foo { String foo; }`)
parseBadRDL(test, `type Foo Struct { String bar; } resource Foo GET "/foo?d={debug}" {String debug (optinal); }`)
parseGoodRDL(test, `type Foo Any; type X Struct { Any y; } type Y Struct { Foo y;}`)
parseGoodRDL(test, `type A String (pattern="[a-z]"); type B A; type C B; type D string (pattern="{C}-{A}");`)
parseGoodRDL(test, `type foo struct { String foo; }`)
parseGoodRDL(test, `type Bar enum { ONE TWO }`)
parseGoodRDL(test, `
type MultiLine Enum {
ONE
TWO
}`)
schema, err := parseRDLString(`type Base Struct { String bar; } type Foo Base;`)
if err != nil {
test.Errorf("Cannot parse: %v\n", err)
} else {
reg := NewTypeRegistry(schema)
t1 := reg.FindType("Foo")
if t1 == nil {
test.Errorf("Expected type, found nothing")
} else {
_, tSuper, _ := TypeInfo(t1)
assertStringEquals(test, "supertype", "Base", string(tSuper))
}
}
} | explode_data.jsonl/74346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 410
} | [
2830,
3393,
14463,
8623,
353,
8840,
836,
8,
341,
75115,
17082,
49,
16524,
8623,
11,
1565,
1313,
9180,
16139,
314,
923,
15229,
26,
923,
15229,
26,
335,
24183,
75115,
17082,
49,
16524,
8623,
11,
1565,
1313,
33428,
16139,
314,
923,
15229,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteFSMetadata(t *testing.T) {
disk := filepath.Join(globalTestTmpDir, "minio-"+nextSuffix())
defer removeAll(disk)
obj := initFSObjects(disk, t)
fs := obj.(*fsObjects)
bucketName := "bucket"
objectName := "object"
if err := obj.MakeBucket(bucketName); err != nil {
t.Fatal("Unexpected err: ", err)
}
sha256sum := ""
if _, err := obj.PutObject(bucketName, objectName, int64(len("abcd")), bytes.NewReader([]byte("abcd")),
map[string]string{"X-Amz-Meta-AppId": "a"}, sha256sum); err != nil {
t.Fatal("Unexpected err: ", err)
}
// Construct the full path of fs.json
fsPath := pathJoin("buckets", bucketName, objectName, "fs.json")
fsPath = pathJoin(fs.fsPath, minioMetaBucket, fsPath)
rlk, err := fs.rwPool.Open(fsPath)
if err != nil {
t.Fatal("Unexpected error ", err)
}
defer rlk.Close()
// FS metadata reading, no errors expected (healthy disk)
fsMeta := fsMetaV1{}
_, err = fsMeta.ReadFrom(rlk.LockedFile)
if err != nil {
t.Fatal("Unexpected error ", err)
}
if fsMeta.Version != "1.0.0" {
t.Fatalf("Unexpected version %s", fsMeta.Version)
}
if fsMeta.Format != "fs" {
t.Fatalf("Unexpected format %s", fsMeta.Format)
}
} | explode_data.jsonl/68542 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 471
} | [
2830,
3393,
7985,
8485,
14610,
1155,
353,
8840,
836,
8,
341,
2698,
3187,
1669,
26054,
22363,
31951,
2271,
35986,
6184,
11,
330,
1065,
815,
52077,
3600,
40177,
2398,
16867,
65099,
1500,
3187,
692,
22671,
1669,
2930,
8485,
11543,
1500,
3187... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReactorInvalidPrecommit(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
config := configSetup(t)
n := 4
states, cleanup := makeConsensusState(ctx, t,
config, n, "consensus_reactor_test",
newMockTickerFunc(true))
t.Cleanup(cleanup)
for i := 0; i < 4; i++ {
ticker := NewTimeoutTicker(states[i].logger)
states[i].SetTimeoutTicker(ticker)
}
rts := setup(ctx, t, n, states, 100) // buffer must be large enough to not deadlock
for _, reactor := range rts.reactors {
state := reactor.state.GetState()
reactor.SwitchToConsensus(ctx, state, false)
}
// this val sends a random precommit at each height
node := rts.network.RandomNode()
byzState := rts.states[node.NodeID]
byzReactor := rts.reactors[node.NodeID]
signal := make(chan struct{})
// Update the doPrevote function to just send a valid precommit for a random
// block and otherwise disable the priv validator.
byzState.mtx.Lock()
privVal := byzState.privValidator
byzState.doPrevote = func(ctx context.Context, height int64, round int32) {
defer close(signal)
invalidDoPrevoteFunc(ctx, t, height, round, byzState, byzReactor, privVal)
}
byzState.mtx.Unlock()
// wait for a bunch of blocks
//
// TODO: Make this tighter by ensuring the halt happens by block 2.
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
for _, sub := range rts.subs {
wg.Add(1)
go func(s eventbus.Subscription) {
defer wg.Done()
_, err := s.Next(ctx)
if ctx.Err() != nil {
return
}
if !assert.NoError(t, err) {
cancel() // cancel other subscribers on failure
}
}(sub)
}
}
wait := make(chan struct{})
go func() { defer close(wait); wg.Wait() }()
select {
case <-wait:
if _, ok := <-signal; !ok {
t.Fatal("test condition did not fire")
}
case <-ctx.Done():
if _, ok := <-signal; !ok {
t.Fatal("test condition did not fire after timeout")
return
}
case <-signal:
// test passed
}
} | explode_data.jsonl/80923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 780
} | [
2830,
3393,
693,
5621,
7928,
4703,
17413,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
220,
16,
15,
77053,
32435,
340,
16867,
9121,
2822,
25873,
1669,
2193,
21821,
1155,
692,
9038,
1669,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSet_AddIfNotExistFuncLock(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
s := gset.New(true)
wg := sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
r := s.AddIfNotExistFuncLock(1, func() bool {
time.Sleep(500 * time.Millisecond)
return true
})
t.Assert(r, true)
}()
time.Sleep(100 * time.Millisecond)
go func() {
defer wg.Done()
r := s.AddIfNotExistFuncLock(1, func() bool {
return true
})
t.Assert(r, false)
}()
wg.Wait()
})
} | explode_data.jsonl/34400 | {
"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,
1649,
21346,
2679,
45535,
9626,
11989,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
1903,
1669,
342,
746,
7121,
3715,
340,
197,
72079,
1669,
12811,
28384,
2808,
16094,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodePublishVolumeBadAttribute(t *testing.T) {
// Create server and client connection
s := newTestServer(t)
defer s.Stop()
// Make a call
c := csi.NewNodeClient(s.Conn())
name := "myvol"
s.MockDriver().
EXPECT().
Type().
Return(api.DriverType_DRIVER_TYPE_BLOCK).
Times(1)
os.Mkdir("mypath", 0750)
defer os.Remove("mypath")
req := &csi.NodePublishVolumeRequest{
VolumeId: name,
TargetPath: "mypath",
VolumeCapability: &csi.VolumeCapability{
AccessMode: &csi.VolumeCapability_AccessMode{},
},
// This will cause an error
VolumeContext: map[string]string{
api.SpecFilesystem: "whatkindoffsisthis?",
},
Secrets: map[string]string{authsecrets.SecretTokenKey: systemUserToken},
}
_, err := c.NodePublishVolume(context.Background(), req)
assert.NotNil(t, err)
serverError, ok := status.FromError(err)
assert.True(t, ok)
assert.Equal(t, serverError.Code(), codes.InvalidArgument)
assert.Contains(t, serverError.Message(), "Invalid volume attributes")
} | explode_data.jsonl/51444 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
1955,
50145,
18902,
17082,
3907,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
3538,
323,
2943,
3633,
198,
1903,
1669,
501,
2271,
5475,
1155,
340,
16867,
274,
30213,
2822,
197,
322,
7405,
264,
1618,
198,
1444,
1669,
272,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEventsAreLoaded(t *testing.T) {
loaders := map[string]func(*trace.Event, *ThreadTransitionSetBuilder) error{
"migrate-n-sleep": func(ev *trace.Event, ttsb *ThreadTransitionSetBuilder) error {
pid, ok := ev.NumberProperties["pid"]
if !ok {
return MissingFieldError("pid", ev)
}
comm := ev.TextProperties["comm"]
prio, ok := ev.NumberProperties["prio"]
priority := Priority(prio)
if !ok {
priority = UnknownPriority
}
targetCPU, ok := ev.NumberProperties["target_cpu"]
if !ok {
return MissingFieldError("target_cpu", ev)
}
ttsb.WithTransition(ev.Index, ev.Timestamp, PID(pid)).
WithPrevCommand(comm).
WithNextCommand(comm).
WithPrevPriority(priority).
WithNextPriority(priority).
WithPrevCPU(CPUID(ev.CPU)).
WithNextCPU(CPUID(targetCPU)).
WithCPUPropagatesThrough(false).
WithNextState(SleepingState).
WithStatePropagatesThrough(false)
return nil
},
"wake-n-switch-in": func(ev *trace.Event, ttsb *ThreadTransitionSetBuilder) error {
pid, ok := ev.NumberProperties["pid"]
if !ok {
return MissingFieldError("pid", ev)
}
comm := ev.TextProperties["comm"]
prio, ok := ev.NumberProperties["prio"]
priority := Priority(prio)
if !ok {
priority = UnknownPriority
}
ttsb.WithTransition(ev.Index, ev.Timestamp, PID(pid)).
WithPrevCommand(comm).
WithNextCommand(comm).
WithPrevPriority(priority).
WithNextPriority(priority).
WithPrevCPU(CPUID(ev.CPU)).
WithNextCPU(CPUID(ev.CPU)).
WithPrevState(SleepingState).
WithNextState(RunningState).
WithStatePropagatesThrough(false)
return nil
}}
eventSetBase := eventsetbuilder.NewBuilder().
WithEventDescriptor(
"migrate-n-sleep",
eventsetbuilder.Number("pid"),
eventsetbuilder.Text("comm"),
eventsetbuilder.Number("prio"),
eventsetbuilder.Number("target_cpu")).
WithEventDescriptor(
"wake-n-switch-in",
eventsetbuilder.Number("pid"),
eventsetbuilder.Text("comm"),
eventsetbuilder.Number("prio"))
tests := []struct {
description string
eventSet *eventpb.EventSet
wantErr bool // True if a loader will return an error.
wantTransitions func(sb *stringBank) []*threadTransition
}{{
description: "events load",
eventSet: testeventsetbuilder.TestProtobuf(t,
eventSetBase.TestClone(t).
WithEvent("migrate-n-sleep", 1, 1000, false,
100, "thread 1", 50, 2).
WithEvent("wake-n-switch-in", 2, 1010, false,
100, "thread 1", 50)),
wantErr: false,
wantTransitions: func(sb *stringBank) []*threadTransition {
return []*threadTransition{
emptyTransition(0, 1000, 100).
withCommands(sb.stringIDByString("thread 1"), sb.stringIDByString("thread 1")).
withPriorities(50, 50).
withCPUs(1, 2).
withStates(AnyState, SleepingState).
withStatePropagatesThrough(false),
emptyTransition(1, 1010, 100).
withCommands(sb.stringIDByString("thread 1"), sb.stringIDByString("thread 1")).
withPriorities(50, 50).
withCPUs(2, 2).
withStates(SleepingState, RunningState).
withStatePropagatesThrough(false),
}
},
}}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
sb := newStringBank()
el, err := newEventLoader(loaders, sb)
if err != nil {
t.Fatalf("wanted no EventLoader errors but got %s", err)
}
var tts []*threadTransition
coll, err := trace.NewCollection(test.eventSet)
if err != nil {
t.Fatalf("wanted no trace.NewCollection errors but got %s", err)
}
for i := 0; i < coll.EventCount(); i++ {
ev, err := coll.EventByIndex(i)
if err != nil {
t.Fatalf("wanted no trace.EventByIndex errors but got %s", err)
}
res, err := el.threadTransitions(ev)
if test.wantErr && err == nil {
t.Fatalf("threadTransitions yielded no errors, wanted one")
}
if err != nil && !test.wantErr {
t.Fatalf("threadTransitions yielded unepected error %s", err)
}
tts = append(tts, res...)
}
wantTts := test.wantTransitions(sb)
if len(tts) != len(wantTts) {
t.Fatalf("Expected %d transitions, got %d", len(wantTts), len(tts))
}
for i := 0; i < len(tts); i++ {
got, want := tts[i], wantTts[i]
if !cmp.Equal(want, got, cmp.AllowUnexported(threadTransition{})) {
t.Errorf("transition mismatch: want %s, got %s", want, got)
}
}
})
}
} | explode_data.jsonl/47250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1836
} | [
2830,
3393,
7900,
11526,
22369,
1155,
353,
8840,
836,
8,
341,
49386,
388,
1669,
2415,
14032,
60,
2830,
4071,
15067,
6904,
11,
353,
6855,
21768,
1649,
3297,
8,
1465,
515,
197,
197,
1,
76,
34479,
5279,
1331,
3499,
788,
2915,
32647,
353,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStoreRemovePlaceholderOnRaftIgnored(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
tc.Start(t, stopper)
s := tc.store
ctx := context.Background()
// Clobber the existing range and recreated it with an uninitialized
// descriptor so we can test nonoverlapping placeholders.
repl1, err := s.GetReplica(1)
if err != nil {
t.Fatal(err)
}
if err := s.RemoveReplica(context.Background(), repl1, repl1.Desc().NextReplicaID, RemoveOptions{
DestroyData: true,
}); err != nil {
t.Fatal(err)
}
uninitDesc := roachpb.RangeDescriptor{RangeID: repl1.Desc().RangeID}
if _, err := stateloader.WriteInitialState(
ctx, s.Engine(), enginepb.MVCCStats{}, uninitDesc, roachpb.Lease{},
hlc.Timestamp{}, stateloader.TruncatedStateUnreplicated,
); err != nil {
t.Fatal(err)
}
uninitRepl1, err := newReplica(ctx, &uninitDesc, s, 2)
if err != nil {
t.Fatal(err)
}
if err := s.addReplicaToRangeMapLocked(uninitRepl1); err != nil {
t.Fatal(err)
}
// Generate a minimal fake snapshot.
snapData := &roachpb.RaftSnapshotData{}
data, err := protoutil.Marshal(snapData)
if err != nil {
t.Fatal(err)
}
// Wrap the snapshot in a minimal header. The request will be dropped
// because the Raft log index and term are less than the hard state written
// above.
req := &SnapshotRequest_Header{
State: kvserverpb.ReplicaState{Desc: repl1.Desc()},
RaftMessageRequest: RaftMessageRequest{
RangeID: 1,
ToReplica: roachpb.ReplicaDescriptor{
NodeID: 1,
StoreID: 1,
ReplicaID: 2,
},
FromReplica: roachpb.ReplicaDescriptor{
NodeID: 2,
StoreID: 2,
ReplicaID: 3,
},
Message: raftpb.Message{
Type: raftpb.MsgSnap,
Snapshot: raftpb.Snapshot{
Data: data,
Metadata: raftpb.SnapshotMetadata{
Index: 1,
Term: 1,
},
},
},
},
}
if err := s.processRaftSnapshotRequest(ctx, req,
IncomingSnapshot{
SnapUUID: uuid.MakeV4(),
State: &kvserverpb.ReplicaState{Desc: repl1.Desc()},
}); err != nil {
t.Fatal(err)
}
testutils.SucceedsSoon(t, func() error {
s.mu.Lock()
numPlaceholders := len(s.mu.replicaPlaceholders)
s.mu.Unlock()
if numPlaceholders != 0 {
return errors.Errorf("expected 0 placeholders, but found %d", numPlaceholders)
}
// The count of dropped placeholders is incremented after the placeholder
// is removed (and while not holding Store.mu), so we need to perform the
// check of the number of dropped placeholders in this retry loop.
if n := atomic.LoadInt32(&s.counts.droppedPlaceholders); n != 1 {
return errors.Errorf("expected 1 dropped placeholder, but found %d", n)
}
return nil
})
} | explode_data.jsonl/115 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1096
} | [
2830,
3393,
6093,
13021,
48305,
1925,
55535,
723,
43337,
3018,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
78255,
1669,
1273,
1972,
16094,
62644,
712,
1669,
2936,
7121,
10674,
712,
741,
16867,
2936,
712,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFormatterOverline(test *testing.T) {
formatted, err := formatter.Format("{overline}text{overline | off}")
assert.NoError(test, err)
assert.Equal(test, "\x1b[53mtext\x1b[55m", formatted)
} | explode_data.jsonl/39777 | {
"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,
14183,
1918,
1056,
8623,
353,
8840,
836,
8,
341,
37410,
12127,
11,
1848,
1669,
24814,
9978,
13976,
1975,
1056,
92,
1318,
90,
1975,
1056,
760,
1007,
55266,
6948,
35699,
8623,
11,
1848,
340,
6948,
12808,
8623,
11,
2917,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNestedJoins(t *testing.T) {
catalogStore, err := store.Open("catalog_nestedjoins", store.DefaultOptions())
require.NoError(t, err)
defer os.RemoveAll("catalog_nestedjoins")
dataStore, err := store.Open("sqldata_nestedjoins", store.DefaultOptions())
require.NoError(t, err)
defer os.RemoveAll("sqldata_nestedjoins")
engine, err := NewEngine(catalogStore, dataStore, DefaultOptions().WithPrefix(sqlPrefix))
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE DATABASE db1", nil, true)
require.NoError(t, err)
err = engine.UseDatabase("db1")
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE TABLE table1 (id INTEGER, title VARCHAR, fkid1 INTEGER, PRIMARY KEY id)", nil, true)
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE TABLE table2 (id INTEGER, amount INTEGER, fkid1 INTEGER, PRIMARY KEY id)", nil, true)
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE TABLE table3 (id INTEGER, age INTEGER, PRIMARY KEY id)", nil, true)
require.NoError(t, err)
rowCount := 10
for i := 0; i < rowCount; i++ {
_, err = engine.ExecStmt(fmt.Sprintf("UPSERT INTO table1 (id, title, fkid1) VALUES (%d, 'title%d', %d)", i, i, rowCount-1-i), nil, true)
require.NoError(t, err)
_, err = engine.ExecStmt(fmt.Sprintf("UPSERT INTO table2 (id, amount, fkid1) VALUES (%d, %d, %d)", rowCount-1-i, i*i, i), nil, true)
require.NoError(t, err)
_, err = engine.ExecStmt(fmt.Sprintf("UPSERT INTO table3 (id, age) VALUES (%d, %d)", i, 30+i), nil, true)
require.NoError(t, err)
}
r, err := engine.QueryStmt(`
SELECT id, title, t2.amount AS total_amount, t3.age
FROM table1 t1
INNER JOIN table2 t2 ON (fkid1 = t2.id AND title != NULL)
INNER JOIN table3 t3 ON t2.fkid1 = t3.id
ORDER BY id DESC`, nil, true)
require.NoError(t, err)
cols, err := r.Columns()
require.NoError(t, err)
require.Len(t, cols, 4)
for i := 0; i < rowCount; i++ {
row, err := r.Read()
require.NoError(t, err)
require.NotNil(t, row)
require.Len(t, row.Values, 4)
require.Equal(t, int64(rowCount-1-i), row.Values[EncodeSelector("", "db1", "t1", "id")].Value())
require.Equal(t, fmt.Sprintf("title%d", rowCount-1-i), row.Values[EncodeSelector("", "db1", "t1", "title")].Value())
require.Equal(t, int64((rowCount-1-i)*(rowCount-1-i)), row.Values[EncodeSelector("", "db1", "t2", "total_amount")].Value())
require.Equal(t, int64(30+(rowCount-1-i)), row.Values[EncodeSelector("", "db1", "t3", "age")].Value())
}
err = r.Close()
require.NoError(t, err)
err = engine.Close()
require.NoError(t, err)
} | explode_data.jsonl/64081 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1067
} | [
2830,
3393,
71986,
22493,
1330,
1155,
353,
8840,
836,
8,
341,
1444,
7750,
6093,
11,
1848,
1669,
3553,
12953,
445,
26539,
66279,
7305,
1330,
497,
3553,
13275,
3798,
2398,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
84427,
445,
26539,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateColPointGet(t *testing.T) {
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
defer func() {
tk.MustExec(fmt.Sprintf("set global tidb_row_format_version = %d", variable.DefTiDBRowFormatV2))
}()
tests2 := []int{variable.DefTiDBRowFormatV1, variable.DefTiDBRowFormatV2}
for _, rowFormat := range tests2 {
tk.MustExec(fmt.Sprintf("set global tidb_row_format_version = %d", rowFormat))
tk.MustExec("drop table if exists tu")
tk.MustExec("CREATE TABLE `tu`(`x` int, `y` int, `z` int GENERATED ALWAYS AS (x + y) VIRTUAL, PRIMARY KEY (`x`), UNIQUE KEY `idz` (`z`))")
tk.MustExec("insert into tu(x, y) values(1, 2);")
// test point get lock
tk.MustExec("begin pessimistic")
tk.MustQuery("select * from tu where z = 3 for update").Check(testkit.Rows("1 2 3"))
tk2 := testkit.NewTestKit(t, store)
tk2.MustExec("use test")
tk2.MustExec("begin pessimistic")
err := tk2.ExecToErr("select * from tu where z = 3 for update nowait")
require.Error(t, err)
require.True(t, terror.ErrorEqual(err, storeerr.ErrLockAcquireFailAndNoWaitSet))
tk.MustExec("begin pessimistic")
tk.MustExec("insert into tu(x, y) values(2, 2);")
err = tk2.ExecToErr("select * from tu where z = 4 for update nowait")
require.Error(t, err)
require.True(t, terror.ErrorEqual(err, storeerr.ErrLockAcquireFailAndNoWaitSet))
// test batch point get lock
tk.MustExec("begin pessimistic")
tk2.MustExec("begin pessimistic")
tk.MustQuery("select * from tu where z in (1, 3, 5) for update").Check(testkit.Rows("1 2 3"))
tk2.MustExec("begin pessimistic")
err = tk2.ExecToErr("select x from tu where z in (3, 7, 9) for update nowait")
require.Error(t, err)
require.True(t, terror.ErrorEqual(err, storeerr.ErrLockAcquireFailAndNoWaitSet))
tk.MustExec("begin pessimistic")
tk.MustExec("insert into tu(x, y) values(5, 6);")
err = tk2.ExecToErr("select * from tu where z = 11 for update nowait")
require.Error(t, err)
require.True(t, terror.ErrorEqual(err, storeerr.ErrLockAcquireFailAndNoWaitSet))
tk.MustExec("commit")
tk2.MustExec("commit")
}
} | explode_data.jsonl/12484 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 832
} | [
2830,
3393,
31115,
6127,
2609,
1949,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1855,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50463,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStep(t *testing.T) {
// wide range of step sizes to try and hit edge cases
steps := [...]int{1, 3, 4, 7, 8, 17, 24, 30, 64, 256}
rnd := rand.New(rand.NewSource(123))
for _, c := range testVectors {
s, _ := NewUnauthenticatedCipher(hexDecode(c.key), hexDecode(c.nonce))
input := hexDecode(c.input)
output := make([]byte, len(input))
// step through the buffers
i, step := 0, steps[rnd.Intn(len(steps))]
for i+step < len(input) {
s.XORKeyStream(output[i:i+step], input[i:i+step])
if i+step < len(input) && output[i+step] != 0 {
t.Errorf("length=%v, i=%v, step=%v: output overwritten", len(input), i, step)
}
i += step
step = steps[rnd.Intn(len(steps))]
}
// finish the encryption
s.XORKeyStream(output[i:], input[i:])
// ensure we tolerate a call with an empty input
s.XORKeyStream(output[len(output):], input[len(input):])
got := hex.EncodeToString(output)
if got != c.output {
t.Errorf("length=%v: got %#v, want %#v", len(input), got, c.output)
}
}
} | explode_data.jsonl/80524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 435
} | [
2830,
3393,
8304,
1155,
353,
8840,
836,
8,
341,
197,
322,
6884,
2088,
315,
3019,
12282,
311,
1430,
323,
4201,
6821,
5048,
198,
18388,
7124,
1669,
48179,
396,
90,
16,
11,
220,
18,
11,
220,
19,
11,
220,
22,
11,
220,
23,
11,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestKeepComments(t *testing.T) {
t.Parallel()
in := "# foo\ncmd\n# bar"
want := &File{
Stmts: []*Stmt{{
Comments: []Comment{{Text: " foo"}},
Cmd: litCall("cmd"),
}},
Last: []Comment{{Text: " bar"}},
}
singleParse(NewParser(KeepComments(true)), in, want)(t)
} | explode_data.jsonl/55110 | {
"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,
19434,
17373,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
17430,
1669,
5869,
15229,
59,
1016,
2277,
1699,
2,
3619,
698,
50780,
1669,
609,
1703,
515,
197,
197,
31063,
82,
25,
29838,
31063,
90,
515,
298,
197,
17373... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInsertShardedIgnoreOwnedWithNull(t *testing.T) {
invschema := &vschemapb.SrvVSchema{
Keyspaces: map[string]*vschemapb.Keyspace{
"sharded": {
Sharded: true,
Vindexes: map[string]*vschemapb.Vindex{
"primary": {
Type: "hash",
},
"onecol": {
Type: "lookup",
Params: map[string]string{
"table": "lkp1",
"from": "from",
"to": "toc",
},
Owner: "t1",
},
},
Tables: map[string]*vschemapb.Table{
"t1": {
ColumnVindexes: []*vschemapb.ColumnVindex{{
Name: "primary",
Columns: []string{"id"},
}, {
Name: "onecol",
Columns: []string{"c3"},
}},
},
},
},
},
}
vs, err := vindexes.BuildVSchema(invschema)
if err != nil {
t.Fatal(err)
}
ks := vs.Keyspaces["sharded"]
ins := NewInsert(
InsertShardedIgnore,
ks.Keyspace,
[]sqltypes.PlanValue{{
// colVindex columns: id
Values: []sqltypes.PlanValue{{
// rows for id
Values: []sqltypes.PlanValue{{
Value: sqltypes.NewInt64(1),
}},
}},
}, {
// colVindex columns: c3
Values: []sqltypes.PlanValue{{
// rows for c3
Values: []sqltypes.PlanValue{{
Value: sqltypes.NULL,
}},
}},
}},
ks.Tables["t1"],
"prefix",
[]string{" mid1", " mid2", " mid3", " mid4"},
" suffix",
)
ksid0 := sqltypes.MakeTestResult(
sqltypes.MakeTestFields(
"to",
"varbinary",
),
"\x00",
)
vc := &loggingVCursor{
shards: []string{"-20", "20-"},
shardForKsid: []string{"-20", "20-"},
results: []*sqltypes.Result{
ksid0,
ksid0,
ksid0,
},
}
_, err = ins.Execute(vc, map[string]*querypb.BindVariable{}, false)
if err != nil {
t.Fatal(err)
}
vc.ExpectLog(t, []string{
`Execute insert ignore into lkp1(from, toc) values(:from0, :toc0) from0: toc0: type:VARBINARY ` +
`value:"\026k@\264J\272K\326" true`,
`Execute select from from lkp1 where from = :from and toc = :toc from: toc: type:VARBINARY value:"\026k@\264J\272K\326" false`,
`ResolveDestinations sharded [value:"0" ] Destinations:DestinationKeyspaceID(166b40b44aba4bd6)`,
`ExecuteMultiShard sharded.-20: prefix mid1 suffix /* vtgate:: keyspace_id:166b40b44aba4bd6 */ ` +
`{_c30: _id0: type:INT64 value:"1" } true true`,
})
} | explode_data.jsonl/55993 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1147
} | [
2830,
3393,
13780,
2016,
20958,
12497,
57641,
2354,
3280,
1155,
353,
8840,
836,
8,
341,
17430,
11562,
3416,
1669,
609,
11562,
2407,
391,
65,
808,
10553,
53,
8632,
515,
197,
197,
8850,
27338,
25,
2415,
14032,
8465,
11562,
2407,
391,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCheckBuffer(t *testing.T) {
var buf = make([]byte, 512)
n := uint64(256)
b := CheckBuffer(buf, n)
if uint64(len(b)) != n {
t.Errorf("error %d != %d", len(b), n)
}
} | explode_data.jsonl/58544 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
3973,
4095,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
284,
1281,
10556,
3782,
11,
220,
20,
16,
17,
340,
9038,
1669,
2622,
21,
19,
7,
17,
20,
21,
340,
2233,
1669,
4248,
4095,
10731,
11,
308,
340,
743,
2622,
21,
19,
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... | 2 |
func TestFileServing(t *testing.T) {
const (
fname = "test.txt"
data = "This is test data"
)
dir, err := ioutil.TempDir("", "data")
if err != nil {
t.Fatalf("error creating tmp dir: %v", err)
}
if err := ioutil.WriteFile(filepath.Join(dir, fname), []byte(data), 0755); err != nil {
t.Fatalf("error writing tmp file: %v", err)
}
const prefix = "/foo/"
handler := newFileHandler(prefix, dir)
server := httptest.NewServer(handler)
defer server.Close()
url := server.URL + prefix + fname
res, err := http.Get(url)
if err != nil {
t.Fatalf("http.Get(%q) error: %v", url, err)
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
t.Errorf("res.StatusCode = %d; want %d", res.StatusCode, http.StatusOK)
}
b, err := ioutil.ReadAll(res.Body)
if err != nil {
t.Fatalf("error reading resp body: %v", err)
}
if string(b) != data {
t.Errorf("have %q; want %q", string(b), data)
}
} | explode_data.jsonl/66374 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
1703,
50,
19505,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
1166,
606,
284,
330,
1944,
3909,
698,
197,
8924,
220,
284,
330,
1986,
374,
1273,
821,
698,
197,
340,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
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... | 7 |
func TestUpdateAutoscalerWrongParams(t *testing.T) {
// given
suite := NewBrokerSuiteTest(t)
defer suite.TearDown()
id := uuid.New().String()
resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true&plan_id=7d55d31d-35ae-4438-bf13-6ffdfa107d9f&service_id=47c9dcbf-ff30-448e-ab36-d3bad66ba281", id), `
{
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
"plan_id": "7d55d31d-35ae-4438-bf13-6ffdfa107d9f",
"context": {
"sm_platform_credentials": {
"url": "https://sm.url",
"credentials": {}
},
"globalaccount_id": "g-account-id",
"subaccount_id": "sub-id",
"user_id": "john.smith@email.com"
},
"parameters": {
"name": "testing-cluster",
"autoScalerMin":5,
"autoScalerMax":7,
"maxSurge":3,
"maxUnavailable":4
}
}`)
opID := suite.DecodeOperationID(resp)
suite.processProvisioningByOperationID(opID)
// when
resp = suite.CallAPI("PATCH", fmt.Sprintf("oauth/cf-eu10/v2/service_instances/%s?accepts_incomplete=true", id), `
{
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
"plan_id": "7d55d31d-35ae-4438-bf13-6ffdfa107d9f",
"context": {
"globalaccount_id": "g-account-id",
"user_id": "jack.anvil@email.com"
},
"parameters": {
"autoScalerMin":26,
"autoScalerMax":25,
"maxSurge":10,
"maxUnavailable":7
}
}`)
// then
assert.Equal(t, http.StatusUnprocessableEntity, resp.StatusCode)
} | explode_data.jsonl/8131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 660
} | [
2830,
3393,
4289,
19602,
436,
63084,
29185,
4870,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
96572,
1669,
1532,
65545,
28000,
2271,
1155,
340,
16867,
16182,
836,
682,
4454,
741,
15710,
1669,
16040,
7121,
1005,
703,
2822,
34653,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckForbiddenErrorAndResbmitAllowed(t *testing.T) {
cancel, controller := newController()
defer cancel()
wf := unmarshalWF(resubmitPendingWf)
woc := newWorkflowOperationCtx(wf, controller)
forbiddenErr := apierr.NewForbidden(schema.GroupResource{Group: "test", Resource: "test1"}, "test", errors.New("exceeded quota"))
nonForbiddenErr := apierr.NewBadRequest("badrequest")
t.Run("ForbiddenError", func(t *testing.T) {
node, err := woc.requeueIfTransientErr(forbiddenErr, "resubmit-pending-wf")
assert.NotNil(t, node)
assert.NoError(t, err)
assert.Equal(t, wfv1.NodePending, node.Phase)
})
t.Run("NonForbiddenError", func(t *testing.T) {
node, err := woc.requeueIfTransientErr(nonForbiddenErr, "resubmit-pending-wf")
assert.Error(t, err)
assert.Nil(t, node)
})
} | explode_data.jsonl/71022 | {
"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,
3973,
69115,
1454,
3036,
1061,
65,
1763,
35382,
1155,
353,
8840,
836,
8,
341,
84441,
11,
6461,
1669,
501,
2051,
741,
16867,
9121,
741,
6692,
69,
1669,
650,
27121,
32131,
4590,
392,
1763,
32027,
54,
69,
340,
6692,
509,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFlowRejectsMalformedSchedule(t *testing.T) {
workflow, err := parseString(`workflow "foo" { on = "schedule(" resolves = "a" } action "a" { uses="./x" }`)
assertParseError(t, err, 1, 1, workflow,
"workflow `foo' has an invalid `on' attribute `schedule(' - must be a known event type or schedule expression",
)
} | explode_data.jsonl/55687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
18878,
78413,
82,
29600,
10155,
32210,
1155,
353,
8840,
836,
8,
341,
197,
56249,
11,
1848,
1669,
4715,
703,
5809,
56249,
330,
7975,
1,
314,
389,
284,
330,
28630,
445,
63297,
284,
330,
64,
1,
335,
1917,
330,
64,
1,
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... | 1 |
func TestApp01maDisconnect(t *testing.T) {
var err error
t.Logf("TestDisconnect()...\n")
ioApp01ma = NewIoApp01ma()
ioApp01ma.DefaultParms()
// Disconnect before a connection has been made.
err = ioApp01ma.Disconnect()
if err == nil {
t.Fatal("Error: Never Connected!\n\n\n")
}
if ioApp01ma.IsConnected() {
t.Fatal("Error: Never Connected!\n\n\n")
}
// Now connect then disconnect.
err = ioApp01ma.Connect("")
if err != nil {
t.Fatal("Error: Cannot connect: ", err)
}
if !ioApp01ma.IsConnected() {
t.Fatal("Error: Never Connected!\n\n\n")
}
err = ioApp01ma.Disconnect()
if err != nil {
t.Fatal("Error: Cannot disconnect: ", err)
}
ioApp01ma = nil
t.Logf("TestDisconnect() - End of Test\n\n\n")
} | explode_data.jsonl/16189 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 371
} | [
2830,
3393,
2164,
15,
16,
1728,
60651,
1155,
353,
8840,
836,
8,
341,
262,
762,
1848,
260,
1465,
271,
3244,
98954,
445,
2271,
60651,
368,
30801,
77,
1138,
53112,
2164,
15,
16,
1728,
284,
1532,
42799,
2164,
15,
16,
1728,
741,
53112,
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... | 6 |
func TestGrpcMatchEventStreaming(t *testing.T) {
log.Printf("Starting GET5 gRPC Client...")
conn, err := grpc.Dial("127.0.0.1:50055", grpc.WithInsecure())
if err != nil {
t.Errorf("client connection error:%v\n", err)
}
defer conn.Close()
req := &pb.MatchEventRequest{
Matchid: 97,
}
client := pb.NewGet5Client(conn)
stream, err := client.MatchEvent(context.Background(), req)
if err != nil {
}
for {
resp, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
log.Fatalf("ERR : %v", err)
}
log.Printf("resp : %v\n", resp)
}
} | explode_data.jsonl/40917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
6464,
3992,
8331,
1556,
76509,
1155,
353,
8840,
836,
8,
341,
6725,
19367,
445,
24617,
7890,
20,
342,
29528,
8423,
33093,
32917,
11,
1848,
1669,
47900,
98462,
445,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
20,
15,
15,
20,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestSignUp(t *testing.T) {
// Load the environment variables, this is where things like api keys should be stored.
// Can also store constants shared by multiple services
err := godotenv.Load("../.env")
if err != nil {
panic(errors.Wrap(err, "Could not load .env file"))
}
// Connect to the database
err = db.InitLocalDatabase()
if err != nil {
t.Fatalf("Could not initialize database connection: %v", err)
}
// Mock a request
requestByte, _ := json.Marshal(TestUser)
req, err := http.NewRequest("POST", "localhost:8080/signup", bytes.NewReader(requestByte))
if err != nil {
t.Fatalf("Could not create request: %v", err)
}
rec := httptest.NewRecorder()
routes.HandleSignUp(rec, req)
res := rec.Result()
defer func() {
err = res.Body.Close()
if err != nil {
fmt.Printf("\nThere is an error on body close: %v", err)
}
}()
// Verify correct status code was received
if res.StatusCode != http.StatusOK {
t.Fatalf("expected status OK; got %v instead, with error: %v", res.StatusCode, err)
}
// Parse body of the response
body, err := ioutil.ReadAll(res.Body)
if err != nil {
t.Fatalf("there was an error reading the body of response: %v", err)
}
// Unmarshal the body so we can verify its contents
var response models.WebTokenResponse
err = json.Unmarshal(body, &response)
if err != nil {
t.Fatalf("there was an error marshalling the body of the response: %v", err)
}
// Ensure the web token is valid
email, err := auth.VerifyWebToken(response.Token)
if err != nil {
t.Fatalf("there was an error verifying the web token response: %v", err)
}
// Ensure the corresponding email address matches up
if email != TestUser.ID {
t.Errorf("expected the users email: %v; got %v", TestUser.ID, email)
}
} | explode_data.jsonl/24067 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
57522,
1155,
353,
8840,
836,
8,
341,
197,
322,
8893,
279,
4573,
7332,
11,
419,
374,
1380,
2513,
1075,
6330,
6894,
1265,
387,
9768,
624,
197,
322,
2980,
1083,
3553,
18021,
6094,
553,
5248,
3516,
198,
9859,
1669,
9886,
354,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSortedArray_Empty(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.NewSortedArray(gutil.ComparatorInt)
v, ok := array.PopLeft()
t.Assert(v, nil)
t.Assert(ok, false)
t.Assert(array.PopLefts(10), nil)
v, ok = array.PopRight()
t.Assert(v, nil)
t.Assert(ok, false)
t.Assert(array.PopRights(10), nil)
v, ok = array.PopRand()
t.Assert(v, nil)
t.Assert(ok, false)
t.Assert(array.PopRands(10), nil)
})
} | explode_data.jsonl/67014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
51051,
1857,
76060,
1595,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11923,
1669,
342,
1653,
7121,
51051,
1857,
3268,
1314,
79257,
1072,
340,
197,
5195,
11,
5394,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFilteringServerGetSrvKeyspameNamesFiltersEverythingOut(t *testing.T) {
_, _, f := newFiltering(nil)
doTestGetSrvKeyspaceNames(t, f, stockCell, []string{}, nil)
} | explode_data.jsonl/2376 | {
"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,
5632,
287,
5475,
1949,
50,
10553,
8850,
79,
373,
7980,
28351,
34964,
2662,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
282,
1669,
501,
5632,
287,
27907,
340,
19935,
2271,
1949,
50,
10553,
8850,
1306,
7980,
1155,
11,
282... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCollectTxFeesRollback(t *testing.T) {
cleanAndPrepare()
randVar := rand.New(rand.NewSource(time.Now().Unix()))
var funds, funds2 []*protocol.FundsTx
accAHash := protocol.SerializeHashContent(accA.Address)
accBHash := protocol.SerializeHashContent(accB.Address)
minerHash := protocol.SerializeHashContent(validatorAcc.Address)
minerBal := validatorAcc.Balance
//Rollback everything
var fee uint64
loopMax := int(randVar.Uint64() % 1000)
for i := 0; i < loopMax+1; i++ {
tx, _ := protocol.ConstrFundsTx(0x01, randVar.Uint64()%1000000+1, randVar.Uint64()%100+1, uint32(i), accAHash, accBHash, PrivKeyAccA, nil, nil)
funds = append(funds, tx)
fee += tx.Fee
}
collectTxFees(nil, funds, nil, nil, minerHash)
if minerBal+fee != validatorAcc.Balance {
t.Errorf("%v + %v != %v\n", minerBal, fee, validatorAcc.Balance)
}
collectTxFeesRollback(nil, funds, nil, nil, minerHash)
if minerBal != validatorAcc.Balance {
t.Errorf("Tx fees rollback failed: %v != %v\n", minerBal, validatorAcc.Balance)
}
validatorAcc.Balance = MAX_MONEY - 100
var fee2 uint64
minerBal = validatorAcc.Balance
//Miner gets fees, the miner account balance will overflow at some point
for i := 2; i < 100; i++ {
tx, _ := protocol.ConstrFundsTx(0x01, randVar.Uint64()%1000000+1, uint64(i), uint32(i), accAHash, accBHash, PrivKeyAccA, nil, nil)
funds2 = append(funds2, tx)
fee2 += tx.Fee
}
accABal := accA.Balance
accBBal := accB.Balance
//Should throw an error and result in a rollback, because of acc balance overflow
tmpBlock := newBlock([32]byte{}, [crypto.COMM_KEY_LENGTH]byte{}, 1)
tmpBlock.Beneficiary = minerHash
data := blockData{nil, funds2, nil, nil, tmpBlock}
if err := validateState(data); err == nil ||
minerBal != validatorAcc.Balance ||
accA.Balance != accABal ||
accB.Balance != accBBal {
t.Errorf("No rollback resulted, %v != %v\n", minerBal, validatorAcc.Balance)
}
} | explode_data.jsonl/41099 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 727
} | [
2830,
3393,
47504,
51,
9770,
5516,
32355,
1419,
1155,
353,
8840,
836,
8,
341,
1444,
2675,
3036,
50590,
2822,
7000,
437,
3962,
1669,
10382,
7121,
37595,
7121,
3608,
9730,
13244,
1005,
55832,
49962,
2405,
10514,
11,
10514,
17,
29838,
17014,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestGetOpQueueParameters(t *testing.T) {
t.Run("Valid env values -> error", func(t *testing.T) {
restorePoolEnv := setEnv(t, opQueuePoolEnvKey, "221")
restoreTaskMonitorIntervalEnv := setEnv(t, opQueueTaskMonitorIntervalEnvKey, "17s")
restoreTaskExpirationEnv := setEnv(t, opQueueTaskExpirationEnvKey, "33s")
restoreMaxRepostsEnv := setEnv(t, opQueueMaxRepostsEnvKey, "23")
defer func() {
restorePoolEnv()
restoreTaskExpirationEnv()
restoreTaskMonitorIntervalEnv()
restoreMaxRepostsEnv()
}()
cmd := getTestCmd(t)
opQueueParams, err := getOpQueueParameters(cmd, time.Minute)
require.NoError(t, err)
require.Equal(t, 221, opQueueParams.PoolSize)
require.Equal(t, 17*time.Second, opQueueParams.TaskMonitorInterval)
require.Equal(t, 33*time.Second, opQueueParams.TaskExpiration)
require.Equal(t, 23, opQueueParams.MaxRetries)
require.Equal(t, defaultBatchWriterTimeout+opQueueOperationExpirationGracePeriod, opQueueParams.OpExpiration)
})
t.Run("Not specified -> default value", func(t *testing.T) {
cmd := getTestCmd(t)
opQueueParams, err := getOpQueueParameters(cmd, time.Minute)
require.NoError(t, err)
require.Equal(t, opQueueDefaultPoolSize, opQueueParams.PoolSize)
require.Equal(t, opQueueDefaultTaskMonitorInterval, opQueueParams.TaskMonitorInterval)
require.Equal(t, opQueueDefaultTaskExpiration, opQueueParams.TaskExpiration)
require.Equal(t, opQueueDefaultMaxReposts, opQueueParams.MaxRetries)
require.Equal(t, defaultBatchWriterTimeout+opQueueOperationExpirationGracePeriod, opQueueParams.OpExpiration)
})
t.Run("Invalid pool size value -> error", func(t *testing.T) {
restoreEnv := setEnv(t, opQueuePoolEnvKey, "xxx")
defer func() {
restoreEnv()
}()
cmd := getTestCmd(t)
_, err := getOpQueueParameters(cmd, time.Minute)
require.Error(t, err)
require.Contains(t, err.Error(), "invalid value")
})
t.Run("Invalid pool size value -> error", func(t *testing.T) {
restoreTaskMonitorIntervalEnv := setEnv(t, opQueueTaskMonitorIntervalEnvKey, "17")
defer func() {
restoreTaskMonitorIntervalEnv()
}()
cmd := getTestCmd(t)
_, err := getOpQueueParameters(cmd, time.Minute)
require.Error(t, err)
require.Contains(t, err.Error(), "invalid value")
})
t.Run("Invalid task expiration value -> error", func(t *testing.T) {
restoreTaskExpirationEnv := setEnv(t, opQueueTaskExpirationEnvKey, "33")
defer func() {
restoreTaskExpirationEnv()
}()
cmd := getTestCmd(t)
_, err := getOpQueueParameters(cmd, time.Minute)
require.Error(t, err)
require.Contains(t, err.Error(), "invalid value")
})
t.Run("Invalid max reposts value -> error", func(t *testing.T) {
restoreMaxRepostsEnv := setEnv(t, opQueueMaxRepostsEnvKey, "xxx")
defer func() {
restoreMaxRepostsEnv()
}()
cmd := getTestCmd(t)
_, err := getOpQueueParameters(cmd, time.Minute)
require.Error(t, err)
require.Contains(t, err.Error(), "invalid value")
})
} | explode_data.jsonl/31135 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1156
} | [
2830,
3393,
1949,
7125,
7554,
9706,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4088,
6105,
2750,
1464,
1465,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
96027,
10551,
14359,
1669,
738,
14359,
1155,
11,
1179,
7554,
10551,
14359,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestColorizeResultStringr(t *testing.T) {
cases := []struct {
query []string
from string
expect string
}{
{[]string{""}, "", ""},
{[]string{"qt"}, "libqt", "lib[B]qt[/B]"},
{[]string{"qt"}, "libqtconfig", "lib[B]qt[/B]config"},
{[]string{"Qt"}, "libqt", "lib[B]qt[/B]"},
{[]string{"Qt"}, "libqtconfig", "lib[B]qt[/B]config"},
{[]string{"qt"}, "libQt", "lib[B]Qt[/B]"},
{[]string{"qt"}, "libQtconfig", "lib[B]Qt[/B]config"},
{[]string{"qt"}, "libQtqt", "lib[B]Qt[/B][B]qt[/B]"},
{[]string{"qt"}, "libQtconfigqt", "lib[B]Qt[/B]config[B]qt[/B]"},
{[]string{"qt", "lib"}, "libQtconfigqt", "[B]lib[/B][B]Qt[/B]config[B]qt[/B]"},
}
colorBold = "[B]"
colorNorm = "[/B]"
for _, c := range cases {
res := colorizeResultString(c.query, c.from)
if res != c.expect {
t.Errorf(`Result mismatch
------------------------
query: %#v
string: %#v
expected: %v
got: %v`,
c.query,
c.from,
c.expect, res)
return
}
}
} | explode_data.jsonl/54430 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 462
} | [
2830,
3393,
1636,
551,
2077,
703,
81,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
27274,
220,
3056,
917,
198,
197,
42727,
256,
914,
198,
197,
24952,
914,
198,
197,
59403,
197,
197,
90,
1294,
917,
90,
3014,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.