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 TestGoverallsExisting(t *testing.T) {
p := myImportPath()
t.Logf("My import path is %q", p)
tmp := prepareTest(t)
defer os.RemoveAll(tmp)
runCmd(t, "go", "get", p+"/tester")
runCmd(t, "go", "get", "github.com/axw/gocov/gocov")
b := runCmd(t, "goveralls", "-gocovdata=tester/cov.json",
"-package="+p+"/tester", "")
lines := strings.Split(strings.TrimSpace(string(b)), "\n")
s := lines[len(lines)-1]
if s != "Succeeded" {
t.Fatalf("Expected test of tester are succeeded, but failured")
}
} | explode_data.jsonl/4596 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
38,
1975,
5583,
53067,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
847,
11511,
1820,
741,
3244,
98954,
445,
5050,
1159,
1815,
374,
1018,
80,
497,
281,
692,
20082,
1669,
10549,
2271,
1155,
340,
16867,
2643,
84427,
10368,
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... | 2 |
func TestYouonV(t *testing.T) {
const want = "vyavyuvyovavivuvevo"
for _, v := range [2]string{"γγγγ
γγγγγγγγ
γγγγ", "γ΄γ£γ΄γ₯γ΄γ§γ΄γ‘γ΄γ£γ΄γ₯γ΄γ§γ΄γ©"} {
got, err := KanaToRomaji(v)
assert.Equal(t, want, got)
assert.Nil(t, err)
}
} | explode_data.jsonl/11314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 141
} | [
2830,
3393,
2610,
263,
53,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
330,
13714,
5663,
12058,
88,
859,
402,
344,
56023,
3334,
1837,
2023,
8358,
348,
1669,
2088,
508,
17,
30953,
4913,
148455,
124234,
148455,
138218,
148455,
124180,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserGroupInvalid(t *testing.T) {
tests := []App{
App{
Exec: []string{"/app"},
},
App{
Exec: []string{"/app"},
User: "0",
},
App{
Exec: []string{"app"},
Group: "0",
},
}
for i, tt := range tests {
if err := tt.assertValid(); err == nil {
t.Errorf("#%d: err == nil, want non-nil", i)
}
}
} | explode_data.jsonl/8863 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
1474,
2808,
7928,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
2164,
515,
197,
59557,
515,
298,
197,
10216,
25,
3056,
917,
90,
3115,
676,
7115,
197,
197,
1583,
197,
59557,
515,
298,
197,
10216,
25,
3056,
917,
90,
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... | 3 |
func TestDeleteBlockImageFailure(t *testing.T) {
clientFunc := func(client RookRestClient) (interface{}, error) {
return client.DeleteBlockImage(model.BlockImage{Name: "image1"})
}
verifyFunc := getStringVerifyFunc(t)
ClientFailureHelperWithVerification(t, clientFunc, verifyFunc)
} | explode_data.jsonl/27856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
6435,
4713,
1906,
17507,
1155,
353,
8840,
836,
8,
341,
25291,
9626,
1669,
2915,
12805,
431,
1941,
12416,
2959,
8,
320,
4970,
22655,
1465,
8,
341,
197,
853,
2943,
18872,
4713,
1906,
7635,
28477,
1906,
63121,
25,
330,
1805,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStateCallbacks(t *testing.T) {
orderStateMachine := getStateMachine()
order := &Order{}
address1 := "I'm an address should be set when enter checkout"
address2 := "I'm an address should be set when exit checkout"
orderStateMachine.State("checkout").Enter(func(order interface{}, tx *gorm.DB) error {
order.(*Order).Address = address1
return nil
}).Exit(func(order interface{}, tx *gorm.DB) error {
order.(*Order).Address = address2
return nil
})
if err := orderStateMachine.Trigger("checkout", order, db); err != nil {
t.Errorf("should not raise any error when trigger event checkout")
}
if order.Address != address1 {
t.Errorf("enter callback not triggered")
}
if err := orderStateMachine.Trigger("pay", order, db); err != nil {
t.Errorf("should not raise any error when trigger event pay")
}
if order.Address != address2 {
t.Errorf("exit callback not triggered")
}
} | explode_data.jsonl/2614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
1397,
44461,
1155,
353,
8840,
836,
8,
341,
42245,
94666,
1669,
39070,
21605,
741,
42245,
1669,
609,
4431,
31483,
63202,
16,
1669,
330,
40,
2776,
458,
2621,
1265,
387,
738,
979,
3725,
27264,
698,
63202,
17,
1669,
330,
40,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDecode(t *testing.T) {
var one, two map[string]interface{}
codec := NewCodec()
codec.SortbyUTF8(true)
out := codec.Decode(codec.Encode(json1))
json.Unmarshal(json1, &one)
json.Unmarshal(out, &two)
if !reflect.DeepEqual(one, two) {
t.Error("Decode fails, did you change the encoding format ?")
}
} | explode_data.jsonl/80299 | {
"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,
32564,
1155,
353,
8840,
836,
8,
341,
2405,
825,
11,
1378,
2415,
14032,
31344,
31483,
43343,
66,
1669,
1532,
36913,
741,
43343,
66,
35976,
1694,
8561,
23,
3715,
340,
13967,
1669,
34647,
56372,
67922,
50217,
9304,
16,
4390,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNoMoreOptions(t *testing.T) {
var args struct {
Foo string
Bar []string `arg:"positional"`
}
err := parse("abc -- --foo xyz", &args)
require.NoError(t, err)
assert.Equal(t, "", args.Foo)
assert.Equal(t, []string{"abc", "--foo", "xyz"}, args.Bar)
} | explode_data.jsonl/13023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
2753,
7661,
3798,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
12727,
2624,
914,
198,
197,
197,
3428,
3056,
917,
1565,
858,
2974,
966,
3005,
8805,
197,
532,
9859,
1669,
4715,
445,
13683,
1177,
1177,
7975,
4051... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateRotationRequest_Validate(t *testing.T) {
createRequest := &CreateRotationRequest{}
err := createRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Schedule identifier cannot be empty.").Error())
rotation := &og.Rotation{}
createRequest.Rotation = rotation
createRequest.ScheduleIdentifierType = Name
createRequest.ScheduleIdentifierValue = "test"
err = createRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Rotation type cannot be empty.").Error())
rotation.Type = og.Hourly
err = createRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Rotation start date cannot be empty.").Error())
startDate := time.Now()
rotation.StartDate = &startDate
rotation.EndDate = &startDate
err = createRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Rotation end time should be later than start time.").Error())
rotation.EndDate = nil
participants := make([]og.Participant, 1)
participant1 := &og.Participant{}
participants[0] = *participant1
rotation.Participants = participants
err = createRequest.Validate()
assert.Equal(t, err.Error(), errors.New("Participant type cannot be empty.").Error())
participant1 = &og.Participant{
Type: og.Team,
Name: "team1",
}
participants[0] = *participant1
rotation.Participants = participants
err = createRequest.Validate()
assert.Equal(t, err, nil)
} | explode_data.jsonl/64419 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 448
} | [
2830,
3393,
4021,
18440,
1900,
62,
17926,
1155,
353,
8840,
836,
8,
341,
39263,
1900,
1669,
609,
4021,
18440,
1900,
16094,
9859,
1669,
1855,
1900,
47667,
741,
6948,
12808,
1155,
11,
1848,
6141,
1507,
5975,
7121,
445,
32210,
12816,
4157,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadConfiguration(t *testing.T) {
t.Parallel()
v := viper.New()
log := tools.DiscardLogger()
v.SetConfigType("yaml")
tc, err := FixtureWithSection("various.txt", "LoadConfiguration")
if err != nil {
t.Fatalf("error getting fixture: %v", err)
}
v.ReadConfig(tc.Body)
readers := map[string]string{"reader_1": "not_exists"}
recorders := map[string]string{"recorder_1": "elasticsearch"}
routeMap := map[string]route{"routes": {
readers: []string{"reader_1"},
recorders: []string{"recorder_1"},
}}
_, err = loadConfiguration(v, log, routeMap, readers, recorders)
if _, ok := errors.Cause(err).(NotSupportedError); !ok {
t.Errorf("err.(NotSupportedError) = (%T); want NotSupportedError", err)
}
readers = map[string]string{"reader_1": "expvar"}
recorders = map[string]string{"recorder_1": "not_exists"}
_, err = loadConfiguration(v, log, routeMap, readers, recorders)
if _, ok := errors.Cause(err).(NotSupportedError); !ok {
t.Errorf("err.(NotSupportedError) = (%T); want (NotSupportedError)", err)
}
readers = map[string]string{"reader_1": "expvar", "reader_2": "self"}
recorders = map[string]string{"recorder_2": "elasticsearch"}
_, err = loadConfiguration(v, log, routeMap, readers, recorders)
if err == nil {
t.Error("err = (nil);want (error)")
}
readers = map[string]string{"reader_1": "expvar", "reader_2": "self"}
recorders = map[string]string{"recorder_1": "elasticsearch"}
_, err = loadConfiguration(v, log, routeMap, readers, recorders)
if err != nil {
t.Errorf("err = (%v); want (nil)", err)
}
} | explode_data.jsonl/33306 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 576
} | [
2830,
3393,
5879,
7688,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
5195,
1669,
95132,
7121,
741,
6725,
1669,
7375,
909,
47560,
7395,
741,
5195,
4202,
2648,
929,
445,
41466,
5130,
78255,
11,
1848,
1669,
73252,
2354,
9620,
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... | 6 |
func TestProgressShouldWait(t *testing.T) {
tests := []struct {
m uint64
wait int
w bool
}{
// match != 0 is always not wait
{1, 0, false},
{1, 1, false},
{0, 1, true},
{0, 0, false},
}
for i, tt := range tests {
p := &Progress{
Match: tt.m,
Wait: tt.wait,
}
if g := p.shouldWait(); g != tt.w {
t.Errorf("#%d: shouldwait = %t, want %t", i, g, tt.w)
}
}
} | explode_data.jsonl/67330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
9496,
14996,
14190,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
2109,
262,
2622,
21,
19,
198,
197,
48750,
526,
271,
197,
6692,
1807,
198,
197,
59403,
197,
197,
322,
2432,
961,
220,
15,
374,
2677,
537... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilesetStructuralValidatorValid(t *testing.T) {
object := testObjectResource([]string{})
fileset := testFilesetResource("object1")
validator := NewFilesetStructuralValidator(newMockRepository(object))
err := validator.ValidateResource(fileset)
assert.Nil(t, err)
} | explode_data.jsonl/16715 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
1703,
746,
9422,
4176,
14256,
4088,
1155,
353,
8840,
836,
8,
341,
35798,
1669,
1273,
1190,
4783,
10556,
917,
37790,
17661,
746,
1669,
1273,
1703,
746,
4783,
445,
1700,
16,
1138,
197,
16112,
1669,
1532,
1703,
746,
9422,
4176,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetKeyVersion(t *testing.T) {
store := NewRedisStateStore(logger.NewLogger("test"))
t.Run("With all required fields", func(t *testing.T) {
key, ver, err := store.getKeyVersion([]interface{}{"data", "TEST_KEY", "version", "TEST_VER"})
assert.Equal(t, nil, err, "failed to read all fields")
assert.Equal(t, "TEST_KEY", key, "failed to read key")
assert.Equal(t, ptr.String("TEST_VER"), ver, "failed to read version")
})
t.Run("With missing data", func(t *testing.T) {
_, _, err := store.getKeyVersion([]interface{}{"version", "TEST_VER"})
assert.NotNil(t, err, "failed to respond to missing data field")
})
t.Run("With missing version", func(t *testing.T) {
_, _, err := store.getKeyVersion([]interface{}{"data", "TEST_KEY"})
assert.NotNil(t, err, "failed to respond to missing version field")
})
t.Run("With all required fields - out of order", func(t *testing.T) {
key, ver, err := store.getKeyVersion([]interface{}{"version", "TEST_VER", "dragon", "TEST_DRAGON", "data", "TEST_KEY"})
assert.Equal(t, nil, err, "failed to read all fields")
assert.Equal(t, "TEST_KEY", key, "failed to read key")
assert.Equal(t, ptr.String("TEST_VER"), ver, "failed to read version")
})
t.Run("With no fields", func(t *testing.T) {
_, _, err := store.getKeyVersion([]interface{}{})
assert.NotNil(t, err, "failed to respond to missing fields")
})
t.Run("With wrong fields", func(t *testing.T) {
_, _, err := store.getKeyVersion([]interface{}{"dragon", "TEST_DRAGON"})
assert.NotNil(t, err, "failed to respond to missing fields")
})
} | explode_data.jsonl/78637 | {
"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,
1949,
1592,
5637,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
1532,
48137,
1397,
6093,
37833,
7121,
7395,
445,
1944,
5455,
3244,
16708,
445,
2354,
678,
2567,
5043,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
23634,
11,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInboundValidity(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
buildMsg := func(class stun.MessageClass, username, key string) *stun.Message {
msg, err := stun.Build(stun.NewType(stun.MethodBinding, class), stun.TransactionID,
stun.NewUsername(username),
stun.NewShortTermIntegrity(key),
stun.Fingerprint,
)
if err != nil {
t.Fatal(err)
}
return msg
}
remote := &net.UDPAddr{IP: net.ParseIP("172.17.0.3"), Port: 999}
hostConfig := CandidateHostConfig{
Network: "udp",
Address: "192.168.0.2",
Port: 777,
Component: 1,
}
local, err := NewCandidateHost(&hostConfig)
local.conn = &mockPacketConn{}
if err != nil {
t.Fatalf("failed to create a new candidate: %v", err)
}
t.Run("Invalid Binding requests should be discarded", func(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
a.handleInbound(buildMsg(stun.ClassRequest, "invalid", a.localPwd), local, remote)
if len(a.remoteCandidates) == 1 {
t.Fatal("Binding with invalid Username was able to create prflx candidate")
}
a.handleInbound(buildMsg(stun.ClassRequest, a.localUfrag+":"+a.remoteUfrag, "Invalid"), local, remote)
if len(a.remoteCandidates) == 1 {
t.Fatal("Binding with invalid MessageIntegrity was able to create prflx candidate")
}
assert.NoError(t, a.Close())
})
t.Run("Invalid Binding success responses should be discarded", func(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
a.handleInbound(buildMsg(stun.ClassSuccessResponse, a.localUfrag+":"+a.remoteUfrag, "Invalid"), local, remote)
if len(a.remoteCandidates) == 1 {
t.Fatal("Binding with invalid MessageIntegrity was able to create prflx candidate")
}
assert.NoError(t, a.Close())
})
t.Run("Discard non-binding messages", func(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
a.handleInbound(buildMsg(stun.ClassErrorResponse, a.localUfrag+":"+a.remoteUfrag, "Invalid"), local, remote)
if len(a.remoteCandidates) == 1 {
t.Fatal("non-binding message was able to create prflxRemote")
}
assert.NoError(t, a.Close())
})
t.Run("Valid bind request", func(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
err = a.run(func(a *Agent) {
a.selector = &controllingSelector{agent: a, log: a.log}
a.connectivityTicker = time.NewTicker(a.taskLoopInterval)
a.handleInbound(buildMsg(stun.ClassRequest, a.localUfrag+":"+a.remoteUfrag, a.localPwd), local, remote)
if len(a.remoteCandidates) != 1 {
t.Fatal("Binding with valid values was unable to create prflx candidate")
}
})
assert.NoError(t, err)
assert.NoError(t, a.Close())
})
t.Run("Valid bind without fingerprint", func(t *testing.T) {
var config AgentConfig
runAgentTest(t, &config, func(a *Agent) {
a.selector = &controllingSelector{agent: a, log: a.log}
a.connectivityTicker = time.NewTicker(a.taskLoopInterval)
msg, err := stun.Build(stun.BindingRequest, stun.TransactionID,
stun.NewUsername(a.localUfrag+":"+a.remoteUfrag),
stun.NewShortTermIntegrity(a.localPwd),
)
if err != nil {
t.Fatal(err)
}
a.handleInbound(msg, local, remote)
if len(a.remoteCandidates) != 1 {
t.Fatal("Binding with valid values (but no fingerprint) was unable to create prflx candidate")
}
})
})
t.Run("Success with invalid TransactionID", func(t *testing.T) {
a, err := NewAgent(&AgentConfig{})
if err != nil {
t.Fatalf("Error constructing ice.Agent")
}
hostConfig := CandidateHostConfig{
Network: "udp",
Address: "192.168.0.2",
Port: 777,
Component: 1,
}
local, err := NewCandidateHost(&hostConfig)
local.conn = &mockPacketConn{}
if err != nil {
t.Fatalf("failed to create a new candidate: %v", err)
}
remote := &net.UDPAddr{IP: net.ParseIP("172.17.0.3"), Port: 999}
tID := [stun.TransactionIDSize]byte{}
copy(tID[:], []byte("ABC"))
msg, err := stun.Build(stun.BindingSuccess, stun.NewTransactionIDSetter(tID),
stun.NewShortTermIntegrity(a.remotePwd),
stun.Fingerprint,
)
assert.NoError(t, err)
a.handleInbound(msg, local, remote)
if len(a.remoteCandidates) != 0 {
t.Fatal("unknown remote was able to create a candidate")
}
assert.NoError(t, a.Close())
})
} | explode_data.jsonl/50566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1798
} | [
2830,
3393,
641,
10891,
69538,
1155,
353,
8840,
836,
8,
341,
69931,
1669,
1273,
10600,
49,
28628,
1155,
340,
16867,
1895,
2822,
69371,
6611,
1669,
2915,
21956,
65428,
8472,
1957,
11,
5934,
11,
1376,
914,
8,
353,
267,
359,
8472,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDeleteHost(t *testing.T) {
cli := client.NewClientSet(tests.ServiceEndpoint)
result, err := cli.V1().Hosts().Delete(context.TODO(), "host-192.168.21.31")
if err != nil {
t.Error(err)
return
}
t.Logf("%+v", result)
} | explode_data.jsonl/45742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
6435,
9296,
1155,
353,
8840,
836,
8,
341,
86448,
1669,
2943,
7121,
2959,
1649,
8623,
82,
13860,
27380,
340,
9559,
11,
1848,
1669,
21348,
5058,
16,
1005,
9296,
82,
1005,
6435,
5378,
90988,
1507,
330,
3790,
12,
16,
24,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPart2(t *testing.T) {
input := readInputs("input.txt")
foodSlice := parseInputs(input)
want := "bjpkhx,nsnqf,snhph,zmfqpn,qrbnjtj,dbhfd,thn,sthnsg"
allergens := getAllergens(foodSlice)
assignments := assignAllergens(allergens)
got := summarise(assignments)
if got != want {
t.Errorf("got %s; want %s", got, want)
}
} | explode_data.jsonl/26578 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
5800,
17,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
1349,
31946,
445,
1355,
3909,
1138,
197,
13915,
33236,
1669,
4715,
31946,
5384,
692,
50780,
1669,
330,
35751,
20819,
58424,
11,
4412,
77,
80,
69,
11,
9613,
71,
759,
2266... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetArgWithBadType(t *testing.T) {
rep, ctrl := createFixtures(t)
defer ctrl.Finish()
s := new(Subject)
// This should catch a type error:
rep.assertFatal(func() {
ctrl.RecordCall(s, "FooMethod", "1").SetArg(0, "blah")
})
ctrl.Call(s, "FooMethod", "1")
} | explode_data.jsonl/17293 | {
"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,
1649,
2735,
2354,
17082,
929,
1155,
353,
8840,
836,
8,
341,
73731,
11,
23743,
1669,
1855,
25958,
18513,
1155,
340,
16867,
23743,
991,
18176,
2822,
1903,
1669,
501,
7,
13019,
340,
197,
322,
1096,
1265,
2287,
264,
943,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteTimer(t *testing.T) {
testActorsRuntime := newTestActorsRuntime()
actorType, actorID := getTestActorTypeAndID()
actorKey := testActorsRuntime.constructCompositeKey(actorType, actorID)
fakeCallAndActivateActor(testActorsRuntime, actorKey)
timer := createTimer(actorID, actorType, "timer1", "100ms", "100ms", "callback", "")
err := testActorsRuntime.CreateTimer(&timer)
assert.Nil(t, err)
timerKey := testActorsRuntime.constructCompositeKey(actorKey, timer.Name)
_, ok := testActorsRuntime.activeTimers.Load(timerKey)
assert.True(t, ok)
err = testActorsRuntime.DeleteTimer(&DeleteTimerRequest{
Name: timer.Name,
ActorID: actorID,
ActorType: actorType,
})
assert.Nil(t, err)
_, ok = testActorsRuntime.activeTimers.Load(timerKey)
assert.False(t, ok)
} | explode_data.jsonl/12881 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 283
} | [
2830,
3393,
6435,
10105,
1155,
353,
8840,
836,
8,
341,
18185,
2414,
1087,
15123,
1669,
501,
2271,
2414,
1087,
15123,
741,
93410,
929,
11,
12089,
915,
1669,
633,
2271,
18870,
929,
3036,
915,
741,
93410,
1592,
1669,
1273,
2414,
1087,
1512... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTopoAnnotationUpdateHelm(t *testing.T) {
g := gomega.NewGomegaWithT(t)
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0"})
g.Expect(err).NotTo(gomega.HaveOccurred())
c = mgr.GetClient()
ctx, cancel := context.WithCancel(context.Background())
mgrStopped := StartTestManager(ctx, mgr, g)
defer func() {
cancel()
mgrStopped.Wait()
}()
g.Expect(mgr.GetCache().WaitForCacheSync(ctx)).Should(gomega.BeTrue())
rec := newReconciler(mgr).(*ReconcileSubscription)
chn := chHelm.DeepCopy()
g.Expect(c.Create(context.TODO(), chn)).NotTo(gomega.HaveOccurred())
defer func() {
g.Expect(c.Delete(context.TODO(), chn)).Should(gomega.Succeed())
}()
subIns := subscription.DeepCopy()
subIns.SetName("helm-sub")
subIns.Spec.Package = "nginx-ingress"
subIns.Spec.Channel = helmKey.String()
subIns.Spec.PackageFilter = &subv1.PackageFilter{Version: "1.26.0"}
g.Expect(c.Create(context.TODO(), subIns)).NotTo(gomega.HaveOccurred())
defer func() {
g.Expect(c.Delete(context.TODO(), subIns)).Should(gomega.Succeed())
}()
g.Expect(rec.doMCMHubReconcile(subIns)).NotTo(gomega.HaveOccurred())
subAnno := subIns.GetAnnotations()
g.Expect(subAnno).ShouldNot(gomega.HaveLen(0))
g.Expect(subAnno[subv1.AnnotationTopo]).ShouldNot(gomega.HaveLen(0))
fmt.Println(subAnno[subv1.AnnotationTopo])
} | explode_data.jsonl/51107 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 560
} | [
2830,
3393,
5366,
78,
19711,
4289,
39,
23162,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
2109,
901,
11,
1848,
1669,
6645,
7121,
28272,
11,
6645,
22179,
90,
27328,
9950,
4286,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGCHelmSortVersionMissing(t *testing.T) {
test_versions := []string{"aptly-broken3", "aptly-broken2", "aptly-broken1"}
sort.Sort(ByVersion(test_versions))
assert.Equal(t, "aptly-broken3", test_versions[0])
assert.Equal(t, "aptly-broken2", test_versions[1])
assert.Equal(t, "aptly-broken1", test_versions[2])
} | explode_data.jsonl/57815 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
38,
2149,
23162,
10231,
5637,
25080,
1155,
353,
8840,
836,
8,
341,
18185,
65148,
1669,
3056,
917,
4913,
2689,
398,
1455,
81709,
18,
497,
330,
2689,
398,
1455,
81709,
17,
497,
330,
2689,
398,
1455,
81709,
16,
16707,
39487,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSearchResultNames(t *testing.T) {
assert := assert.New(t)
var sr []*Searchresult
sr = append(sr, newSearchresult(SampleSearchResults[0]))
sr = append(sr, newSearchresult(SampleSearchResults[1]))
names := SearchresultNames(sr)
assert.Equal(len(names), 2)
assert.Equal(names[0], "GoBook.pdf")
assert.Equal(names[1], "Dive_into_Python3.pdf")
} | explode_data.jsonl/33980 | {
"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,
5890,
2077,
7980,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
2405,
18962,
29838,
5890,
1382,
198,
1903,
81,
284,
8737,
67650,
11,
501,
5890,
1382,
3759,
1516,
5890,
9801,
58,
15,
10907,
1903,
81,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIncident_GetAlert(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/incidents/1/alerts/1", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
_, _ = w.Write([]byte(`{"alert": {"id": "1"}}`))
})
client := defaultTestClient(server.URL, "foo")
incidentID := "1"
alertID := "1"
res, _, err := client.GetIncidentAlert(incidentID, alertID)
want := &IncidentAlertResponse{
IncidentAlert: &IncidentAlert{
APIObject: APIObject{
ID: "1",
},
},
}
if err != nil {
t.Fatal(err)
}
testEqual(t, want, res)
} | explode_data.jsonl/76403 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
39245,
1713,
13614,
9676,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
2840,
6880,
14,
16,
79688,
82,
14,
16,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
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 TestResolveConstIntWithIdentWithInvalidObjKind(t *testing.T) {
for kind := ast.Bad; kind <= ast.Lbl; kind++ {
// ast.Con is the only valid kind, so don't test it here
if kind == ast.Con {
continue
}
obj := ast.Object{Kind: kind}
expr := ast.Ident{Obj: &obj}
_, err := resolveConstInt(&expr)
if err == nil {
t.Error("should have received error because expr.Obj.Kind is invalid")
}
}
} | explode_data.jsonl/33717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
56808,
19167,
1072,
2354,
28301,
2354,
7928,
5261,
10629,
1155,
353,
8840,
836,
8,
341,
2023,
3093,
1669,
11763,
45946,
26,
3093,
2651,
11763,
1214,
2024,
26,
3093,
1027,
341,
197,
197,
322,
11763,
4801,
374,
279,
1172,
2697... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormCodecMarshal(t *testing.T) {
req := &LoginRequest{
Username: "kratos",
Password: "kratos_pwd",
}
content, err := encoding.GetCodec(contentType).Marshal(req)
require.NoError(t, err)
require.Equal(t, []byte("password=kratos_pwd&username=kratos"), content)
req = &LoginRequest{
Username: "kratos",
Password: "",
}
content, err = encoding.GetCodec(contentType).Marshal(req)
require.NoError(t, err)
require.Equal(t, []byte("username=kratos"), content)
} | explode_data.jsonl/11923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 192
} | [
2830,
3393,
1838,
36913,
55438,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
609,
6231,
1900,
515,
197,
197,
11115,
25,
330,
9855,
14030,
756,
197,
197,
4876,
25,
330,
9855,
14030,
50957,
756,
197,
532,
27751,
11,
1848,
1669,
11170,
223... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInstancers(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
testInstancers(t, Instancers{})
testInstancers(t, Instancers{}.Copy())
})
t.Run("Nil", func(t *testing.T) {
testInstancers(t, nil)
testInstancers(t, Instancers(nil).Copy())
})
} | explode_data.jsonl/69503 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
8724,
31742,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
3522,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
18185,
8724,
31742,
1155,
11,
5984,
31742,
37790,
197,
18185,
8724,
31742,
1155,
11,
5984,
31742,
46391,
12106,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAuthentication(t *testing.T) {
user, pass := "username", "password"
srv := serve(func(conn conn) {
req, err := conn.ReadRequest()
require.NoError(t, err)
rsp := gremlin.Response{RequestID: req.RequestID}
rsp.Status.Code = gremlin.StatusAuthenticate
err = conn.WriteResponse(&rsp)
require.NoError(t, err)
areq, err := conn.ReadRequest()
require.NoError(t, err)
var acreds gremlin.Credentials
err = acreds.UnmarshalText([]byte(areq.Arguments["sasl"].(string)))
assert.NoError(t, err)
areq.Arguments["sasl"] = acreds
assert.Equal(t, gremlin.NewAuthRequest(req.RequestID, user, pass), areq)
rsp = gremlin.Response{RequestID: req.RequestID}
rsp.Status.Code = gremlin.StatusNoContent
err = conn.WriteResponse(&rsp)
require.NoError(t, err)
})
defer srv.Close()
dialer := *DefaultDialer
dialer.user = user
dialer.pass = pass
client, err := dialer.Dial("ws://" + srv.Listener.Addr().String())
require.NoError(t, err)
defer client.Close()
_, err = client.Execute(context.Background(), gremlin.NewEvalRequest("g.E().drop()"))
assert.NoError(t, err)
} | explode_data.jsonl/9360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 433
} | [
2830,
3393,
19297,
1155,
353,
8840,
836,
8,
341,
19060,
11,
1494,
1669,
330,
5113,
497,
330,
3833,
698,
1903,
10553,
1669,
8683,
18552,
20571,
4534,
8,
341,
197,
24395,
11,
1848,
1669,
4534,
6503,
1900,
741,
197,
17957,
35699,
1155,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue2379(t *testing.T) {
// 1) no aliasing
q := NewRat(3, 2)
x := new(Rat)
x.SetFrac(NewInt(3), NewInt(2))
if x.Cmp(q) != 0 {
t.Errorf("1) got %s want %s", x, q)
}
// 2) aliasing of numerator
x = NewRat(2, 3)
x.SetFrac(NewInt(3), x.Num())
if x.Cmp(q) != 0 {
t.Errorf("2) got %s want %s", x, q)
}
// 3) aliasing of denominator
x = NewRat(2, 3)
x.SetFrac(x.Denom(), NewInt(2))
if x.Cmp(q) != 0 {
t.Errorf("3) got %s want %s", x, q)
}
// 4) aliasing of numerator and denominator
x = NewRat(2, 3)
x.SetFrac(x.Denom(), x.Num())
if x.Cmp(q) != 0 {
t.Errorf("4) got %s want %s", x, q)
}
// 5) numerator and denominator are the same
q = NewRat(1, 1)
x = new(Rat)
n := NewInt(7)
x.SetFrac(n, n)
if x.Cmp(q) != 0 {
t.Errorf("5) got %s want %s", x, q)
}
} | explode_data.jsonl/35079 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 416
} | [
2830,
3393,
42006,
17,
18,
22,
24,
1155,
353,
8840,
836,
8,
341,
197,
322,
220,
16,
8,
902,
15534,
287,
198,
18534,
1669,
1532,
49,
266,
7,
18,
11,
220,
17,
340,
10225,
1669,
501,
2785,
266,
340,
10225,
4202,
37,
19959,
35063,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRewards(t *testing.T) {
tests := []struct {
duration time.Duration
stakeAmount uint64
existingAmount uint64
expectedReward uint64
}{
// Max duration:
{ // (720M - 360M) * (1M / 360M) * 12%
duration: defaultMaxStakingDuration,
stakeAmount: units.MegaDjtx,
existingAmount: 360 * units.MegaDjtx,
expectedReward: 120 * units.KiloDjtx,
},
{ // (720M - 400M) * (1M / 400M) * 12%
duration: defaultMaxStakingDuration,
stakeAmount: units.MegaDjtx,
existingAmount: 400 * units.MegaDjtx,
expectedReward: 96 * units.KiloDjtx,
},
{ // (720M - 400M) * (2M / 400M) * 12%
duration: defaultMaxStakingDuration,
stakeAmount: 2 * units.MegaDjtx,
existingAmount: 400 * units.MegaDjtx,
expectedReward: 192 * units.KiloDjtx,
},
{ // (720M - 720M) * (1M / 720M) * 12%
duration: defaultMaxStakingDuration,
stakeAmount: units.MegaDjtx,
existingAmount: SupplyCap,
expectedReward: 0,
},
// Min duration:
// (720M - 360M) * (1M / 360M) * (10% + 2% * MinimumStakingDuration / MaximumStakingDuration) * MinimumStakingDuration / MaximumStakingDuration
{
duration: defaultMinStakingDuration,
stakeAmount: units.MegaDjtx,
existingAmount: 360 * units.MegaDjtx,
expectedReward: 274122724713,
},
// (720M - 360M) * (.005 / 360M) * (10% + 2% * MinimumStakingDuration / MaximumStakingDuration) * MinimumStakingDuration / MaximumStakingDuration
{
duration: defaultMinStakingDuration,
stakeAmount: defaultMinValidatorStake,
existingAmount: 360 * units.MegaDjtx,
expectedReward: 1370,
},
// (720M - 400M) * (1M / 400M) * (10% + 2% * MinimumStakingDuration / MaximumStakingDuration) * MinimumStakingDuration / MaximumStakingDuration
{
duration: defaultMinStakingDuration,
stakeAmount: units.MegaDjtx,
existingAmount: 400 * units.MegaDjtx,
expectedReward: 219298179771,
},
// (720M - 400M) * (2M / 400M) * (10% + 2% * MinimumStakingDuration / MaximumStakingDuration) * MinimumStakingDuration / MaximumStakingDuration
{
duration: defaultMinStakingDuration,
stakeAmount: 2 * units.MegaDjtx,
existingAmount: 400 * units.MegaDjtx,
expectedReward: 438596359542,
},
// (720M - 720M) * (1M / 720M) * (10% + 2% * MinimumStakingDuration / MaximumStakingDuration) * MinimumStakingDuration / MaximumStakingDuration
{
duration: defaultMinStakingDuration,
stakeAmount: units.MegaDjtx,
existingAmount: SupplyCap,
expectedReward: 0,
},
}
for _, test := range tests {
name := fmt.Sprintf("reward(%s,%d,%d)==%d",
test.duration,
test.stakeAmount,
test.existingAmount,
test.expectedReward,
)
t.Run(name, func(t *testing.T) {
r := reward(
test.duration,
test.stakeAmount,
test.existingAmount,
defaultMaxStakingDuration,
)
if r != test.expectedReward {
t.Fatalf("expected %d; got %d", test.expectedReward, r)
}
})
}
} | explode_data.jsonl/16537 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1236
} | [
2830,
3393,
58465,
2347,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
89300,
981,
882,
33795,
198,
197,
18388,
726,
10093,
262,
2622,
21,
19,
198,
197,
8122,
11083,
10093,
2622,
21,
19,
198,
197,
42400,
59622,
2622... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCanCreateTwoBoxesFromSimpleBoxes(t *testing.T) {
assert := assert.New(t)
bh := BoxHandler{}
boxes := []SimpleBox{SimpleBox{Boxname: "dev", Username: "benphegan", Provider: "virtualbox", Version: "1.0"},
SimpleBox{Boxname: "uat", Username: "benphegan", Provider: "virtualbox", Version: "1.0"}}
host := "localhost"
bh.createBoxes(boxes, 80, &host)
assert.Equal(2, len(bh.Boxes["benphegan"]))
} | explode_data.jsonl/51583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
6713,
4021,
11613,
93665,
3830,
16374,
93665,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
2233,
71,
1669,
8261,
3050,
16094,
197,
22204,
1669,
3056,
16374,
1611,
90,
16374,
1611,
90,
1611,
606,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOAuthStore(t *testing.T) {
ctx := test.Context()
WithDB(t, func(t *testing.T, db *gorm.DB) {
prepareTest(db,
&ClientAuthorization{},
&AuthorizationCode{},
&AccessToken{},
&User{},
&Client{},
&Account{},
)
s := newStore(db)
store := GetOAuthStore(db)
s.createEntity(ctx, &User{Account: Account{UID: "test-user"}})
userIDs := &ttnpb.UserIdentifiers{UserID: "test-user"}
s.createEntity(ctx, &Client{ClientID: "test-client"})
clientIDs := &ttnpb.ClientIdentifiers{ClientID: "test-client"}
rights := []ttnpb.Right{ttnpb.RIGHT_ALL}
t.Run("Authorize", func(t *testing.T) {
a := assertions.New(t)
empty, err := store.GetAuthorization(ctx, userIDs, clientIDs)
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(empty, should.BeNil)
start := cleanTime(time.Now())
created, err := store.Authorize(ctx, &ttnpb.OAuthClientAuthorization{
ClientIDs: *clientIDs,
UserIDs: *userIDs,
Rights: rights,
})
a.So(err, should.BeNil)
a.So(created, should.NotBeNil)
if a.So(created, should.NotBeNil) {
a.So(created.UserIDs.UserID, should.Equal, "test-user")
a.So(created.ClientIDs.ClientID, should.Equal, "test-client")
a.So(created.CreatedAt, should.HappenOnOrAfter, start)
a.So(created.UpdatedAt, should.HappenOnOrAfter, start)
}
got, err := store.GetAuthorization(ctx, userIDs, clientIDs)
a.So(err, should.BeNil)
a.So(got, should.NotBeNil)
if a.So(got, should.NotBeNil) {
a.So(created.UserIDs.UserID, should.Equal, "test-user")
a.So(created.ClientIDs.ClientID, should.Equal, "test-client")
a.So(got.CreatedAt, should.HappenOnOrAfter, start)
a.So(got.UpdatedAt, should.HappenOnOrAfter, start)
}
list, err := store.ListAuthorizations(ctx, userIDs)
a.So(err, should.BeNil)
if a.So(list, should.NotBeNil) && a.So(list, should.HaveLength, 1) {
a.So(list[0], should.Resemble, got)
}
err = store.DeleteAuthorization(ctx, userIDs, clientIDs)
a.So(err, should.BeNil)
deleted, err := store.GetAuthorization(ctx, userIDs, clientIDs)
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(deleted, should.BeNil)
})
t.Run("Authorization Code", func(t *testing.T) {
a := assertions.New(t)
code := "test-authorization-code"
redirectURI := "http://test-redirect-url:8080/callback"
state := "test-state"
authCode, err := store.GetAuthorizationCode(ctx, "")
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(authCode, should.BeNil)
empty, err := store.GetAuthorizationCode(ctx, code)
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(empty, should.BeNil)
err = store.DeleteAuthorizationCode(ctx, "")
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
start := cleanTime(time.Now())
err = store.CreateAuthorizationCode(ctx, &ttnpb.OAuthAuthorizationCode{
ClientIDs: *clientIDs,
UserIDs: *userIDs,
Rights: rights,
Code: code,
RedirectURI: redirectURI,
State: state,
})
a.So(err, should.BeNil)
got, err := store.GetAuthorizationCode(ctx, code)
a.So(err, should.BeNil)
if a.So(got, should.NotBeNil) {
a.So(got.UserIDs.UserID, should.Equal, userIDs.UserID)
a.So(got.ClientIDs.ClientID, should.Equal, clientIDs.ClientID)
a.So(got.Code, should.Equal, code)
a.So(got.RedirectURI, should.Equal, redirectURI)
a.So(got.State, should.Equal, state)
a.So(got.CreatedAt, should.HappenOnOrAfter, start)
if a.So(got.Rights, should.HaveLength, len(rights)) {
for _, right := range rights {
a.So(got.Rights, should.Contain, right)
}
}
}
err = store.DeleteAuthorizationCode(ctx, code)
a.So(err, should.BeNil)
deleted, err := store.GetAuthorizationCode(ctx, code)
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(deleted, should.BeNil)
})
t.Run("Access Token", func(t *testing.T) {
a := assertions.New(t)
tokenID := "test-token-id"
access := "test-access-token"
refresh := "test-refresh-token"
prevID := ""
accessToken, err := store.GetAccessToken(ctx, "")
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(accessToken, should.BeNil)
err = store.DeleteAccessToken(ctx, "")
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
empty, err := store.GetAccessToken(ctx, tokenID)
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(empty, should.BeNil)
start := cleanTime(time.Now())
err = store.CreateAccessToken(ctx, &ttnpb.OAuthAccessToken{
UserIDs: *userIDs,
ClientIDs: *clientIDs,
ID: tokenID,
AccessToken: access,
RefreshToken: refresh,
Rights: rights,
}, prevID)
a.So(err, should.BeNil)
got, err := store.GetAccessToken(ctx, tokenID)
a.So(err, should.BeNil)
if a.So(got, should.NotBeNil) {
a.So(got.UserIDs.UserID, should.Equal, userIDs.UserID)
a.So(got.ClientIDs.ClientID, should.Equal, clientIDs.ClientID)
a.So(got.ID, should.Equal, tokenID)
a.So(got.AccessToken, should.Equal, access)
a.So(got.RefreshToken, should.Equal, refresh)
a.So(got.CreatedAt, should.HappenOnOrAfter, start)
if a.So(got.Rights, should.HaveLength, len(rights)) {
for _, right := range rights {
a.So(got.Rights, should.Contain, right)
}
}
}
list, err := store.ListAccessTokens(ctx, userIDs, clientIDs)
a.So(err, should.BeNil)
if a.So(list, should.NotBeNil) && a.So(list, should.HaveLength, 1) {
a.So(list[0], should.Resemble, got)
}
err = store.DeleteAccessToken(ctx, tokenID)
a.So(err, should.BeNil)
deleted, err := store.GetAccessToken(ctx, tokenID)
if a.So(err, should.NotBeNil) {
a.So(errors.IsNotFound(err), should.BeTrue)
}
a.So(deleted, should.BeNil)
})
})
} | explode_data.jsonl/39117 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2820
} | [
2830,
3393,
57850,
6093,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1273,
9328,
2822,
197,
2354,
3506,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
2927,
353,
73281,
22537,
8,
341,
197,
197,
13609,
2271,
9791,
345,
298,
197,
5,
2959,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppendBool(t *testing.T) {
testList := []string{"foo"}
key := Bar
value := false
compareList := []string{"foo", "bar = false"}
newList := appendBool(testList, key, &value)
require.NotEqual(t, len(newList), 0)
require.ElementsMatch(t, newList, compareList)
} | explode_data.jsonl/24527 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
23877,
11233,
1155,
353,
8840,
836,
8,
341,
18185,
852,
1669,
3056,
917,
4913,
7975,
16707,
23634,
1669,
4716,
198,
16309,
1669,
895,
198,
197,
18948,
852,
1669,
3056,
917,
4913,
7975,
497,
330,
2257,
284,
895,
16707,
8638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListCommandRunEClosureWithYAMLOutput(t *testing.T) {
assert := assert.New(t)
cli := test.NewCLI()
testUsers := []corev2.User{
*corev2.FixtureUser("user1"),
*corev2.FixtureUser("user2"),
}
client := cli.Client.(*client.MockClient)
resources := []corev2.User{}
client.On("List", mock.Anything, &resources, mock.Anything, mock.Anything).Return(nil).Run(
func(args mock.Arguments) {
resources := args[1].(*[]corev2.User)
*resources = testUsers
},
)
cmd := ListCommand(cli)
require.NoError(t, cmd.Flags().Set("format", "yaml"))
out, err := test.RunCmd(cmd, []string{})
assert.NoError(err)
assert.NotEmpty(out)
assert.Contains(out, "username")
assert.Contains(out, "groups")
assert.Contains(out, "disabled")
assert.Contains(out, "user1")
assert.Contains(out, "user2")
assert.Contains(out, "false")
} | explode_data.jsonl/11558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
852,
4062,
6727,
7498,
11653,
2354,
56,
1402,
1593,
332,
628,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
86448,
1669,
1273,
7121,
63959,
2822,
18185,
7137,
1669,
3056,
98645,
17,
7344,
515,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAtoi(t *testing.T) {
switch intSize {
case 32:
for i := range atoi32tests {
test := &atoi32tests[i]
out, ok := runtime.Atoi(test.in)
if test.out != int32(out) || test.ok != ok {
t.Errorf("atoi(%q) = (%v, %v) want (%v, %v)",
test.in, out, ok, test.out, test.ok)
}
}
case 64:
for i := range atoi64tests {
test := &atoi64tests[i]
out, ok := runtime.Atoi(test.in)
if test.out != int64(out) || test.ok != ok {
t.Errorf("atoi(%q) = (%v, %v) want (%v, %v)",
test.in, out, ok, test.out, test.ok)
}
}
}
} | explode_data.jsonl/79325 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
32,
52609,
1155,
353,
8840,
836,
8,
341,
8961,
526,
1695,
341,
2722,
220,
18,
17,
510,
197,
2023,
600,
1669,
2088,
25227,
18,
17,
23841,
341,
298,
18185,
1669,
609,
51071,
18,
17,
23841,
989,
921,
298,
13967,
11,
5394,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInheritsInValid(t *testing.T) {
in1 := "http://www.test.com/doc.json"
in2 := "#/a/b"
r1, _ := New(in1)
r2 := Ref{}
result, err := r1.Inherits(r2)
assert.Error(t, err)
assert.Nil(t, result)
r1 = Ref{}
r2, _ = New(in2)
result, err = r1.Inherits(r2)
assert.NoError(t, err)
assert.Equal(t, r2, *result)
} | explode_data.jsonl/13768 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
641,
38693,
641,
4088,
1155,
353,
8840,
836,
8,
341,
17430,
16,
1669,
330,
1254,
1110,
2136,
5958,
905,
39510,
4323,
698,
17430,
17,
1669,
5869,
14,
64,
3470,
1837,
7000,
16,
11,
716,
1669,
1532,
5900,
16,
340,
7000,
17,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetFileContentTypeODT(t *testing.T) {
file := `../testdata/files/test3.odt`
fileType, err := GetFileContentType(file)
if err != nil {
t.Log("Error -> ", err)
t.Fail()
}
if fileType != "application/odt" {
t.Log(fileType)
t.Fail()
}
} | explode_data.jsonl/24008 | {
"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,
1949,
1703,
29504,
2069,
51,
1155,
353,
8840,
836,
8,
341,
17661,
1669,
1565,
1244,
92425,
33220,
12697,
18,
71599,
83,
3989,
17661,
929,
11,
1848,
1669,
2126,
1703,
29504,
4866,
692,
743,
1848,
961,
2092,
341,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGenerateFromUTF16(t *testing.T) {
q := apiclient.ManifestRequest{
Repo: &argoappv1.Repository{},
ApplicationSource: &argoappv1.ApplicationSource{},
}
res1, err := GenerateManifests(context.Background(), "./testdata/utf-16", "/", "", &q, false, &git.NoopCredsStore{})
assert.Nil(t, err)
assert.Equal(t, 2, len(res1.Manifests))
} | explode_data.jsonl/5687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
31115,
3830,
8561,
16,
21,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1443,
292,
1451,
72272,
1900,
515,
197,
197,
25243,
25,
1060,
609,
12088,
676,
85,
16,
25170,
38837,
197,
78329,
3608,
25,
609,
12088,
676,
85,
16,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSSLClientCertificatesMissingFiles(t *testing.T) {
maybeSkipSSLTests(t)
// Environment sanity check: should fail without SSL
checkSSLSetup(t, "sslmode=disable user=pqgossltest")
// Key missing, should fail
_, err := openSSLConn(t, getCertConninfo(t, "missingkey"))
if err == nil {
t.Fatal("expected error")
}
// should be a PathError
_, ok := err.(*os.PathError)
if !ok {
t.Fatalf("expected PathError, got %#+v", err)
}
// Cert missing, should fail
_, err = openSSLConn(t, getCertConninfo(t, "missingcert"))
if err == nil {
t.Fatal("expected error")
}
// should be a PathError
_, ok = err.(*os.PathError)
if !ok {
t.Fatalf("expected PathError, got %#+v", err)
}
// Key has wrong permissions, should fail
_, err = openSSLConn(t, getCertConninfo(t, "certtwice"))
if err == nil {
t.Fatal("expected error")
}
if err != ErrSSLKeyHasWorldPermissions {
t.Fatalf("expected ErrSSLKeyHasWorldPermissions, got %#+v", err)
}
} | explode_data.jsonl/1387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
22594,
2959,
97140,
25080,
10809,
1155,
353,
8840,
836,
8,
341,
2109,
49791,
35134,
22594,
18200,
1155,
340,
197,
322,
11586,
46842,
1779,
25,
1265,
3690,
2041,
25316,
198,
25157,
22594,
21821,
1155,
11,
330,
24635,
8516,
28,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestWarnOnUnknownConfig(t *testing.T) {
testFileDir := "../../../../test/fixture/config"
type logEntry struct {
section string
keys string
}
cases := []struct {
msg string
confFile string
expectedLogEntries []logEntry
}{
{
msg: "in root block",
confFile: "server_and_agent_bad_root_block.conf",
expectedLogEntries: []logEntry{
{
section: "top-level",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in server block",
confFile: "server_bad_server_block.conf",
expectedLogEntries: []logEntry{
{
section: "server",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in nested ca_subject block",
confFile: "server_bad_nested_ca_subject_block.conf",
expectedLogEntries: []logEntry{
{
section: "ca_subject",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in ratelimit block",
confFile: "server_bad_ratelimit_block.conf",
expectedLogEntries: []logEntry{
{
section: "ratelimit",
keys: "unknown_option1,unknown_option2",
},
},
},
// TODO: Re-enable unused key detection for experimental config. See
// https://github.com/spiffe/spire/issues/1101 for more information
//
//{
// msg: "in nested experimental block",
// confFile: "/server_bad_nested_experimental_block.conf",
// expectedLogEntries: []logEntry{
// {
// section: "experimental",
// keys: "unknown_option1,unknown_option2",
// },
// },
//},
//{
// msg: "in nested federation block",
// confFile: "/server_bad_nested_federation_block.conf",
// expectedLogEntries: []logEntry{
// {
// section: "federation",
// keys: "unknown_option1,unknown_option2",
// },
// },
//},
{
msg: "in nested federation.bundle_endpoint block",
confFile: "server_bad_nested_bundle_endpoint_block.conf",
expectedLogEntries: []logEntry{
{
section: "bundle endpoint",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in nested bundle_endpoint.acme block",
confFile: "server_bad_nested_bundle_endpoint_acme_block.conf",
expectedLogEntries: []logEntry{
{
section: "bundle endpoint ACME",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in nested federates_with block",
confFile: "server_bad_nested_federates_with_block.conf",
expectedLogEntries: []logEntry{
{
section: `federates_with "test1"`,
keys: "unknown_option1,unknown_option2",
},
{
section: `federates_with "test2"`,
keys: "unknown_option1,unknown_option2",
},
},
},
// TODO: Re-enable unused key detection for telemetry. See
// https://github.com/spiffe/spire/issues/1101 for more information
//
//{
// msg: "in telemetry block",
// confFile: "/server_and_agent_bad_telemetry_block.conf",
// expectedLogEntries: []logEntry{
// {
// section: "telemetry",
// keys: "unknown_option1,unknown_option2",
// },
// },
//},
{
msg: "in nested Prometheus block",
confFile: "server_and_agent_bad_nested_Prometheus_block.conf",
expectedLogEntries: []logEntry{
{
section: "Prometheus",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in nested DogStatsd block",
confFile: "server_and_agent_bad_nested_DogStatsd_block.conf",
expectedLogEntries: []logEntry{
{
section: "DogStatsd",
keys: "unknown_option1,unknown_option2",
},
{
section: "DogStatsd",
keys: "unknown_option3,unknown_option4",
},
},
},
{
msg: "in nested Statsd block",
confFile: "server_and_agent_bad_nested_Statsd_block.conf",
expectedLogEntries: []logEntry{
{
section: "Statsd",
keys: "unknown_option1,unknown_option2",
},
{
section: "Statsd",
keys: "unknown_option3,unknown_option4",
},
},
},
{
msg: "in nested M3 block",
confFile: "server_and_agent_bad_nested_M3_block.conf",
expectedLogEntries: []logEntry{
{
section: "M3",
keys: "unknown_option1,unknown_option2",
},
{
section: "M3",
keys: "unknown_option3,unknown_option4",
},
},
},
{
msg: "in nested InMem block",
confFile: "server_and_agent_bad_nested_InMem_block.conf",
expectedLogEntries: []logEntry{
{
section: "InMem",
keys: "unknown_option1,unknown_option2",
},
},
},
{
msg: "in nested health_checks block",
confFile: "server_and_agent_bad_nested_health_checks_block.conf",
expectedLogEntries: []logEntry{
{
section: "health check",
keys: "unknown_option1,unknown_option2",
},
},
},
}
for _, testCase := range cases {
testCase := testCase
c, err := ParseFile(filepath.Join(testFileDir, testCase.confFile), false)
require.NoError(t, err)
t.Run(testCase.msg, func(t *testing.T) {
log, hook := test.NewNullLogger()
err := checkForUnknownConfig(c, log)
assert.EqualError(t, err, "unknown configuration detected")
var logEntries []spiretest.LogEntry
for _, expectedLogEntry := range testCase.expectedLogEntries {
logEntries = append(logEntries, spiretest.LogEntry{
Level: logrus.ErrorLevel,
Message: "Unknown configuration detected",
Data: logrus.Fields{
"section": expectedLogEntry.section,
"keys": expectedLogEntry.keys,
},
})
}
spiretest.AssertLogsAnyOrder(t, hook.AllEntries(), logEntries)
})
}
} | explode_data.jsonl/51905 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2601
} | [
2830,
3393,
38244,
1925,
13790,
2648,
1155,
353,
8840,
836,
8,
341,
18185,
1703,
6184,
1669,
63392,
1944,
14,
59612,
14730,
1837,
13158,
1487,
5874,
2036,
341,
197,
197,
2809,
914,
198,
197,
80112,
262,
914,
198,
197,
630,
1444,
2264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTranslateAPI(t *testing.T) {
Convey("#GetLangs", t, func() {
tr := New(apiKey)
Convey("On success it returns available codes and languages", func() {
response, err := tr.GetLangs("en")
So(err, ShouldBeNil)
So(response.Dirs, ShouldNotBeEmpty)
pairs := []string{"ru-en", "ru-de", "ru-it", "ru-fr", "en-de", "en-it", "en-ru"}
for _, pair := range pairs {
So(response.Dirs, ShouldContain, pair)
}
So(response.Langs, ShouldNotBeNil)
So(response.Langs["en"], ShouldEqual, "English")
So(response.Langs["ru"], ShouldEqual, "Russian")
So(response.Langs["mumbayumba"], ShouldBeBlank)
})
Convey("On failure it returns error code and message", func() {
tr := New(apiKey + "a")
response, err := tr.GetLangs("en")
So(response, ShouldBeNil)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldEqual, "(401) API key is invalid")
})
})
Convey("#Translate", t, func() {
tr := New(apiKey)
Convey("On success it returns translation of the word", func() {
response, err := tr.Translate("ru", "dog")
So(err, ShouldBeNil)
So(response, ShouldNotBeNil)
So(response.Code, ShouldEqual, 200)
So(response.Message, ShouldBeBlank)
So(response.Lang, ShouldEqual, "en-ru")
So(response.Detected["lang"], ShouldEqual, "en")
So(response.Text, ShouldContain, "ΡΠΎΠ±Π°ΠΊΠ°")
})
Convey("On fail it returns an error with error code and message", func() {
response, err := tr.Translate("mumba-yumba", "dog")
So(err, ShouldNotBeNil)
So(response, ShouldBeNil)
So(err.Error(), ShouldEqual, "can't get translation for dog: 502, Invalid parameter: lang")
})
})
Convey("#Result", t, func() {
tr := New(apiKey)
response, _ := tr.Translate("ru", "dog")
So(response.Result(), ShouldEqual, "ΡΠΎΠ±Π°ΠΊΠ°")
})
} | explode_data.jsonl/38223 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 726
} | [
2830,
3393,
27473,
7082,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
3584,
1949,
26223,
82,
497,
259,
11,
2915,
368,
341,
197,
25583,
1669,
1532,
24827,
1592,
692,
197,
93070,
5617,
445,
1925,
2393,
432,
4675,
2500,
13912,
323,
15459,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSessionCookieShouldNotAddedIfPresent(t *testing.T) {
// Setup test to get a session cookie
requestCookieValue := "test123"
w, r, next := getDefaultHandlerMocks()
var responseHeader http.Header = make(map[string][]string)
w.mock.On("Header").Return(responseHeader)
handler := server.SessionCookieHandler(next, cookieName, cookieLifeTime)
r.Header.Set("Cookie", cookieName+"="+requestCookieValue)
handler.ServeHTTP(w, r)
//make sure that cookie has not been set in response
_, ok := w.Header()["Set-Cookie"]
assert.False(t, ok)
cookieValue := getCookieFromCtx(t, next.r.Context())
assert.Equal(t, requestCookieValue, cookieValue)
} | explode_data.jsonl/29912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
5283,
20616,
14996,
2623,
19337,
2679,
21195,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
1273,
311,
633,
264,
3797,
12544,
198,
23555,
20616,
1130,
1669,
330,
1944,
16,
17,
18,
698,
6692,
11,
435,
11,
1790,
1669,
69106... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFirst(t *testing.T) {
for i, this := range []struct {
count interface{}
sequence interface{}
expect interface{}
}{
{int(2), []string{"a", "b", "c"}, []string{"a", "b"}},
{int32(3), []string{"a", "b"}, []string{"a", "b"}},
{int64(2), []int{100, 200, 300}, []int{100, 200}},
{100, []int{100, 200}, []int{100, 200}},
{"1", []int{100, 200, 300}, []int{100}},
{int64(-1), []int{100, 200, 300}, false},
{"noint", []int{100, 200, 300}, false},
{1, nil, false},
{nil, []int{100}, false},
{1, t, false},
{1, (*string)(nil), false},
} {
results, err := first(this.count, this.sequence)
if b, ok := this.expect.(bool); ok && !b {
if err == nil {
t.Errorf("[%d] First didn't return an expected error", i)
}
} else {
if err != nil {
t.Errorf("[%d] failed: %s", i, err)
continue
}
if !reflect.DeepEqual(results, this.expect) {
t.Errorf("[%d] First %d items, got %v but expected %v", i, this.count, results, this.expect)
}
}
}
} | explode_data.jsonl/9211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
5338,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
419,
1669,
2088,
3056,
1235,
341,
197,
18032,
262,
3749,
16094,
197,
197,
15512,
3749,
16094,
197,
24952,
256,
3749,
16094,
197,
59403,
197,
197,
90,
396,
7,
17,
701,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSafeRedirectURL(t *testing.T) {
tests := map[string]string{
"": "/",
"/": "/",
"a@b.com:c": "/",
"a@b.com/c": "/",
"//a": "/",
"http://a.com/b": "/b",
"//a.com/b": "/b",
"//a@b.com/c": "/c",
"/a?b": "/a?b",
}
for input, want := range tests {
got := SafeRedirectURL(input)
if got != want {
t.Errorf("%q: got %q, want %q", input, got, want)
}
}
} | explode_data.jsonl/31665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
25663,
17725,
3144,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
30953,
515,
197,
197,
28796,
2290,
3521,
756,
197,
197,
3115,
788,
1060,
3521,
756,
197,
197,
56693,
31,
65,
905,
48031,
788,
414,
3521,
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... | 3 |
func TestCreateNoNameItem(t *testing.T) {
items := []runtime.Object{}
items = append(items, &api.Service{
TypeMeta: api.TypeMeta{APIVersion: "v1beta1", Kind: "Service"},
})
typer, mapper := getTyperAndMapper()
client, s := getFakeClient(t, []string{"/api/v1beta1/services"})
errs := CreateObjects(typer, mapper, client, items)
s.Close()
if len(errs) == 0 {
t.Errorf("Expected required value error for missing name")
}
errStr := errs[0].Error()
if !strings.Contains(errStr, "Config.item[0]: name") {
t.Errorf("Expected 'Config.item[0]: name' in error string, got '%s'", errStr)
}
} | explode_data.jsonl/58837 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
4021,
2753,
675,
1234,
1155,
353,
8840,
836,
8,
341,
46413,
1669,
3056,
22255,
8348,
31483,
46413,
284,
8737,
24337,
11,
609,
2068,
13860,
515,
197,
27725,
12175,
25,
6330,
10184,
12175,
90,
7082,
5637,
25,
330,
85,
16,
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... | 3 |
func TestPreAuthTransaction(t *testing.T) {
// Address: GDK3YEHGI3ORGVO7ZEV2XF4SV5JU3BOKHMHPP4QFJ74ZRIIRROZ7ITOJ
kp0 := newKeypair("SDY4PF6F6OWWERZT6OL2LVNREHUGHKALUI5W4U2JK4GAKPAC2RM43OAU")
sourceAccount := NewSimpleAccount(kp0.Address(), int64(4353383146192898)) // sequence number is in the future
createAccount := CreateAccount{
Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z",
Amount: "10",
}
// build transaction to be submitted in the future.
txFuture, err := NewTransaction(
TransactionParams{
SourceAccount: &sourceAccount,
IncrementSequenceNum: true,
Operations: []Operation{&createAccount},
BaseFee: MinBaseFee,
Timebounds: NewInfiniteTimeout(),
},
)
assert.NoError(t, err)
// save the hash of the future transaction.
txFutureHash, err := txFuture.Hash(network.TestNetworkPassphrase)
assert.NoError(t, err)
// sign transaction without keypairs, the hash of the future transaction on the account
// will be used for authorisation.
txFuture, err = txFuture.Sign(network.TestNetworkPassphrase)
assert.NoError(t, err)
txeFutureB64, err := txFuture.Base64()
assert.NoError(t, err)
expected := "AAAAAgAAAADVvBDmRt0TVd/JK6uXkq9TTYXKOw738gVP+ZihEYuz9AAAAGQAD3dhAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAAF9eEAAAAAAAAAAAA="
assert.Equal(t, expected, txeFutureB64, "Base 64 XDR should match")
//encode the txFutureHash as a stellar HashTx signer key.
preAuth, err := strkey.Encode(strkey.VersionByteHashTx, txFutureHash[:])
assert.NoError(t, err)
// set sequence number to the current number.
sourceAccount.Sequence = int64(4353383146192897)
// add hash of future transaction as signer to account
setOptions := SetOptions{
Signer: &Signer{Address: preAuth, Weight: Threshold(2)},
}
// build a transaction to add the hash of the future transaction as a signer on the account.
txNow, err := NewTransaction(
TransactionParams{
SourceAccount: &sourceAccount,
IncrementSequenceNum: true,
Operations: []Operation{&setOptions},
BaseFee: 500,
Timebounds: NewInfiniteTimeout(),
},
)
assert.NoError(t, err)
assert.Equal(t, int64(500), txNow.MaxFee(), "Transaction fee should match")
txNow, err = txNow.Sign(network.TestNetworkPassphrase, kp0)
assert.NoError(t, err)
txeNowB64, err := txNow.Base64()
assert.NoError(t, err)
expected = "AAAAAgAAAADVvBDmRt0TVd/JK6uXkq9TTYXKOw738gVP+ZihEYuz9AAAAfQAD3dhAAAAAgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAGPXOumKQj5/MjKKSmjQXe4G4g9nK/mkyzmmROMIZnjtQAAAAIAAAAAAAAAARGLs/QAAABAutrV0Cg03KwfFbzkCGiNxAldLsqQZKRjbsqHZyy2Nu4ouEDHQeIOKLWCLymOp21kKmGGqTYekPXVbGHyujh0DA=="
assert.Equal(t, expected, txeNowB64, "Base 64 XDR should match")
// Note: txeFutureB64 can be submitted to the network after txeNowB64 has been applied to the account
} | explode_data.jsonl/20693 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1229
} | [
2830,
3393,
4703,
5087,
8070,
1155,
353,
8840,
836,
8,
341,
197,
322,
9177,
25,
73886,
18,
56,
45589,
28034,
18,
44927,
11169,
22,
57,
46010,
17,
66138,
19,
17803,
20,
41,
52,
18,
33,
3925,
39,
48202,
4406,
19,
48,
37,
41,
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... | 1 |
func TestAccCloudStackNetwork_updateACL(t *testing.T) {
var network cloudstack.Network
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudStackNetworkDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCloudStackNetwork_acl,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackNetworkExists(
"cloudstack_network.foo", &network),
testAccCheckCloudStackNetworkVPCAttributes(&network),
),
},
resource.TestStep{
Config: testAccCloudStackNetwork_updateACL,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackNetworkExists(
"cloudstack_network.foo", &network),
testAccCheckCloudStackNetworkVPCAttributes(&network),
),
},
},
})
} | explode_data.jsonl/79601 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
14603,
16055,
4336,
12320,
8882,
55393,
1155,
353,
8840,
836,
8,
341,
2405,
3922,
9437,
7693,
30149,
271,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,
2915,
368,
314,
1273,
14603,
4703,
3973,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMaxMultiplies(t *testing.T) {
require := require.New(t)
g := NewGuardianEngine(nil, nil)
maxNeighbors := uint32(1 << maxLogNeighbors)
require.Equal(maxNeighbors, g.maxMultiply(1))
require.Equal(maxNeighbors*maxNeighbors, g.maxMultiply(2))
} | explode_data.jsonl/45581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
5974,
20358,
7202,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
340,
3174,
1669,
1532,
20806,
1103,
4571,
27907,
11,
2092,
340,
22543,
58086,
1669,
2622,
18,
17,
7,
16,
1115,
1932,
2201,
58086,
340,
17957,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTopLevelAwaitNoBundleIIFE(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
await foo;
for await (foo of bar) ;
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
OutputFormat: config.FormatIIFE,
Mode: config.ModeConvertFormat,
AbsOutputFile: "/out.js",
},
expectedScanLog: `entry.js: error: Top-level await is currently not supported with the "iife" output format
entry.js: error: Top-level await is currently not supported with the "iife" output format
`,
})
} | explode_data.jsonl/38572 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
5366,
4449,
37352,
2753,
8409,
40,
39677,
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,
34436,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldRaiseWhenNoXForwardedHostHeaderProvidedToDetectTargetURL(t *testing.T) {
mock := mocks.NewMockAutheliaCtx(t)
defer mock.Close()
mock.Ctx.Request.Header.Set("X-Forwarded-Proto", "https")
_, err := mock.Ctx.GetOriginalURL()
assert.Error(t, err)
assert.Equal(t, "Missing header X-Forwarded-Host", err.Error())
} | explode_data.jsonl/20175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
14996,
93101,
4498,
2753,
55,
25925,
291,
9296,
4047,
35819,
291,
1249,
57193,
6397,
3144,
1155,
353,
8840,
836,
8,
341,
77333,
1669,
68909,
7121,
11571,
5087,
35929,
23684,
1155,
340,
16867,
7860,
10421,
2822,
77333,
727,
399... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterByCopyPassesInputThroughUnchanged(t *testing.T) {
t.Parallel()
p := script.Echo("hello").Filter(func(r io.Reader, w io.Writer) error {
_, err := io.Copy(w, r)
return err
})
want := "hello"
got, err := p.String()
if err != nil {
t.Fatal(err)
}
if want != got {
t.Error(cmp.Diff(want, got))
}
} | explode_data.jsonl/51469 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
5632,
1359,
12106,
12187,
288,
2505,
23857,
1806,
17353,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
5316,
5142,
958,
445,
14990,
1827,
5632,
18552,
2601,
6399,
47431,
11,
289,
6399,
47838,
8,
1465,
341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAscendingOrdinal(t *testing.T) {
set := newStatefulSet(10)
pods := make([]*v1.Pod, 10)
perm := rand.Perm(10)
for i, v := range perm {
pods[i] = newStatefulSetPod(set, v)
}
sort.Sort(ascendingOrdinal(pods))
if !sort.IsSorted(ascendingOrdinal(pods)) {
t.Error("ascendingOrdinal fails to sort Pods")
}
} | explode_data.jsonl/68373 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
82952,
34779,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
36848,
1262,
1649,
7,
16,
15,
340,
3223,
29697,
1669,
1281,
85288,
85,
16,
88823,
11,
220,
16,
15,
340,
197,
19913,
1669,
10382,
1069,
4195,
7,
16,
15,
340,
2023,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMatcherMatches(t *testing.T) {
tests := []struct {
name string
cfg *MatchProperties
metric pdata.Metric
shouldMatch bool
}{
{
name: "regexpNameMatch",
cfg: createConfig(regexpFilters, filterset.Regexp),
metric: createMetric("test/match/suffix"),
shouldMatch: true,
}, {
name: "regexpNameMisatch",
cfg: createConfig(regexpFilters, filterset.Regexp),
metric: createMetric("test/match/wrongsuffix"),
shouldMatch: false,
}, {
name: "strictNameMatch",
cfg: createConfig(strictFilters, filterset.Strict),
metric: createMetric("exact_string_match"),
shouldMatch: true,
}, {
name: "strictNameMismatch",
cfg: createConfig(regexpFilters, filterset.Regexp),
metric: createMetric("wrong_string_match"),
shouldMatch: false,
}, {
name: "matcherWithNoPropertyFilters",
cfg: createConfig([]string{}, filterset.Strict),
metric: createMetric("metric"),
shouldMatch: false,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
matcher, err := NewMatcher(test.cfg)
assert.NotNil(t, matcher)
assert.NoError(t, err)
matches, err := matcher.MatchMetric(test.metric)
assert.NoError(t, err)
assert.Equal(t, test.shouldMatch, matches)
})
}
} | explode_data.jsonl/33913 | {
"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,
37554,
42470,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
50286,
260,
353,
8331,
7903,
198,
197,
2109,
16340,
414,
70311,
1321,
16340,
198,
197,
197,
5445,
8331,
1807,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddScaled(t *testing.T) {
t.Parallel()
s := []float64{3, 4, 1, 7, 5}
alpha := 6.0
dst := []float64{1, 2, 3, 4, 5}
ans := []float64{19, 26, 9, 46, 35}
AddScaled(dst, alpha, s)
if !EqualApprox(dst, ans, EqTolerance) {
t.Errorf("Adding scaled did not match")
}
short := []float64{1}
if !Panics(func() { AddScaled(dst, alpha, short) }) {
t.Errorf("Doesn't panic if s is smaller than dst")
}
if !Panics(func() { AddScaled(short, alpha, s) }) {
t.Errorf("Doesn't panic if dst is smaller than s")
}
} | explode_data.jsonl/1209 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
2212,
94201,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
1669,
3056,
3649,
21,
19,
90,
18,
11,
220,
19,
11,
220,
16,
11,
220,
22,
11,
220,
20,
532,
73063,
1669,
220,
21,
13,
15,
198,
52051,
1669,
3056... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBot_DeleteChatStickerSet(t *testing.T) {
type fields struct {
apiClient apiClient
}
tests := []struct {
name string
fields fields
wantResult bool
wantErr bool
}{
{
name: "test1",
fields: fields{
apiClient: &mockAPIClient{
method: "deleteChatStickerSet",
interfaceMethod: func() interface{} {
return true
},
bytesMethod: func() []byte {
return []byte("true")
},
},
},
wantResult: true,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &Bot{
apiClient: tt.fields.apiClient,
}
gotResult, err := b.DeleteChatStickerSet(nil)
if (err != nil) != tt.wantErr {
t.Errorf("Bot.DeleteChatStickerSet() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotResult != tt.wantResult {
t.Errorf("Bot.DeleteChatStickerSet() = %v, want %v", gotResult, tt.wantResult)
}
})
}
} | explode_data.jsonl/46093 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 447
} | [
2830,
3393,
23502,
57418,
15672,
623,
5215,
1649,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
54299,
2959,
6330,
2959,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
55276,
257,
5043,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFqName(t *testing.T) {
obj := &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "tests/v1alpha1",
"kind": "Test",
"metadata": map[string]interface{}{
"name": "myname",
},
},
}
if n := FqName(obj); n != "myname" {
t.Errorf("Got %q for %v", n, obj)
}
obj.SetNamespace("mynamespace")
if n := FqName(obj); n != "mynamespace.myname" {
t.Errorf("Got %q for %v", n, obj)
}
} | explode_data.jsonl/10850 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
37,
80,
675,
1155,
353,
8840,
836,
8,
341,
22671,
1669,
609,
359,
51143,
10616,
51143,
515,
197,
23816,
25,
2415,
14032,
31344,
67066,
298,
197,
1,
2068,
5637,
788,
330,
23841,
5457,
16,
7141,
16,
756,
298,
197,
1,
15314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetIssuerFromUrl(t *testing.T) {
cases := []struct {
Input string
Expected string
}{
{"http://somewebsite.com", url.QueryEscape("somewebsite.com")},
{"https://somewebsite.com", url.QueryEscape("somewebsite.com")},
{"https://some.website.com", url.QueryEscape("some.website.com")},
{" https://www.somewebsite.com", url.QueryEscape("somewebsite.com")},
{"http://somewebsite.com/chat", url.QueryEscape("somewebsite.com/chat")},
{"somewebsite.com ", url.QueryEscape("somewebsite.com")},
{"http://localhost:8065", url.QueryEscape("localhost:8065")},
{"", "Mattermost"},
{" ", "Mattermost"},
}
for _, c := range cases {
assert.Equal(t, c.Expected, getIssuerFromUrl(c.Input))
}
} | explode_data.jsonl/64309 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
1949,
98902,
3830,
2864,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
66588,
262,
914,
198,
197,
197,
18896,
914,
198,
197,
59403,
197,
197,
4913,
1254,
1110,
56739,
87723,
3222,
905,
497,
2515,
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 TestBootstrapNewStore(t *testing.T) {
defer leaktest.AfterTest(t)()
ctx := context.Background()
e := storage.NewDefaultInMem()
if _, err := bootstrapCluster(
ctx, []storage.Engine{e}, clusterversion.TestingClusterVersion, zonepb.DefaultZoneConfigRef(), zonepb.DefaultSystemZoneConfigRef(),
); err != nil {
t.Fatal(err)
}
// Start a new node with two new stores which will require bootstrapping.
engines := Engines([]storage.Engine{
e,
storage.NewDefaultInMem(),
storage.NewDefaultInMem(),
})
defer engines.Close()
_, _, node, stopper := createAndStartTestNode(
ctx,
util.TestAddr,
engines,
util.TestAddr,
roachpb.Locality{},
t,
)
defer stopper.Stop(ctx)
// Non-initialized stores (in this case the new in-memory-based
// store) will be bootstrapped by the node upon start. This happens
// in a goroutine, so we'll have to wait a bit until we can find the
// new node.
testutils.SucceedsSoon(t, func() error {
if n := node.stores.GetStoreCount(); n != 3 {
return errors.Errorf("expected 3 stores but got %d", n)
}
return nil
})
// Check whether all stores are started properly.
if err := node.stores.VisitStores(func(s *kvserver.Store) error {
if !s.IsStarted() {
return errors.Errorf("fail to start store: %s", s)
}
return nil
}); err != nil {
t.Error(err)
}
} | explode_data.jsonl/49427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 485
} | [
2830,
3393,
45511,
3564,
6093,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
20985,
1669,
2266,
19047,
741,
7727,
1669,
5819,
7121,
3675,
641,
18816,
741,
743,
8358,
1848,
1669,
26925,
28678,
1006,
197,
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... | 2 |
func TestICEServerParser(t *testing.T) {
Convey("Test parsing of ICE servers", t, func() {
for _, test := range []struct {
input []string
urls [][]string
length int
}{
{
[]string{"stun:stun.l.google.com:19302"},
[][]string{[]string{"stun:stun.l.google.com:19302"}},
1,
},
{
[]string{"stun:stun.l.google.com:19302", "stun.ekiga.net"},
[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
2,
},
{
[]string{"stun:stun.l.google.com:19302", "stun.ekiga.net"},
[][]string{[]string{"stun:stun.l.google.com:19302"}, []string{"stun.ekiga.net"}},
2,
},
} {
servers := parseIceServers(test.input)
if test.urls == nil {
So(servers, ShouldBeNil)
} else {
So(servers, ShouldNotBeNil)
}
So(len(servers), ShouldEqual, test.length)
for _, server := range servers {
So(test.urls, ShouldContain, server.URLs)
}
}
})
} | explode_data.jsonl/9150 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
15835,
2836,
6570,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2271,
22314,
315,
40563,
16293,
497,
259,
11,
2915,
368,
341,
197,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
298,
22427,
220,
3056,
917,
198,
298,
193... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRepeatedOpenAndClose(t *testing.T) {
obj := New()
err := obj.OpenSvc()
if err != nil {
t.Errorf("OpenSvc() returned unexpected error %v", err)
}
err = obj.OpenSvc()
if err == nil {
t.Error("expected error from OpenSvc() but got nil")
}
err = obj.CloseSvc()
if err != nil {
t.Errorf("CloseSvc() returned unexpected error %v", err)
}
err = obj.CloseSvc()
if err == nil {
t.Error("expected error from CloseSvc() but got nil")
}
} | explode_data.jsonl/71384 | {
"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,
90989,
5002,
3036,
7925,
1155,
353,
8840,
836,
8,
341,
22671,
1669,
1532,
2822,
9859,
1669,
2839,
12953,
92766,
741,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
5002,
92766,
368,
5927,
16500,
1465,
1018,
85,
497,
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... | 5 |
func Test_PostConfig_UpdatesConfig(t *testing.T) {
setup(t)
defer cleanup(t)
userID := makeUserID()
for _, c := range allClients {
view1 := c.post(t, userID, makeConfig())
config2 := makeConfig()
view2 := c.post(t, userID, config2)
assert.True(t, view2.ID > view1.ID, "%v > %v", view2.ID, view1.ID)
assert.Equal(t, config2, view2.Config)
}
} | explode_data.jsonl/37311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
66726,
2648,
62,
37091,
2648,
1155,
353,
8840,
836,
8,
341,
84571,
1155,
340,
16867,
21290,
1155,
692,
19060,
915,
1669,
1281,
36899,
741,
2023,
8358,
272,
1669,
2088,
678,
47174,
341,
197,
36867,
16,
1669,
272,
6542,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMetricsMetadata_RowToMetrics(t *testing.T) {
metricDataType := metricValueDataType{dataType: metricDataType}
timestamp := time.Now().UTC()
labelValueMetadata := StringLabelValueMetadata{
queryLabelValueMetadata: newQueryLabelValueMetadata(labelName, labelColumnName),
}
metricValueMetadata := Int64MetricValueMetadata{
queryMetricValueMetadata: newQueryMetricValueMetadata(metricName, metricColumnName, metricDataType, metricUnit),
}
queryLabelValuesMetadata := []LabelValueMetadata{labelValueMetadata}
queryMetricValuesMetadata := []MetricValueMetadata{metricValueMetadata}
databaseID := databaseID()
metadata := MetricsMetadata{
MetricNamePrefix: metricNamePrefix,
TimestampColumnName: timestampColumnName,
QueryLabelValuesMetadata: queryLabelValuesMetadata,
QueryMetricValuesMetadata: queryMetricValuesMetadata,
}
testCases := map[string]struct {
rowColumnNames []string
rowColumnValues []interface{}
expectError bool
}{
"Happy path": {[]string{labelColumnName, metricColumnName, timestampColumnName}, []interface{}{stringValue, int64Value, timestamp}, false},
"Error on timestamp": {[]string{labelColumnName, metricColumnName}, []interface{}{stringValue, int64Value}, true},
"Error on label value": {[]string{metricColumnName, timestampColumnName}, []interface{}{int64Value, timestamp}, true},
"Error on metric value": {[]string{labelColumnName, timestampColumnName}, []interface{}{stringValue, timestamp}, true},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
row, _ := spanner.NewRow(testCase.rowColumnNames, testCase.rowColumnValues)
metrics, err := metadata.RowToMetrics(databaseID, row)
if testCase.expectError {
require.Error(t, err)
} else {
require.NoError(t, err)
assert.Equal(t, 1, len(metrics))
}
})
}
} | explode_data.jsonl/64257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 634
} | [
2830,
3393,
27328,
14610,
66932,
1249,
27328,
1155,
353,
8840,
836,
8,
341,
2109,
16340,
22653,
1669,
18266,
1130,
22653,
90,
57694,
25,
18266,
22653,
532,
3244,
4702,
1669,
882,
13244,
1005,
21183,
741,
29277,
1130,
14610,
1669,
923,
247... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRetryThrottling(t *testing.T) {
defer enableRetry()()
i := -1
ss := &stubServer{
emptyCall: func(context.Context, *testpb.Empty) (*testpb.Empty, error) {
i++
switch i {
case 0, 3, 6, 10, 11, 12, 13, 14, 16, 18:
return &testpb.Empty{}, nil
}
return nil, status.New(codes.Unavailable, "retryable error").Err()
},
}
if err := ss.Start([]grpc.ServerOption{}); err != nil {
t.Fatalf("Error starting endpoint server: %v", err)
}
defer ss.Stop()
ss.r.NewServiceConfig(`{
"methodConfig": [{
"name": [{"service": "grpc.testing.TestService"}],
"waitForReady": true,
"retryPolicy": {
"MaxAttempts": 4,
"InitialBackoff": ".01s",
"MaxBackoff": ".01s",
"BackoffMultiplier": 1.0,
"RetryableStatusCodes": [ "UNAVAILABLE" ]
}
}],
"retryThrottling": {
"maxTokens": 10,
"tokenRatio": 0.5
}
}`)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
for {
if ctx.Err() != nil {
t.Fatalf("Timed out waiting for service config update")
}
if ss.cc.GetMethodConfig("/grpc.testing.TestService/EmptyCall").WaitForReady != nil {
break
}
time.Sleep(time.Millisecond)
}
cancel()
testCases := []struct {
code codes.Code
count int
}{
{codes.OK, 0}, // tokens = 10
{codes.OK, 3}, // tokens = 8.5 (10 - 2 failures + 0.5 success)
{codes.OK, 6}, // tokens = 6
{codes.Unavailable, 8}, // tokens = 5 -- first attempt is retried; second aborted.
{codes.Unavailable, 9}, // tokens = 4
{codes.OK, 10}, // tokens = 4.5
{codes.OK, 11}, // tokens = 5
{codes.OK, 12}, // tokens = 5.5
{codes.OK, 13}, // tokens = 6
{codes.OK, 14}, // tokens = 6.5
{codes.OK, 16}, // tokens = 5.5
{codes.Unavailable, 17}, // tokens = 4.5
}
for _, tc := range testCases {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
_, err := ss.client.EmptyCall(ctx, &testpb.Empty{})
cancel()
if status.Code(err) != tc.code {
t.Errorf("EmptyCall(_, _) = _, %v; want _, <Code() = %v>", err, tc.code)
}
if i != tc.count {
t.Errorf("i = %v; want %v", i, tc.count)
}
}
} | explode_data.jsonl/64034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1031
} | [
2830,
3393,
51560,
1001,
46689,
2718,
1155,
353,
8840,
836,
8,
341,
16867,
7283,
51560,
368,
741,
8230,
1669,
481,
16,
198,
34472,
1669,
609,
59398,
5475,
515,
197,
197,
3194,
7220,
25,
2915,
5378,
9328,
11,
353,
1944,
16650,
11180,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTermCriteria(t *testing.T) {
tc := NewTermCriteria(Count, 50, 2.0)
if tc.p == nil {
t.Error("TermCriteria has invalid value")
}
} | explode_data.jsonl/81724 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
17249,
12823,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
1532,
17249,
12823,
7,
2507,
11,
220,
20,
15,
11,
220,
17,
13,
15,
340,
743,
17130,
556,
621,
2092,
341,
197,
3244,
6141,
445,
17249,
12823,
702,
8318,
897,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func Test_updateMaxRuntimeDuration(t *testing.T) {
testRE := newQueryRegexp()
testcases := []struct {
value string
usename string
datname string
state string
etype string
query string
want postgresActivityStat
}{
{value: "1", usename: "", datname: "", state: "", etype: "", query: "",
want: newPostgresActivityStat(testRE),
},
{value: "2", usename: "testuser", datname: "testdb", state: "idle", etype: "Client", query: "UPDATE table",
want: newPostgresActivityStat(testRE),
},
{value: "3", usename: "testuser", datname: "testdb", state: "active", etype: "Lock", query: "UPDATE table",
want: newPostgresActivityStat(testRE),
},
{value: "qq", usename: "testuser", datname: "testdb", state: "active", etype: "", query: "UPDATE table",
want: newPostgresActivityStat(testRE),
},
{value: "4", usename: "testuser", datname: "testdb", state: "idle in transaction", etype: "", query: "UPDATE table",
want: newPostgresActivityStat(testRE),
},
{value: "5", usename: "testuser", datname: "testdb", state: "active", query: "UPDATE table",
want: postgresActivityStat{
waitEvents: map[string]float64{},
maxIdleUser: map[string]float64{}, maxIdleMaint: map[string]float64{},
maxActiveUser: map[string]float64{"testuser/testdb": 5}, maxActiveMaint: map[string]float64{},
maxWaitUser: map[string]float64{}, maxWaitMaint: map[string]float64{},
vacuumOps: map[string]float64{"regular": 0, "user": 0, "wraparound": 0},
re: testRE,
},
},
{value: "6", usename: "testuser", datname: "testdb", state: "active", query: "autovacuum: VACUUM table",
want: postgresActivityStat{
waitEvents: map[string]float64{},
maxIdleUser: map[string]float64{}, maxIdleMaint: map[string]float64{},
maxActiveUser: map[string]float64{}, maxActiveMaint: map[string]float64{"testuser/testdb": 6},
maxWaitUser: map[string]float64{}, maxWaitMaint: map[string]float64{},
vacuumOps: map[string]float64{"regular": 0, "user": 0, "wraparound": 0},
re: testRE,
},
},
}
for _, tc := range testcases {
s := newPostgresActivityStat(testRE)
s.updateMaxRuntimeDuration(tc.value, tc.usename, tc.datname, tc.state, tc.etype, tc.query)
assert.Equal(t, tc.want, s)
}
} | explode_data.jsonl/74549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 912
} | [
2830,
3393,
8882,
5974,
15123,
12945,
1155,
353,
8840,
836,
8,
341,
18185,
787,
1669,
501,
2859,
3477,
4580,
2822,
18185,
23910,
1669,
3056,
1235,
341,
197,
16309,
256,
914,
198,
197,
70175,
1840,
914,
198,
197,
2698,
266,
606,
914,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPatMatch(t *testing.T) {
testMatch(t, "DELETE", "/foo/{name}", "/foo/bar", true, map[string]string{":name": "bar"})
testMatch(t, "GET", "/foo/{name}", "/foo/bar/baz", true, map[string]string{":name": "bar"})
testMatch(t, "POST", "/foo/{name}/baz", "/foo/bar/baz", true, map[string]string{":name": "bar"})
testMatch(t, "PUT", "/foo/{name}/baz", "/foo/bar/baz/ding", true, map[string]string{":name": "bar"})
testMatch(t, "GET", "/foo/x{name}", "/foo/xbar", true, map[string]string{":name": "bar"})
testMatch(t, "GET", "/foo/x{name}", "/foo/xbar/baz", true, map[string]string{":name": "bar"})
} | explode_data.jsonl/50505 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 262
} | [
2830,
3393,
27106,
8331,
1155,
353,
8840,
836,
8,
341,
18185,
8331,
1155,
11,
330,
14424,
497,
3521,
7975,
9388,
606,
9545,
3521,
7975,
49513,
497,
830,
11,
2415,
14032,
30953,
90,
788,
606,
788,
330,
2257,
23625,
18185,
8331,
1155,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCheckpointSortByFailoverLog(t *testing.T) {
assert := assert.New(t)
fmt.Println("============== Test case start: TestCheckpointSortByFailoverLog =================")
defer fmt.Println("============== Test case end: TestCheckpointSortByFailoverLog =================")
var unsortedList CheckpointRecordsList
validFailoverLog := uint64(1234)
validFailoverLog2 := uint64(12345)
failoverLog := &mcc.FailoverLog{[2]uint64{validFailoverLog, 0}, [2]uint64{validFailoverLog2, 0}}
recordA := &CheckpointRecord{Failover_uuid: validFailoverLog2}
recordB := &CheckpointRecord{Failover_uuid: validFailoverLog}
unsortedList = append(unsortedList, recordA)
unsortedList = append(unsortedList, recordB)
toSortList := unsortedList.PrepareSortStructure(failoverLog, nil)
sort.Sort(toSortList)
outputList := toSortList.ToRegularList()
// Failover log that shows up first is higher priority
assert.Equal(validFailoverLog, outputList[0].Failover_uuid)
assert.Equal(validFailoverLog2, outputList[1].Failover_uuid)
} | explode_data.jsonl/25102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 335
} | [
2830,
3393,
92688,
10231,
1359,
19524,
1975,
2201,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
11009,
12419,
445,
38603,
3393,
1142,
1191,
25,
3393,
92688,
10231,
1359,
19524,
1975,
2201,
24818,
1138,
16867,
8879,
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... | 1 |
func TestApplicationContext_BeanCache(t *testing.T) {
t.Run("not implement interface", func(t *testing.T) {
c := gs.New()
c.Object(new(int)).Export((*filter)(nil))
err := c.Refresh()
assert.Error(t, err, "doesn't implement interface gs_test.filter")
})
t.Run("implement interface", func(t *testing.T) {
var server struct {
F1 filter `autowire:"f1"`
F2 filter `autowire:"f2"`
}
c := gs.New()
c.Provide(func() filter { return new(filterImpl) }).Name("f1")
c.Object(new(filterImpl)).Export((*filter)(nil)).Name("f2")
c.Object(&server)
err := c.Refresh()
assert.Nil(t, err)
})
} | explode_data.jsonl/17425 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 256
} | [
2830,
3393,
19736,
1668,
5307,
8233,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
1921,
4211,
3749,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1444,
1669,
28081,
7121,
741,
197,
1444,
8348,
1755,
1548,
4579,
16894,
26609,
5315,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNextNumberPowerOf2(t *testing.T) {
assert.Equal(t, uint64(16), NextNumberPowerOf2(10))
assert.Equal(t, uint64(32), NextNumberPowerOf2(20))
assert.Equal(t, uint64(32), NextNumberPowerOf2(30))
assert.Equal(t, uint64(64), NextNumberPowerOf2(40))
assert.Equal(t, uint64(128), NextNumberPowerOf2(100))
assert.Equal(t, uint64(256), NextNumberPowerOf2(200))
assert.Equal(t, uint64(512), NextNumberPowerOf2(500))
assert.Equal(t, uint64(1024), NextNumberPowerOf2(1000))
} | explode_data.jsonl/41775 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
5847,
2833,
14986,
2124,
17,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
2622,
21,
19,
7,
16,
21,
701,
9295,
2833,
14986,
2124,
17,
7,
16,
15,
1171,
6948,
12808,
1155,
11,
2622,
21,
19,
7,
18,
17,
701,
9295,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergeFieldErrors(t *testing.T) {
tests := []struct {
name string
err *FieldError
also []FieldError
prefixes [][]string
want string
}{{
name: "simple",
err: &FieldError{
Message: "A simple error message",
Paths: []string{"bar"},
},
also: []FieldError{{
Message: "A simple error message",
Paths: []string{"foo"},
}},
want: `A simple error message: bar, foo`,
}, {
name: "conflict",
err: &FieldError{
Message: "A simple error message",
Paths: []string{"bar", "foo"},
},
also: []FieldError{{
Message: "A simple error message",
Paths: []string{"foo"},
}},
want: `A simple error message: bar, foo`,
}, {
name: "lots of also",
err: (&FieldError{
Message: "this error",
Paths: []string{"bar", "foo"},
}).Also(&FieldError{
Message: "another",
Paths: []string{"right", "left"},
}).ViaField("head"),
also: []FieldError{{
Message: "An alpha error message",
Paths: []string{"A"},
}, {
Message: "An alpha error message",
Paths: []string{"B"},
}, {
Message: "An alpha error message",
Paths: []string{"B"},
}, {
Message: "An alpha error message",
Paths: []string{"B"},
}, {
Message: "An alpha error message",
Paths: []string{"B"},
}, {
Message: "An alpha error message",
Paths: []string{"B"},
}, {
Message: "An alpha error message",
Paths: []string{"B"},
}, {
Message: "An alpha error message",
Paths: []string{"C"},
}, {
Message: "An alpha error message",
Paths: []string{"D"},
}, {
Message: "this error",
Paths: []string{"foo"},
Details: "devil is in the details",
}, {
Message: "this error",
Paths: []string{"foo"},
Details: "more details",
}},
prefixes: [][]string{{"this"}},
want: `An alpha error message: this.A, this.B, this.C, this.D
another: this.head.left, this.head.right
this error: this.head.bar, this.head.foo
this error: this.foo
devil is in the details
this error: this.foo
more details`,
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
fe := test.err
for _, err := range test.also {
fe = fe.Also(&err)
}
// Simulate propagation up a call stack.
for _, prefix := range test.prefixes {
fe = fe.ViaField(prefix...)
}
if test.want != "" {
got := fe.Error()
if got != test.want {
t.Errorf("%s: Error() = %v, wanted %v", test.name, got, test.want)
}
} else if fe != nil {
t.Errorf("%s: ViaField() = %v, wanted nil", test.name, fe)
}
})
}
} | explode_data.jsonl/68804 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1099
} | [
2830,
3393,
52096,
1877,
13877,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
9859,
414,
353,
1877,
1454,
198,
197,
197,
18654,
257,
3056,
1877,
1454,
198,
197,
3223,
5060,
288,
52931,
917... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestServiceRemoveEmitter(t *testing.T) {
if dipper.Logger == nil {
f, _ := os.OpenFile(os.DevNull, os.O_APPEND, 0o777)
defer f.Close()
dipper.GetLogger("test service", "DEBUG", f, f)
}
svc := &Service{
name: "testsvc",
driverRuntimes: map[string]*driver.Runtime{
"driver:d1": {
State: driver.DriverAlive,
Handler: driver.NewDriver(map[string]interface{}{
"name": "d1",
"type": "builtin",
"handlerData": map[string]interface{}{
"shortName": "testdriver1",
},
}),
},
"emitter": {
State: driver.DriverAlive,
Handler: driver.NewDriver(map[string]interface{}{
"name": "test-emitter",
"type": "builtin",
"handlerData": map[string]interface{}{
"shortName": "testdriver1",
},
}),
Feature: "emitter",
},
},
Route: func(m *dipper.Message) []RoutedMessage {
return nil
},
}
daemon.Emitters["testsvc"] = svc
daemon.ShuttingDown = false
svc.driverRuntimes["driver:d1"].Stream = make(chan dipper.Message, 1)
svc.driverRuntimes["driver:d1"].Output, _ = os.OpenFile(os.DevNull, os.O_APPEND, 0o777)
svc.driverRuntimes["emitter"].Stream = make(chan dipper.Message, 1)
svc.driverRuntimes["emitter"].Output, _ = os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, 0o777)
go func() {
assert.NotPanics(t, svc.serviceLoop, "service loop should recover panic if emitter is removed")
}()
go func() {
daemon.Children.Add(1)
defer daemon.Children.Done()
assert.NotPanics(t, func() {
for i := 0; i < 50; i++ {
select {
case svc.driverRuntimes["driver:d1"].Stream <- dipper.Message{
Channel: "test",
Subject: "noerror",
}:
dipper.Logger.Infof("written msg no. %+v", i)
time.Sleep(10 * time.Millisecond)
default:
dipper.Logger.Infof("unable to write, server shutdown")
}
}
}, "sending message to service should not panic when emitter is removed")
}()
newCfg := &config.Config{
Services: []string{"testsvc"},
Staged: &config.DataSet{
Drivers: map[string]interface{}{
"daemon": map[string]interface{}{
"features": map[string]interface{}{
"global": []interface{}{
map[string]interface{}{
"name": "driver:d1",
},
},
},
"drivers": map[string]interface{}{
"d1": map[string]interface{}{
"name": "d1",
"type": "builtin",
},
},
},
},
},
}
svc.config = newCfg
svc.config.ResetStage()
time.Sleep(100 * time.Millisecond)
assert.NotPanics(t, svc.Reload, "service reload should not panic when emitter is removed")
time.Sleep(100 * time.Millisecond)
daemon.ShutDown()
} | explode_data.jsonl/12389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1178
} | [
2830,
3393,
1860,
13021,
21971,
1155,
353,
8840,
836,
8,
341,
743,
23604,
712,
12750,
621,
2092,
341,
197,
1166,
11,
716,
1669,
2643,
12953,
1703,
9638,
77611,
3280,
11,
2643,
8382,
65851,
11,
220,
15,
78,
22,
22,
22,
340,
197,
1686... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDatabase_Client_GetStepStatusCount(t *testing.T) {
// setup types
b := testBuild()
b.SetID(2)
b.SetRepoID(1)
b.SetNumber(1)
sOne := testStep()
sOne.SetID(1)
sOne.SetRepoID(1)
sOne.SetBuildID(1)
sOne.SetNumber(1)
sOne.SetName("foo")
sOne.SetImage("baz")
sOne.SetStatus("success")
sTwo := testStep()
sTwo.SetID(2)
sTwo.SetRepoID(2)
sTwo.SetBuildID(2)
sTwo.SetNumber(1)
sTwo.SetName("foo")
sTwo.SetImage("baz")
sTwo.SetStatus("success")
sThree := testStep()
sThree.SetID(3)
sThree.SetRepoID(2)
sThree.SetBuildID(2)
sThree.SetNumber(2)
sThree.SetName("bar")
sThree.SetImage("bazian:latest")
sThree.SetStatus("failure")
want := make(map[string]float64)
want["success"] = 2
want["failure"] = 1
// setup database
db, _ := NewTest()
defer func() {
db.Database.Exec("delete from steps;")
db.Database.Close()
}()
_ = db.CreateStep(sOne)
_ = db.CreateStep(sTwo)
_ = db.CreateStep(sThree)
// run test
got, err := db.GetStepStatusCount()
if err != nil {
t.Errorf("GetStepStatusCount returned err: %v", err)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("GetStepStatusCount is %v, want %v", got, want)
}
} | explode_data.jsonl/69137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 515
} | [
2830,
3393,
5988,
46102,
13614,
8304,
2522,
2507,
1155,
353,
8840,
836,
8,
341,
197,
322,
6505,
4494,
198,
2233,
1669,
1273,
11066,
741,
2233,
4202,
915,
7,
17,
340,
2233,
4202,
25243,
915,
7,
16,
340,
2233,
4202,
2833,
7,
16,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPromQLQueryEndpoint(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
testCases := []testCase{
{
name: "basic query",
query: "metric_1",
},
{
name: "basic query, capital metric name",
query: "METRIC_4",
},
{
name: "basic query, not regex match metric name",
query: `{__name__!~".*_1", instance="1"}`,
},
{
name: "basic query, regex match metric name",
query: `{__name__=~"metric_.*"}`,
},
{
name: "basic query, regex no wildcards",
query: `{__name__=~"metric_1"}`,
},
{
name: "basic query, no metric name matchers",
query: `{instance="1", foo=""}`,
},
{
name: "basic query, multiple matchers",
query: `{__name__!="metric_1", instance="1"}`,
},
{
name: "basic query, non-existant metric",
query: `nonexistant_metric_name`,
},
{
name: "basic query, with offset",
query: `metric_3 offset 5m`,
},
{
name: "basic aggregator",
query: `sum (metric_3)`,
},
{
name: "aggregator by empty",
query: `avg by() (metric_2)`,
},
{
name: "aggregator by instance",
query: `max by(instance) (metric_1)`,
},
{
name: "aggregator by instance and foo",
query: `min by(instance, foo) (metric_3)`,
},
{
name: "aggregator by non-existant",
query: `count by(nonexistant) (metric_2)`,
},
{
name: "aggregator without empty",
query: `avg without() (metric_2)`,
},
{
name: "aggregator without instance",
query: `max without(instance) (metric_1)`,
},
{
name: "aggregator without instance and foo",
query: `min without(instance, foo) (metric_3)`,
},
{
name: "aggregator without non-existant",
query: `count without(nonexistant) (metric_2)`,
},
{
name: "topk",
query: `topk (3, metric_2)`,
},
{
name: "bottomk",
query: `bottomk (3, metric_1)`,
},
{
name: "topk by instance",
query: `topk by(instance) (2, metric_3)`,
},
{
name: "quantile 0.5",
query: `quantile(0.5, metric_1)`,
},
{
name: "quantile 0.1",
query: `quantile(0.1, metric_2)`,
},
{
name: "quantile 0.95",
query: `quantile(0.95, metric_3)`,
},
{
name: "sum_over_time",
query: `sum_over_time(metric_1[5m])`,
},
{
name: "count_over_time",
query: `count_over_time(metric_2[5m])`,
},
{
name: "avg_over_time",
query: `avg_over_time(metric_3[5m])`,
},
{
name: "min_over_time",
query: `min_over_time(metric_1[5m])`,
},
{
name: "max_over_time",
query: `max_over_time(metric_2[5m])`,
},
{
name: "stddev_over_time",
query: `stddev_over_time(metric_2[5m])`,
},
{
name: "delta",
query: `delta(metric_3[5m])`,
},
{
name: "delta 1m",
query: `delta(metric_3[1m])`,
},
{
name: "increase",
query: `increase(metric_1[5m])`,
},
{
name: "rate",
query: `rate(metric_2[5m])`,
},
{
name: "resets",
query: `resets(metric_3[5m])`,
},
{
name: "changes",
query: `changes(metric_1[5m])`,
},
{
name: "idelta",
query: `idelta(metric_2[5m])`,
},
{
name: "predict_linear",
query: `predict_linear(metric_3[5m], 100)`,
},
{
name: "deriv",
query: `deriv(metric_1[5m])`,
},
{
name: "timestamp",
query: `timestamp(metric_2)`,
},
{
name: "timestamp timestamp",
query: `timestamp(timestamp(metric_2))`,
},
{
name: "vector",
query: `vector(1)`,
},
{
name: "vector time",
query: `vector(time())`,
},
{
name: "histogram quantile non-existent",
query: `histogram_quantile(0.9, nonexistent_metric)`,
},
{
name: "histogram quantile complex",
query: `histogram_quantile(0.5, rate(metric_1[1m]))`,
},
{
name: "complex query 1",
query: `sum by(instance) (metric_1) + on(instance) group_left(foo) metric_2`,
},
{
name: "complex query 2",
query: `max_over_time((time() - max(metric_3) < 1000)[5m:10s] offset 5m)`,
},
{
name: "complex query 3",
query: `holt_winters(metric_1[10m], 0.1, 0.5)`,
},
{
name: "query with @ modifier",
query: fmt.Sprintf("sum(metric_1[5m] @ %d)", startTime+30000/1000),
},
{
name: "double name",
query: `{__name__="metric_1", __name__="metric_1"}`,
},
{
name: "contradictory name",
query: `{__name__="metric_1", __name__="metric_2"}`,
},
{
name: "non-contradictory name",
query: `{__name__="metric_1", __name__!="metric_2"}`,
},
}
start := time.Unix(startTime/1000, 0)
end := time.Unix(endTime/1000, 0)
runPromQLQueryTests(t, testCases, start, end)
} | explode_data.jsonl/77720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2293
} | [
2830,
3393,
35186,
3588,
2859,
27380,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
17590,
1273,
1138,
197,
630,
18185,
37302,
1669,
3056,
66194,
515,
197,
197,
515,
298,
11609,
25,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestComputePodActionsWithInitContainers(t *testing.T) {
_, _, m, err := createTestRuntimeManager()
require.NoError(t, err)
// Createing a pair reference pod and status for the test cases to refer
// the specific fields.
basePod, baseStatus := makeBasePodAndStatusWithInitContainers()
noAction := podActions{
SandboxID: baseStatus.SandboxStatuses[0].Id,
ContainersToStart: []int{},
ContainersToKill: map[kubecontainer.ContainerID]containerToKillInfo{},
}
for desc, test := range map[string]struct {
mutatePodFn func(*v1.Pod)
mutateStatusFn func(*kubecontainer.PodStatus)
actions podActions
}{
"initialization completed; start all containers": {
actions: podActions{
SandboxID: baseStatus.SandboxStatuses[0].Id,
ContainersToStart: []int{0, 1, 2},
ContainersToKill: getKillMap(basePod, baseStatus, []int{}),
},
},
"initialization in progress; do nothing": {
mutatePodFn: func(pod *v1.Pod) { pod.Spec.RestartPolicy = v1.RestartPolicyAlways },
mutateStatusFn: func(status *kubecontainer.PodStatus) {
status.ContainerStatuses[2].State = kubecontainer.ContainerStateRunning
},
actions: noAction,
},
"Kill pod and restart the first init container if the pod sandbox is dead": {
mutatePodFn: func(pod *v1.Pod) { pod.Spec.RestartPolicy = v1.RestartPolicyAlways },
mutateStatusFn: func(status *kubecontainer.PodStatus) {
status.SandboxStatuses[0].State = runtimeapi.PodSandboxState_SANDBOX_NOTREADY
},
actions: podActions{
KillPod: true,
CreateSandbox: true,
SandboxID: baseStatus.SandboxStatuses[0].Id,
Attempt: uint32(1),
NextInitContainerToStart: &basePod.Spec.InitContainers[0],
ContainersToStart: []int{},
ContainersToKill: getKillMap(basePod, baseStatus, []int{}),
},
},
"initialization failed; restart the last init container if RestartPolicy == Always": {
mutatePodFn: func(pod *v1.Pod) { pod.Spec.RestartPolicy = v1.RestartPolicyAlways },
mutateStatusFn: func(status *kubecontainer.PodStatus) {
status.ContainerStatuses[2].ExitCode = 137
},
actions: podActions{
SandboxID: baseStatus.SandboxStatuses[0].Id,
NextInitContainerToStart: &basePod.Spec.InitContainers[2],
ContainersToStart: []int{},
ContainersToKill: getKillMap(basePod, baseStatus, []int{}),
},
},
"initialization failed; restart the last init container if RestartPolicy == OnFailure": {
mutatePodFn: func(pod *v1.Pod) { pod.Spec.RestartPolicy = v1.RestartPolicyOnFailure },
mutateStatusFn: func(status *kubecontainer.PodStatus) {
status.ContainerStatuses[2].ExitCode = 137
},
actions: podActions{
SandboxID: baseStatus.SandboxStatuses[0].Id,
NextInitContainerToStart: &basePod.Spec.InitContainers[2],
ContainersToStart: []int{},
ContainersToKill: getKillMap(basePod, baseStatus, []int{}),
},
},
"initialization failed; kill pod if RestartPolicy == Never": {
mutatePodFn: func(pod *v1.Pod) { pod.Spec.RestartPolicy = v1.RestartPolicyNever },
mutateStatusFn: func(status *kubecontainer.PodStatus) {
status.ContainerStatuses[2].ExitCode = 137
},
actions: podActions{
KillPod: true,
SandboxID: baseStatus.SandboxStatuses[0].Id,
ContainersToStart: []int{},
ContainersToKill: getKillMap(basePod, baseStatus, []int{}),
},
},
} {
pod, status := makeBasePodAndStatusWithInitContainers()
if test.mutatePodFn != nil {
test.mutatePodFn(pod)
}
if test.mutateStatusFn != nil {
test.mutateStatusFn(status)
}
actions := m.computePodActions(pod, status)
verifyActions(t, &test.actions, &actions, desc)
}
} | explode_data.jsonl/14244 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1586
} | [
2830,
3393,
46254,
23527,
12948,
2354,
3803,
74632,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
296,
11,
1848,
1669,
1855,
2271,
15123,
2043,
741,
17957,
35699,
1155,
11,
1848,
692,
197,
322,
4230,
287,
264,
6716,
5785,
7509,
323,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Response_Data_IgnoreHeaderAfterWrite_After(t *testing.T) {
const msg = "<html>this is HTML."
testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error {
io.WriteString(w, msg)
w.Header().Set("foo", "should be ignored")
return nil
}, func(st *serverTester) {
getSlash(st)
hf := st.wantHeaders()
if hf.StreamEnded() {
t.Fatal("unexpected END_STREAM")
}
if !hf.HeadersEnded() {
t.Fatal("want END_HEADERS flag")
}
goth := st.decodeHeader(hf.HeaderBlockFragment())
wanth := [][2]string{
{":status", "200"},
{"content-type", "text/html; charset=utf-8"},
{"content-length", strconv.Itoa(len(msg))},
}
if !reflect.DeepEqual(goth, wanth) {
t.Errorf("Got headers %v; want %v", goth, wanth)
}
})
} | explode_data.jsonl/71665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
5475,
65873,
17817,
7959,
10289,
4047,
6025,
7985,
1566,
1046,
1155,
353,
8840,
836,
8,
341,
4777,
3750,
284,
4055,
1551,
89810,
374,
9308,
10040,
18185,
5475,
2582,
1155,
11,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
965... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidateClientSideStateGoesToAllStreams(t *testing.T) {
sp := &mockStreamProvider{credentialOfDesiredType: config.SDKKey("")}
store := makeMockStore(nil, nil)
es := NewEnvStreams([]StreamProvider{sp}, store, 0, ldlog.NewDisabledLoggers())
defer es.Close()
sdkKey1, sdkKey2, sdkKey3 := config.SDKKey("sdk-key1"), config.SDKKey("sdk-key2"), config.SDKKey("sdk-key3")
es.AddCredential(sdkKey1)
es.AddCredential(sdkKey2)
es.AddCredential(sdkKey3)
require.Len(t, sp.createdStreams, 3)
esp1, esp2, esp3 := sp.createdStreams[0], sp.createdStreams[1], sp.createdStreams[2]
es.RemoveCredential(sdkKey2)
es.InvalidateClientSideState()
assert.Equal(t, 1, esp1.clientSideUps)
assert.Equal(t, 0, esp2.clientSideUps)
assert.Equal(t, 1, esp3.clientSideUps)
} | explode_data.jsonl/69850 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
641,
7067,
2959,
16384,
1397,
38,
7072,
1249,
2403,
73576,
1155,
353,
8840,
836,
8,
341,
41378,
1669,
609,
16712,
3027,
5179,
90,
66799,
2124,
4896,
2690,
929,
25,
2193,
46822,
1592,
39047,
630,
57279,
1669,
1281,
11571,
609... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestErrorNoRootCreate(t *testing.T) {
s := zktest.New()
z, ch, _ := s.Connect()
zkConnFunc := ZkConnCreatorFunc(func() (ZkConn, <-chan zk.Event, error) {
zkp, err := zkplus.NewBuilder().PathPrefix("/test").Connector(&zkplus.StaticConnector{C: z, Ch: ch}).Build()
return zkp, zkp.EventChan(), err
})
c := 0
z.SetErrorCheck(func(s string) error {
c++
if c < 2 {
return nil
}
return zk.ErrNoNode
})
d1, _ := New(zkConnFunc, "TestAdvertise1", nil)
require.Equal(t, zk.ErrNoNode, errors.Tail(d1.Advertise("TestAdvertiseService", "", (uint16)(1234))))
} | explode_data.jsonl/46864 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
1454,
2753,
8439,
4021,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
94528,
1944,
7121,
741,
20832,
11,
521,
11,
716,
1669,
274,
43851,
741,
20832,
74,
9701,
9626,
1669,
1863,
74,
9701,
31865,
9626,
18552,
368,
320,
57,
74,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNative_Unquote(t *testing.T) {
s := `hello\b\f\n\r\t\\\"\u2333world`
d := make([]byte, 0, len(s))
ep := -1
dp := (*rt.GoSlice)(unsafe.Pointer(&d))
sp := (*rt.GoString)(unsafe.Pointer(&s))
rv := __unquote(sp.Ptr, sp.Len, dp.Ptr, &ep, 0)
if rv < 0 {
require.NoError(t, types.ParsingError(-rv))
}
dp.Len = rv
assert.Equal(t, -1, ep)
assert.Equal(t, "hello\b\f\n\r\t\\\"\u2333world", string(d))
} | explode_data.jsonl/60913 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
20800,
40687,
2949,
1155,
353,
8840,
836,
8,
341,
262,
274,
1669,
1565,
14990,
43456,
64526,
1699,
12016,
4955,
3422,
22245,
84,
17,
18,
18,
18,
14615,
3989,
262,
294,
1669,
1281,
10556,
3782,
11,
220,
15,
11,
2422,
1141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddNotificationsErrors(t *testing.T) {
c := &Client{}
b := c.Bucket("b")
for _, n := range []*Notification{
{ID: "foo", TopicProjectID: "p", TopicID: "t"}, // has ID
{TopicProjectID: "p"}, // missing TopicID
{TopicID: "t"}, // missing TopicProjectID
} {
_, err := b.AddNotification(context.Background(), n)
if err == nil {
t.Errorf("%+v: got nil, want error", n)
}
}
} | explode_data.jsonl/57372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
2212,
34736,
13877,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
2959,
16094,
2233,
1669,
272,
1785,
11152,
445,
65,
1138,
2023,
8358,
308,
1669,
2088,
29838,
11196,
515,
197,
197,
90,
915,
25,
330,
7975,
497,
32911,
784... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWidgetSection_SetArea(t *testing.T) {
type args struct {
t WidgetAreaType
a *WidgetArea
}
tests := []struct {
name string
args args
nil bool
}{
{
name: "top",
args: args{
t: WidgetAreaTop,
a: &WidgetArea{},
},
},
{
name: "middle",
args: args{
t: WidgetAreaMiddle,
a: &WidgetArea{},
},
},
{
name: "bottom",
args: args{
t: WidgetAreaBottom,
a: &WidgetArea{},
},
},
{
name: "nil area",
args: args{
t: WidgetAreaTop,
a: nil,
},
},
{
name: "nil",
args: args{
t: WidgetAreaTop,
a: &WidgetArea{},
},
nil: true,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var s *WidgetSection
if !tt.nil {
s = &WidgetSection{}
}
s.SetArea(tt.args.t, tt.args.a)
if !tt.nil {
var a2 *WidgetArea
switch tt.args.t {
case WidgetAreaTop:
a2 = s.top
case WidgetAreaMiddle:
a2 = s.middle
case WidgetAreaBottom:
a2 = s.bottom
}
assert.Same(t, tt.args.a, a2)
}
})
}
} | explode_data.jsonl/77657 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 593
} | [
2830,
3393,
4548,
9620,
14812,
8726,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
3244,
12980,
8726,
929,
198,
197,
11323,
353,
4548,
8726,
198,
197,
630,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestBRFork1(t *testing.T) {
g := *mp1.InitializeGame(LER, mp1.GameConfig{MaxTurns: 20})
g.Players[0].CurrentSpace = mp1.NewChainSpace(5, 3)
g.NextEvent.Handle(mp1.NewChainSpace(3, 2), &g) //Star
gBlueUp := g
gBlueUp.Board.Data = lerBoardData{true}
g.NextEvent.Handle(1, &g)
SpaceIs(mp1.NewChainSpace(6, 10), 0, g, "", t)
gBlueUp.NextEvent.Handle(1, &gBlueUp)
SpaceIs(mp1.NewChainSpace(9, 0), 0, gBlueUp, "BlueUp", t)
} | explode_data.jsonl/70285 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
13095,
37,
669,
16,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
353,
1307,
16,
45829,
4868,
4957,
640,
11,
10490,
16,
20940,
2648,
90,
5974,
19389,
82,
25,
220,
17,
15,
3518,
3174,
98182,
58,
15,
936,
5405,
9914,
284,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepareProposalAddedTxsIncluded(t *testing.T) {
const height = 2
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
logger := log.NewNopLogger()
eventBus := eventbus.NewDefault(logger)
require.NoError(t, eventBus.Start(ctx))
state, stateDB, privVals := makeState(t, 1, height)
stateStore := sm.NewStore(stateDB)
evpool := &mocks.EvidencePool{}
evpool.On("PendingEvidence", mock.Anything).Return([]types.Evidence{}, int64(0))
txs := factory.MakeNTxs(height, 10)
mp := &mpmocks.Mempool{}
mp.On("ReapMaxBytesMaxGas", mock.Anything, mock.Anything).Return(types.Txs(txs[2:]))
trs := txsToTxRecords(types.Txs(txs))
trs[0].Action = abci.TxRecord_ADDED
trs[1].Action = abci.TxRecord_ADDED
app := abcimocks.NewApplication(t)
app.On("PrepareProposal", mock.Anything, mock.Anything).Return(&abci.ResponsePrepareProposal{
TxRecords: trs,
}, nil)
cc := abciclient.NewLocalClient(logger, app)
proxyApp := proxy.New(cc, logger, proxy.NopMetrics())
err := proxyApp.Start(ctx)
require.NoError(t, err)
blockExec := sm.NewBlockExecutor(
stateStore,
logger,
proxyApp,
mp,
evpool,
nil,
eventBus,
sm.NopMetrics(),
)
pa, _ := state.Validators.GetByIndex(0)
commit, _ := makeValidCommit(ctx, t, height, types.BlockID{}, state.Validators, privVals)
block, err := blockExec.CreateProposalBlock(ctx, height, state, commit, pa)
require.NoError(t, err)
require.Equal(t, txs[0], block.Data.Txs[0])
require.Equal(t, txs[1], block.Data.Txs[1])
mp.AssertExpectations(t)
} | explode_data.jsonl/49122 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 609
} | [
2830,
3393,
50590,
98637,
19337,
51,
18561,
84610,
1155,
353,
8840,
836,
8,
341,
4777,
2608,
284,
220,
17,
198,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
17060,
1669,
1487,
7121,
45,
453,
7395,
741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReconcileSecurityGroupRemoveServiceRemovesPort(t *testing.T) {
az := getTestCloud()
svc := getTestService("servicea", v1.ProtocolTCP, 80, 443)
clusterResources := getClusterResources(az, 1, 1)
sg := getTestSecurityGroup(az, svc)
svcUpdated := getTestService("servicea", v1.ProtocolTCP, 80)
lb, _ := az.reconcileLoadBalancer(testClusterName, &svc, clusterResources.nodes, true)
lbStatus, _ := az.getServiceLoadBalancerStatus(&svc, lb)
sg, err := az.reconcileSecurityGroup(testClusterName, &svcUpdated, &lbStatus.Ingress[0].IP, true /* wantLb */)
if err != nil {
t.Errorf("Unexpected error: %q", err)
}
validateSecurityGroup(t, sg, svcUpdated)
} | explode_data.jsonl/50402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
693,
40446,
457,
15352,
2808,
13021,
1860,
6590,
10088,
7084,
1155,
353,
8840,
836,
8,
341,
197,
1370,
1669,
633,
2271,
16055,
741,
1903,
7362,
1669,
633,
2271,
1860,
445,
7936,
64,
497,
348,
16,
54096,
49896,
11,
220,
23,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClient_XmlEmptyMaps_awsRestxmlSerialize(t *testing.T) {
cases := map[string]struct {
Params *XmlEmptyMapsInput
ExpectMethod string
ExpectURIPath string
ExpectQuery []smithytesting.QueryItem
RequireQuery []string
ForbidQuery []string
ExpectHeader http.Header
RequireHeader []string
ForbidHeader []string
BodyMediaType string
BodyAssert func(io.Reader) error
}{
// Serializes Empty XML maps
"XmlEmptyMaps": {
Params: &XmlEmptyMapsInput{
MyMap: map[string]types.GreetingStruct{},
},
ExpectMethod: "POST",
ExpectURIPath: "/XmlEmptyMaps",
ExpectQuery: []smithytesting.QueryItem{},
ExpectHeader: http.Header{
"Content-Type": []string{"application/xml"},
},
BodyMediaType: "application/xml",
BodyAssert: func(actual io.Reader) error {
return smithytesting.CompareXMLReaderBytes(actual, []byte(`<XmlMapsInputOutput>
<myMap></myMap>
</XmlMapsInputOutput>
`))
},
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
var actualReq *http.Request
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
actualReq = r.Clone(r.Context())
if len(actualReq.URL.RawPath) == 0 {
actualReq.URL.RawPath = actualReq.URL.Path
}
if v := actualReq.ContentLength; v != 0 {
actualReq.Header.Set("Content-Length", strconv.FormatInt(v, 10))
}
var buf bytes.Buffer
if _, err := io.Copy(&buf, r.Body); err != nil {
t.Errorf("failed to read request body, %v", err)
}
actualReq.Body = ioutil.NopCloser(&buf)
w.WriteHeader(200)
}))
defer server.Close()
url := server.URL
client := New(Options{
APIOptions: []func(*middleware.Stack) error{
func(s *middleware.Stack) error {
s.Finalize.Clear()
return nil
},
},
EndpointResolver: EndpointResolverFunc(func(region string, options EndpointResolverOptions) (e aws.Endpoint, err error) {
e.URL = url
e.SigningRegion = "us-west-2"
return e, err
}),
HTTPClient: awshttp.NewBuildableClient(),
IdempotencyTokenProvider: smithyrand.NewUUIDIdempotencyToken(&smithytesting.ByteLoop{}),
Region: "us-west-2",
})
result, err := client.XmlEmptyMaps(context.Background(), c.Params)
if err != nil {
t.Fatalf("expect nil err, got %v", err)
}
if result == nil {
t.Fatalf("expect not nil result")
}
if e, a := c.ExpectMethod, actualReq.Method; e != a {
t.Errorf("expect %v method, got %v", e, a)
}
if e, a := c.ExpectURIPath, actualReq.URL.RawPath; e != a {
t.Errorf("expect %v path, got %v", e, a)
}
queryItems := smithytesting.ParseRawQuery(actualReq.URL.RawQuery)
smithytesting.AssertHasQuery(t, c.ExpectQuery, queryItems)
smithytesting.AssertHasQueryKeys(t, c.RequireQuery, queryItems)
smithytesting.AssertNotHaveQueryKeys(t, c.ForbidQuery, queryItems)
smithytesting.AssertHasHeader(t, c.ExpectHeader, actualReq.Header)
smithytesting.AssertHasHeaderKeys(t, c.RequireHeader, actualReq.Header)
smithytesting.AssertNotHaveHeaderKeys(t, c.ForbidHeader, actualReq.Header)
if c.BodyAssert != nil {
if err := c.BodyAssert(actualReq.Body); err != nil {
t.Errorf("expect body equal, got %v", err)
}
}
})
}
} | explode_data.jsonl/43285 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1449
} | [
2830,
3393,
2959,
6859,
1014,
3522,
36562,
62,
8635,
12416,
6455,
15680,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
4870,
286,
353,
11593,
3522,
36562,
2505,
198,
197,
35911,
3523,
220,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateSSHAuthSecret(t *testing.T) {
validSSHAuthSecret := func() core.Secret {
return core.Secret{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"},
Type: core.SecretTypeSSHAuth,
Data: map[string][]byte{
core.SSHAuthPrivateKey: []byte("foo-bar-baz"),
},
}
}
missingSSHAuthPrivateKey := validSSHAuthSecret()
delete(missingSSHAuthPrivateKey.Data, core.SSHAuthPrivateKey)
tests := map[string]struct {
secret core.Secret
valid bool
}{
"valid": {validSSHAuthSecret(), true},
"missing private key": {missingSSHAuthPrivateKey, false},
}
for name, tc := range tests {
errs := ValidateSecret(&tc.secret)
if tc.valid && len(errs) > 0 {
t.Errorf("%v: Unexpected error: %v", name, errs)
}
if !tc.valid && len(errs) == 0 {
t.Errorf("%v: Unexpected non-error", name)
}
}
} | explode_data.jsonl/1054 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
17926,
62419,
5087,
19773,
1155,
353,
8840,
836,
8,
341,
56322,
62419,
5087,
19773,
1669,
2915,
368,
6200,
74779,
341,
197,
853,
6200,
74779,
515,
298,
23816,
12175,
25,
77520,
16,
80222,
63121,
25,
330,
7975,
497,
41962,
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 TestPlayer_FlashDurationTimeRemaining_Default(t *testing.T) {
pl := NewPlayer(mockDemoInfoProvider(0, 128))
assert.Equal(t, time.Duration(0), pl.FlashDurationTimeRemaining())
} | explode_data.jsonl/12168 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 62
} | [
2830,
3393,
4476,
1400,
24686,
12945,
1462,
54745,
60336,
1155,
353,
8840,
836,
8,
341,
72213,
1669,
1532,
4476,
30389,
37413,
1731,
5179,
7,
15,
11,
220,
16,
17,
23,
4390,
6948,
12808,
1155,
11,
882,
33795,
7,
15,
701,
625,
991,
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 |
func TestHashSet(t *testing.T) {
set := NewHashSet()
var other *HashSet
set.Add(3)
set.Add(4)
// other.Add(3)
is := set.Same(other)
fmt.Println(is)
} | explode_data.jsonl/29362 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
44601,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
1532,
44601,
741,
2405,
1008,
353,
44601,
271,
8196,
1904,
7,
18,
340,
8196,
1904,
7,
19,
692,
197,
322,
1008,
1904,
7,
18,
340,
19907,
1669,
738,
808,
373,
17094,
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 |
func TestFlatten(t *testing.T) {
jsonStr := `[1,[2],[3,4],[5,[6,[7]]],{"hi":"there"},8,[9]]`
assert(t, Get(jsonStr, "@flatten").String() == `[1,2,3,4,5,[6,[7]],{"hi":"there"},8,9]`)
assert(t, Get(jsonStr, `@flatten:{"deep":true}`).String() == `[1,2,3,4,5,6,7,{"hi":"there"},8,9]`)
assert(t, Get(`{"9999":1234}`, "@flatten").String() == `{"9999":1234}`)
} | explode_data.jsonl/43476 | {
"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,
3882,
14456,
1155,
353,
8840,
836,
8,
341,
30847,
2580,
1669,
77644,
16,
17259,
17,
14955,
18,
11,
19,
14955,
20,
17259,
21,
17259,
22,
5053,
1125,
4913,
6023,
3252,
18532,
14345,
23,
17259,
24,
5053,
3989,
6948,
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 TestBlockStmt(t *testing.T) {
gopClTest(t, `
package main
func main() {
{
type T int
t := T(100)
println(t)
}
{
type T string
t := "hello"
println(t)
}
}
`, `package main
import fmt "fmt"
func main() {
{
type T int
t := T(100)
fmt.Println(t)
}
{
type T string
t := "hello"
fmt.Println(t)
}
}
`)
} | explode_data.jsonl/73594 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
4713,
31063,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
1722,
1887,
271,
2830,
1887,
368,
341,
197,
515,
197,
13158,
350,
526,
198,
197,
3244,
1669,
350,
7,
16,
15,
15,
340,
197,
81168,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAPIModelWithoutServicePrincipalProfileAndClientIdAndSecretInGenerateCmd(t *testing.T) {
t.Parallel()
apiloader := &api.Apiloader{
Translator: nil,
}
apimodel := getAPIModelWithoutServicePrincipalProfile(false)
cs, ver, err := apiloader.DeserializeContainerService([]byte(apimodel), false, false, nil)
if err != nil {
t.Fatalf("unexpected error deserializing the example apimodel: %s", err)
}
cs.Properties.LinuxProfile.SSH.PublicKeys[0].KeyData = "ssh test"
outfile, del := makeTmpFile(t, "_test_output")
defer del()
clientID, _ := uuid.Parse("e810b868-afab-412d-98cc-ce7db5cc840b")
clientSecret := "Test Client secret"
generateCmd := &generateCmd{
apimodelPath: "./this/is/unused.json",
outputDirectory: outfile,
ClientID: clientID,
ClientSecret: clientSecret,
containerService: cs,
apiVersion: ver,
}
err = generateCmd.autofillApimodel()
if err != nil {
t.Fatalf("unexpected error autofilling the example apimodel: %s", err)
}
if generateCmd.containerService.Properties.ServicePrincipalProfile == nil || generateCmd.containerService.Properties.ServicePrincipalProfile.ClientID == "" || generateCmd.containerService.Properties.ServicePrincipalProfile.Secret == "" {
t.Fatalf("expected service principal profile to be populated from deployment command arguments")
}
if generateCmd.containerService.Properties.ServicePrincipalProfile.ClientID != clientID.String() {
t.Fatalf("expected service principal profile client id to be %s but got %s", clientID.String(), generateCmd.containerService.Properties.ServicePrincipalProfile.ClientID)
}
if generateCmd.containerService.Properties.ServicePrincipalProfile.Secret != clientSecret {
t.Fatalf("expected service principal profile client secret to be %s but got %s", clientSecret, generateCmd.containerService.Properties.ServicePrincipalProfile.Secret)
}
err = generateCmd.validateAPIModelAsVLabs()
if err != nil {
t.Fatalf("unexpected error validateAPIModelAsVLabs the example apimodel: %s", err)
}
} | explode_data.jsonl/58946 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 677
} | [
2830,
3393,
7082,
1712,
26040,
1860,
31771,
8526,
3036,
94116,
3036,
19773,
641,
31115,
15613,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
69898,
18045,
998,
1669,
609,
2068,
22829,
18045,
998,
515,
197,
197,
51653,
25,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestContextNegotiationFormatWithWildcardAccept(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "/", nil)
c.Request.Header.Add("Accept", "*/*")
assert.Equal(t, c.NegotiateFormat("*/*"), "*/*")
assert.Equal(t, c.NegotiateFormat("text/*"), "text/*")
assert.Equal(t, c.NegotiateFormat("application/*"), "application/*")
assert.Equal(t, c.NegotiateFormat(MIMEJSON), MIMEJSON)
assert.Equal(t, c.NegotiateFormat(MIMEXML), MIMEXML)
assert.Equal(t, c.NegotiateFormat(MIMEHTML), MIMEHTML)
c, _ = CreateTestContext(httptest.NewRecorder())
c.Request, _ = http.NewRequest("POST", "/", nil)
c.Request.Header.Add("Accept", "text/*")
assert.Equal(t, c.NegotiateFormat("*/*"), "*/*")
assert.Equal(t, c.NegotiateFormat("text/*"), "text/*")
assert.Equal(t, c.NegotiateFormat("application/*"), "")
assert.Equal(t, c.NegotiateFormat(MIMEJSON), "")
assert.Equal(t, c.NegotiateFormat(MIMEXML), "")
assert.Equal(t, c.NegotiateFormat(MIMEHTML), MIMEHTML)
} | explode_data.jsonl/26808 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 405
} | [
2830,
3393,
1972,
47800,
354,
7101,
4061,
2354,
92988,
16646,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
4230,
2271,
1972,
73392,
83,
70334,
7121,
47023,
2398,
1444,
9659,
11,
716,
284,
1758,
75274,
445,
2946,
497,
64657,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseAppleJWK(t *testing.T) {
testKeys := `{
"keys": [
{
"kty": "RSA",
"kid": "86D88Kf",
"use": "sig",
"alg": "RS256",
"n": "iGaLqP6y-SJCCBq5Hv6pGDbG_SQ11MNjH7rWHcCFYz4hGwHC4lcSurTlV8u3avoVNM8jXevG1Iu1SY11qInqUvjJur--hghr1b56OPJu6H1iKulSxGjEIyDP6c5BdE1uwprYyr4IO9th8fOwCPygjLFrh44XEGbDIFeImwvBAGOhmMB2AD1n1KviyNsH0bEB7phQtiLk-ILjv1bORSRl8AK677-1T8isGfHKXGZ_ZGtStDe7Lu0Ihp8zoUt59kx2o9uWpROkzF56ypresiIl4WprClRCjz8x6cPZXU2qNWhu71TQvUFwvIvbkE1oYaJMb0jcOTmBRZA2QuYw-zHLwQ",
"e": "AQAB"
},
{
"kty": "RSA",
"kid": "eXaunmL",
"use": "sig",
"alg": "RS256",
"n": "4dGQ7bQK8LgILOdLsYzfZjkEAoQeVC_aqyc8GC6RX7dq_KvRAQAWPvkam8VQv4GK5T4ogklEKEvj5ISBamdDNq1n52TpxQwI2EqxSk7I9fKPKhRt4F8-2yETlYvye-2s6NeWJim0KBtOVrk0gWvEDgd6WOqJl_yt5WBISvILNyVg1qAAM8JeX6dRPosahRVDjA52G2X-Tip84wqwyRpUlq2ybzcLh3zyhCitBOebiRWDQfG26EH9lTlJhll-p_Dg8vAXxJLIJ4SNLcqgFeZe4OfHLgdzMvxXZJnPp_VgmkcpUdRotazKZumj6dBPcXI_XID4Z4Z3OM1KrZPJNdUhxw",
"e": "AQAB"
},
{
"kty": "RSA",
"kid": "YuyXoY",
"use": "sig",
"alg": "RS256",
"n": "1JiU4l3YCeT4o0gVmxGTEK1IXR-Ghdg5Bzka12tzmtdCxU00ChH66aV-4HRBjF1t95IsaeHeDFRgmF0lJbTDTqa6_VZo2hc0zTiUAsGLacN6slePvDcR1IMucQGtPP5tGhIbU-HKabsKOFdD4VQ5PCXifjpN9R-1qOR571BxCAl4u1kUUIePAAJcBcqGRFSI_I1j_jbN3gflK_8ZNmgnPrXA0kZXzj1I7ZHgekGbZoxmDrzYm2zmja1MsE5A_JX7itBYnlR41LOtvLRCNtw7K3EFlbfB6hkPL-Swk5XNGbWZdTROmaTNzJhV-lWT0gGm6V1qWAK2qOZoIDa_3Ud0Gw",
"e": "AQAB"
}
]
}`
testKeySet, err := parseAppleJWK([]byte(testKeys))
assert.NoError(t, err)
key, err := testKeySet.get("YuyXoY")
assert.NoError(t, err)
assert.Equal(t, key.ID, "YuyXoY")
testKeySet = appleKeySet{} // reset previous value
testKeySet, err = parseAppleJWK([]byte(`{"keys":[]}`))
assert.NoError(t, err)
assert.Equal(t, 0, len(testKeySet.keys))
testKeySet = appleKeySet{} // reset previous value
testKeySet, err = parseAppleJWK([]byte(`{"keys":[{
"kty": "RSA",
"kid": "86D88Kf",
"use": "sig",
"alg": "RS256",
"n": "invalid-value",
"e": "invalid-value"
}]}`))
assert.Error(t, err, errors.New("failed to decode Apple public key modulus (n)"))
testKeySet, err = parseAppleJWK([]byte(`{"keys":[{
"kty": "RSA",
"kid": "86D88Kf",
"use": "sig",
"alg": "RS256",
"n": "1JiU4l3YCeT4o0gVmxGTEK1IXR-Ghdg5Bzka12tzmtdCxU00ChH66aV-4HRBjF1t95IsaeHeDFRgmF0lJbTDTqa6_VZo2hc0zTiUAsGLacN6slePvDcR1IMucQGtPP5tGhIbU-HKabsKOFdD4VQ5PCXifjpN9R-1qOR571BxCAl4u1kUUIePAAJcBcqGRFSI_I1j_jbN3gflK_8ZNmgnPrXA0kZXzj1I7ZHgekGbZoxmDrzYm2zmja1MsE5A_JX7itBYnlR41LOtvLRCNtw7K3EFlbfB6hkPL-Swk5XNGbWZdTROmaTNzJhV-lWT0gGm6V1qWAK2qOZoIDa_3Ud0Gw",
"e": "invalid-value"
}]}`))
assert.Error(t, err, errors.New("failed to decode Apple public key modulus (e)"))
testKeySet, err = parseAppleJWK([]byte(`{invalid-json}`))
assert.Error(t, err)
} | explode_data.jsonl/74294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1912
} | [
2830,
3393,
14463,
26567,
41,
68316,
1155,
353,
8840,
836,
8,
341,
18185,
8850,
1669,
1565,
515,
464,
197,
1,
10563,
788,
2278,
464,
197,
515,
23263,
330,
74,
1881,
788,
330,
73564,
756,
23263,
330,
63281,
788,
330,
23,
21,
35,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJoin1(t *testing.T) {
tsEngine, _ := xorm.NewEngine("mysql",
"root:root@tcp(127.0.0.1:3306)/radius?charset=utf8")
tsEngine.ShowSQL(true)
//var users = make([]RadUserProduct, 0)
//total, err := tsEngine.Table("rad_user").Alias("r").
// Limit(10, 0).Join("INNER", []string{"rad_product", "sp"}, "r.product_id = sp.id").
// FindAndCount(&users)
//if err != nil {
// fmt.Println("δ½ ε¦ΉηεΌεΈΈδΊ", err.Error())
//}
//users := make([]RadUser, 0)
var users model.RadUser
tsEngine.Get(&users)
fmt.Printf("%#v", users) //, total, err)
} | explode_data.jsonl/28480 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
12292,
16,
1155,
353,
8840,
836,
8,
341,
57441,
4571,
11,
716,
1669,
856,
493,
7121,
4571,
445,
12272,
756,
197,
197,
1,
2888,
25,
2888,
31,
27161,
7,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
18,
18,
15,
21,
5620,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessProposals(t *testing.T) {
// Build clients that return a range of status codes (for verifying each client is called).
mockClients := []pb.EndorserClient{}
for i := 2; i <= 5; i++ {
response := &pb.ProposalResponse{
Response: &pb.Response{Status: int32(i * 100)},
Endorsement: &pb.Endorsement{},
}
mockClients = append(mockClients, common.GetMockEndorserClient(response, nil))
}
mockErrorClient := common.GetMockEndorserClient(nil, errors.New("failed to call endorser"))
signedProposal := &pb.SignedProposal{}
t.Run("should process a proposal for a single peer", func(t *testing.T) {
responses, err := processProposals([]pb.EndorserClient{mockClients[0]}, signedProposal)
assert.NoError(t, err)
assert.Len(t, responses, 1)
assert.Equal(t, responses[0].Response.Status, int32(200))
})
t.Run("should process a proposal for multiple peers", func(t *testing.T) {
responses, err := processProposals(mockClients, signedProposal)
assert.NoError(t, err)
assert.Len(t, responses, 4)
// Sort the statuses (as they may turn up in different order) before comparing.
statuses := []int32{}
for _, response := range responses {
statuses = append(statuses, response.Response.Status)
}
sort.Slice(statuses, func(i, j int) bool { return statuses[i] < statuses[j] })
assert.EqualValues(t, []int32{200, 300, 400, 500}, statuses)
})
t.Run("should return an error from processing a proposal for a single peer", func(t *testing.T) {
responses, err := processProposals([]pb.EndorserClient{mockErrorClient}, signedProposal)
assert.EqualError(t, err, "failed to call endorser")
assert.Nil(t, responses)
})
t.Run("should return an error from processing a proposal for a single peer within multiple peers", func(t *testing.T) {
responses, err := processProposals([]pb.EndorserClient{mockClients[0], mockErrorClient, mockClients[1]}, signedProposal)
assert.EqualError(t, err, "failed to call endorser")
assert.Nil(t, responses)
})
} | explode_data.jsonl/46380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 705
} | [
2830,
3393,
7423,
2008,
85975,
1155,
353,
8840,
836,
8,
341,
197,
322,
7854,
8239,
429,
470,
264,
2088,
315,
2639,
13912,
320,
1958,
68863,
1817,
2943,
374,
2598,
4292,
77333,
47174,
1669,
3056,
16650,
18569,
269,
799,
2959,
16094,
2023... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapProxy_ReplaceWithNonSerializableOldValue(t *testing.T) {
_, err := mp.ReplaceIfSame("test", student{}, "test")
AssertErrorNotNil(t, err, "replaceIfSame did not return an error for nonserializable oldValue")
mp.Clear()
} | explode_data.jsonl/57064 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
2227,
16219,
62,
23107,
2354,
8121,
29268,
18284,
1130,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
10490,
20858,
2679,
19198,
445,
1944,
497,
5458,
22655,
330,
1944,
1138,
18017,
1454,
96144,
1155,
11,
1848,
11,
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 |
func TestNextIndex(t *testing.T) {
type scenario struct {
testName string
list []int
element int
expected int
}
scenarios := []scenario{
{
// I'm not really fussed about how it behaves here
"no elements",
[]int{},
1,
0,
},
{
"one element",
[]int{1},
1,
0,
},
{
"two elements",
[]int{1, 2},
1,
1,
},
{
"two elements, giving second one",
[]int{1, 2},
2,
0,
},
{
"three elements, giving second one",
[]int{1, 2, 3},
2,
2,
},
}
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
assert.EqualValues(t, s.expected, NextIndex(s.list, s.element))
})
}
} | explode_data.jsonl/11582 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
5847,
1552,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
18185,
675,
914,
198,
197,
14440,
257,
3056,
396,
198,
197,
43707,
220,
526,
198,
197,
42400,
526,
198,
197,
630,
29928,
60494,
1669,
3056,
61422,
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 TestDust(t *testing.T) {
ctx := createSweeperTestContext(t)
// Sweeping a single output produces a tx of 486 weight units. With the
// test fee rate, the sweep tx will pay 4860 sat in fees.
//
// Create an input so that the output after paying fees is still
// positive (400 sat), but less than the dust limit (537 sat) for the
// sweep tx output script (P2WPKH).
dustInput := createTestInput(5260, input.CommitmentTimeLock)
_, err := ctx.sweeper.SweepInput(&dustInput, defaultFeePref)
if err != nil {
t.Fatal(err)
}
// No sweep transaction is expected now. The sweeper should recognize
// that the sweep output will not be relayed and not generate the tx.
// Sweep another input that brings the tx output above the dust limit.
largeInput := createTestInput(100000, input.CommitmentTimeLock)
_, err = ctx.sweeper.SweepInput(&largeInput, defaultFeePref)
if err != nil {
t.Fatal(err)
}
ctx.tick()
// The second input brings the sweep output above the dust limit. We
// expect a sweep tx now.
sweepTx := ctx.receiveTx()
if len(sweepTx.TxIn) != 2 {
t.Fatalf("Expected tx to sweep 2 inputs, but contains %v "+
"inputs instead", len(sweepTx.TxIn))
}
ctx.backend.mine()
ctx.finish(1)
} | explode_data.jsonl/34221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
35,
590,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1855,
50,
896,
10436,
2271,
1972,
1155,
692,
197,
322,
36226,
54223,
264,
3175,
2550,
18644,
264,
9854,
315,
220,
19,
23,
21,
4680,
8153,
13,
3085,
279,
198,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestPathStyleBucketBuild(t *testing.T) {
s := s3.New(unit.Session, &aws.Config{S3ForcePathStyle: aws.Bool(true)})
runTests(t, s, forcepathTests)
} | explode_data.jsonl/9971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
1820,
2323,
36018,
11066,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
274,
18,
7121,
24144,
20674,
11,
609,
8635,
10753,
90,
50,
18,
18573,
1820,
2323,
25,
31521,
52497,
3715,
59209,
56742,
18200,
1155,
11,
274,
11,
5344,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestPrintPodList(t *testing.T) {
tests := []struct {
pods api.PodList
expect []metav1.TableRow
}{
// Test podList's pod: name, num of containers, restarts, container ready status
{
api.PodList{
Items: []api.Pod{
{
ObjectMeta: metav1.ObjectMeta{Name: "test1"},
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
Status: api.PodStatus{
Phase: "podPhase",
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
{Ready: true, RestartCount: 3, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "test2"},
Spec: api.PodSpec{Containers: make([]api.Container, 1)},
Status: api.PodStatus{
Phase: "podPhase",
ContainerStatuses: []api.ContainerStatus{
{Ready: true, RestartCount: 1, State: api.ContainerState{Running: &api.ContainerStateRunning{}}},
},
},
},
},
},
[]metav1.TableRow{{Cells: []interface{}{"test1", "2/2", "podPhase", int64(6), "<unknown>"}}, {Cells: []interface{}{"test2", "1/1", "podPhase", int64(1), "<unknown>"}}},
},
}
for _, test := range tests {
rows, err := printPodList(&test.pods, printers.GenerateOptions{})
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expect, rows) {
t.Errorf("mismatch: %s", diff.ObjectReflectDiff(test.expect, rows))
}
}
} | explode_data.jsonl/21600 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 704
} | [
2830,
3393,
8994,
23527,
852,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
3223,
29697,
256,
6330,
88823,
852,
198,
197,
24952,
3056,
4059,
402,
16,
18257,
3102,
198,
197,
59403,
197,
197,
322,
3393,
7509,
852,
594... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSservice_UninstallSetup_immugw(t *testing.T) {
op := Option{}
mpss := make([]immudb.ManpageService, 2)
mpss[0] = immudbcmdtest.ManpageServiceMock{}
mpss[1] = immudbcmdtest.ManpageServiceMock{}
ss := sservice{osMock, &servicetest.ConfigServiceMock{}, mpss, op}
err := ss.UninstallSetup("immugw")
assert.Nil(t, err)
} | explode_data.jsonl/57705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
50,
7936,
40687,
12248,
21821,
71370,
768,
86,
1155,
353,
8840,
836,
8,
341,
39703,
1669,
6959,
16094,
53230,
778,
1669,
1281,
10556,
12543,
661,
65,
29902,
2893,
1860,
11,
220,
17,
340,
53230,
778,
58,
15,
60,
284,
4893,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLabel_String(t *testing.T) {
v := Label{
ID: Int64(0),
URL: String(""),
Name: String(""),
Color: String(""),
Description: String(""),
Default: Bool(false),
NodeID: String(""),
}
want := `github.Label{ID:0, URL:"", Name:"", Color:"", Description:"", Default:false, NodeID:""}`
if got := v.String(); got != want {
t.Errorf("Label.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33254 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
2476,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
9402,
515,
197,
29580,
25,
688,
1333,
21,
19,
7,
15,
1326,
197,
79055,
25,
260,
923,
445,
4461,
197,
21297,
25,
286,
923,
445,
4461,
197,
57814,
25,
981,
923,
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... | 2 |
func TestGetAutoPromotionEnabledOrDefault(t *testing.T) {
autoPromote := false
rolloutNonDefaultValue := &v1alpha1.Rollout{
Spec: v1alpha1.RolloutSpec{
Strategy: v1alpha1.RolloutStrategy{
BlueGreen: &v1alpha1.BlueGreenStrategy{
AutoPromotionEnabled: &autoPromote,
},
},
},
}
assert.Equal(t, autoPromote, GetAutoPromotionEnabledOrDefault(rolloutNonDefaultValue))
rolloutNoStrategyDefaultValue := &v1alpha1.Rollout{}
assert.Equal(t, DefaultAutoPromotionEnabled, GetAutoPromotionEnabledOrDefault(rolloutNoStrategyDefaultValue))
rolloutNoAutoPromotionEnabled := &v1alpha1.Rollout{
Spec: v1alpha1.RolloutSpec{
Strategy: v1alpha1.RolloutStrategy{
BlueGreen: &v1alpha1.BlueGreenStrategy{},
},
},
}
assert.Equal(t, DefaultAutoPromotionEnabled, GetAutoPromotionEnabledOrDefault(rolloutNoAutoPromotionEnabled))
} | explode_data.jsonl/15135 | {
"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,
1949,
13253,
35186,
5956,
5462,
14188,
1155,
353,
8840,
836,
8,
341,
14735,
35186,
1272,
1669,
895,
198,
197,
1100,
411,
8121,
41533,
1669,
609,
85,
16,
7141,
16,
71212,
411,
515,
197,
7568,
992,
25,
348,
16,
7141,
16,
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 Test_getOrganizations(t *testing.T) {
t.Parallel()
tests := []struct {
testDescription string
orgLister gits.OrganisationLister
userName string
want []string
}{
{"Should return user name when ListOrganisations() fails", FakeOrgLister{fail: true}, "testuser", []string{"testuser"}},
{"Should return user name when organization list is empty", FakeOrgLister{orgNames: []string{}}, "testuser", []string{"testuser"}},
{"Should include user name when only 1 organization exists", FakeOrgLister{orgNames: []string{"testorg"}}, "testuser", []string{"testorg", "testuser"}},
{"Should include user name together with all organizations when multiple exists", FakeOrgLister{orgNames: []string{"testorg", "anotherorg"}}, "testuser", []string{"anotherorg", "testorg", "testuser"}},
}
for _, tt := range tests {
t.Run(tt.testDescription, func(t *testing.T) {
result := gits.GetOrganizations(tt.orgLister, tt.userName)
assert.Equal(t, tt.want, result)
})
}
} | explode_data.jsonl/46900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
3062,
23227,
8040,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
78216,
1669,
3056,
1235,
341,
197,
18185,
5009,
914,
198,
197,
87625,
852,
261,
981,
342,
1199,
8382,
8443,
7923,
852,
261,
198,
197,
19060,
675,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.