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 Test_HandleList(t *testing.T) {
RegisterTestingT(t)
req, rw := GetHandlerParams("GET", "/", nil)
type args struct {
w http.ResponseWriter
r *http.Request
cfg *HandlerConfig
httpStatus int
}
tests := []struct {
name string
args args
}{
{
name: "Should call HandleList and return no error when no error is returned in the action",
args: args{
w: rw,
r: req,
cfg: &HandlerConfig{
Action: func() (interface{}, *errors.ServiceError) {
return api.RegionCapacityListItem{
InstanceType: "test",
}, nil
},
},
httpStatus: http.StatusOK,
},
},
{
name: "Should call HandleList and return an error when an error is returned in the action",
args: args{
w: rw,
r: req,
cfg: &HandlerConfig{
Action: func() (interface{}, *errors.ServiceError) {
return nil, errors.NotFound("some action error")
},
},
httpStatus: http.StatusOK,
},
},
{
name: "Should validate without error",
args: args{
w: rw,
r: req,
cfg: &HandlerConfig{
Validate: []Validate{
func() *errors.ServiceError {
return nil
},
},
Action: func() (interface{}, *errors.ServiceError) {
return nil, nil
},
},
},
},
{
name: "Should throw an error if validation fails",
args: args{
w: rw,
r: req,
cfg: &HandlerConfig{
Validate: []Validate{
func() *errors.ServiceError {
return errors.GeneralError("validation failed")
},
},
Action: func() (interface{}, *errors.ServiceError) {
return nil, nil
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
HandleList(tt.args.w, tt.args.r, tt.args.cfg)
Expect(rw.Code).ToNot(Equal(0))
})
}
} | explode_data.jsonl/39861 | {
"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,
42714,
852,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
340,
24395,
11,
25991,
1669,
2126,
3050,
4870,
445,
3806,
497,
64657,
2092,
340,
13158,
2827,
2036,
341,
197,
6692,
688,
1758,
37508,
198,
197,
7000,
688,
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 TestClock_Delay_200kJob(t *testing.T) {
// skip just for pass travis because of lack of performance
t.Skip()
var (
jobsNum = 200000 //添加任务数量
myClock = NewClock()
jobInterval = time.Second
countChan = make(chan int, 0)
count = 0
fn = func() {
countChan <- 1
}
)
start := time.Now()
//初始化20万条任务。考虑到初始化耗时,延时1秒后启动
go func() {
for i := 0; i < jobsNum; i++ {
myClock.AddJobWithInterval(jobInterval, fn)
}
}()
for range countChan {
count++
if count == jobsNum {
break
}
}
end := time.Now()
if end.Sub(start) > time.Second*3 {
t.Errorf("消耗应该控制在%v s,实际消耗%v s。\n", 3, end.Sub(start))
}
} | explode_data.jsonl/2026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
26104,
92726,
62,
17,
15,
15,
74,
12245,
1155,
353,
8840,
836,
8,
341,
197,
322,
10706,
1101,
369,
1494,
10137,
285,
1576,
315,
6853,
315,
5068,
198,
3244,
57776,
741,
2405,
2399,
197,
12428,
5481,
4651,
257,
284,
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... | 1 |
func TestAfter(t *testing.T) {
MockMode = true
done := make(chan struct{})
c := After(5 * time.Second)
go func() {
<-c
done <- struct{}{}
}()
Elapse(5 * time.Second)
<-done
} | explode_data.jsonl/68927 | {
"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,
6025,
1155,
353,
8840,
836,
8,
341,
9209,
1176,
3636,
284,
830,
198,
40495,
1669,
1281,
35190,
2036,
37790,
1444,
1669,
4636,
7,
20,
353,
882,
32435,
692,
30680,
2915,
368,
341,
197,
197,
45342,
66,
198,
197,
40495,
9119,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeamsService_AddTeamProjectByID(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
opt := &TeamProjectOptions{
Permission: String("admin"),
}
wantAcceptHeaders := []string{mediaTypeProjectsPreview}
mux.HandleFunc("/organizations/1/team/1/projects/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
v := &TeamProjectOptions{}
json.NewDecoder(r.Body).Decode(v)
if !cmp.Equal(v, opt) {
t.Errorf("Request body = %+v, want %+v", v, opt)
}
w.WriteHeader(http.StatusNoContent)
})
ctx := context.Background()
_, err := client.Teams.AddTeamProjectByID(ctx, 1, 1, 1, opt)
if err != nil {
t.Errorf("Teams.AddTeamProjectByID returned error: %v", err)
}
const methodName = "AddTeamProjectByID"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Teams.AddTeamProjectByID(ctx, -1, -1, -1, opt)
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Teams.AddTeamProjectByID(ctx, 1, 1, 1, opt)
})
} | explode_data.jsonl/4549 | {
"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,
60669,
1860,
21346,
14597,
7849,
60572,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
64838,
1669,
609,
14597,
7849,
3798,
515,
197,
197,
14966,
25,
923,
445,
2882,
446... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_NewBuffer(t *testing.T) {
buf := New(256)
for i, item := range buf.Bytes() {
if item != 0xdb {
t.Logf("item[%d] = %02x", i, item)
t.Fail()
}
}
buf = nil
runtime.GC()
} | explode_data.jsonl/49447 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
39582,
4095,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
1532,
7,
17,
20,
21,
340,
2023,
600,
11,
1509,
1669,
2088,
6607,
36868,
368,
341,
197,
743,
1509,
961,
220,
15,
54555,
341,
298,
3244,
98954,
445,
1203,
25113,
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... | 3 |
func TestDialect(t *testing.T) {
zdb.RunTest(t, func(t *testing.T, ctx context.Context) {
db := zdb.MustGetDB(ctx)
t.Log(db.SQLDialect())
})
} | explode_data.jsonl/57562 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
35,
55056,
1155,
353,
8840,
836,
8,
341,
20832,
1999,
16708,
2271,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
5635,
2266,
9328,
8,
341,
197,
20939,
1669,
1147,
1999,
50463,
1949,
3506,
7502,
340,
197,
3244,
5247,
9791,
2509... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSellCoinTxCustomToBaseBaseCommission(t *testing.T) {
// sell_coin: TEST
// buy_coin: MNT
// gas_coin: MNT
coinToSell := types.StrToCoinSymbol("TEST")
coinToBuy := types.GetBaseCoin()
gasCoin := types.GetBaseCoin()
initialBalance := helpers.NoahToQNoah(big.NewInt(10000000))
initialGasBalance := helpers.NoahToQNoah(big.NewInt(1))
toSell := helpers.NoahToQNoah(big.NewInt(100))
cState := getState()
initialVolume, initialReserve, crr := createTestCoinWithSymbol(cState, coinToSell)
privateKey, addr := getAccount()
cState.Accounts.AddBalance(addr, coinToSell, initialBalance)
cState.Accounts.AddBalance(addr, gasCoin, initialGasBalance)
tx := createSellCoinTx(coinToSell, coinToBuy, gasCoin, toSell, 1)
if err := tx.Sign(privateKey); err != nil {
t.Fatal(err)
}
encodedTx, err := rlp.EncodeToBytes(tx)
if err != nil {
t.Fatal(err)
}
// check response
response := RunTx(cState, false, encodedTx, big.NewInt(0), 0, &sync.Map{}, 0)
if response.Code != code.OK {
t.Fatalf("Response code is not 0. Error %s", response.Log)
}
// check received coins + commission
buyCoinBalance := cState.Accounts.GetBalance(addr, coinToBuy)
estimatedBuyBalance := formula.CalculateSaleReturn(initialVolume, initialReserve, crr, toSell)
estimatedBuyBalance.Add(estimatedBuyBalance, initialGasBalance)
estimatedBuyBalance.Sub(estimatedBuyBalance, tx.CommissionInBaseCoin())
if buyCoinBalance.Cmp(estimatedBuyBalance) != 0 {
t.Fatalf("Buy coin balance is not correct. Expected %s, got %s", estimatedBuyBalance.String(), buyCoinBalance.String())
}
// check sold coins
sellCoinBalance := cState.Accounts.GetBalance(addr, coinToSell)
estimatedSellCoinBalance := big.NewInt(0).Set(initialBalance)
estimatedSellCoinBalance.Sub(estimatedSellCoinBalance, toSell)
if sellCoinBalance.Cmp(estimatedSellCoinBalance) != 0 {
t.Fatalf("Sell coin balance is not correct")
}
// check reserve and supply
coinData := cState.Coins.GetCoin(coinToSell)
estimatedReserve := big.NewInt(0).Set(initialReserve)
estimatedReserve.Sub(estimatedReserve, formula.CalculateSaleReturn(initialVolume, initialReserve, crr, toSell))
if coinData.Reserve().Cmp(estimatedReserve) != 0 {
t.Fatalf("Wrong coin reserve")
}
estimatedSupply := big.NewInt(0).Set(initialVolume)
estimatedSupply.Sub(estimatedSupply, toSell)
if coinData.Volume().Cmp(estimatedSupply) != 0 {
t.Fatalf("Wrong coin supply")
}
} | explode_data.jsonl/21872 | {
"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,
68533,
41180,
31584,
10268,
1249,
3978,
3978,
73750,
1155,
353,
8840,
836,
8,
341,
197,
322,
4559,
75718,
25,
13602,
198,
197,
322,
3695,
75718,
25,
386,
6408,
198,
197,
322,
6819,
75718,
25,
386,
6408,
271,
197,
7160,
124... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestConfigRemoveWithName(t *testing.T) {
names := []string{"foo", "bar"}
var removedConfigs []string
cli := test.NewFakeCli(&fakeClient{
configRemoveFunc: func(name string) error {
removedConfigs = append(removedConfigs, name)
return nil
},
})
cmd := newConfigRemoveCommand(cli)
cmd.SetArgs(names)
assert.NoError(t, cmd.Execute())
assert.Equal(t, names, strings.Split(strings.TrimSpace(cli.OutBuffer().String()), "\n"))
assert.Equal(t, names, removedConfigs)
} | explode_data.jsonl/2727 | {
"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,
2648,
13021,
54523,
1155,
353,
8840,
836,
8,
341,
93940,
1669,
3056,
917,
4913,
7975,
497,
330,
2257,
16707,
2405,
6963,
84905,
3056,
917,
198,
86448,
1669,
1273,
7121,
52317,
87014,
2099,
30570,
2959,
515,
197,
25873,
13021,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnums(t *testing.T) {
assert := assert.New(t)
type User struct {
Name *string `enums:"alice,bob"`
Age *int64 `enums:"20,30"`
}
assert.NoError(
v.Validate(&User{}, valis.EachFields(tagrule.Enums)),
)
assert.EqualError(
v.Validate(&User{
Name: henge.ToStringPtr(""),
Age: henge.ToIntPtr(0),
}, valis.EachFields(tagrule.Enums)),
"(inclusion) .Name is not included in [alice bob]\n(inclusion) .Age is not included in [20 30]",
)
assert.EqualError(
v.Validate(&User{
Name: henge.ToStringPtr("a"),
Age: henge.ToIntPtr(10),
}, valis.EachFields(tagrule.Enums)),
"(inclusion) .Name is not included in [alice bob]\n(inclusion) .Age is not included in [20 30]",
)
assert.NoError(
v.Validate(&User{
Name: henge.ToStringPtr("alice"),
Age: henge.ToIntPtr(20),
}, valis.EachFields(tagrule.Enums)),
)
} | explode_data.jsonl/17248 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 378
} | [
2830,
3393,
71586,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
13158,
2657,
2036,
341,
197,
21297,
353,
917,
1565,
92572,
2974,
63195,
8402,
674,
8805,
197,
197,
16749,
220,
353,
396,
21,
19,
220,
1565,
92572,
297... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRenameVersion(t *testing.T) {
tests := []struct {
version, want string
}{
{
version: "directory_v1",
want: "directory/v1",
},
{
version: "email_migration_v1",
want: "email_migration/v1",
},
{
version: "my_api_v1.2",
want: "my_api/v1.2",
},
}
for _, test := range tests {
if got := renameVersion(test.version); got != test.want {
t.Errorf("renameVersion(%q) = %q; want %q", test.version, got, test.want)
}
}
} | explode_data.jsonl/77379 | {
"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,
88757,
5637,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
74954,
11,
1366,
914,
198,
197,
59403,
197,
197,
515,
298,
74954,
25,
330,
23037,
2273,
16,
756,
298,
50780,
25,
262,
330,
23037,
5457,
16,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestContainerIgnoredPorts(t *testing.T) {
tests := []struct {
name string
container FakeContainer
want map[int]bool
}{
{
name: "No label",
container: FakeContainer{
FakeID: "1234",
FakeContainerName: "test",
},
want: map[int]bool{},
},
{
name: "ignore-443",
container: FakeContainer{
FakeID: "1234",
FakeContainerName: "test",
FakeLabels: map[string]string{
"glouton.check.ignore.port.443": "true",
},
},
want: map[int]bool{
443: true,
},
},
{
name: "unknown-labels",
container: FakeContainer{
FakeID: "1234",
FakeContainerName: "test",
FakeLabels: map[string]string{
"prometheus.io/scrape-port=443": "true",
"check.ignore.port.443": "true",
"port": "443",
},
},
want: map[int]bool{},
},
{
name: "multiple-ignore",
container: FakeContainer{
FakeID: "1234",
FakeContainerName: "test",
FakeLabels: map[string]string{
"glouton.check.ignore.port.1000": "true",
"glouton.check.ignore.port.1001": "tRuE",
"glouton.check.ignore.port.1002": "on",
"glouton.check.ignore.port.1003": "1",
},
},
want: map[int]bool{
1000: true,
1001: true,
1002: true,
1003: true,
},
},
{
name: "with-ignore-and-not-ignore",
container: FakeContainer{
FakeID: "1234",
FakeContainerName: "test",
FakeLabels: map[string]string{
"glouton.check.ignore.port.1000": "true",
"glouton.check.ignore.port.1001": "faLse",
"glouton.check.ignore.port.1002": "oFf",
"glouton.check.ignore.port.1003": "0",
"another-label": "unread",
},
},
want: map[int]bool{
1000: true,
1001: false,
1002: false,
1003: false,
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if got := ContainerIgnoredPorts(tt.container); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ContainerIgnoredPorts() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/32998 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1090
} | [
2830,
3393,
4502,
43337,
3018,
68273,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
53290,
36965,
4502,
198,
197,
50780,
414,
2415,
18640,
96436,
198,
197,
59403,
197,
197,
515,
298,
11609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnvColorForced(t *testing.T) {
orig_NO_COLOR := os.Getenv("NO_COLOR")
orig_CLICOLOR := os.Getenv("CLICOLOR")
orig_CLICOLOR_FORCE := os.Getenv("CLICOLOR_FORCE")
t.Cleanup(func() {
os.Setenv("NO_COLOR", orig_NO_COLOR)
os.Setenv("CLICOLOR", orig_CLICOLOR)
os.Setenv("CLICOLOR_FORCE", orig_CLICOLOR_FORCE)
})
tests := []struct {
name string
NO_COLOR string
CLICOLOR string
CLICOLOR_FORCE string
want bool
}{
{
name: "pristine env",
NO_COLOR: "",
CLICOLOR: "",
CLICOLOR_FORCE: "",
want: false,
},
{
name: "NO_COLOR enabled",
NO_COLOR: "1",
CLICOLOR: "",
CLICOLOR_FORCE: "",
want: false,
},
{
name: "CLICOLOR disabled",
NO_COLOR: "",
CLICOLOR: "0",
CLICOLOR_FORCE: "",
want: false,
},
{
name: "CLICOLOR enabled",
NO_COLOR: "",
CLICOLOR: "1",
CLICOLOR_FORCE: "",
want: false,
},
{
name: "CLICOLOR_FORCE enabled",
NO_COLOR: "",
CLICOLOR: "",
CLICOLOR_FORCE: "1",
want: true,
},
{
name: "CLICOLOR_FORCE disabled",
NO_COLOR: "",
CLICOLOR: "",
CLICOLOR_FORCE: "0",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
os.Setenv("NO_COLOR", tt.NO_COLOR)
os.Setenv("CLICOLOR", tt.CLICOLOR)
os.Setenv("CLICOLOR_FORCE", tt.CLICOLOR_FORCE)
if got := EnvColorForced(); got != tt.want {
t.Errorf("EnvColorForced(): want %v, got %v", tt.want, got)
}
})
}
} | explode_data.jsonl/42287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 984
} | [
2830,
3393,
14359,
1636,
2461,
1998,
1155,
353,
8840,
836,
8,
341,
197,
4670,
9100,
14471,
1669,
2643,
64883,
445,
8996,
14471,
1138,
197,
4670,
6843,
1317,
8497,
1669,
2643,
64883,
445,
3140,
1317,
8497,
1138,
197,
4670,
6843,
1317,
84... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseTemplate(t *testing.T) {
for _, tt := range []struct {
name string
annotationFilter string
fqdnTemplate string
combineFQDNAndAnnotation bool
expectError bool
}{
{
name: "invalid template",
expectError: true,
fqdnTemplate: "{{.Name",
},
{
name: "valid empty template",
expectError: false,
},
{
name: "valid template",
expectError: false,
fqdnTemplate: "{{.Name}}-{{.Namespace}}.ext-dns.test.com",
},
{
name: "valid template",
expectError: false,
fqdnTemplate: "{{.Name}}-{{.Namespace}}.ext-dns.test.com, {{.Name}}-{{.Namespace}}.ext-dna.test.com",
},
{
name: "valid template",
expectError: false,
fqdnTemplate: "{{.Name}}-{{.Namespace}}.ext-dns.test.com, {{.Name}}-{{.Namespace}}.ext-dna.test.com",
combineFQDNAndAnnotation: true,
},
{
name: "non-empty annotation filter label",
expectError: false,
annotationFilter: "kubernetes.io/ingress.class=nginx",
},
} {
t.Run(tt.name, func(t *testing.T) {
_, err := parseTemplate(tt.fqdnTemplate)
if tt.expectError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
})
}
} | explode_data.jsonl/55708 | {
"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,
14463,
7275,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
3824,
914,
198,
197,
197,
24674,
5632,
260,
914,
198,
197,
1166,
80,
17395,
7275,
1797,
914,
198,
197,
197,
63136,
37,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTopDownPartialObjectDoc(t *testing.T) {
tests := []struct {
note string
rule string
expected interface{}
}{
{"identity", `p[k] = v { b[k] = v }`, `{"v1": "hello", "v2": "goodbye"}`},
{"composites", `p[k] = v { d[k] = v }`, `{"e": ["bar", "baz"]}`},
{"body/join var", `p[k] = v { a[i] = v; g[k][i] = v }`, `{"a": 1, "b": 2, "c": 4}`},
{"composite value", `p[k] = [v1, {"v2": v2}] { g[k] = x; x[v1] = v2; v2 != 0 }`, `{
"a": [0, {"v2": 1}],
"b": [1, {"v2": 2}],
"c": [3, {"v2": 4}]
}`},
{"same key/value pair", `p[k] = 1 { ks = ["a", "b", "c", "a"]; ks[_] = k }`, `{"a":1,"b":1,"c":1}`},
}
data := loadSmallTestData()
for _, tc := range tests {
runTopDownTestCase(t, data, tc.note, []string{tc.rule}, tc.expected)
}
} | explode_data.jsonl/25194 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 404
} | [
2830,
3393,
5366,
4454,
37314,
1190,
9550,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
9038,
1272,
257,
914,
198,
197,
7000,
1111,
257,
914,
198,
197,
42400,
3749,
16094,
197,
59403,
197,
197,
4913,
16912,
497,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCloudTasksTestIamPermissionsError(t *testing.T) {
errCode := codes.PermissionDenied
mockCloudTasks.err = gstatus.Error(errCode, "test error")
var formattedResource string = fmt.Sprintf("projects/%s/locations/%s/queues/%s", "[PROJECT]", "[LOCATION]", "[QUEUE]")
var permissions []string = nil
var request = &iampb.TestIamPermissionsRequest{
Resource: formattedResource,
Permissions: permissions,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.TestIamPermissions(context.Background(), request)
if st, ok := gstatus.FromError(err); !ok {
t.Errorf("got error %v, expected grpc error", err)
} else if c := st.Code(); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
_ = resp
} | explode_data.jsonl/30860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
16055,
25449,
2271,
40,
309,
23851,
1454,
1155,
353,
8840,
836,
8,
341,
9859,
2078,
1669,
13912,
73409,
54481,
198,
77333,
16055,
25449,
18441,
284,
342,
2829,
6141,
3964,
2078,
11,
330,
1944,
1465,
5130,
2405,
23126,
4783,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIgnoreMapKey(t *testing.T) {
data := map[string]interface{}{
"x": 99,
"items": []struct {
Id int
Name string
}{
{Id: 3},
{Id: 4, Name: "testname"},
},
}
tmpl, err := New("t1").Option("missingkey=ignore").Parse(
`x={{.x | printf "num %d"}} {{.y | printf "y=%s"}}
{{- if .z }}
z={{ .z }}
{{- end }}
nested={{ .a.b.c }}
{{- range $item := .items }}
id={{ $item.Id }}, name={{ $item.Name }}
{{- end }}
end
`)
if err != nil {
t.Fatal(err)
}
var b bytes.Buffer
err = tmpl.Execute(&b, data)
if err != nil {
t.Fatal("default:", err)
}
want := `x=num 99 {{ .y | printf "y=%s" }}
nested={{ .a.b.c }}
id=3, name=
id=4, name=testname
end
`
got := b.String()
if got != want {
t.Errorf("got %q; expected %q", got, want)
}
} | explode_data.jsonl/41527 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 372
} | [
2830,
3393,
12497,
2227,
1592,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
2415,
14032,
31344,
67066,
197,
197,
65438,
788,
220,
24,
24,
345,
197,
197,
1,
3615,
788,
3056,
1235,
341,
298,
67211,
256,
526,
198,
298,
21297,
914,
198,
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... | 4 |
func Test_newHDG(t *testing.T) {
tests := []struct {
name string
raw string
want HDG
wantErr bool
}{
// TODO: Add test cases.
{
name: "test1",
raw: makeSentence("$BDHDG,5.0,100.1,E,9.00,W"),
want: HDG{
Heading: 5.0,
Deviation: 100.1,
DeviationDirection: "E",
Variation: 9.00,
VariationDirection: "W",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m, err := Parse(tt.raw)
if err != nil {
t.Errorf("newHDG() error = %v", err)
return
}
msg := m.(HDG)
msg.BaseSentence = BaseSentence{}
if diff := deep.Equal(msg, tt.want); diff != nil {
t.Errorf("newHDG() = %#v, want %#v, dif = %v", msg, tt.want, diff)
}
})
}
} | explode_data.jsonl/13312 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 425
} | [
2830,
3393,
5921,
19147,
38,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
76559,
257,
914,
198,
197,
50780,
262,
12169,
38,
198,
197,
50780,
7747,
1807,
198,
197,
59403,
197,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetDeploymentPayload(t *testing.T) {
defaultGopath := os.Getenv("GOPATH")
testdataPath, err := filepath.Abs("testdata")
require.NoError(t, err)
platform := &Platform{}
var tests = []struct {
gopath string
spec *pb.ChaincodeSpec
succ bool
}{
{gopath: defaultGopath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "github.com/sinochem-tech/fabric/examples/chaincode/go/map"}}, succ: true},
{gopath: defaultGopath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "github.com/sinochem-tech/fabric/examples/bad/go/map"}}, succ: false},
{gopath: testdataPath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "chaincodes/BadImport"}}, succ: false},
{gopath: testdataPath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "chaincodes/BadMetadataInvalidIndex"}}, succ: false},
{gopath: testdataPath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "chaincodes/BadMetadataUnexpectedFolderContent"}}, succ: false},
{gopath: testdataPath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "chaincodes/BadMetadataIgnoreHiddenFile"}}, succ: true},
{gopath: testdataPath, spec: &pb.ChaincodeSpec{ChaincodeId: &pb.ChaincodeID{Name: "Test Chaincode", Path: "chaincodes/empty/"}}, succ: false},
}
for _, tst := range tests {
reset := updateGopath(t, tst.gopath)
_, err := platform.GetDeploymentPayload(tst.spec)
t.Log(err)
if err = testerr(err, tst.succ); err != nil {
t.Errorf("Error validating chaincode spec: %s, %s", tst.spec.ChaincodeId.Path, err)
}
reset()
}
} | explode_data.jsonl/2266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 640
} | [
2830,
3393,
1949,
75286,
29683,
1155,
353,
8840,
836,
8,
341,
11940,
38,
35111,
1669,
2643,
64883,
445,
98733,
4827,
1138,
18185,
691,
1820,
11,
1848,
1669,
26054,
33255,
445,
92425,
1138,
17957,
35699,
1155,
11,
1848,
692,
197,
15734,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoute_GetId(t *testing.T) {
route := Route{}
route.id = uuid.New().String()
got := route.GetId()
if got != route.id {
t.Errorf("getId() = %s, want %s", got, route.id)
}
} | explode_data.jsonl/67787 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
4899,
13614,
764,
1155,
353,
8840,
836,
8,
341,
7000,
2133,
1669,
9572,
16094,
7000,
2133,
1764,
284,
16040,
7121,
1005,
703,
741,
3174,
354,
1669,
6021,
2234,
764,
2822,
743,
2684,
961,
6021,
1764,
341,
197,
3244,
13080,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTargetBC(t *testing.T) {
cases := []struct {
name string
pa *PodAutoscaler
want float64
wantOK bool
}{{
name: "not present",
pa: pa(map[string]string{}),
}, {
name: "present",
pa: pa(map[string]string{
autoscaling.TargetBurstCapacityKey: "101.0",
}),
want: 101,
wantOK: true,
}, {
name: "present 0",
pa: pa(map[string]string{
autoscaling.TargetBurstCapacityKey: "0",
}),
want: 0,
wantOK: true,
}, {
name: "present -1",
pa: pa(map[string]string{
autoscaling.TargetBurstCapacityKey: "-1",
}),
want: -1,
wantOK: true,
}, {
name: "malformed",
pa: pa(map[string]string{
autoscaling.TargetBurstCapacityKey: "NPH",
}),
}}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got, gotOK := tc.pa.TargetBC()
if got, want := got, tc.want; got != want {
t.Errorf("TBC = %v, want: %v", got, want)
}
if gotOK != tc.wantOK {
t.Errorf("OK = %v, want: %v", gotOK, tc.wantOK)
}
})
}
} | explode_data.jsonl/27238 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
6397,
4897,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
3223,
64,
257,
353,
23527,
19602,
436,
63084,
198,
197,
50780,
256,
2224,
21,
19,
198,
197,
50780,
3925,
1807,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestLookupHostResultIsNotRandomizedWithNoRandom(t *testing.T) {
orgAddrs, err := net.LookupHost("localhost")
if err != nil {
t.Fatalf("Error looking up host: %v", err)
}
// We actually want the IPv4 and IPv6 addresses, so lets make sure.
if !reflect.DeepEqual(orgAddrs, []string{"::1", "127.0.0.1"}) {
t.Skip("Was looking for IPv4 and IPv6 addresses for localhost to perform test")
}
opts := gnatsd.DefaultTestOptions
opts.Host = orgAddrs[0]
opts.Port = TEST_PORT
s1 := RunServerWithOptions(&opts)
defer s1.Shutdown()
opts.Host = orgAddrs[1]
s2 := RunServerWithOptions(&opts)
defer s2.Shutdown()
for i := 0; i < 100; i++ {
nc, err := Connect(fmt.Sprintf("localhost:%d", TEST_PORT), DontRandomize())
if err != nil {
t.Fatalf("Error on connect: %v", err)
}
defer nc.Close()
}
if ncls := s1.NumClients(); ncls != 100 {
t.Fatalf("Expected all clients on first server, only got %d of 100", ncls)
}
} | explode_data.jsonl/44931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
34247,
9296,
2077,
3872,
2623,
13999,
1506,
2354,
2753,
13999,
1155,
353,
8840,
836,
8,
341,
87625,
2212,
5428,
11,
1848,
1669,
4179,
79261,
9296,
445,
8301,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1454,
3330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnschedulablePodsMap(t *testing.T) {
var pods = []*v1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Name: "p0",
Namespace: "ns1",
Annotations: map[string]string{
"annot1": "val1",
},
},
Status: v1.PodStatus{
NominatedNodeName: "node1",
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "p1",
Namespace: "ns1",
Annotations: map[string]string{
"annot": "val",
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "p2",
Namespace: "ns2",
Annotations: map[string]string{
"annot2": "val2", "annot3": "val3",
},
},
Status: v1.PodStatus{
NominatedNodeName: "node3",
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "p3",
Namespace: "ns4",
},
Status: v1.PodStatus{
NominatedNodeName: "node1",
},
},
}
var updatedPods = make([]*v1.Pod, len(pods))
updatedPods[0] = pods[0].DeepCopy()
updatedPods[1] = pods[1].DeepCopy()
updatedPods[3] = pods[3].DeepCopy()
tests := []struct {
name string
podsToAdd []*v1.Pod
expectedMapAfterAdd map[string]*framework.QueuedPodInfo
podsToUpdate []*v1.Pod
expectedMapAfterUpdate map[string]*framework.QueuedPodInfo
podsToDelete []*v1.Pod
expectedMapAfterDelete map[string]*framework.QueuedPodInfo
}{
{
name: "create, update, delete subset of pods",
podsToAdd: []*v1.Pod{pods[0], pods[1], pods[2], pods[3]},
expectedMapAfterAdd: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[0]): {PodInfo: framework.NewPodInfo(pods[0]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[1]): {PodInfo: framework.NewPodInfo(pods[1]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[2]): {PodInfo: framework.NewPodInfo(pods[2]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[3]): {PodInfo: framework.NewPodInfo(pods[3]), UnschedulablePlugins: sets.NewString()},
},
podsToUpdate: []*v1.Pod{updatedPods[0]},
expectedMapAfterUpdate: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[0]): {PodInfo: framework.NewPodInfo(updatedPods[0]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[1]): {PodInfo: framework.NewPodInfo(pods[1]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[2]): {PodInfo: framework.NewPodInfo(pods[2]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[3]): {PodInfo: framework.NewPodInfo(pods[3]), UnschedulablePlugins: sets.NewString()},
},
podsToDelete: []*v1.Pod{pods[0], pods[1]},
expectedMapAfterDelete: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[2]): {PodInfo: framework.NewPodInfo(pods[2]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[3]): {PodInfo: framework.NewPodInfo(pods[3]), UnschedulablePlugins: sets.NewString()},
},
},
{
name: "create, update, delete all",
podsToAdd: []*v1.Pod{pods[0], pods[3]},
expectedMapAfterAdd: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[0]): {PodInfo: framework.NewPodInfo(pods[0]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[3]): {PodInfo: framework.NewPodInfo(pods[3]), UnschedulablePlugins: sets.NewString()},
},
podsToUpdate: []*v1.Pod{updatedPods[3]},
expectedMapAfterUpdate: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[0]): {PodInfo: framework.NewPodInfo(pods[0]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[3]): {PodInfo: framework.NewPodInfo(updatedPods[3]), UnschedulablePlugins: sets.NewString()},
},
podsToDelete: []*v1.Pod{pods[0], pods[3]},
expectedMapAfterDelete: map[string]*framework.QueuedPodInfo{},
},
{
name: "delete non-existing and existing pods",
podsToAdd: []*v1.Pod{pods[1], pods[2]},
expectedMapAfterAdd: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[1]): {PodInfo: framework.NewPodInfo(pods[1]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[2]): {PodInfo: framework.NewPodInfo(pods[2]), UnschedulablePlugins: sets.NewString()},
},
podsToUpdate: []*v1.Pod{updatedPods[1]},
expectedMapAfterUpdate: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[1]): {PodInfo: framework.NewPodInfo(updatedPods[1]), UnschedulablePlugins: sets.NewString()},
util.GetPodFullName(pods[2]): {PodInfo: framework.NewPodInfo(pods[2]), UnschedulablePlugins: sets.NewString()},
},
podsToDelete: []*v1.Pod{pods[2], pods[3]},
expectedMapAfterDelete: map[string]*framework.QueuedPodInfo{
util.GetPodFullName(pods[1]): {PodInfo: framework.NewPodInfo(updatedPods[1]), UnschedulablePlugins: sets.NewString()},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
upm := newUnschedulablePodsMap(nil)
for _, p := range test.podsToAdd {
upm.addOrUpdate(newQueuedPodInfoForLookup(p))
}
if !reflect.DeepEqual(upm.podInfoMap, test.expectedMapAfterAdd) {
t.Errorf("Unexpected map after adding pods. Expected: %v, got: %v",
test.expectedMapAfterAdd, upm.podInfoMap)
}
if len(test.podsToUpdate) > 0 {
for _, p := range test.podsToUpdate {
upm.addOrUpdate(newQueuedPodInfoForLookup(p))
}
if !reflect.DeepEqual(upm.podInfoMap, test.expectedMapAfterUpdate) {
t.Errorf("Unexpected map after updating pods. Expected: %v, got: %v",
test.expectedMapAfterUpdate, upm.podInfoMap)
}
}
for _, p := range test.podsToDelete {
upm.delete(p)
}
if !reflect.DeepEqual(upm.podInfoMap, test.expectedMapAfterDelete) {
t.Errorf("Unexpected map after deleting pods. Expected: %v, got: %v",
test.expectedMapAfterDelete, upm.podInfoMap)
}
upm.clear()
if len(upm.podInfoMap) != 0 {
t.Errorf("Expected the map to be empty, but has %v elements.", len(upm.podInfoMap))
}
})
}
} | explode_data.jsonl/68196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2657
} | [
2830,
3393,
1806,
72243,
360,
480,
23527,
82,
2227,
1155,
353,
8840,
836,
8,
341,
2405,
54587,
284,
29838,
85,
16,
88823,
515,
197,
197,
515,
298,
23816,
12175,
25,
77520,
16,
80222,
515,
571,
21297,
25,
414,
330,
79,
15,
756,
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... | 9 |
func TestEvents_Send(t *testing.T) {
m := NewClient(os.Getenv("MNUBO_CLIENT_ID"), os.Getenv("MNUBO_CLIENT_SECRET"), os.Getenv("MNUBO_HOST"))
var results [3][]SendEventsReport
cases := []struct {
Error error
Expected []SendEventsReport
}{
{
Error: m.Events.Send([]EventWithObject{
{
XObject: XObject{
XDeviceID: uuid.New().String(),
},
XEventType: "event_type1",
},
}, SendEventsOptions{
ReportResults: false,
ObjectsMustExist: false,
}, &results[0]),
Expected: nil,
},
{
Error: m.Events.Send([]EventWithObject{
{
XObject: XObject{
XDeviceID: uuid.New().String(),
},
XEventType: "event_type1",
},
}, SendEventsOptions{
ReportResults: true,
ObjectsMustExist: false,
}, &results[1]),
Expected: []SendEventsReport{
{
Result: "success",
ObjectExists: false,
},
},
},
{
Error: m.Events.Send([]EventWithObject{
{
XObject: XObject{
XDeviceID: uuid.New().String(),
},
XEventType: "event_type1",
},
}, SendEventsOptions{
ReportResults: true,
ObjectsMustExist: true,
}, &results[2]),
Expected: []SendEventsReport{
{
Result: "error",
ObjectExists: false,
},
},
},
}
for i, c := range cases {
if c.Error != nil {
t.Errorf("%d, client call failed: %+v", i, c.Error)
}
if len(results[i]) != len(c.Expected) {
t.Errorf("%d, expecting: %d, got: %d", i, len(c.Expected), len(results[i]))
}
for j := range results[i] {
ra := results[i][j].Result
re := c.Expected[j].Result
oa := results[i][j].ObjectExists
oe := c.Expected[j].ObjectExists
if ra != re {
t.Errorf("%d, expecting: %+v, got: %+v", i, ra, re)
}
if oa != oe {
t.Errorf("%d, expecting: %+v, got: %+v", i, oa, oe)
}
}
}
} | explode_data.jsonl/81377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 916
} | [
2830,
3393,
7900,
46267,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
2959,
9638,
64883,
445,
44,
3926,
4677,
22521,
3450,
3975,
2643,
64883,
445,
44,
3926,
4677,
22521,
31408,
3975,
2643,
64883,
445,
44,
3926,
4677,
17213,
28075,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestUptimeTag(t *testing.T) {
startTime = timeutil.Unix(0, 0)
testCases := []struct {
crashTime time.Time
expected string
}{
{timeutil.Unix(0, 0), "<1s"},
{timeutil.Unix(0, 0), "<1s"},
{timeutil.Unix(1, 0), "<10s"},
{timeutil.Unix(9, 0), "<10s"},
{timeutil.Unix(10, 0), "<1m"},
{timeutil.Unix(59, 0), "<1m"},
{timeutil.Unix(60, 0), "<10m"},
{timeutil.Unix(9*60, 0), "<10m"},
{timeutil.Unix(10*60, 0), "<1h"},
{timeutil.Unix(59*60, 0), "<1h"},
{timeutil.Unix(60*60, 0), "<10h"},
{timeutil.Unix(9*60*60, 0), "<10h"},
{timeutil.Unix(10*60*60, 0), "<1d"},
{timeutil.Unix(23*60*60, 0), "<1d"},
{timeutil.Unix(24*60*60, 0), "<2d"},
{timeutil.Unix(47*60*60, 0), "<2d"},
{timeutil.Unix(119*60*60, 0), "<5d"},
{timeutil.Unix(10*24*60*60, 0), "<11d"},
{timeutil.Unix(365*24*60*60, 0), "<366d"},
}
for _, tc := range testCases {
if a, e := uptimeTag(tc.crashTime), tc.expected; a != e {
t.Errorf("uptimeTag(%v) got %v, want %v)", tc.crashTime, a, e)
}
}
} | explode_data.jsonl/55530 | {
"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,
52,
28941,
5668,
1155,
353,
8840,
836,
8,
341,
21375,
1462,
284,
882,
1314,
10616,
941,
7,
15,
11,
220,
15,
340,
18185,
37302,
1669,
3056,
1235,
341,
197,
91492,
988,
1462,
882,
16299,
198,
197,
42400,
220,
914,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNewWsConn(t *testing.T) {
Log.SetLevel(DEBUG)
clientId := "a"
args := make([]interface{}, 0)
var heartbeatFunc = func() []byte {
ts := time.Now().Unix()*1000 + 42029
args = append(args, ts)
//ping := fmt.Sprintf("{\"cmd\":\"ping\",\"args\":[%d],\"id\":\"%s\"}", ts, clientId)
ping2 := map[string]interface{}{
"cmd": "ping",
"id": clientId,
"args": args}
ping3, _ := json.Marshal(ping2)
return ping3
}
//fmt.Println(ping)
//fmt.Println(ping2)
//fmt.Println(err, string(ping3))
ws := NewWsBuilder().Dump().WsUrl("wss://api.fcoin.com/v2/ws").
ProxyUrl("socks5://127.0.0.1:1080").AutoReconnect().
Heartbeat(heartbeatFunc, 5*time.Second).ProtoHandleFunc(ProtoHandle).Build()
t.Log(ws.Subscribe(map[string]string{
//"cmd":"sub", "args":"[\"ticker.btcusdt\"]", "id": clientId}))
"cmd":"sub", "args":"ticker.btcusdt", "id": clientId}))
time.Sleep(time.Second * 20)
ws.c.Close()
time.Sleep(time.Second*120)
} | explode_data.jsonl/72684 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
3564,
74733,
9701,
1155,
353,
8840,
836,
8,
341,
24201,
4202,
4449,
52792,
692,
25291,
764,
1669,
330,
64,
698,
31215,
1669,
1281,
10556,
4970,
22655,
220,
15,
692,
2405,
52105,
9626,
284,
2915,
368,
3056,
3782,
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... | 1 |
func TestGetBotUser(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
defer th.RestoreDefaultRolePermissions(th.SaveDefaultRolePermissions())
th.AddPermissionToRole(model.PermissionCreateBot.Id, model.TeamUserRoleId)
th.App.UpdateUserRoles(th.BasicUser.Id, model.SystemUserRoleId+" "+model.TeamUserRoleId, false)
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.EnableBotAccountCreation = true
})
bot := &model.Bot{
Username: GenerateTestUsername(),
DisplayName: "a bot",
Description: "bot",
}
createdBot, resp, err := th.Client.CreateBot(bot)
require.NoError(t, err)
CheckCreatedStatus(t, resp)
defer th.App.PermanentDeleteBot(createdBot.UserId)
botUser, _, err := th.Client.GetUser(createdBot.UserId, "")
require.NoError(t, err)
require.Equal(t, bot.Username, botUser.Username)
require.True(t, botUser.IsBot)
} | explode_data.jsonl/47490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
1949,
23502,
1474,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
16867,
270,
31129,
460,
3675,
9030,
23851,
24365,
13599,
3675,
9030,
23851,
12367,
70479,
1904... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChatSrvTLFConversationsLocal(t *testing.T) {
runWithMemberTypes(t, func(mt chat1.ConversationMembersType) {
ctc := makeChatTestContext(t, "TestChatSrvTLFConversationsLocal", 2)
defer ctc.cleanup()
users := ctc.users()
// Only run this test for teams
switch mt {
case chat1.ConversationMembersType_TEAM:
default:
return
}
ctx := ctc.as(t, users[0]).startCtx
ctx1 := ctc.as(t, users[1]).startCtx
listener0 := newServerChatListener()
ctc.as(t, users[0]).h.G().NotifyRouter.AddListener(listener0)
ctc.world.Tcs[users[0].Username].ChatG.Syncer.(*Syncer).isConnected = true
listener1 := newServerChatListener()
ctc.as(t, users[1]).h.G().NotifyRouter.AddListener(listener1)
ctc.world.Tcs[users[1].Username].ChatG.Syncer.(*Syncer).isConnected = true
conv := mustCreateConversationForTest(t, ctc, users[0], chat1.TopicType_CHAT,
mt, ctc.as(t, users[1]).user())
t.Logf("first conv: %s", conv.Id)
t.Logf("create a conversation, and join user 1 into by sending a message")
topicName := "zjoinonsend"
ncres, err := ctc.as(t, users[0]).chatLocalHandler().NewConversationLocal(ctx,
chat1.NewConversationLocalArg{
TlfName: conv.TlfName,
TopicName: &topicName,
TopicType: chat1.TopicType_CHAT,
TlfVisibility: keybase1.TLFVisibility_PRIVATE,
MembersType: chat1.ConversationMembersType_TEAM,
})
require.NoError(t, err)
_, err = postLocalForTest(t, ctc, users[1], ncres.Conv.Info, chat1.NewMessageBodyWithText(chat1.MessageText{
Body: fmt.Sprintf("JOINME"),
}))
require.NoError(t, err)
getTLFRes, err := ctc.as(t, users[1]).chatLocalHandler().GetTLFConversationsLocal(ctx1,
chat1.GetTLFConversationsLocalArg{
TlfName: conv.TlfName,
TopicType: chat1.TopicType_CHAT,
MembersType: chat1.ConversationMembersType_TEAM,
})
require.NoError(t, err)
require.Equal(t, 2, len(getTLFRes.Convs))
require.Equal(t, globals.DefaultTeamTopic, getTLFRes.Convs[0].Channel)
require.Equal(t, chat1.ConversationMemberStatus_ACTIVE, getTLFRes.Convs[1].MemberStatus)
require.Equal(t, 2, len(getTLFRes.Convs[1].Participants))
_, err = ctc.as(t, users[1]).chatLocalHandler().LeaveConversationLocal(ctx1,
ncres.Conv.GetConvID())
require.NoError(t, err)
ignoreTypes := []chat1.MessageType{chat1.MessageType_SYSTEM, chat1.MessageType_JOIN, chat1.MessageType_TEXT}
consumeNewMsgWhileIgnoring(t, listener0, chat1.MessageType_LEAVE, ignoreTypes, chat1.ChatActivitySource_REMOTE)
// make sure both users have processed the leave in their inbox
for i, user := range users {
getTLFRes, err = ctc.as(t, user).chatLocalHandler().GetTLFConversationsLocal(ctc.as(t, user).startCtx,
chat1.GetTLFConversationsLocalArg{
TlfName: conv.TlfName,
TopicType: chat1.TopicType_CHAT,
MembersType: chat1.ConversationMembersType_TEAM,
})
require.NoError(t, err)
require.Equal(t, 2, len(getTLFRes.Convs))
require.Equal(t, globals.DefaultTeamTopic, getTLFRes.Convs[0].Channel)
if i == 1 {
require.Equal(t, chat1.ConversationMemberStatus_LEFT, getTLFRes.Convs[1].MemberStatus)
} else {
require.Equal(t, chat1.ConversationMemberStatus_ACTIVE, getTLFRes.Convs[1].MemberStatus)
}
require.Equal(t, 1, len(getTLFRes.Convs[1].Participants))
require.Equal(t, users[0].Username, getTLFRes.Convs[1].Participants[0].Assertion)
}
// delete the channel make sure it's gone from both inboxes
_, err = ctc.as(t, users[0]).chatLocalHandler().DeleteConversationLocal(ctx,
chat1.DeleteConversationLocalArg{
ConvID: ncres.Conv.GetConvID(),
Confirmed: true,
})
require.NoError(t, err)
consumeLeaveConv(t, listener0)
consumeTeamType(t, listener0)
consumeLeaveConv(t, listener1)
consumeTeamType(t, listener1)
for _, user := range users {
getTLFRes, err = ctc.as(t, user).chatLocalHandler().GetTLFConversationsLocal(ctc.as(t, user).startCtx,
chat1.GetTLFConversationsLocalArg{
TlfName: conv.TlfName,
TopicType: chat1.TopicType_CHAT,
MembersType: chat1.ConversationMembersType_TEAM,
})
require.NoError(t, err)
require.Equal(t, 1, len(getTLFRes.Convs))
require.Equal(t, globals.DefaultTeamTopic, getTLFRes.Convs[0].Channel)
}
})
} | explode_data.jsonl/63704 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1806
} | [
2830,
3393,
15672,
50,
10553,
13470,
37,
1109,
72995,
7319,
1155,
353,
8840,
836,
8,
341,
56742,
2354,
9366,
4173,
1155,
11,
2915,
81618,
6236,
16,
4801,
22323,
24371,
929,
8,
341,
197,
89216,
66,
1669,
1281,
15672,
2271,
1972,
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... | 5 |
func TestServer_Run(t *testing.T) {
t.Run("Should: return error", func(t *testing.T) {
s := &application{
config: &configErrorMock{},
apiServ: nil,
}
assert.Error(t, s.Run())
})
t.Run("Should: return error", func(t *testing.T) {
s := &application{
config: &configMock{},
apiServ: &mockApiStorage{},
}
go func() {
_ = s.Run()
}()
time.Sleep(time.Second)
_, err := net.Dial("tcp", "localhost:23233")
assert.Equal(t, nil, err)
})
} | explode_data.jsonl/24669 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
5475,
84158,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
14996,
25,
470,
1465,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1903,
1669,
609,
5132,
515,
298,
25873,
25,
220,
609,
1676,
1454,
11571,
38837,
298,
54299,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseMdsDump(t *testing.T) {
c := &Ceph{Log: testutil.Logger{}}
dump, err := c.parseDump(mdsPerfDump)
require.NoError(t, err)
require.InEpsilon(t, 2408386.600934982, dump["mds"]["reply_latency.sum"], epsilon)
require.Equal(t, float64(0), dump["throttle-write_buf_throttle"]["wait.avgcount"])
} | explode_data.jsonl/40222 | {
"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,
14463,
44,
5356,
51056,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
34,
23544,
90,
2201,
25,
1273,
1314,
12750,
6257,
532,
2698,
1510,
11,
1848,
1669,
272,
4632,
51056,
1255,
5356,
3889,
69,
51056,
340,
17957,
35699,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFlushManagerFlushDoneSnapshotError(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
var (
fakeErr = errors.New("fake error while marking snapshot done")
mockPersistManager = persist.NewMockManager(ctrl)
mockFlushPersist = persist.NewMockFlushPreparer(ctrl)
mockSnapshotPersist = persist.NewMockSnapshotPreparer(ctrl)
)
mockFlushPersist.EXPECT().DoneFlush().Return(nil).Times(2)
mockPersistManager.EXPECT().StartFlushPersist().Return(mockFlushPersist, nil).Times(2)
mockSnapshotPersist.EXPECT().DoneSnapshot(gomock.Any(), testCommitlogFile).Return(fakeErr)
mockPersistManager.EXPECT().StartSnapshotPersist(gomock.Any()).Return(mockSnapshotPersist, nil)
mockIndexFlusher := persist.NewMockIndexFlush(ctrl)
mockIndexFlusher.EXPECT().DoneIndex().Return(nil)
mockPersistManager.EXPECT().StartIndexPersist().Return(mockIndexFlusher, nil)
testOpts := DefaultTestOptions().SetPersistManager(mockPersistManager)
db := newMockdatabase(ctrl)
db.EXPECT().Options().Return(testOpts).AnyTimes()
db.EXPECT().GetOwnedNamespaces().Return(nil, nil)
cl := commitlog.NewMockCommitLog(ctrl)
cl.EXPECT().RotateLogs().Return(testCommitlogFile, nil).AnyTimes()
fm := newFlushManager(db, cl, tally.NoopScope).(*flushManager)
fm.pm = mockPersistManager
now := time.Unix(0, 0)
require.EqualError(t, fakeErr, fm.Flush(now).Error())
} | explode_data.jsonl/82125 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 511
} | [
2830,
3393,
46874,
2043,
46874,
17453,
15009,
1454,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
2405,
2399,
197,
1166,
726,
7747,
1797,
284,
5975,
7121,
445,
30570,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetComponentPorts(t *testing.T) {
type args struct {
componentName string
applicationName string
}
tests := []struct {
name string
args args
wantErr bool
output []string
}{
{
name: "Case 1: Invalid/Unexisting component name",
args: args{
componentName: "r",
applicationName: "app",
},
wantErr: true,
output: []string{},
},
{
name: "Case 2: Valid params with multiple containers each with multiple ports",
args: args{
componentName: "python",
applicationName: "app",
},
output: []string{"10080/TCP", "8080/TCP", "9090/UDP", "10090/UDP"},
wantErr: false,
},
{
name: "Case 3: Valid params with single container and single port",
args: args{
componentName: "nodejs",
applicationName: "app",
},
output: []string{"8080/TCP"},
wantErr: false,
},
{
name: "Case 4: Valid params with single container and multiple port",
args: args{
componentName: "wildfly",
applicationName: "app",
},
output: []string{"8090/TCP", "8080/TCP"},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Fake the client with the appropriate arguments
client, fakeClientSet := occlient.FakeNew()
fakeClientSet.AppsClientset.PrependReactor("list", "deploymentconfigs", func(action ktesting.Action) (bool, runtime.Object, error) {
return true, testingutil.FakeDeploymentConfigs(), nil
})
// The function we are testing
output, err := GetComponentPorts(client, tt.args.componentName, tt.args.applicationName)
// Checks for error in positive cases
if !tt.wantErr == (err != nil) {
t.Errorf("component List() unexpected error %v, wantErr %v", err, tt.wantErr)
}
// Sort the output and expected o/p in-order to avoid issues due to order as its not important
sort.Strings(output)
sort.Strings(tt.output)
// Check if the output is the same as what's expected (tags)
// and only if output is more than 0 (something is actually returned)
if len(output) > 0 && !(reflect.DeepEqual(output, tt.output)) {
t.Errorf("expected tags: %s, got: %s", tt.output, output)
}
})
}
} | explode_data.jsonl/4412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 859
} | [
2830,
3393,
25640,
68273,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
52228,
675,
256,
914,
198,
197,
197,
5132,
675,
914,
198,
197,
630,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestByteReader_AnchorsAweigh(t *testing.T) {
const input = `
data:
color: &color-used blue
feeling: *color-used
`
var rNode *yaml.RNode
{
rNodes, err := (&ByteReader{
OmitReaderAnnotations: true,
AnchorsAweigh: false,
Reader: bytes.NewBuffer([]byte(input)),
}).Read()
assert.NoError(t, err)
assert.Equal(t, 1, len(rNodes))
rNode = rNodes[0]
}
// Confirm internal representation.
{
yNode := rNode.YNode()
// The high level object is a map of "data" to some value.
assert.Equal(t, yaml.NodeTagMap, yNode.Tag)
yNodes := yNode.Content
assert.Equal(t, 2, len(yNodes))
// Confirm that the key is "data".
assert.Equal(t, yaml.NodeTagString, yNodes[0].Tag)
assert.Equal(t, "data", yNodes[0].Value)
assert.Equal(t, yaml.NodeTagMap, yNodes[1].Tag)
// The value of the "data" key.
yNodes = yNodes[1].Content
// Expect two name-value pairs.
assert.Equal(t, 4, len(yNodes))
assert.Equal(t, yaml.ScalarNode, yNodes[0].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[0].Tag)
assert.Equal(t, "color", yNodes[0].Value)
assert.Empty(t, yNodes[0].Anchor)
assert.Nil(t, yNodes[0].Alias)
assert.Equal(t, yaml.ScalarNode, yNodes[1].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[1].Tag)
assert.Equal(t, "blue", yNodes[1].Value)
assert.Equal(t, "color-used", yNodes[1].Anchor)
assert.Nil(t, yNodes[1].Alias)
assert.Equal(t, yaml.ScalarNode, yNodes[2].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[2].Tag)
assert.Equal(t, "feeling", yNodes[2].Value)
assert.Empty(t, yNodes[2].Anchor)
assert.Nil(t, yNodes[2].Alias)
assert.Equal(t, yaml.AliasNode, yNodes[3].Kind)
assert.Empty(t, yNodes[3].Tag)
assert.Equal(t, "color-used", yNodes[3].Value)
assert.Empty(t, yNodes[3].Anchor)
assert.NotNil(t, yNodes[3].Alias)
}
str, err := rNode.String()
assert.NoError(t, err)
// The string version matches the input (it still has anchors and aliases).
assert.Equal(t, strings.TrimSpace(input), strings.TrimSpace(str))
// Now do same thing again, but this time set AnchorsAweigh = true.
{
rNodes, err := (&ByteReader{
OmitReaderAnnotations: true,
AnchorsAweigh: true,
Reader: bytes.NewBuffer([]byte(input)),
}).Read()
assert.NoError(t, err)
assert.Equal(t, 1, len(rNodes))
rNode = rNodes[0]
}
// Again make assertions on the internals.
{
yNode := rNode.YNode()
assert.Equal(t, yaml.NodeTagMap, yNode.Tag)
yNodes := yNode.Content
assert.Equal(t, 2, len(yNodes))
assert.Equal(t, yaml.NodeTagString, yNodes[0].Tag)
assert.Equal(t, "data", yNodes[0].Value)
assert.Equal(t, yaml.NodeTagMap, yNodes[1].Tag)
yNodes = yNodes[1].Content
assert.Equal(t, 4, len(yNodes))
assert.Equal(t, yaml.ScalarNode, yNodes[0].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[0].Tag)
assert.Equal(t, "color", yNodes[0].Value)
assert.Empty(t, yNodes[0].Anchor)
assert.Nil(t, yNodes[0].Alias)
assert.Equal(t, yaml.ScalarNode, yNodes[1].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[1].Tag)
assert.Equal(t, "blue", yNodes[1].Value)
assert.Empty(t, yNodes[1].Anchor)
assert.Nil(t, yNodes[1].Alias)
assert.Equal(t, yaml.ScalarNode, yNodes[2].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[2].Tag)
assert.Equal(t, "feeling", yNodes[2].Value)
assert.Empty(t, yNodes[2].Anchor)
assert.Nil(t, yNodes[2].Alias)
assert.Equal(t, yaml.ScalarNode, yNodes[3].Kind)
assert.Equal(t, yaml.NodeTagString, yNodes[3].Tag)
assert.Equal(t, "blue", yNodes[3].Value)
assert.Empty(t, yNodes[3].Anchor)
assert.Nil(t, yNodes[3].Alias)
}
str, err = rNode.String()
assert.NoError(t, err)
// This time, the alias has been replaced with the anchor definition.
assert.Equal(t, strings.TrimSpace(`
data:
color: blue
feeling: blue
`), strings.TrimSpace(str))
} | explode_data.jsonl/53078 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1779
} | [
2830,
3393,
7153,
5062,
32699,
331,
1087,
32,
56640,
1155,
353,
8840,
836,
8,
341,
4777,
1946,
284,
22074,
691,
510,
220,
1894,
25,
609,
3423,
68521,
6303,
198,
220,
8266,
25,
353,
3423,
68521,
198,
3989,
2405,
435,
1955,
353,
41466,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDiscoveryReplaceAliases(t *testing.T) {
tests := []struct {
name string
arg string
expected string
}{
{
name: "no-replacement",
arg: "service",
expected: "service",
},
{
name: "all-replacement",
arg: "all",
expected: "pods,replicationcontrollers,services,statefulsets,horizontalpodautoscalers,jobs,deployments,replicasets",
},
{
name: "alias-in-comma-separated-arg",
arg: "all,secrets",
expected: "pods,replicationcontrollers,services,statefulsets,horizontalpodautoscalers,jobs,deployments,replicasets,secrets",
},
}
mapper := NewShortcutExpander(testapi.Default.RESTMapper(), nil)
b := resource.NewBuilder(mapper, api.Scheme, fakeClient(), testapi.Default.Codec())
for _, test := range tests {
replaced := b.ReplaceAliases(test.arg)
if replaced != test.expected {
t.Errorf("%s: unexpected argument: expected %s, got %s", test.name, test.expected, replaced)
}
}
} | explode_data.jsonl/43213 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
67400,
23107,
95209,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
47903,
414,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
257,
330,
2152,
5504,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_UnsafeSetSymmetricDifference(t *testing.T) {
a := NewThreadUnsafeSet()
a.Add(1)
a.Add(2)
a.Add(3)
a.Add(45)
b := NewThreadUnsafeSet()
b.Add(1)
b.Add(3)
b.Add(4)
b.Add(5)
b.Add(6)
b.Add(99)
c := a.SymmetricDifference(b)
if !(c.Cardinality() == 6 && c.Contains(2) && c.Contains(45) && c.Contains(4) && c.Contains(5) && c.Contains(6) && c.Contains(99)) {
t.Error("the symmetric difference of set a to b is the set of 6 items: 2, 45, 4, 5, 6, 99")
}
} | explode_data.jsonl/197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
40687,
18675,
1649,
27912,
15903,
62707,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
6855,
78770,
1649,
741,
11323,
1904,
7,
16,
340,
11323,
1904,
7,
17,
340,
11323,
1904,
7,
18,
340,
11323,
1904,
7,
19,
20,
692,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestReaderPropsGetStreamInsufficient(t *testing.T) {
data := "shorter than expected"
buf := memory.NewBufferBytes([]byte(data))
rdr := bytes.NewReader(buf.Bytes())
props := parquet.NewReaderProperties(nil)
_, err := props.GetStream(rdr, 12, 15)
assert.Error(t, err)
} | explode_data.jsonl/68539 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
5062,
5992,
1949,
3027,
15474,
26683,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
330,
8676,
261,
1091,
3601,
698,
26398,
1669,
4938,
7121,
4095,
7078,
10556,
3782,
2592,
1171,
7000,
3612,
1669,
5820,
68587,
10731,
36868,
12367,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServer_Configure(t *testing.T) {
privateKey, err := crypto.GenerateSecp256k1Key()
if err != nil {
t.Fatal(err)
}
pssPrivateKey, err := crypto.GenerateSecp256k1Key()
if err != nil {
t.Fatal(err)
}
overlay := boson.MustParseHexAddress("ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c")
addresses := []multiaddr.Multiaddr{
mustMultiaddr(t, "/ip4/127.0.0.1/tcp/7071/p2p/16Uiu2HAmTBuJT9LvNmBiQiNoTsxE5mtNy6YG3paw79m94CRa9sRb"),
mustMultiaddr(t, "/ip4/192.168.0.101/tcp/7071/p2p/16Uiu2HAmTBuJT9LvNmBiQiNoTsxE5mtNy6YG3paw79m94CRa9sRb"),
mustMultiaddr(t, "/ip4/127.0.0.1/udp/7071/quic/p2p/16Uiu2HAmTBuJT9LvNmBiQiNoTsxE5mtNy6YG3paw79m94CRa9sRb"),
}
ethereumAddress := common.HexToAddress("abcd")
o := testServerOptions{
PublicKey: privateKey.PublicKey,
PSSPublicKey: pssPrivateKey.PublicKey,
Overlay: overlay,
EthereumAddress: ethereumAddress,
P2P: mock.New(mock.WithAddressesFunc(func() ([]multiaddr.Multiaddr, error) {
return addresses, nil
})),
}
topologyDriver := topologymock.NewTopologyDriver(o.TopologyOpts...)
acc := accountingmock.NewAccounting(o.AccountingOpts...)
settlement := swapmock.New(o.SettlementOpts...)
chequebook := chequebookmock.NewChequebook(o.ChequebookOpts...)
swapserv := swapmock.NewApiInterface(o.SwapOpts...)
s := debugapi.New(o.Overlay, o.PublicKey, o.PSSPublicKey, o.EthereumAddress, logging.New(ioutil.Discard, 0), nil, nil)
ts := httptest.NewServer(s)
t.Cleanup(ts.Close)
client := &http.Client{
Transport: web.RoundTripperFunc(func(r *http.Request) (*http.Response, error) {
u, err := url.Parse(ts.URL + r.URL.String())
if err != nil {
return nil, err
}
r.URL = u
return ts.Client().Transport.RoundTrip(r)
}),
}
testBasicRouter(t, client)
jsonhttptest.Request(t, client, http.MethodGet, "/readiness", http.StatusNotFound,
jsonhttptest.WithExpectedJSONResponse(jsonhttp.StatusResponse{
Message: http.StatusText(http.StatusNotFound),
Code: http.StatusNotFound,
}),
)
jsonhttptest.Request(t, client, http.MethodGet, "/addresses", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.AddressesResponse{
Overlay: o.Overlay,
Underlay: make([]multiaddr.Multiaddr, 0),
Ethereum: o.EthereumAddress,
PublicKey: hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(&o.PublicKey)),
PSSPublicKey: hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(&o.PSSPublicKey)),
}),
)
s.Configure(o.P2P, o.Pingpong, topologyDriver, o.Storer,acc, settlement, true, swapserv, chequebook)
testBasicRouter(t, client)
jsonhttptest.Request(t, client, http.MethodGet, "/readiness", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.StatusResponse{
Status: "ok",
Version: bee.Version,
}),
)
jsonhttptest.Request(t, client, http.MethodGet, "/addresses", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.AddressesResponse{
Overlay: o.Overlay,
Underlay: addresses,
Ethereum: o.EthereumAddress,
PublicKey: hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(&o.PublicKey)),
PSSPublicKey: hex.EncodeToString(crypto.EncodeSecp256k1PublicKey(&o.PSSPublicKey)),
}),
)
} | explode_data.jsonl/28618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1403
} | [
2830,
3393,
5475,
15100,
17781,
1155,
353,
8840,
836,
8,
341,
2455,
1592,
11,
1848,
1669,
19028,
57582,
8430,
79,
17,
20,
21,
74,
16,
1592,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
3223,
778,
75981,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStartAndShutdownWithLeaderAwareWithLostElection(t *testing.T) {
promoted := make(chan struct{})
r := &countingLeaderAwareReconciler{
LeaderAwareFuncs: reconciler.LeaderAwareFuncs{
PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error {
close(promoted)
return nil
},
},
}
cc := leaderelection.ComponentConfig{
Component: "component",
LeaseDuration: 15 * time.Second,
RenewDeadline: 10 * time.Second,
RetryPeriod: 2 * time.Second,
}
kc := fakekube.NewSimpleClientset(
&coordinationv1.Lease{
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace(),
Name: "component.testing.00-of-01",
},
Spec: coordinationv1.LeaseSpec{
HolderIdentity: ptr.String("not-us"),
LeaseDurationSeconds: ptr.Int32(3000),
AcquireTime: &metav1.MicroTime{Time: time.Now()},
RenewTime: &metav1.MicroTime{Time: time.Now().Add(3000 * time.Second)},
},
},
)
impl := NewImplWithStats(r, TestLogger(t), "Testing", &FakeStatsReporter{})
ctx, cancel := context.WithCancel(context.Background())
ctx = leaderelection.WithStandardLeaderElectorBuilder(ctx, kc, cc)
doneCh := make(chan struct{})
go func() {
defer close(doneCh)
StartAll(ctx, impl)
}()
t.Cleanup(func() {
cancel()
<-doneCh
})
select {
case <-promoted:
t.Fatal("Unexpected promotion.")
case <-time.After(3 * time.Second):
// Wait for 3 seconds for good measure.
case <-doneCh:
t.Error("StartAll finished early.")
}
cancel()
select {
case <-time.After(time.Second):
t.Error("Timed out waiting for controller to finish.")
case <-doneCh:
// We expect the work to complete.
}
if got, want := r.count.Load(), int32(0); got != want {
t.Errorf("reconcile count = %v, wanted %v", got, want)
}
} | explode_data.jsonl/45287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 742
} | [
2830,
3393,
3479,
3036,
62004,
2354,
52621,
58793,
2354,
47253,
36,
1170,
1155,
353,
8840,
836,
8,
341,
3223,
441,
9253,
1669,
1281,
35190,
2036,
37790,
7000,
1669,
609,
1830,
287,
52621,
58793,
693,
40446,
5769,
515,
197,
197,
52621,
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 TestUnsentDDL(t *testing.T) {
if testing.Short() {
t.Skip()
}
execStatement(t, "create table unsent(id int, val varbinary(128), primary key(id))")
testcases := []testcase{{
input: []string{
"drop table unsent",
},
// An unsent DDL is sent as an empty transaction.
output: [][]string{{
`gtid`,
`type:OTHER`,
}},
}}
filter := &binlogdatapb.Filter{
Rules: []*binlogdatapb.Rule{{
Match: "/none/",
}},
}
runCases(t, filter, testcases, "", nil)
} | explode_data.jsonl/10417 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
1806,
24512,
58781,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
741,
197,
630,
67328,
8636,
1155,
11,
330,
3182,
1965,
6975,
306,
3724,
526,
11,
1044,
762,
25891,
7,
16,
17,
23,
701,
6028,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetStackTimeWaitReuse(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
s := c.Stack()
testCases := []struct {
v int
err tcpip.Error
}{
{int(tcpip.TCPTimeWaitReuseDisabled), nil},
{int(tcpip.TCPTimeWaitReuseGlobal), nil},
{int(tcpip.TCPTimeWaitReuseLoopbackOnly), nil},
{int(tcpip.TCPTimeWaitReuseLoopbackOnly) + 1, &tcpip.ErrInvalidOptionValue{}},
{int(tcpip.TCPTimeWaitReuseDisabled) - 1, &tcpip.ErrInvalidOptionValue{}},
}
for _, tc := range testCases {
opt := tcpip.TCPTimeWaitReuseOption(tc.v)
err := s.SetTransportProtocolOption(tcp.ProtocolNumber, &opt)
if got, want := err, tc.err; got != want {
t.Fatalf("s.SetTransportProtocolOption(%d, &%T(%d)) = %s, want = %s", tcp.ProtocolNumber, tc.v, tc.v, err, tc.err)
}
if tc.err != nil {
continue
}
var twReuse tcpip.TCPTimeWaitReuseOption
if err := s.TransportProtocolOption(tcp.ProtocolNumber, &twReuse); err != nil {
t.Fatalf("s.TransportProtocolOption(%v, %v) = %v, want nil", tcp.ProtocolNumber, &twReuse, err)
}
if got, want := twReuse, tcpip.TCPTimeWaitReuseOption(tc.v); got != want {
t.Fatalf("got tcpip.TCPTimeWaitReuseOption: %v, want: %v", got, want)
}
}
} | explode_data.jsonl/76034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 532
} | [
2830,
3393,
1649,
4336,
1462,
14190,
38081,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
1903,
1669,
272,
58646,
741,
18185,
37302,
1669,
3056,
1235,
341,
197,
5195,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestIP2Long(t *testing.T) {
l1 := IP2Long("127.0.0.1")
if l1 != 2130706433 {
t.Fatalf("ip2long expect %d, actual %d", 2130706433, l1)
}
l2 := IP2Long("192.168.0.1")
if l2 != 3232235521 {
t.Fatalf("ip2long expect %d, actual %d", 3232235521, l2)
}
} | explode_data.jsonl/64882 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
3298,
17,
6583,
1155,
353,
8840,
836,
8,
341,
8810,
16,
1669,
6790,
17,
6583,
445,
16,
17,
22,
13,
15,
13,
15,
13,
16,
1138,
743,
326,
16,
961,
220,
17,
16,
18,
15,
22,
15,
21,
19,
18,
18,
341,
197,
3244,
30762,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetStack(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetSuccessfully(t, GetOutput)
actual, err := stacks.Get(fake.ServiceClient(), "postman_stack").Extract()
th.AssertNoErr(t, err)
expected := GetExpected
th.AssertDeepEquals(t, expected, actual)
} | explode_data.jsonl/53520 | {
"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,
1949,
4336,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
197,
6999,
1949,
35959,
1155,
11,
2126,
5097,
692,
88814,
11,
1848,
1669,
39950,
2234,
74138,
13860,
2959,
1507,
330,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadConfig(t *testing.T) {
currWd, err := os.Getwd()
assert.NoError(t, err)
cfgPath := path.Join(currWd, "../../test/testdata/config-example.yaml")
args := RunArgs{
Database: "example",
Host: "localhost",
Password: "root",
Port: "3306",
Safe: false,
Tables: []string{cfgPath},
User: "root",
}
_, defs, err := LoadConfig(args)
assert.NoError(t, err)
assert.False(t, defs[0].SafeImport) // zero value
assert.Equal(t, 5031, defs[0].TotalRecords)
} | explode_data.jsonl/54075 | {
"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,
5879,
2648,
1155,
353,
8840,
836,
8,
341,
54966,
54,
67,
11,
1848,
1669,
2643,
2234,
6377,
741,
6948,
35699,
1155,
11,
1848,
340,
50286,
1820,
1669,
1815,
22363,
26903,
54,
67,
11,
10208,
1944,
12697,
691,
14730,
43430,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApiTest_ExposesRequestAndResponse(t *testing.T) {
apiTest := apitest.New()
assert.Equal(t, true, apiTest.Request() != nil)
assert.Equal(t, true, apiTest.Response() != nil)
} | explode_data.jsonl/54815 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
6563,
2271,
62531,
8285,
1900,
3036,
2582,
1155,
353,
8840,
836,
8,
341,
54299,
2271,
1669,
1443,
97105,
7121,
2822,
6948,
12808,
1155,
11,
830,
11,
6330,
2271,
9659,
368,
961,
2092,
340,
6948,
12808,
1155,
11,
830,
11,
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 |
func TestNonScaledWindowConnect(t *testing.T) {
// This test ensures that window scaling is not used when the peer
// doesn't advertise it and connection is established with Connect().
c := context.New(t, defaultMTU)
defer c.Cleanup()
// Set the window size greater than the maximum non-scaled window.
c.CreateConnected(context.TestInitialSequenceNumber, 30000, 65535*3)
data := []byte{1, 2, 3}
var r bytes.Reader
r.Reset(data)
if _, err := c.EP.Write(&r, tcpip.WriteOptions{}); err != nil {
t.Fatalf("Write failed: %s", err)
}
// Check that data is received, and that advertised window is 0xffff,
// that is, that it's not scaled.
b := c.GetPacket()
iss := seqnum.Value(context.TestInitialSequenceNumber).Add(1)
checker.IPv4(t, b,
checker.PayloadLen(len(data)+header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS)+1),
checker.TCPAckNum(uint32(iss)),
checker.TCPWindow(0xffff),
checker.TCPFlagsMatch(header.TCPFlagAck, ^header.TCPFlagPsh),
),
)
} | explode_data.jsonl/75959 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 395
} | [
2830,
3393,
8121,
94201,
4267,
14611,
1155,
353,
8840,
836,
8,
341,
197,
322,
1096,
1273,
25351,
429,
3241,
26943,
374,
537,
1483,
979,
279,
14397,
198,
197,
322,
3171,
944,
50836,
432,
323,
3633,
374,
9555,
448,
13015,
25829,
1444,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClone(t *testing.T) {
Convey("Given a state with some balances, accounts, and requests", t, func() {
ctx := context.Background()
tm := time.Unix(100, 0).UTC()
s := New(tm)
s.AddAccount(ctx, "aid", NewAccountConfig(1, nil, 1, []float32{2, 3, 4}, false, ""), nil)
s.AddRequest(ctx, NewTaskRequest("req1", "a1", stringset.NewFromSlice("provision 1", "provision 2"), stringset.NewFromSlice("base 1", "base 2"), tm), tm, nil, NullEventSink)
s.AddRequest(ctx, NewTaskRequest("req2", "a1", stringset.NewFromSlice("provision 3", "provision 4"), stringset.NewFromSlice("base 3", "base 4"), tm), tm, nil, NullEventSink)
s.MarkIdle(ctx, "worker 1", stringset.NewFromSlice("base 1", "base 2"), tm, NullEventSink)
s.MarkIdle(ctx, "worker 2", stringset.NewFromSlice("base foo", "base bar"), tm, NullEventSink)
s.RunOnce(ctx, NullEventSink)
Convey("when state is Cloned via proto roundtrip, it should resemble itself.", func() {
sClone := s.state.Clone()
// Null out memoization fields.
for _, t := range s.state.queuedRequests {
t.memoizedFanoutGroup = 0
t.fanoutGroupIsMemoized = false
}
for _, w := range s.state.workers {
if !w.IsIdle() {
w.runningTask.request.memoizedFanoutGroup = 0
w.runningTask.request.fanoutGroupIsMemoized = false
}
}
diff := pretty.Compare(s.state, sClone)
So(diff, ShouldBeBlank)
})
})
} | explode_data.jsonl/53393 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 558
} | [
2830,
3393,
37677,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
264,
1584,
448,
1045,
38854,
11,
9618,
11,
323,
7388,
497,
259,
11,
2915,
368,
341,
197,
20985,
1669,
2266,
19047,
741,
197,
3244,
76,
1669,
882,
10616,
941,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBTreeUpdateAndSearsh1(t *testing.T) {
tree := newRangeTree()
tree.update(&metapb.Range{StartKey: []byte("a"), EndKey: []byte("e")})
tree.update(&metapb.Range{StartKey: []byte("e"), EndKey: []byte("k")})
tree.update(&metapb.Range{StartKey: []byte("k"), EndKey: []byte("t")})
tree.update(&metapb.Range{StartKey: []byte("t"), EndKey: []byte("w")})
tree.update(&metapb.Range{StartKey: []byte("w"), EndKey: []byte("z")})
tree.update(&metapb.Range{StartKey: []byte("l"), EndKey: []byte("q")})
r := tree.search([]byte("p"))
if r == nil {
t.Errorf("test failed")
return
}
if bytes.Compare([]byte("l"), r.StartKey) != 0 || bytes.Compare([]byte("q"), r.EndKey) != 0 {
t.Errorf("test failed")
return
}
r = tree.search([]byte("r"))
if r != nil {
t.Errorf("test failed")
return
}
} | explode_data.jsonl/25351 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
33,
6533,
4289,
3036,
50,
682,
927,
16,
1155,
353,
8840,
836,
8,
341,
51968,
1669,
501,
6046,
6533,
741,
51968,
5317,
2099,
4059,
391,
65,
24783,
90,
3479,
1592,
25,
3056,
3782,
445,
64,
3975,
3972,
1592,
25,
3056,
3782,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCloseClientEOFServer(t *testing.T) {
c, s, err := getConnection(nil)
if err != nil {
t.Fatal(err)
}
defer c.Close()
defer s.Close()
ensureEOFOnClose(t, c, s)
} | explode_data.jsonl/11426 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
7925,
2959,
23483,
5475,
1155,
353,
8840,
836,
8,
341,
1444,
11,
274,
11,
1848,
1669,
65313,
27907,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
272,
10421,
741,
16867,
274,
10421,
741,
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
] | 2 |
func TestKubernetesServiceIPInference(t *testing.T) {
// We sill assert that after parsing the network configuration,
// KubernetesServiceIP is the correct pre-determined value
testConfigs := []struct {
NetworkConfig string
KubernetesServiceIP string
}{
{
NetworkConfig: `
serviceCIDR: 172.5.10.10/22
dnsServiceIP: 172.5.10.10
`,
KubernetesServiceIP: "172.5.8.1",
},
{
NetworkConfig: `
serviceCIDR: 10.5.70.10/18
dnsServiceIP: 10.5.64.10
`,
KubernetesServiceIP: "10.5.64.1",
},
{
NetworkConfig: `
serviceCIDR: 172.4.155.98/27
dnsServiceIP: 172.4.155.100
`,
KubernetesServiceIP: "172.4.155.97",
},
{
NetworkConfig: `
serviceCIDR: 10.6.142.100/28
dnsServiceIP: 10.6.142.100
`,
KubernetesServiceIP: "10.6.142.97",
},
}
for _, testConfig := range testConfigs {
configBody := singleAzConfigYaml + testConfig.NetworkConfig
cluster, err := ClusterFromBytes([]byte(configBody))
if err != nil {
t.Errorf("Unexpected error parsing config: %v\n %s", err, configBody)
continue
}
_, serviceNet, err := net.ParseCIDR(cluster.ServiceCIDR)
if err != nil {
t.Errorf("invalid serviceCIDR: %v", err)
continue
}
kubernetesServiceIP := netutil.IncrementIP(serviceNet.IP)
if kubernetesServiceIP.String() != testConfig.KubernetesServiceIP {
t.Errorf("KubernetesServiceIP mismatch: got %s, expected %s",
kubernetesServiceIP,
testConfig.KubernetesServiceIP)
}
}
} | explode_data.jsonl/4366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 644
} | [
2830,
3393,
42,
29827,
1860,
3298,
641,
2202,
1155,
353,
8840,
836,
8,
1476,
197,
322,
1205,
84267,
2060,
429,
1283,
22314,
279,
3922,
6546,
345,
197,
322,
66374,
1860,
3298,
374,
279,
4396,
855,
1737,
46637,
897,
198,
18185,
84905,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestComparisonFailsIfClusterNotAdded(t *testing.T) {
Given(t).
Path(guestbookPath).
DestServer("https://not-registered-cluster/api").
When().
IgnoreErrors().
CreateApp().
Then().
Expect(DoesNotExist())
} | explode_data.jsonl/35627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
33487,
37,
6209,
2679,
28678,
2623,
19337,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
69640,
3268,
3045,
2190,
1820,
4292,
197,
10957,
477,
5475,
445,
2428,
1110,
1921,
12,
34909,
93208,
10508,
38609,
197,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestRemoveResourcesWhenDone(t *testing.T) {
rc, _, cleanupMockScr := setupTest()
defer cleanupMockScr()
podIP := "192.168.101.11"
state := "LEFT"
mockClient := &mocks.Client{}
rc.Client = mockClient
rc.Datacenter.SetCondition(api.DatacenterCondition{
Status: v1.ConditionTrue,
Type: api.DatacenterScalingDown,
})
mockStatus := &statusMock{}
k8sMockClientStatus(mockClient, mockStatus)
labels := make(map[string]string)
labels[api.CassNodeState] = stateDecommissioning
rc.dcPods = []*v1.Pod{{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-1",
Labels: labels,
},
Status: v1.PodStatus{
PodIP: podIP,
},
}}
makeInt := func(i int32) *int32 {
return &i
}
ssLabels := make(map[string]string)
rc.statefulSets = []*appsv1.StatefulSet{{
ObjectMeta: metav1.ObjectMeta{
Name: "ss-1",
Labels: ssLabels,
},
Spec: appsv1.StatefulSetSpec{
Replicas: makeInt(1),
},
}}
epData := httphelper.CassMetadataEndpoints{
Entity: []httphelper.EndpointState{
{
RpcAddress: podIP,
Status: state,
},
},
}
r := rc.CheckDecommissioningNodes(epData)
if r != result.RequeueSoon(5) {
t.Fatalf("expected result of blah but got %s", r)
}
if mockStatus.called != 1 {
t.Fatalf("expected 1 call to mockStatus but had %v", mockStatus.called)
}
} | explode_data.jsonl/20072 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 565
} | [
2830,
3393,
13021,
11277,
4498,
17453,
1155,
353,
8840,
836,
8,
341,
30295,
11,
8358,
21290,
11571,
65508,
1669,
6505,
2271,
741,
16867,
21290,
11571,
65508,
741,
3223,
347,
3298,
1669,
330,
16,
24,
17,
13,
16,
21,
23,
13,
16,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBaseMetricListPushBackElemWithDefaultPipeline(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
l, err := newBaseMetricList(testShard, time.Second, nil, nil, nil, testOptions(ctrl))
require.NoError(t, err)
elem, err := NewCounterElem(ElemData{}, NewElemOptions(l.opts))
require.NoError(t, err)
// Push a counter to the list.
e, err := l.PushBack(elem)
require.NoError(t, err)
require.Equal(t, 1, l.aggregations.Len())
require.Equal(t, elem, e.Value.(*CounterElem))
require.Nil(t, elem.writeForwardedMetricFn)
require.Nil(t, elem.onForwardedAggregationWrittenFn)
// Push a counter to a closed list should result in an error.
l.Lock()
l.closed = true
l.Unlock()
_, err = l.PushBack(elem)
require.Equal(t, err, errListClosed)
} | explode_data.jsonl/43580 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 309
} | [
2830,
3393,
3978,
54310,
852,
16644,
3707,
25586,
2354,
3675,
34656,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
8810,
11,
1848,
1669,
501,
3978,
54310,
852,
8623,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDaoUpVerifyState(t *testing.T) {
var (
c = context.TODO()
tid = int64(0)
verifyState = int32(0)
)
convey.Convey("UpVerifyState", t, func(ctx convey.C) {
affect, err := d.UpVerifyState(c, tid, verifyState)
ctx.Convey("Then err should be nil.affect should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(affect, convey.ShouldNotBeNil)
})
})
} | explode_data.jsonl/36688 | {
"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,
12197,
2324,
32627,
1397,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
1444,
1843,
284,
2266,
90988,
741,
197,
3244,
307,
260,
284,
526,
21,
19,
7,
15,
340,
197,
93587,
1397,
284,
526,
18,
17,
7,
15,
340,
197,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParamOverwrite(t *testing.T) {
var req = URL("http://example.com/xyz")
req.Param("foo", "bar")
req.Param("foo", "bar2")
req.Param("foo", "bar3")
var want = "http://example.com/xyz?foo=bar3"
if req.URL != want {
t.Errorf("Wanted url %v, got %v instead", want, req.URL)
}
} | explode_data.jsonl/24757 | {
"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,
2001,
1918,
4934,
1155,
353,
8840,
836,
8,
341,
2405,
4232,
284,
5548,
445,
1254,
1110,
8687,
905,
14,
28854,
5130,
24395,
9580,
445,
7975,
497,
330,
2257,
1138,
24395,
9580,
445,
7975,
497,
330,
2257,
17,
1138,
24395,
958... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCodeValidateBasic(t *testing.T) {
specs := map[string]struct {
srcMutator func(*Code)
expError bool
}{
"all good": {srcMutator: func(_ *Code) {}},
"code id invalid": {
srcMutator: func(c *Code) {
c.CodeID = 0
},
expError: true,
},
"codeinfo invalid": {
srcMutator: func(c *Code) {
c.CodeInfo.CodeHash = nil
},
expError: true,
},
"codeBytes empty": {
srcMutator: func(c *Code) {
c.CodeBytes = []byte{}
},
expError: true,
},
"codeBytes nil": {
srcMutator: func(c *Code) {
c.CodeBytes = nil
},
expError: true,
},
"codeBytes greater limit": {
srcMutator: func(c *Code) {
c.CodeBytes = bytes.Repeat([]byte{0x1}, MaxWasmSize+1)
},
expError: true,
},
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
state := CodeFixture(spec.srcMutator)
got := state.ValidateBasic()
if spec.expError {
require.Error(t, got)
return
}
require.NoError(t, got)
})
}
} | explode_data.jsonl/13137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 469
} | [
2830,
3393,
2078,
17926,
15944,
1155,
353,
8840,
836,
8,
341,
98100,
82,
1669,
2415,
14032,
60,
1235,
341,
197,
41144,
51440,
850,
2915,
4071,
2078,
340,
197,
48558,
1454,
256,
1807,
198,
197,
59403,
197,
197,
1,
541,
1661,
788,
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 TestPostHooksCalledWithError(t *testing.T) {
p := pipeline.New(
pipeline.Node(&NoOpProcessor{ReturnError: true}),
)
errChan := make(chan error, 1)
p.AddPostProcessingHook(func(ctx context.Context, err error) error {
errChan <- err
return nil
})
err := <-p.Process(&SimpleReader{CountObject: 10})
assert.Error(t, err)
assert.Equal(t, "Processor NoOpProcessor errored: Test error", err.Error())
hookErr := <-errChan
assert.Error(t, hookErr)
assert.Equal(t, "Processor NoOpProcessor errored: Test error", hookErr.Error())
} | explode_data.jsonl/64698 | {
"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,
4133,
67769,
20960,
66102,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
15301,
7121,
1006,
197,
3223,
8790,
21714,
2099,
2753,
7125,
22946,
90,
5598,
1454,
25,
830,
30793,
197,
692,
9859,
46019,
1669,
1281,
35190,
1465,
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 |
func TestInterpreterInterpreterOperators(t *testing.T) {
s, err := parseFile("src/parse/asp/test_data/interpreter/operators.build")
require.NoError(t, err)
require.NotNil(t, s.Lookup("y"))
i := s.Lookup("y").(pyInt)
assert.EqualValues(t, 7, i)
assert.True(t, s.Lookup("z").IsTruthy())
} | explode_data.jsonl/81056 | {
"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,
58426,
58426,
77760,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
4715,
1703,
445,
3548,
14,
6400,
14,
13367,
12697,
1769,
14,
90554,
46481,
13239,
1138,
17957,
35699,
1155,
11,
1848,
340,
17957,
93882,
1155,
11,
274,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApp_Run_Version(t *testing.T) {
var versionArguments = [][]string{{"boom", "--version"}, {"boom", "-v"}}
for _, args := range versionArguments {
buf := new(bytes.Buffer)
t.Logf("==> checking with arguments %v", args)
app := &App{
Name: "boom",
Usage: "make an explosive entrance",
Version: "0.1.0",
Writer: buf,
Action: func(c *Context) error {
buf.WriteString("boom I say!")
return nil
},
}
err := app.Run(args)
if err != nil {
t.Error(err)
}
output := buf.String()
t.Logf("output: %q\n", buf.Bytes())
if !strings.Contains(output, "0.1.0") {
t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output)
}
}
} | explode_data.jsonl/52589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
2164,
84158,
85217,
1155,
353,
8840,
836,
8,
341,
2405,
2319,
19139,
284,
52931,
917,
2979,
1,
95316,
497,
14482,
4366,
14345,
5212,
95316,
497,
6523,
85,
9207,
630,
2023,
8358,
2827,
1669,
2088,
2319,
19139,
341,
197,
26398... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocale(t *testing.T) {
trans := New()
expected := "si"
if trans.Locale() != expected {
t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale())
}
} | explode_data.jsonl/41540 | {
"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,
19231,
1155,
353,
8840,
836,
8,
1476,
72453,
1669,
1532,
741,
42400,
1669,
330,
6321,
1837,
743,
1356,
59094,
368,
961,
3601,
341,
197,
3244,
13080,
445,
18896,
7677,
82,
6,
24528,
7677,
82,
22772,
3601,
11,
1356,
59094,
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
] | 2 |
func TestDeleteVolumeDBEntry(t *testing.T) {
var vol = &model.VolumeSpec{
BaseModel: &model.BaseModel{
Id: "bd5b12a8-a101-11e7-941e-d77981b584d8",
},
Status: model.VolumeAvailable,
ProfileId: "3769855c-a102-11e7-b772-17b880d2f537",
PoolId: "3762355c-a102-11e7-b772-17b880d2f537",
}
var in = &model.VolumeSpec{
BaseModel: &model.BaseModel{
Id: "bd5b12a8-a101-11e7-941e-d77981b584d8",
},
Status: model.VolumeDeleting,
ProfileId: "3769855c-a102-11e7-b772-17b880d2f537",
PoolId: "3762355c-a102-11e7-b772-17b880d2f537",
}
t.Run("Everything should work well", func(t *testing.T) {
mockClient := new(dbtest.Client)
mockClient.On("DeleteVolume", context.NewAdminContext(), vol.Id).Return(nil)
mockClient.On("ListSnapshotsByVolumeId", context.NewAdminContext(), vol.Id).Return(nil, nil)
mockClient.On("ListAttachmentsByVolumeId", context.NewAdminContext(), vol.Id).Return(nil, nil)
mockClient.On("UpdateVolume", context.NewAdminContext(), in).Return(nil, nil)
db.C = mockClient
err := DeleteVolumeDBEntry(context.NewAdminContext(), vol)
if err != nil {
t.Errorf("failed to delete volume, err is %v\n", err)
}
})
t.Run("Volume to be deleted should not contain any snapshots", func(t *testing.T) {
var sampleSnapshots = []*model.VolumeSnapshotSpec{&SampleSnapshots[0]}
// Considering vol has been updated inisde DeleteVolumeDBEntry, so the status
// should be rolled back here.
vol.Status = model.VolumeAvailable
mockClient := new(dbtest.Client)
mockClient.On("DeleteVolume", context.NewAdminContext(), vol.Id).Return(nil)
mockClient.On("ListSnapshotsByVolumeId", context.NewAdminContext(), vol.Id).Return(sampleSnapshots, nil)
mockClient.On("ListAttachmentsByVolumeId", context.NewAdminContext(), vol.Id).Return(nil, nil)
mockClient.On("UpdateVolume", context.NewAdminContext(), in).Return(nil, nil)
db.C = mockClient
err := DeleteVolumeDBEntry(context.NewAdminContext(), vol)
expectedError := fmt.Sprintf("volume %s can not be deleted, because it still has snapshots", in.Id)
assertTestResult(t, err.Error(), expectedError)
})
t.Run("Volume to be deleted should not be in-use", func(t *testing.T) {
var sampleAttachments = []*model.VolumeAttachmentSpec{&SampleAttachments[0]}
// Considering vol has been updated inisde DeleteVolumeDBEntry, so the status
// should be rolled back here.
vol.Status = model.VolumeAvailable
mockClient := new(dbtest.Client)
mockClient.On("DeleteVolume", context.NewAdminContext(), vol.Id).Return(nil)
mockClient.On("ListSnapshotsByVolumeId", context.NewAdminContext(), vol.Id).Return(nil, nil)
mockClient.On("ListAttachmentsByVolumeId", context.NewAdminContext(), vol.Id).Return(sampleAttachments, nil)
mockClient.On("UpdateVolume", context.NewAdminContext(), in).Return(nil, nil)
db.C = mockClient
err := DeleteVolumeDBEntry(context.NewAdminContext(), vol)
expectedError := fmt.Sprintf("volume %s can not be deleted, because it's in use", in.Id)
assertTestResult(t, err.Error(), expectedError)
})
} | explode_data.jsonl/29973 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1108
} | [
2830,
3393,
6435,
18902,
3506,
5874,
1155,
353,
8840,
836,
8,
341,
2405,
4400,
284,
609,
2528,
79106,
8327,
515,
197,
66732,
1712,
25,
609,
2528,
13018,
1712,
515,
298,
67211,
25,
330,
8940,
20,
65,
16,
17,
64,
23,
7409,
16,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEc2Instance_LoadDetails_ErrGetSubnet(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ec2Instance, mockEC2ApiHelper := getMockInstance(ctrl)
mockEC2ApiHelper.EXPECT().GetInstanceDetails(&instanceID).Return(nwInterfaces, nil)
mockEC2ApiHelper.EXPECT().GetSubnet(&subnetID).Return(nil, mockError)
err := ec2Instance.LoadDetails(mockEC2ApiHelper)
assert.Error(t, mockError, err)
} | explode_data.jsonl/757 | {
"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,
50730,
17,
2523,
19553,
7799,
93623,
1949,
3136,
4711,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
757,
17,
2523,
11,
7860,
7498,
17,
6563,
5511,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigRedirects(t *testing.T) {
var data = `
redirects:
left: right
up: down
/slash/prefix: noslash
`
newTestConfig(data, func(c Config, seq sequence) {
c.loadRedirects(seq)
assert.Len(t, c.redirects, 3)
assert.Equal(t, "right", c.Redirects()["left"])
assert.Equal(t, "down", c.Redirects()["up"])
assert.Equal(t, "noslash", c.Redirects()["slash/prefix"])
})
} | explode_data.jsonl/8663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
2648,
17725,
82,
1155,
353,
8840,
836,
8,
341,
2405,
821,
284,
22074,
8117,
82,
510,
220,
2115,
25,
1290,
198,
220,
705,
25,
1495,
198,
220,
608,
50256,
4322,
5060,
25,
11891,
24686,
198,
3989,
8638,
2271,
2648,
2592,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetAllEndpoints(t *testing.T) {
lc := LocationCache{}
nodeName := nodes[0]
eplist := []v1.Endpoints{
{
ObjectMeta: metav1.ObjectMeta{
Name: "ep1",
Namespace: "default",
},
Subsets: []v1.EndpointSubset{
{
Addresses: []v1.EndpointAddress{
{
IP: "10.0.0.1",
NodeName: &nodeName,
},
{
IP: "10.0.0.2",
NodeName: &nodeName,
},
},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "ep2",
Namespace: "default",
},
Subsets: []v1.EndpointSubset{
{
Addresses: []v1.EndpointAddress{
{
IP: "10.0.0.3",
NodeName: &nodeName,
},
{
IP: "10.0.0.4",
NodeName: &nodeName,
},
},
},
},
},
}
for _, ep := range eplist {
lc.endpoints.Store(ep.GetNamespace()+"/"+ep.GetName(), ep)
}
t.Run("TestGetAllEndpoints() Case: Get all endpoints", func(t *testing.T) {
got := lc.GetAllEndpoints()
if len(got) != len(eplist) {
t.Errorf("Manager.TestGetAllEndpoints() case failed: len(got): %v, len(eplist): %v", len(got), len(eplist))
}
m := map[string]v1.Endpoints{}
for _, ep := range got {
m[ep.GetNamespace()+"/"+ep.GetName()] = ep
}
for _, ep := range eplist {
if _, ok := m[ep.GetNamespace()+"/"+ep.GetName()]; !ok {
t.Errorf("Manager.TestGetAllEndpoints() case failed: endpoints not exist in GetAllEndpoints() result. got: %v want: %v ", got, ep)
}
}
})
} | explode_data.jsonl/53311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 800
} | [
2830,
3393,
1949,
2403,
80786,
1155,
353,
8840,
836,
8,
341,
8810,
66,
1669,
9866,
8233,
16094,
20831,
675,
1669,
7798,
58,
15,
921,
7727,
39934,
1669,
3056,
85,
16,
18569,
7706,
515,
197,
197,
515,
298,
23816,
12175,
25,
77520,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGetMounts(t *testing.T) {
type fields struct {
runtime *datav1alpha1.GooseFSRuntime
dataset *datav1alpha1.Dataset
name string
namespace string
Log logr.Logger
Client client.Client
}
tests := []struct {
name string
fields fields
wantResultInCtx []string
wantResultHaveMounted []string
wantErr bool
}{
{
name: "test",
fields: fields{
runtime: &datav1alpha1.GooseFSRuntime{
ObjectMeta: v1.ObjectMeta{
Name: "spark",
Namespace: "default",
},
},
dataset: &datav1alpha1.Dataset{
ObjectMeta: v1.ObjectMeta{
Name: "spark",
Namespace: "default",
},
Spec: datav1alpha1.DatasetSpec{
Mounts: []datav1alpha1.Mount{
{
Name: "test0",
MountPoint: "cos://test0",
Path: "/spec",
},
{
Name: "test1",
MountPoint: "cos://test1",
Path: "/spec",
},
},
},
Status: datav1alpha1.DatasetStatus{
Mounts: []datav1alpha1.Mount{
{
Name: "test0",
MountPoint: "cos://test0",
Path: "/status",
},
{
Name: "test1",
MountPoint: "cos://test1",
Path: "/status",
},
},
},
},
name: "spark",
namespace: "default",
Log: fake.NullLogger(),
},
wantResultInCtx: []string{"/spec", "/spec"},
wantResultHaveMounted: []string{"/status", "/status"},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
testObjs := []runtime.Object{}
testObjs = append(testObjs, tt.fields.runtime, tt.fields.dataset)
client := fake.NewFakeClientWithScheme(testScheme, testObjs...)
e := &GooseFSEngine{
runtime: tt.fields.runtime,
name: tt.fields.name,
namespace: tt.fields.namespace,
Log: tt.fields.Log,
Client: client,
}
var goosefsFileUtils operations.GooseFSFileUtils
patch1 := ApplyMethod(reflect.TypeOf(goosefsFileUtils), "Ready", func(_ operations.GooseFSFileUtils) bool {
return true
})
defer patch1.Reset()
gotResultInCtx, gotResultHaveMounted, err := e.getMounts()
if (err != nil) != tt.wantErr {
t.Errorf("GooseFSEngine.getMounts() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotResultInCtx, tt.wantResultInCtx) {
t.Errorf("GooseFSEngine.getMounts() gotResultInCtx = %v, want %v", gotResultInCtx, tt.wantResultInCtx)
}
if !reflect.DeepEqual(gotResultHaveMounted, tt.wantResultHaveMounted) {
t.Errorf("GooseFSEngine.getMounts() gotResultHaveMounted = %v, want %v", gotResultHaveMounted, tt.wantResultHaveMounted)
}
})
}
} | explode_data.jsonl/70299 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1462
} | [
2830,
3393,
1949,
16284,
82,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
7000,
4466,
256,
353,
5911,
402,
16,
7141,
16,
1224,
13752,
8485,
15123,
198,
197,
2698,
8369,
256,
353,
5911,
402,
16,
7141,
16,
79356,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCopyFileCompareDest(t *testing.T) {
ctx := context.Background()
ci := fs.GetConfig(ctx)
r := fstest.NewRun(t)
defer r.Finalise()
ci.CompareDest = r.FremoteName + "/CompareDest"
defer func() {
ci.CompareDest = ""
}()
fdst, err := fs.NewFs(ctx, r.FremoteName+"/dst")
require.NoError(t, err)
// check empty dest, empty compare
file1 := r.WriteFile("one", "one", t1)
fstest.CheckItems(t, r.Flocal, file1)
err = operations.CopyFile(ctx, fdst, r.Flocal, file1.Path, file1.Path)
require.NoError(t, err)
file1dst := file1
file1dst.Path = "dst/one"
fstest.CheckItems(t, r.Fremote, file1dst)
// check old dest, empty compare
file1b := r.WriteFile("one", "onet2", t2)
fstest.CheckItems(t, r.Fremote, file1dst)
fstest.CheckItems(t, r.Flocal, file1b)
err = operations.CopyFile(ctx, fdst, r.Flocal, file1b.Path, file1b.Path)
require.NoError(t, err)
file1bdst := file1b
file1bdst.Path = "dst/one"
fstest.CheckItems(t, r.Fremote, file1bdst)
// check old dest, new compare
file3 := r.WriteObject(ctx, "dst/one", "one", t1)
file2 := r.WriteObject(ctx, "CompareDest/one", "onet2", t2)
file1c := r.WriteFile("one", "onet2", t2)
fstest.CheckItems(t, r.Fremote, file2, file3)
fstest.CheckItems(t, r.Flocal, file1c)
err = operations.CopyFile(ctx, fdst, r.Flocal, file1c.Path, file1c.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.Fremote, file2, file3)
// check empty dest, new compare
file4 := r.WriteObject(ctx, "CompareDest/two", "two", t2)
file5 := r.WriteFile("two", "two", t2)
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
fstest.CheckItems(t, r.Flocal, file1c, file5)
err = operations.CopyFile(ctx, fdst, r.Flocal, file5.Path, file5.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
// check new dest, new compare
err = operations.CopyFile(ctx, fdst, r.Flocal, file5.Path, file5.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
// check empty dest, old compare
file5b := r.WriteFile("two", "twot3", t3)
fstest.CheckItems(t, r.Fremote, file2, file3, file4)
fstest.CheckItems(t, r.Flocal, file1c, file5b)
err = operations.CopyFile(ctx, fdst, r.Flocal, file5b.Path, file5b.Path)
require.NoError(t, err)
file5bdst := file5b
file5bdst.Path = "dst/two"
fstest.CheckItems(t, r.Fremote, file2, file3, file4, file5bdst)
} | explode_data.jsonl/51944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1023
} | [
2830,
3393,
12106,
1703,
27374,
34830,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
72,
1669,
8619,
2234,
2648,
7502,
340,
7000,
1669,
48434,
477,
7121,
6727,
1155,
340,
16867,
435,
991,
977,
1064,
2822,
1444,
72,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRedisScriptLoad(t *testing.T) {
runOnRedis(t, func(client *Redis) {
client.Ping()
_, err := NewRedis(client.Addr, "").scriptLoad("foo")
assert.NotNil(t, err)
_, err = client.scriptLoad("foo")
assert.NotNil(t, err)
})
} | explode_data.jsonl/39190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
48137,
5910,
5879,
1155,
353,
8840,
836,
8,
341,
56742,
1925,
48137,
1155,
11,
2915,
12805,
353,
48137,
8,
341,
197,
25291,
1069,
287,
741,
197,
197,
6878,
1848,
1669,
1532,
48137,
12805,
93626,
11,
35229,
2282,
5879,
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 TestTracepointMissing(t *testing.T) {
// Requires at least 4.7 (98b5c2c65c29 "perf, bpf: allow bpf programs attach to tracepoints")
testutils.SkipOnOldKernel(t, "4.7", "tracepoint support")
prog := mustLoadProgram(t, ebpf.TracePoint, 0, "")
_, err := Tracepoint("missing", "foobazbar", prog, nil)
if !errors.Is(err, os.ErrNotExist) {
t.Error("Expected os.ErrNotExist, got", err)
}
} | explode_data.jsonl/27668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
6550,
2768,
25080,
1155,
353,
8840,
836,
8,
341,
197,
322,
44089,
518,
3245,
220,
19,
13,
22,
320,
24,
23,
65,
20,
66,
17,
66,
21,
20,
66,
17,
24,
330,
59545,
11,
293,
15897,
25,
2138,
293,
15897,
7468,
15498,
311,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVerbatim(t *testing.T) {
dir := testutil.TempDir(t, "fs")
defer os.RemoveAll(dir)
store := &fs.Store{
Path: dir,
}
if err := store.Init(); err != nil {
t.Fatal(err)
}
expect := testutil.GenRandBytes(t, int(64*unit.MB))
input := bytes.NewReader(expect)
ctx := context.Background()
// Ensure the key does not exist
_, _, err := store.Pull(ctx, "foo")
if storage.ErrKeyNotFound != err {
t.Errorf("expect error %s, but got %s", storage.ErrKeyNotFound, err)
}
// Push/Pull
if err := store.Push(ctx, "foo", input); err != nil {
t.Fatal("Error pushing data to storage", err)
}
out, _, err := store.Pull(ctx, "foo")
if err != nil {
t.Fatal("Error pulling data from storage", err)
}
// Tests
got, err := ioutil.ReadAll(out)
if err != nil {
t.Fatal(err)
}
if len(expect) != len(got) {
t.Errorf("expect length of %d, but got %d", len(expect), len(got))
}
if string(expect) != string(got) {
t.Errorf("expect text %s, but got %s",
testutil.Truncate(expect, 140), testutil.Truncate(got, 140),
)
}
// Close reader
if err := out.Close(); err != nil {
t.Error("output close err", err)
}
} | explode_data.jsonl/26282 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 473
} | [
2830,
3393,
10141,
54748,
1155,
353,
8840,
836,
8,
341,
48532,
1669,
1273,
1314,
65009,
6184,
1155,
11,
330,
3848,
1138,
16867,
2643,
84427,
14161,
692,
57279,
1669,
609,
3848,
38047,
515,
197,
69640,
25,
5419,
345,
197,
532,
743,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestBankin(t *testing.T) {
client := v1.New(&v1.Config{
Key: os.Getenv("BFKEY"),
Secret: os.Getenv("BFSECRET"),
})
bank, err := client.Bankin(banks.NewForIn().SetPagination(10, 0, 0))
assert.NoError(t, err)
for i, v := range *bank {
fmt.Printf("%d: %+v\n", i, v)
}
} | explode_data.jsonl/41208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
25828,
258,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
348,
16,
7121,
2099,
85,
16,
10753,
515,
197,
55242,
25,
262,
2643,
64883,
445,
19883,
4784,
4461,
197,
7568,
50856,
25,
2643,
64883,
445,
19883,
65310,
4461,
197,
351... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStatus(t *testing.T) {
server := newTestServer(t, t.TempDir(), time.Duration(0), "/api/worker/v1")
handler := server.Handler()
test.TestRoute(t, handler, false, "GET", "/api/worker/v1/status", ``, http.StatusOK, `{"status":"OK", "href": "/api/worker/v1/status", "kind":"Status"}`, "message", "id")
} | explode_data.jsonl/1098 | {
"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,
2522,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
501,
2271,
5475,
1155,
11,
259,
65009,
6184,
1507,
882,
33795,
7,
15,
701,
3521,
2068,
14,
21462,
5457,
16,
1138,
53326,
1669,
3538,
31010,
741,
18185,
8787,
4899,
1155,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSum(t *testing.T) {
type args struct {
numbers []int
}
tests := []struct {
name string
args args
wantSum int
}{
{
name: "return sum of numbers",
args: args{
numbers: []int{1,2,3},
},
wantSum: 6,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotSum := Sum(tt.args.numbers); gotSum != tt.wantSum {
t.Errorf("Sum() = %v, want %v", gotSum, tt.wantSum)
}
})
}
} | explode_data.jsonl/6344 | {
"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,
9190,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
22431,
1902,
3056,
396,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
198,
197,
50780,
9190,
526,
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 TestInit(t *testing.T) {
table := []struct {
name string
executor Executor
wantErr error
wantIacProvider iacProvider.IacProvider
wantNotifiers []notifications.Notifier
}{
{
name: "valid filePath",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v14",
policyPath: []string{"./testdata/testpolicies"},
},
wantErr: nil,
wantIacProvider: &tfv14.TfV14{},
wantNotifiers: []notifications.Notifier{},
},
{
name: "valid notifier",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v14",
configFile: "./testdata/webhook.toml",
policyPath: []string{"./testdata/testpolicies"},
},
wantErr: nil,
wantIacProvider: &tfv14.TfV14{},
wantNotifiers: []notifications.Notifier{&webhook.Webhook{}},
},
{
name: "invalid notifier",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v14",
configFile: "testdata/invalid-notifier.toml",
},
wantErr: fmt.Errorf("notifier not supported"),
wantIacProvider: &tfv14.TfV14{},
wantNotifiers: []notifications.Notifier{&webhook.Webhook{}},
},
{
name: "config not present",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v14",
configFile: "./testdata/does-not-exist",
},
wantErr: config.ErrNotPresent,
wantIacProvider: &tfv14.TfV14{},
},
{
name: "invalid policy path",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v14",
configFile: "./testdata/webhook.toml",
policyPath: []string{"./testdata/notthere"},
},
wantErr: fmt.Errorf("failed to initialize OPA policy engine"),
wantIacProvider: &tfv14.TfV14{},
wantNotifiers: []notifications.Notifier{&webhook.Webhook{}},
},
}
for _, tt := range table {
t.Run(tt.name, func(t *testing.T) {
gotErr := tt.executor.Init()
if !reflect.DeepEqual(gotErr, tt.wantErr) {
t.Errorf("unexpected error; gotErr: '%v', wantErr: '%v'", gotErr, tt.wantErr)
}
if !reflect.DeepEqual(tt.executor.iacProvider, tt.wantIacProvider) {
t.Errorf("got: '%v', want: '%v'", tt.executor.iacProvider, tt.wantIacProvider)
}
for i, notifier := range tt.executor.notifiers {
if !reflect.DeepEqual(reflect.TypeOf(notifier), reflect.TypeOf(tt.wantNotifiers[i])) {
t.Errorf("got: '%v', want: '%v'", reflect.TypeOf(notifier), reflect.TypeOf(tt.wantNotifiers[i]))
}
}
})
}
table = []struct {
name string
executor Executor
wantErr error
wantIacProvider iacProvider.IacProvider
wantNotifiers []notifications.Notifier
}{
{
name: "valid filePath",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v12",
policyPath: []string{"./testdata/testpolicies"},
},
wantErr: nil,
wantIacProvider: &tfv12.TfV12{},
wantNotifiers: []notifications.Notifier{},
},
{
name: "valid notifier",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v12",
configFile: "./testdata/webhook.toml",
policyPath: []string{"./testdata/testpolicies"},
},
wantErr: nil,
wantIacProvider: &tfv12.TfV12{},
wantNotifiers: []notifications.Notifier{&webhook.Webhook{}},
},
{
name: "invalid notifier",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v12",
configFile: "testdata/invalid-notifier.toml",
},
wantErr: fmt.Errorf("notifier not supported"),
wantIacProvider: &tfv12.TfV12{},
wantNotifiers: []notifications.Notifier{&webhook.Webhook{}},
},
{
name: "config not present",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v12",
configFile: "./testdata/does-not-exist",
},
wantErr: config.ErrNotPresent,
wantIacProvider: &tfv12.TfV12{},
},
{
name: "invalid policy path",
executor: Executor{
filePath: "./testdata/testfile",
dirPath: "",
cloudType: []string{"aws"},
iacType: "terraform",
iacVersion: "v12",
configFile: "./testdata/webhook.toml",
policyPath: []string{"./testdata/notthere"},
},
wantErr: fmt.Errorf("failed to initialize OPA policy engine"),
wantIacProvider: &tfv12.TfV12{},
wantNotifiers: []notifications.Notifier{&webhook.Webhook{}},
},
}
for _, tt := range table {
t.Run(tt.name, func(t *testing.T) {
gotErr := tt.executor.Init()
if !reflect.DeepEqual(gotErr, tt.wantErr) {
t.Errorf("unexpected error; gotErr: '%v', wantErr: '%v'", gotErr, tt.wantErr)
}
if !reflect.DeepEqual(tt.executor.iacProvider, tt.wantIacProvider) {
t.Errorf("got: '%v', want: '%v'", tt.executor.iacProvider, tt.wantIacProvider)
}
for i, notifier := range tt.executor.notifiers {
if !reflect.DeepEqual(reflect.TypeOf(notifier), reflect.TypeOf(tt.wantNotifiers[i])) {
t.Errorf("got: '%v', want: '%v'", reflect.TypeOf(notifier), reflect.TypeOf(tt.wantNotifiers[i]))
}
}
})
}
} | explode_data.jsonl/65422 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2781
} | [
2830,
3393,
3803,
1155,
353,
8840,
836,
8,
1476,
26481,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
67328,
4831,
286,
56032,
198,
197,
50780,
7747,
260,
1465,
198,
197,
50780,
40,
580,
5179,
600,
580,
5179,
2447,
580,
5179,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDb_SizeOf_MixOfSmallAndLarge(t *testing.T) {
h := newDbHarnessWopt(t, &opt.Options{Compression: opt.NoCompression})
defer h.close()
sizes := []uint64{
10000,
10000,
100000,
10000,
100000,
10000,
300000,
10000,
}
for i, n := range sizes {
h.put(numKey(i), strings.Repeat(fmt.Sprintf("v%09d", i), int(n)/10))
}
for r := 0; r < 3; r++ {
h.reopenDB()
var x uint64
for i, n := range sizes {
y := x
if i > 0 {
y += 1000
}
h.sizeAssert("", numKey(i), x, y)
x += n
}
h.sizeAssert(numKey(3), numKey(5), 110000, 111000)
h.compactRangeAt(0, "", "")
}
} | explode_data.jsonl/6024 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
7994,
45553,
2124,
1245,
941,
2124,
25307,
3036,
34253,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
7994,
74248,
54,
2912,
1155,
11,
609,
2912,
22179,
90,
81411,
25,
3387,
16766,
81411,
3518,
16867,
305,
4653,
2822,
1903,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStorageCompact(t *testing.T) {
ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
tests := []struct {
i uint64
werr error
windex uint64
wterm uint64
wlen int
}{
{2, ErrCompacted, 3, 3, 3},
{3, ErrCompacted, 3, 3, 3},
{4, nil, 4, 4, 2},
{5, nil, 5, 5, 1},
}
for i, tt := range tests {
s := &MemoryStorage{ents: ents}
err := s.Compact(tt.i)
if err != tt.werr {
t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
}
if s.ents[0].Index != tt.windex {
t.Errorf("#%d: index = %d, want %d", i, s.ents[0].Index, tt.windex)
}
if s.ents[0].Term != tt.wterm {
t.Errorf("#%d: term = %d, want %d", i, s.ents[0].Term, tt.wterm)
}
if len(s.ents) != tt.wlen {
t.Errorf("#%d: len = %d, want %d", i, len(s.ents), tt.wlen)
}
}
} | explode_data.jsonl/66755 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 427
} | [
2830,
3393,
5793,
98335,
1155,
353,
8840,
836,
8,
341,
197,
805,
1669,
3056,
16650,
22330,
2979,
1552,
25,
220,
18,
11,
17519,
25,
220,
18,
2137,
314,
1552,
25,
220,
19,
11,
17519,
25,
220,
19,
2137,
314,
1552,
25,
220,
20,
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... | 6 |
func TestObjectInsertGetLen(t *testing.T) {
tests := []struct {
insert [][2]string
expected map[string]string
}{
{[][2]string{{`null`, `value1`}, {`null`, `value2`}}, map[string]string{`null`: `value2`}},
{[][2]string{{`false`, `value`}, {`true`, `value1`}, {`true`, `value2`}}, map[string]string{`false`: `value`, `true`: `value2`}},
{[][2]string{{`0`, `value`}, {`1`, `value1`}, {`1`, `value2`}, {`1.5`, `value`}}, map[string]string{`0`: `value`, `1`: `value2`, `1.5`: `value`}},
{[][2]string{{`"string"`, `value1`}, {`"string"`, `value2`}}, map[string]string{`"string"`: `value2`}},
{[][2]string{{`["other"]`, `value1`}, {`["other"]`, `value2`}}, map[string]string{`["other"]`: `value2`}},
}
for _, tc := range tests {
o := NewObject()
for _, kv := range tc.insert {
o.Insert(MustParseTerm(kv[0]), MustParseTerm(kv[1]))
if v := o.Get(MustParseTerm(kv[0])); v == nil || !MustParseTerm(kv[1]).Equal(v) {
t.Errorf("Expected the object to contain %v", v)
}
}
if o.Len() != len(tc.expected) {
t.Errorf("Expected the object to have %v entries", len(tc.expected))
}
for k, v := range tc.expected {
if x := o.Get(MustParseTerm(k)); x == nil || !MustParseTerm(v).Equal(x) {
t.Errorf("Expected the object to contain %v", k)
}
}
}
} | explode_data.jsonl/2906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 591
} | [
2830,
3393,
1190,
13780,
1949,
11271,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
59847,
256,
508,
1457,
17,
30953,
198,
197,
42400,
2415,
14032,
30953,
198,
197,
59403,
197,
197,
90,
63449,
17,
30953,
2979,
63,
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... | 9 |
func Test_validate_map(t *testing.T) {
should := require.New(t)
schemas, err := ThriftSchemas(`
struct Request {
1: map<string, string> words;
}
`)
should.Nil(err)
obj := NewObject()
obj.Schema = schemas["Request"]
obj.Set("words", NewObject("hello", "world"))
should.Panics(func() {
obj.Set("words", 1)
})
should.Panics(func() {
obj.Set("words", NewList(1))
})
} | explode_data.jsonl/61928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
42681,
5376,
1155,
353,
8840,
836,
8,
341,
197,
5445,
1669,
1373,
7121,
1155,
340,
1903,
31126,
11,
1848,
1669,
29565,
2085,
50,
31126,
61528,
6472,
6145,
341,
197,
197,
16,
25,
2415,
4947,
11,
914,
29,
4244,
280,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRows(t *testing.T) {
ri := newRows(&rowsResult1)
wantCols := []string{
"field1",
"field2",
"field3",
"field4",
"field5",
}
gotCols := ri.Columns()
if !reflect.DeepEqual(gotCols, wantCols) {
t.Errorf("cols: %v, want %v", gotCols, wantCols)
}
wantRow := []driver.Value{
int64(1),
float64(1.1),
[]byte("value1"),
int64(2147483647),
uint64(9223372036854775807),
}
gotRow := make([]driver.Value, len(wantRow))
err := ri.Next(gotRow)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(gotRow, wantRow) {
t.Errorf("row1: %v, want %v type: %T", gotRow, wantRow, wantRow[3])
logMismatchedTypes(t, gotRow, wantRow)
}
wantRow = []driver.Value{
int64(2),
float64(2.2),
[]byte("value2"),
int64(4294967295),
uint64(18446744073709551615),
}
err = ri.Next(gotRow)
if err != nil {
t.Error(err)
}
if !reflect.DeepEqual(gotRow, wantRow) {
t.Errorf("row1: %v, want %v", gotRow, wantRow)
logMismatchedTypes(t, gotRow, wantRow)
}
err = ri.Next(gotRow)
if err != io.EOF {
t.Errorf("got: %v, want %v", err, io.EOF)
}
_ = ri.Close()
} | explode_data.jsonl/30384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 536
} | [
2830,
3393,
9024,
1155,
353,
8840,
836,
8,
341,
197,
461,
1669,
501,
9024,
2099,
1811,
2077,
16,
340,
50780,
37567,
1669,
3056,
917,
515,
197,
197,
1,
2566,
16,
756,
197,
197,
1,
2566,
17,
756,
197,
197,
1,
2566,
18,
756,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestPluginReboot(t *testing.T) {
var (
testPodUID = types.UID("test_pod_uid3")
testVolumeName = "test_volume_name"
testNamespace = "test_secret_namespace"
testName = "test_secret_name"
volumeSpec = volumeSpec(testVolumeName, testName, 0644)
secret = secret(testNamespace, testName)
client = fake.NewSimpleClientset(&secret)
pluginMgr = volume.VolumePluginMgr{}
rootDir, host = newTestHost(t, client)
)
defer os.RemoveAll(rootDir)
pluginMgr.InitPlugins(ProbeVolumePlugins(), host)
plugin, err := pluginMgr.FindPluginByName(secretPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
}
pod := &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: testNamespace, UID: testPodUID}}
mounter, err := plugin.NewMounter(volume.NewSpecFromVolume(volumeSpec), pod, volume.VolumeOptions{})
if err != nil {
t.Errorf("Failed to make a new Mounter: %v", err)
}
if mounter == nil {
t.Errorf("Got a nil Mounter")
}
podMetadataDir := fmt.Sprintf("%v/pods/test_pod_uid3/plugins/kubernetes.io~secret/test_volume_name", rootDir)
util.SetReady(podMetadataDir)
volumePath := mounter.GetPath()
if !strings.HasSuffix(volumePath, fmt.Sprintf("pods/test_pod_uid3/volumes/kubernetes.io~secret/test_volume_name")) {
t.Errorf("Got unexpected path: %s", volumePath)
}
err = mounter.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
if _, err := os.Stat(volumePath); err != nil {
if os.IsNotExist(err) {
t.Errorf("SetUp() failed, volume path not created: %s", volumePath)
} else {
t.Errorf("SetUp() failed: %v", err)
}
}
doTestSecretDataInVolume(volumePath, secret, t)
doTestCleanAndTeardown(plugin, testPodUID, testVolumeName, volumePath, t)
} | explode_data.jsonl/15326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 694
} | [
2830,
3393,
11546,
693,
4619,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
18185,
23527,
6463,
257,
284,
4494,
5255,
915,
445,
1944,
85337,
25396,
18,
1138,
197,
18185,
18902,
675,
284,
330,
1944,
26941,
1269,
698,
197,
18185,
22699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleNoDeterministicGroupby(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
// 正面CASE
{
"select c1,c2,c3 from t1 where c2='foo' group by c2",
"select col, col2, sum(col1) from tb group by col",
"select col, col1 from tb group by col,sum(col1)",
"select * from tb group by col",
},
// 反面CASE
{
"select id from film",
"select col, sum(col1) from tb group by col",
"select * from file",
"SELECT COUNT(*) AS cnt, language_id FROM film GROUP BY language_id;",
"SELECT COUNT(*) AS cnt FROM film GROUP BY language_id;",
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleNoDeterministicGroupby()
if rule.Item != "RES.001" {
t.Error("Rule not match:", rule.Item, "Expect : RES.001")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleNoDeterministicGroupby()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76765 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 545
} | [
2830,
3393,
11337,
2753,
92648,
4532,
2808,
1694,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
322,
71928,
96,
27091,
40... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAPI_DeleteNamespace(t *testing.T) {
api, router, mockCtl := initNamespaceAPI(t)
defer mockCtl.Finish()
mkNamespaceService := ms.NewMockNamespaceService(mockCtl)
api.NS = mkNamespaceService
mkTaskService := ms.NewMockTaskService(mockCtl)
api.Task = mkTaskService
mkNamespaceService.EXPECT().Get("testA").Return(nil, nil)
mkTaskService.EXPECT().AddTask(gomock.Any()).Return(nil)
// 200
req, _ := http.NewRequest(http.MethodDelete, "/testA/namespace", nil)
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
assert.Equal(t, http.StatusOK, w.Code)
err := fmt.Errorf("error")
mkNamespaceService.EXPECT().Get("testA").Return(nil, err)
// 500
req, _ = http.NewRequest(http.MethodDelete, "/testA/namespace", nil)
w = httptest.NewRecorder()
router.ServeHTTP(w, req)
assert.Equal(t, http.StatusInternalServerError, w.Code)
} | explode_data.jsonl/54052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
7082,
57418,
22699,
1155,
353,
8840,
836,
8,
341,
54299,
11,
9273,
11,
7860,
94252,
1669,
2930,
22699,
7082,
1155,
340,
16867,
7860,
94252,
991,
18176,
741,
2109,
74,
22699,
1860,
1669,
9829,
7121,
11571,
22699,
1860,
30389,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_reasonForError(t *testing.T) {
if e, a := api.StatusReasonUnknown, reasonForError(nil); e != a {
t.Errorf("unexpected reason type: %#v", a)
}
} | explode_data.jsonl/8867 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 61
} | [
2830,
3393,
38229,
2461,
1454,
1155,
353,
8840,
836,
8,
341,
743,
384,
11,
264,
1669,
6330,
10538,
25139,
13790,
11,
2874,
2461,
1454,
27907,
1215,
384,
961,
264,
341,
197,
3244,
13080,
445,
53859,
2874,
943,
25,
52406,
85,
497,
264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPerformRequestWithCompressionDisabled(t *testing.T) {
testPerformRequestWithCompression(t, &http.Client{
Transport: &http.Transport{
DisableCompression: false,
},
})
} | explode_data.jsonl/38029 | {
"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,
46951,
1900,
2354,
81411,
25907,
1155,
353,
8840,
836,
8,
341,
18185,
46951,
1900,
2354,
81411,
1155,
11,
609,
1254,
11716,
515,
197,
197,
27560,
25,
609,
1254,
87669,
515,
298,
197,
25479,
81411,
25,
895,
345,
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 |
func TestHeaderBoundary(t *testing.T) {
cases := []struct {
desc string
in string
exp []byte
}{{
desc: "With no content-type",
in: "From: Nathaniel Borenstein <nsb@bellcore.com>\r\n" +
"To: Ned Freed <ned@innosoft.com>\r\n" +
"Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\r\n" +
"Subject: Sample message\r\n" +
"\r\n",
}, {
desc: "With invalid content-type",
in: "From: Nathaniel Borenstein <nsb@bellcore.com>\r\n" +
"To: Ned Freed <ned@innosoft.com>\r\n" +
"Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\r\n" +
"Subject: Sample message\r\n" +
"MIME-Version: 1.0\r\n" +
"Content-type: multipart/mixed; boundary=simple:boundary\r\n" +
"\r\n",
}, {
desc: "With boundary",
in: "From: Nathaniel Borenstein <nsb@bellcore.com>\r\n" +
"To: Ned Freed <ned@innosoft.com>\r\n" +
"Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\r\n" +
"Subject: Sample message\r\n" +
"MIME-Version: 1.0\r\n" +
"Content-type: multipart/mixed; boundary=\"simple boundary\"\r\n" +
"\r\n",
exp: []byte("simple boundary"),
}}
for _, c := range cases {
t.Log(c.desc)
header, _, err := ParseHeader([]byte(c.in))
if err != nil {
t.Fatal(err)
}
test.Assert(t, "Boundary", c.exp, header.Boundary(), true)
}
} | explode_data.jsonl/2178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 598
} | [
2830,
3393,
4047,
57977,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
41653,
914,
198,
197,
17430,
256,
914,
198,
197,
48558,
220,
3056,
3782,
198,
197,
15170,
515,
197,
41653,
25,
330,
2354,
902,
2213,
10604,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMuxRegexp(t *testing.T) {
r := NewRouter()
r.Route("/{param:[0-9]*}/test", func(r Router) {
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf("Hi: %s", URLParam(r, "param"))))
})
})
ts := httptest.NewServer(r)
defer ts.Close()
if _, body := testRequest(t, ts, "GET", "//test", nil); body != "Hi: " {
t.Fatalf(body)
}
} | explode_data.jsonl/42888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 176
} | [
2830,
3393,
44,
2200,
3477,
4580,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
9523,
741,
7000,
58004,
65871,
903,
7259,
15,
12,
24,
8465,
4472,
1944,
497,
2915,
2601,
10554,
8,
341,
197,
7000,
2234,
35460,
2915,
3622,
1758,
37508,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandlingRegexRoute(t *testing.T) {
route := mux.NewRoute(
mux.MethodGet,
"/example/([0-9]+)",
mux.NewInlineHandler(
func(w http.ResponseWriter, _ *http.Request, rm *mux.RouteMatch) {
id, _ := rm.Var(0)
w.Write([]byte(id))
},
),
)
recorder := httptest.NewRecorder()
route.Handle(recorder, newRequest("/example/12345"))
assert.Equal(t, "12345", recorder.Body.String())
} | explode_data.jsonl/24486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
38606,
32464,
4899,
1155,
353,
8840,
836,
8,
341,
7000,
2133,
1669,
59807,
7121,
4899,
1006,
197,
2109,
2200,
20798,
1949,
345,
197,
197,
3115,
8687,
14,
2561,
15,
12,
24,
7574,
15752,
197,
2109,
2200,
7121,
25324,
3050,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExample0(t *testing.T) {
var product = 894797020974016837
N := 1000000
start := time.Now()
primes := FindPrimes(N)
fmt.Println(len(primes), "len primes", time.Now())
var first, second int
for _, prime := range primes {
if product%prime == 0 {
second = prime
first = product / prime
//if !IsPrimeFast(first,primes) {
// t.Fatal(first,second ,"not prime")
//}
fmt.Println(first, second)
fmt.Println(time.Now().Sub(start), time.Now())
return
}
}
for i := N + 1; float64(i) < math.Sqrt(float64(product)); i = i + 2 {
ok := IsPrimeFast(i, primes)
if ok {
if product%i == 0 {
second = i
first = product / i
//if !IsPrimeFast(first,primes) {
// t.Fatal(first,second ,"not prime")
//}
fmt.Println(first, " ", second)
fmt.Println(time.Now().Sub(start))
return
}
}
}
t.Fatal("problem error")
} | explode_data.jsonl/20892 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 396
} | [
2830,
3393,
13314,
15,
1155,
353,
8840,
836,
8,
341,
2405,
1985,
284,
220,
23,
24,
19,
22,
24,
22,
15,
17,
15,
24,
22,
19,
15,
16,
21,
23,
18,
22,
198,
18317,
1669,
220,
16,
15,
15,
15,
15,
15,
15,
198,
21375,
1669,
882,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestUtilNotifyProfileNew(t *testing.T) {
q := make(chan string)
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Content-Type", "application/json")
rw.WriteHeader(200)
defer req.Body.Close()
bodyBytes, _ := ioutil.ReadAll(req.Body)
fmt.Printf("body: %s\n", string(bodyBytes))
if string(bodyBytes) != `{"action":"profilenew","identity":"user3@user3.com","mode":"email","profile":{"name":"alex"}}` {
q <- fmt.Sprintf("bad request in notifyConsentChange: %s", string(bodyBytes))
} else {
q <- "ok"
}
}))
// Close the server when test finishes
defer server.Close()
profile := []byte(`{"name":"alex"}`)
notifyProfileNew(server.URL, profile, "email", "user3@user3.com")
response := <-q
if response != "ok" {
t.Fatal(response)
}
} | explode_data.jsonl/9664 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
2742,
28962,
8526,
3564,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1281,
35190,
914,
340,
41057,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
2601,
86,
1758,
37508,
11,
4232,
353,
1254,
9659,
8,
341,
197,
7000,
86,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOVSDeletePortIdempotent(t *testing.T) {
data := &testData{}
data.setup(t)
defer data.teardown(t)
deleteAllPorts(t, data.br)
uuid := testCreatePort(t, data.br, "p1", "internal")
testDeletePort(t, data.br, uuid)
testDeletePort(t, data.br, uuid)
} | explode_data.jsonl/74749 | {
"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,
46,
26050,
6435,
7084,
764,
3262,
63532,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
609,
1944,
1043,
16094,
8924,
25338,
1155,
340,
16867,
821,
31853,
37496,
1155,
692,
15618,
2403,
68273,
1155,
11,
821,
20937,
692,
10676,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_AppRestrictionsEnabled(t *testing.T) {
tests := []struct {
description string
testFile string
org string
want bool
}{
{
description: "return true for enabled orgs",
testFile: "access-restrictions-enabled.html",
want: true,
},
{
description: "return false for disabled orgs",
testFile: "access-restrictions-disabled.html",
want: false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
client, mux, cleanup := setup()
defer cleanup()
mux.HandleFunc("/organizations/o/settings/oauth_application_policy", func(w http.ResponseWriter, r *http.Request) {
copyTestFile(w, tt.testFile)
})
got, err := client.AppRestrictionsEnabled("o")
if err != nil {
t.Errorf("AppRestrictionsEnabled returned err: %v", err)
}
if want := tt.want; got != want {
t.Errorf("AppRestrictionsEnabled returned %t, want %t", got, want)
}
})
}
} | explode_data.jsonl/55775 | {
"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,
36117,
50360,
21439,
5462,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
18185,
1703,
262,
914,
198,
197,
87625,
260,
914,
198,
197,
50780,
286,
1807,
198,
197,
59403,
197,
197,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCache(t *testing.T) {
privKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
t.Fatal(err)
}
tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{CommonName: "example.org"},
NotAfter: time.Now().Add(time.Hour),
}
pub, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &privKey.PublicKey, privKey)
if err != nil {
t.Fatal(err)
}
tlscert := &tls.Certificate{
Certificate: [][]byte{pub},
PrivateKey: privKey,
}
man := &Manager{Cache: newMemCache()}
defer man.stopRenew()
if err := man.cachePut("example.org", tlscert); err != nil {
t.Fatalf("man.cachePut: %v", err)
}
res, err := man.cacheGet("example.org")
if err != nil {
t.Fatalf("man.cacheGet: %v", err)
}
if res == nil {
t.Fatal("res is nil")
}
} | explode_data.jsonl/51428 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
8233,
1155,
353,
8840,
836,
8,
341,
71170,
1592,
11,
1848,
1669,
384,
4385,
9081,
57582,
1592,
7,
613,
11442,
292,
1069,
17,
20,
21,
1507,
10382,
47431,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestPostHandlerIntegration(t *testing.T) {
type request struct {
request events.APIGatewayProxyRequest
}
testcases := []struct {
name string
request request
expectedResponse events.APIGatewayProxyResponse
}{
{
name: "Wrong http method",
request: request{
events.APIGatewayProxyRequest{
HTTPMethod: "POT",
},
},
expectedResponse: events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: Invalid http method",
},
},
{
name: "Incorrect Content-Type",
request: request{
events.APIGatewayProxyRequest{
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/xml",
},
},
},
expectedResponse: events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: Invalid content type. It is not in a JSON format",
},
},
{
name: "Invalid request path",
request: request{
events.APIGatewayProxyRequest{
Path: "/api/d",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
},
},
expectedResponse: events.APIGatewayProxyResponse{
StatusCode: http.StatusForbidden,
Body: "403 Forbidden: You don't have permission to access /api/d",
},
},
{
name: "Request with empty body",
request: request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "",
},
},
expectedResponse: events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: Invalid JSON request. All fields are empty",
},
},
{
name: "Bad JSON format",
request: request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{{:\"id\":}\"/devices/id1\":{},\"deviceModel\":\"/devicemodels/id1\",\"name\":\"Sensor\",\"note\":\"Testing a sensor.\",\"serial\":\"A020000102\"}",
},
},
expectedResponse: events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: Invalid JSON format",
},
},
{
"Request with missed field - ID",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"\",\"deviceModel\":\"/devicemodels/id1\",\"name\":\"Sensor\",\"note\":\"Testing a sensor.\",\"serial\":\"A020000102\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: No value is specified for field(s) 'id' of device in json request",
},
},
{
"Request with missed field - DeviceModel",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"/devices/id1\",\"deviceModel\":\"\",\"name\":\"Sensor\",\"note\":\"Testing a sensor.\",\"serial\":\"A020000102\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: No value is specified for field(s) 'device model' of device in json request",
},
},
{
"Request with missed field - Name",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"/devices/id1\",\"deviceModel\":\"/devicemodels/id1\",\"name\":\"\",\"note\":\"Testing a sensor.\",\"serial\":\"A020000102\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: No value is specified for field(s) 'name' of device in json request",
},
},
{
"Request with missed field - Note",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"/devices/id1\",\"deviceModel\":\"/devicemodels/id1\",\"name\":\"Sensor\",\"note\":\"\",\"serial\":\"A020000102\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: No value is specified for field(s) 'note' of device in json request",
},
},
{
"Request with missed field - Serial",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"/devices/id1\",\"deviceModel\":\"/devicemodels/id1\",\"name\":\"Sensor\",\"note\":\"Testing a sensor.\",\"serial\":\"\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: No value is specified for field(s) 'serial' of device in json request",
},
},
{
"Request with multiple missed fields - Id, Name, Note",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"\",\"deviceModel\":\"/devicemodels/id1\",\"name\":\"\",\"note\":\"\",\"serial\":\"A020000102\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
Body: "400 Bad Request: No value is specified for field(s) 'id' 'name' 'note' of device in json request",
},
},
{
"Complete request without error",
request{
events.APIGatewayProxyRequest{
Path: "/api/devices",
HTTPMethod: "POST",
Headers: map[string]string{
"Content-Type": "application/json",
},
Body: "{\"id\":\"id2\",\"deviceModel\":\"/devicemodels/id2\",\"name\":\"Sensor\",\"note\":\"Testing a sensor.\",\"serial\":\"A020000102\"}",
},
},
events.APIGatewayProxyResponse{
StatusCode: http.StatusCreated,
Body: "{\"id\":\"id2\",\"deviceModel\":\"/devicemodels/id2\",\"name\":\"Sensor\",\"note\":\"Testing a sensor.\",\"serial\":\"A020000102\"}",
},
},
}
for _, testcase := range testcases {
t.Run(testcase.name, func(t *testing.T) {
if gotResponse := PostHandler(testcase.request.request); !reflect.DeepEqual(gotResponse, testcase.expectedResponse) {
t.Errorf("%s \nGot output from postHandler() = %v\nExpected output = %v", testcase.name, gotResponse, testcase.expectedResponse)
}
})
}
} | explode_data.jsonl/63316 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2918
} | [
2830,
3393,
4133,
3050,
52464,
1155,
353,
8840,
836,
8,
341,
13158,
1681,
2036,
341,
197,
23555,
4357,
24922,
40709,
16219,
1900,
198,
197,
532,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
1797,
914,
198,
197,
23555,
688,
1681,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDuplicateEntryPoint(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
console.log(123)
`,
},
entryPaths: []string{"/entry.js", "/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputDir: "/out.js",
},
})
} | explode_data.jsonl/38545 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
53979,
97416,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
12160,
1665,
7,
16,
17,
18,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRemoteSignVoteErrors(t *testing.T) {
for _, tc := range socketTestCases(t) {
func() {
var (
chainID = cmn.RandStr(12)
validatorEndpoint, serviceEndpoint = testSetupSocketPair(
t,
chainID,
types.NewErroringMockPV(),
tc.addr,
tc.dialer)
ts = time.Now()
vType = types.PrecommitType
vote = &types.Vote{Timestamp: ts, Type: vType}
)
defer validatorEndpoint.Stop()
defer serviceEndpoint.Stop()
err := validatorEndpoint.SignVote("", vote)
require.Equal(t, err.(*RemoteSignerError).Description, types.ErroringMockPVErr.Error())
err = serviceEndpoint.privVal.SignVote(chainID, vote)
require.Error(t, err)
err = validatorEndpoint.SignVote(chainID, vote)
require.Error(t, err)
}()
}
} | explode_data.jsonl/77985 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
24703,
7264,
41412,
13877,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
7575,
2271,
37302,
1155,
8,
341,
197,
29244,
368,
341,
298,
2405,
2399,
571,
197,
8819,
915,
999,
284,
9961,
77,
2013,
437,
2580,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetFileLink(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
channel := th.BasicChannel
if *th.App.Config().FileSettings.DriverName == "" {
t.Skip("skipping because no file driver is enabled")
}
enablePublicLink := th.App.Config().FileSettings.EnablePublicLink
publicLinkSalt := *th.App.Config().FileSettings.PublicLinkSalt
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = enablePublicLink })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = publicLinkSalt })
}()
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = model.NewId() })
fileId := ""
if data, err := testutils.ReadTestFile("test.png"); err != nil {
t.Fatal(err)
} else {
fileResp, resp := Client.UploadFile(data, channel.Id, "test.png")
CheckNoError(t, resp)
fileId = fileResp.FileInfos[0].Id
}
_, resp := Client.GetFileLink(fileId)
CheckBadRequestStatus(t, resp)
// Hacky way to assign file to a post (usually would be done by CreatePost call)
store.Must(th.App.Srv.Store.FileInfo().AttachToPost(fileId, th.BasicPost.Id, th.BasicUser.Id))
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = false })
_, resp = Client.GetFileLink(fileId)
CheckNotImplementedStatus(t, resp)
// Wait a bit for files to ready
time.Sleep(2 * time.Second)
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
link, resp := Client.GetFileLink(fileId)
CheckNoError(t, resp)
if link == "" {
t.Fatal("should've received public link")
}
_, resp = Client.GetFileLink("junk")
CheckBadRequestStatus(t, resp)
_, resp = Client.GetFileLink(model.NewId())
CheckNotFoundStatus(t, resp)
Client.Logout()
_, resp = Client.GetFileLink(fileId)
CheckUnauthorizedStatus(t, resp)
otherUser := th.CreateUser()
Client.Login(otherUser.Email, otherUser.Password)
_, resp = Client.GetFileLink(fileId)
CheckForbiddenStatus(t, resp)
Client.Logout()
_, resp = th.SystemAdminClient.GetFileLink(fileId)
CheckNoError(t, resp)
if result := <-th.App.Srv.Store.FileInfo().Get(fileId); result.Err != nil {
t.Fatal(result.Err)
} else {
th.cleanupTestFile(result.Data.(*model.FileInfo))
}
} | explode_data.jsonl/67442 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 857
} | [
2830,
3393,
1949,
1703,
3939,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
198,
71550,
1669,
270,
48868,
9629,
271,
743,
353,
339,
5105,
10753,
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... | 1 |
func Test_processNotificationValues(t *testing.T) {
type args struct {
notif v2.NotificationEntry
}
tests := []struct {
name string
args args
want sdk.WorkflowNotification
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := v2.ProcessNotificationValues(tt.args.notif)
if (err != nil) != tt.wantErr {
t.Errorf("processNotificationValues() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("processNotificationValues() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/10299 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
11305,
11196,
6227,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
197,
85046,
348,
17,
49329,
5874,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
198,
197,
5078... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetMissing(t *testing.T) {
key := "test/get/missing"
_, cache := NewMock(createInitial())
got, err := cache.Get(context.Background(), key)
if err == nil {
t.Fatalf("Expected error, got nil")
}
if got != nil {
t.Fatalf("Got %v, expected nil", *got)
}
} | explode_data.jsonl/80140 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
1949,
25080,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
330,
1944,
23302,
14,
30616,
1837,
197,
6878,
6500,
1669,
1532,
11571,
32602,
6341,
12367,
3174,
354,
11,
1848,
1669,
6500,
2234,
5378,
19047,
1507,
1376,
340,
743,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOverwriteSouce(t *testing.T) {
ctx := context.Background()
t.Run("test source kv string", func(t *testing.T) {
Infov(ctx, KVString("source", "test"))
})
t.Run("test source kv string", func(t *testing.T) {
Infov(ctx, KV("source", "test"))
})
} | explode_data.jsonl/1357 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
1918,
4934,
57432,
346,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
3244,
16708,
445,
1944,
2530,
16178,
914,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197,
1731,
85,
7502,
11,
84648,
703,
445,
2427,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMessageTransaction_ValidateExtended(t *testing.T) {
xmss := helper.GetAliceXMSS(6)
message := "hello"
fee := uint64(1)
xmssPK := misc.UCharVectorToBytes(xmss.PK())
messageTx := NewTestMessageTransaction(message, fee, xmssPK, nil)
assert.NotNil(t, messageTx.tx)
addrFromState := addressstate.GetDefaultAddressState(misc.UCharVectorToBytes(xmss.Address()))
messageTx.tx.Sign(xmss, misc.BytesToUCharVector(messageTx.tx.GetHashableBytes()))
// Since balance is 0, validation should fail as required fee is 1
assert.False(t, messageTx.tx.ValidateExtended(addrFromState, addrFromState))
// Added balance
addrFromState.AddBalance(1)
assert.True(t, messageTx.tx.ValidateExtended(addrFromState, addrFromState))
} | explode_data.jsonl/10389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
2052,
8070,
62,
17926,
53190,
1155,
353,
8840,
836,
8,
341,
10225,
76,
778,
1669,
13137,
2234,
61686,
52337,
1220,
7,
21,
340,
24753,
1669,
330,
14990,
698,
1166,
2127,
1669,
2622,
21,
19,
7,
16,
340,
10225,
76,
778,
222... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInit(t *testing.T) {
folder := setupInitTest(t)
cmd := newInitCmd().cmd
config := "foo.yaml"
cmd.SetArgs([]string{"-f", config})
require.NoError(t, cmd.Execute())
require.FileExists(t, filepath.Join(folder, config))
require.FileExists(t, filepath.Join(folder, ".gitignore"))
} | explode_data.jsonl/25328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
3803,
1155,
353,
8840,
836,
8,
341,
1166,
2018,
1669,
6505,
3803,
2271,
1155,
340,
25920,
1669,
501,
3803,
15613,
1005,
8710,
198,
25873,
1669,
330,
7975,
33406,
698,
25920,
4202,
4117,
10556,
917,
4913,
12,
69,
497,
2193,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCache_expired(t *testing.T) {
const host = "google.com."
ans := &dns.A{
Hdr: dns.RR_Header{
Name: host,
Rrtype: dns.TypeA,
Class: dns.ClassINET,
},
A: net.IP{8, 8, 8, 8},
}
reply := (&dns.Msg{
MsgHdr: dns.MsgHdr{
Response: true,
},
Answer: []dns.RR{ans},
}).SetQuestion(host, dns.TypeA)
testCases := []struct {
name string
ttl uint32
wantTTL uint32
optimistic bool
}{{
name: "realistic_hit",
ttl: defaultTestTTL,
wantTTL: defaultTestTTL,
optimistic: false,
}, {
name: "realistic_miss",
ttl: 0,
wantTTL: 0,
optimistic: false,
}, {
name: "optimistic_hit",
ttl: defaultTestTTL,
wantTTL: defaultTestTTL,
optimistic: true,
}, {
name: "optimistic_expired",
ttl: 0,
wantTTL: optimisticTTL,
optimistic: true,
}}
testCache := &cache{
items: glcache.New(glcache.Config{
MaxSize: defaultCacheSize,
EnableLRU: true,
}),
}
for _, tc := range testCases {
ans.Hdr.Ttl = tc.ttl
req := (&dns.Msg{}).SetQuestion(host, dns.TypeA)
t.Run(tc.name, func(t *testing.T) {
if tc.optimistic {
testCache.optimistic = true
}
t.Cleanup(func() { testCache.optimistic = false })
key := msgToKey(reply)
data := (&cacheItem{
m: reply,
u: testUpsAddr,
}).pack()
testCache.items.Set(key, data)
t.Cleanup(testCache.items.Clear)
r, expired, key := testCache.get(req)
assert.Equal(t, msgToKey(req), key)
assert.Equal(t, tc.ttl == 0, expired)
if tc.wantTTL != 0 {
require.NotNil(t, r)
assert.Equal(t, tc.wantTTL, r.m.Answer[0].Header().Ttl)
assert.Equal(t, testUpsAddr, r.u)
} else {
require.Nil(t, r)
}
})
}
} | explode_data.jsonl/18904 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 893
} | [
2830,
3393,
8233,
80221,
1155,
353,
8840,
836,
8,
341,
4777,
3468,
284,
330,
17485,
905,
2217,
43579,
1669,
609,
45226,
875,
515,
197,
13292,
3612,
25,
44077,
2013,
49,
71353,
515,
298,
21297,
25,
256,
3468,
345,
298,
11143,
32513,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWithEventModifier(t *testing.T) {
f1 := func(module, metricset string, event *mb.Event) {}
f2 := func(module, metricset string, event *mb.Event) {}
w := &Wrapper{}
WithEventModifier(f1)(w)
WithEventModifier(f2)(w)
assert.Len(t, w.eventModifiers, 2)
} | explode_data.jsonl/50277 | {
"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,
2354,
1556,
34405,
1155,
353,
8840,
836,
8,
341,
1166,
16,
1669,
2915,
19123,
11,
18266,
746,
914,
11,
1538,
353,
3096,
6904,
8,
5613,
1166,
17,
1669,
2915,
19123,
11,
18266,
746,
914,
11,
1538,
353,
3096,
6904,
8,
10086... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.