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 TestNewID(t *testing.T) {
hexchars := "0123456789ABCDEFabcdef"
for i := 0; i < 100; i++ {
id := string(NewID())
if !strings.HasPrefix(id, "0x") {
t.Fatalf("invalid ID prefix, want '0x...', got %s", id)
}
id = id[2:]
if len(id) == 0 || len(id) > 32 {
t.Fatalf("invalid ID length, want len(id) > 0 && len(id) <= 32), got %d", len(id))
}
for i := 0; i < len(id); i++ {
if strings.IndexByte(hexchars, id[i]) == -1 {
t.Fatalf("unexpected byte, want any valid hex char, got %c", id[i])
}
}
}
} | explode_data.jsonl/5998 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
3564,
915,
1155,
353,
8840,
836,
8,
341,
9598,
327,
19255,
1669,
330,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25411,
13649,
41202,
698,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
15,
26,
600,
1027,
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... | 7 |
func TestLogsWorkflowOpts_Validate_StartEndFlags(t *testing.T) {
start := time.Unix(0, 773391600000)
end := time.Unix(0, 773391700000)
opts := logsWorkflowOpts{logsWorkflowVars: logsWorkflowVars{logsSharedVars: logsSharedVars{startString: start.Format(time.RFC3339Nano), endString: end.Format(time.RFC3339Nano)}}}
err := opts.Validate()
assert.NoError(t, err)
assert.True(t, start.Equal(*opts.startTime))
assert.True(t, end.Equal(*opts.endTime))
} | explode_data.jsonl/74226 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
51053,
62768,
43451,
62,
17926,
38056,
3727,
9195,
1155,
353,
8840,
836,
8,
341,
21375,
1669,
882,
10616,
941,
7,
15,
11,
220,
22,
22,
18,
18,
24,
16,
21,
15,
15,
15,
15,
15,
340,
6246,
1669,
882,
10616,
941,
7,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVMNoReturnInstruction(t *testing.T) {
_, _, err := testVM(t, []bpf.Instruction{
bpf.LoadConstant{
Dst: bpf.RegA,
Val: 1,
},
})
if errStr(err) != "BPF program must end with RetA or RetConstant" {
t.Fatalf("unexpected error: %v", err)
}
} | explode_data.jsonl/48019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
11187,
2753,
5598,
16664,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
1848,
1669,
1273,
11187,
1155,
11,
3056,
65,
15897,
5337,
3024,
515,
197,
2233,
15897,
13969,
15472,
515,
298,
10957,
267,
25,
293,
15897,
8989,
32,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStore_Put_Internal(t *testing.T) {
t.Run("Document update conflict: exceed maximum number of retries", func(t *testing.T) {
store := &store{
db: &mockDB{
errPut: errors.New(documentUpdateConflictErrMsgFromKivik),
getRowBodyData: `{"_rev":"SomeRevID"}`,
},
maxDocumentConflictRetries: 3, marshal: json.Marshal,
}
err := store.Put("key", []byte("value"))
require.EqualError(t, err, "failure while putting document into CouchDB database: maximum number of "+
"retry attempts (3) exceeded: failed to put value via client: Conflict: Document update conflict.")
})
t.Run("Other error while putting value via client", func(t *testing.T) {
store := &store{
db: &mockDB{
errPut: errors.New("other error"),
getRowBodyData: `{"_rev":"SomeRevID"}`,
},
maxDocumentConflictRetries: 3, marshal: json.Marshal,
}
err := store.Put("key", []byte("value"))
require.EqualError(t, err, "failure while putting document into CouchDB database: failed to put value via "+
"client: other error")
})
t.Run("Fail to get revision ID", func(t *testing.T) {
store := &store{
db: &mockDB{
errGetRow: errors.New("get error"),
},
maxDocumentConflictRetries: 3, marshal: json.Marshal,
}
err := store.Put("key", []byte("value"))
require.EqualError(t, err, "failure while putting document into CouchDB database: "+
"failed to get revision ID: get error")
})
} | explode_data.jsonl/72581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 535
} | [
2830,
3393,
6093,
1088,
332,
37238,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
7524,
2647,
12055,
25,
12488,
7192,
1372,
315,
60601,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
57279,
1669,
609,
4314,
515,
298,
20939,
25,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTypeSystem_ObjectsMustAdhereToInterfaceTheyImplement_AcceptsAnObjectWhichImplementsAnInterface(t *testing.T) {
anotherInterface := graphql.NewInterface(graphql.InterfaceConfig{
Name: "AnotherInterface",
ResolveType: func(p graphql.ResolveTypeParams) *graphql.Object {
return nil
},
Fields: graphql.Fields{
"field": &graphql.Field{
Type: graphql.String,
Args: graphql.FieldConfigArgument{
"input": &graphql.ArgumentConfig{
Type: graphql.String,
},
},
},
},
})
anotherObject := graphql.NewObject(graphql.ObjectConfig{
Name: "AnotherObject",
Interfaces: []*graphql.Interface{anotherInterface},
Fields: graphql.Fields{
"field": &graphql.Field{
Type: graphql.String,
Args: graphql.FieldConfigArgument{
"input": &graphql.ArgumentConfig{
Type: graphql.String,
},
},
},
},
})
_, err := schemaWithObjectFieldOfType(anotherObject)
if err != nil {
t.Fatalf(`unexpected error: %v for type "%v"`, err, anotherObject)
}
} | explode_data.jsonl/79192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 413
} | [
2830,
3393,
929,
2320,
62,
11543,
31776,
2589,
6739,
1249,
5051,
6865,
62980,
1566,
66,
57771,
2082,
1190,
23085,
1427,
4674,
2082,
5051,
1155,
353,
8840,
836,
8,
341,
197,
41963,
5051,
1669,
48865,
7121,
5051,
24312,
1470,
41065,
2648,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_checkEnvForSecret(t *testing.T) {
type args struct {
num int
}
tests := []struct {
name string
args args
want string
want1 string
}{
{
name: "err_input",
args: args{
num: -1,
},
want: "",
want1: "",
},
{
name: "ali_env",
args: args{
num: 0,
},
want: "aliyun_env_id",
want1: "aliyun_env_sec",
},
{
name: "ten_env",
args: args{
num: 1,
},
want: "ten_env_id",
want1: "ten_env_sec",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
switch tt.name {
case "ali_env":
os.Setenv("ACCESS_KEY_ID", "aliyun_env_id")
os.Setenv("ACCESS_KEY_SECRET", "aliyun_env_sec")
case "ten_env":
os.Setenv("TENCENTCLOUD_SECRET_ID", "ten_env_id")
os.Setenv("TENCENTCLOUD_SECRET_KEY", "ten_env_sec")
}
got, got1 := checkEnvForSecret(tt.args.num)
if got != tt.want {
t.Errorf("checkEnvForSecret() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("checkEnvForSecret() got1 = %v, want %v", got1, tt.want1)
}
})
}
} | explode_data.jsonl/53711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 579
} | [
2830,
3393,
7200,
14359,
2461,
19773,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
22431,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
31215,
220,
2827,
198,
197,
50780,
220,
914,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDeepClone(t *testing.T) {
tp := types.NewFieldType(mysql.TypeLonglong)
expr := &expression.Column{RetType: tp}
byItems := []*util.ByItems{{Expr: expr}}
sort1 := &PhysicalSort{ByItems: byItems}
sort2 := &PhysicalSort{ByItems: byItems}
checkDeepClone := func(p1, p2 PhysicalPlan) error {
whiteList := []string{"*property.StatsInfo", "*sessionctx.Context", "*mock.Context"}
return checkDeepClonedCore(reflect.ValueOf(p1), reflect.ValueOf(p2), typeName(reflect.TypeOf(p1)), whiteList, nil)
}
err := checkDeepClone(sort1, sort2)
require.Error(t, err)
require.Regexp(t, "invalid slice pointers, path PhysicalSort.ByItems", err.Error())
byItems2 := []*util.ByItems{{Expr: expr}}
sort2.ByItems = byItems2
err = checkDeepClone(sort1, sort2)
require.Error(t, err)
require.Regexp(t, "same pointer, path PhysicalSort.ByItems.*Expression", err.Error())
expr2 := &expression.Column{RetType: tp}
byItems2[0].Expr = expr2
err = checkDeepClone(sort1, sort2)
require.Error(t, err)
require.Regexp(t, "same pointer, path PhysicalSort.ByItems.*Expression.FieldType", err.Error())
expr2.RetType = types.NewFieldType(mysql.TypeString)
err = checkDeepClone(sort1, sort2)
require.Error(t, err)
require.Regexp(t, "different values, path PhysicalSort.ByItems.*Expression.FieldType.uint8", err.Error())
expr2.RetType = types.NewFieldType(mysql.TypeLonglong)
require.NoError(t, checkDeepClone(sort1, sort2))
} | explode_data.jsonl/25788 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 526
} | [
2830,
3393,
33464,
37677,
1155,
353,
8840,
836,
8,
341,
73423,
1669,
4494,
7121,
63733,
41546,
10184,
6583,
4825,
340,
8122,
649,
1669,
609,
28099,
6153,
90,
12020,
929,
25,
18101,
532,
197,
1694,
4353,
1669,
29838,
1314,
48906,
4353,
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 TestGetMembersResponseValueError(t *testing.T) {
assert := assert.New(t)
pn := NewPubNub(NewDemoConfig())
opts := &getMembersOpts{
pubnub: pn,
}
jsonBytes := []byte(`s`)
_, _, err := newPNGetMembersResponse(jsonBytes, opts, StatusResponse{})
assert.Equal("pubnub/parsing: Error unmarshalling response: {s}", err.Error())
} | explode_data.jsonl/11590 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
1949,
24371,
2582,
1130,
1454,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
3223,
77,
1669,
1532,
29162,
45,
392,
35063,
37413,
2648,
2398,
64734,
1669,
609,
455,
24371,
43451,
515,
197,
62529,
77,
392,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTimeToBCE(t *testing.T) {
tm, err := time.Parse("2006-01-02", "1970-01-01")
if err != nil {
t.Fatal(err)
}
tm = TimeToBCE(tm)
if tm.Year() != -1970 {
t.Fatalf("Failed to convert time to BCE. Expected -1970 but got '%d'", tm.Year())
}
} | explode_data.jsonl/2167 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
1462,
1249,
33,
2104,
1155,
353,
8840,
836,
8,
1476,
3244,
76,
11,
1848,
1669,
882,
8937,
445,
17,
15,
15,
21,
12,
15,
16,
12,
15,
17,
497,
330,
16,
24,
22,
15,
12,
15,
16,
12,
15,
16,
5130,
743,
1848,
961,
2092,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFloatReturn(t *testing.T) {
if _, err := exec.LookPath("gcc"); err != nil {
t.Skip("skipping test: gcc is missing")
}
if runtime.GOARCH != "amd64" {
t.Skipf("skipping test: GOARCH=%s", runtime.GOARCH)
}
const src = `
#include <stdint.h>
#include <windows.h>
float cfuncFloat(uintptr_t a, double b, float c, double d) {
if (a == 1 && b == 2.2 && c == 3.3f && d == 4.4e44) {
return 1.5f;
}
return 0;
}
double cfuncDouble(uintptr_t a, double b, float c, double d) {
if (a == 1 && b == 2.2 && c == 3.3f && d == 4.4e44) {
return 2.5;
}
return 0;
}
`
tmpdir := t.TempDir()
srcname := "mydll.c"
err := os.WriteFile(filepath.Join(tmpdir, srcname), []byte(src), 0)
if err != nil {
t.Fatal(err)
}
outname := "mydll.dll"
cmd := exec.Command("gcc", "-shared", "-s", "-Werror", "-o", outname, srcname)
cmd.Dir = tmpdir
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("failed to build dll: %v - %v", err, string(out))
}
dllpath := filepath.Join(tmpdir, outname)
dll := syscall.MustLoadDLL(dllpath)
defer dll.Release()
proc := dll.MustFindProc("cfuncFloat")
_, r, err := proc.Call(
1,
uintptr(math.Float64bits(2.2)),
uintptr(math.Float32bits(3.3)),
uintptr(math.Float64bits(4.4e44)),
)
fr := math.Float32frombits(uint32(r))
if fr != 1.5 {
t.Errorf("got %f want 1.5 (err=%v)", fr, err)
}
proc = dll.MustFindProc("cfuncDouble")
_, r, err = proc.Call(
1,
uintptr(math.Float64bits(2.2)),
uintptr(math.Float32bits(3.3)),
uintptr(math.Float64bits(4.4e44)),
)
dr := math.Float64frombits(uint64(r))
if dr != 2.5 {
t.Errorf("got %f want 2.5 (err=%v)", dr, err)
}
} | explode_data.jsonl/82616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 742
} | [
2830,
3393,
5442,
5598,
1155,
353,
8840,
836,
8,
341,
743,
8358,
1848,
1669,
3883,
36851,
1820,
445,
70983,
5038,
1848,
961,
2092,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
25,
50917,
374,
7402,
1138,
197,
532,
743,
15592,
97574,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetResourcesWithoutApp(t *testing.T) {
const appStream = `
{
}
`
preparePolicyDataInStore([]byte(appStream), t)
evaluator, err := NewWithStore(conf, testPS)
if err != nil {
t.Errorf("Unable to initialize evaluator due to error [%v].", err)
return
}
subject := adsapi.Subject{
Principals: []*adsapi.Principal{
&adsapi.Principal{
Type: adsapi.PRINCIPAL_TYPE_USER,
Name: "bill",
},
},
}
_, err = evaluator.GetAllGrantedPermissions(adsapi.RequestContext{Subject: &subject, ServiceName: "dummy"})
if err == nil {
t.Fatalf("Error should be returned without an application.")
return
}
t.Logf("Returned error [%v].", err)
} | explode_data.jsonl/48852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
1949,
11277,
26040,
2164,
1155,
353,
8840,
836,
8,
341,
4777,
906,
3027,
284,
22074,
197,
515,
197,
532,
197,
19324,
197,
13609,
13825,
1043,
641,
6093,
10556,
3782,
11462,
3027,
701,
259,
692,
7727,
52389,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestContextWithoutDeadline(t *testing.T) {
ctxWithDeadline, cancelWithDeadline := context.WithTimeout(context.Background(), time.Minute)
defer cancelWithDeadline()
tr, ctxWithDeadline := trace.New(ctxWithDeadline, "", "")
if _, ok := ctxWithDeadline.Deadline(); !ok {
t.Fatal("expected context to have deadline")
}
ctxNoDeadline, cancelNoDeadline := contextWithoutDeadline(ctxWithDeadline)
defer cancelNoDeadline()
if _, ok := ctxNoDeadline.Deadline(); ok {
t.Fatal("expected context to not have deadline")
}
// We want to keep trace info
if tr2 := trace.TraceFromContext(ctxNoDeadline); tr != tr2 {
t.Error("trace information not propogated")
}
// Calling cancelWithDeadline should cancel ctxNoDeadline
cancelWithDeadline()
select {
case <-ctxNoDeadline.Done():
case <-time.After(10 * time.Second):
t.Fatal("expected context to be done")
}
} | explode_data.jsonl/52669 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
1972,
26040,
83593,
1155,
353,
8840,
836,
8,
341,
20985,
2354,
83593,
11,
9121,
2354,
83593,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
882,
75770,
340,
16867,
9121,
2354,
83593,
2822,
25583,
11,
5635,
2354,
83593,
1669,
1165... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeePrefix(t *testing.T) {
var in bytes.Buffer
var out bytes.Buffer
var logged strings.Builder
logSink := func(format string, args ...interface{}) {
logged.WriteString("(" + fmt.Sprintf(format, args...) + ")")
}
// Simulate the primary use case: tee in the background. This also helps avoid I/O races.
var wg sync.WaitGroup
wg.Add(1)
go func() {
TeePrefix(":", &in, &out, logSink)
wg.Done()
}()
in.Write([]byte("goo"))
in.Write([]byte("\n"))
in.Write([]byte("g\r\n\r\n"))
in.Write([]byte("le"))
wg.Wait()
gotBytes := out.Bytes()
wantBytes := []byte("goo\ng\r\n\r\nle")
if !bytes.Equal(gotBytes, wantBytes) {
t.Errorf("output=%q, want: %q", gotBytes, wantBytes)
}
gotLog := logged.String()
wantLog := "(:goo)(:g)(:le)"
if gotLog != wantLog {
t.Errorf("log=%q, want: %q", gotLog, wantLog)
}
} | explode_data.jsonl/30073 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
51,
2127,
14335,
1155,
353,
8840,
836,
8,
341,
2405,
304,
5820,
22622,
198,
2405,
700,
5820,
22622,
198,
2405,
13726,
9069,
15641,
271,
6725,
45094,
1669,
2915,
20698,
914,
11,
2827,
2503,
4970,
28875,
341,
197,
6725,
3556,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExecutorStartCommit(t *testing.T) {
txe, tsv, db := newTestTxExecutor(t)
defer db.Close()
defer tsv.StopService()
commitTransition := fmt.Sprintf("update _vt.dt_state set state = %d where dtid = 'aa' and state = %d", int(querypb.TransactionState_COMMIT), int(querypb.TransactionState_PREPARE))
db.AddQuery(commitTransition, &sqltypes.Result{RowsAffected: 1})
txid := newTxForPrep(tsv)
err := txe.StartCommit(txid, "aa")
require.NoError(t, err)
db.AddQuery(commitTransition, &sqltypes.Result{})
txid = newTxForPrep(tsv)
err = txe.StartCommit(txid, "aa")
require.Error(t, err)
require.Contains(t, err.Error(), "could not transition to COMMIT: aa")
} | explode_data.jsonl/25172 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
25255,
3479,
33441,
1155,
353,
8840,
836,
8,
341,
3244,
8371,
11,
259,
3492,
11,
2927,
1669,
501,
2271,
31584,
25255,
1155,
340,
16867,
2927,
10421,
741,
16867,
259,
3492,
30213,
1860,
2822,
197,
17413,
21768,
1669,
8879,
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 TestCreateFromEmptyConfig(t *testing.T) {
var configData []byte
var policy schedulerapi.Policy
client := fake.NewSimpleClientset()
stopCh := make(chan struct{})
defer close(stopCh)
factory := newConfigFactory(client, v1.DefaultHardPodAffinitySymmetricWeight, stopCh)
configData = []byte(`{}`)
if err := runtime.DecodeInto(scheme.Codecs.UniversalDecoder(), configData, &policy); err != nil {
t.Errorf("Invalid configuration: %v", err)
}
factory.createFromConfig(policy)
wantConfig := []schedulerapi.PluginConfig{
{
Name: noderesources.FitName,
Args: runtime.Unknown{Raw: []byte(`null`)},
},
{
Name: interpodaffinity.Name,
Args: runtime.Unknown{Raw: []byte(`{"hardPodAffinityWeight":1}`)},
},
}
if diff := cmp.Diff(wantConfig, factory.pluginConfig); diff != "" {
t.Errorf("wrong plugin config (-want, +got): %s", diff)
}
} | explode_data.jsonl/39425 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
4021,
3830,
3522,
2648,
1155,
353,
8840,
836,
8,
341,
2405,
2193,
1043,
3056,
3782,
198,
2405,
4842,
28809,
2068,
1069,
8018,
271,
25291,
1669,
12418,
7121,
16374,
2959,
746,
741,
62644,
1143,
1669,
1281,
35190,
2036,
37790,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetadataSet(t *testing.T) {
t.Run("single set on existing key", func(t *testing.T) {
metadata := NewMetadata([]string{"testKey"}, []string{"testValue"})
expected := NewMetadata([]string{"testKey"}, []string{"updatedValue"})
res := metadata.Set("testKey", "updatedValue")
assert.Equal(t, expected, res, "expected %q have %q", expected.String(), res.String())
})
t.Run("single set on new key", func(t *testing.T) {
metadata := NewMetadata([]string{"testKey1"}, []string{"testValue1"})
expected := NewMetadata([]string{"testKey1", "testKey2"}, []string{"testValue1", "testValue2"})
res := metadata.Set("testKey2", "testValue2")
assert.Equal(t, expected, res, "expected %q have %q", expected.String(), res.String())
})
} | explode_data.jsonl/49107 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
14610,
1649,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
15338,
738,
389,
6350,
1376,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2109,
7603,
1669,
1532,
14610,
10556,
917,
4913,
1944,
1592,
14345,
3056,
917,
4913,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrivateActivityYesHeatmapVisibleForUserItselfAtDashboard(t *testing.T) {
defer prepareTestEnv(t)()
testPrivateActivityDoSomethingForActionEntries(t)
testPrivateActivityHelperEnablePrivateActivity(t)
session := loginUser(t, privateActivityTestUser)
visible := testPrivateActivityHelperHasVisibleDashboardHeatmapFromSession(t, session)
assert.True(t, visible, "user should have visible heatmap")
} | explode_data.jsonl/51660 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
16787,
4052,
9454,
61306,
2186,
5715,
2461,
1474,
2132,
721,
1655,
26947,
1155,
353,
8840,
836,
8,
341,
16867,
10549,
2271,
14359,
1155,
8,
741,
18185,
16787,
4052,
5404,
23087,
2461,
2512,
24533,
1155,
340,
18185,
16787,
4052... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlainEncodeInt32s(t *testing.T) {
testCases := []struct {
i32s []int32
expectedResult []byte
}{
{nil, []byte{}},
{[]int32{}, []byte{}},
{[]int32{1}, []byte{1, 0, 0, 0}},
{[]int32{-1}, []byte{255, 255, 255, 255}},
{[]int32{256}, []byte{0, 1, 0, 0}},
{[]int32{math.MinInt32}, []byte{0, 0, 0, 128}},
{[]int32{math.MaxInt32}, []byte{255, 255, 255, 127}},
{[]int32{257, -2}, []byte{1, 1, 0, 0, 254, 255, 255, 255}},
}
for i, testCase := range testCases {
result := plainEncodeInt32s(testCase.i32s)
if !reflect.DeepEqual(result, testCase.expectedResult) {
t.Fatalf("case %v: expected: %v, got: %v", i+1, testCase.expectedResult, result)
}
}
} | explode_data.jsonl/28455 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
26982,
32535,
1072,
18,
17,
82,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
8230,
18,
17,
82,
1843,
3056,
396,
18,
17,
198,
197,
42400,
2077,
3056,
3782,
198,
197,
59403,
197,
197,
90,
8385,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInviasms(t *testing.T) {
type formati []struct {
Numcell string
Valido bool
}
var numeri formati
numeri = formati{
{Numcell: "3353458144", Valido: false},
{Numcell: "+383353458144", Valido: false},
{Numcell: "+38335345814", Valido: false},
{Numcell: "+393353458144", Valido: true},
}
for _, num := range numeri {
result, err := Inviasms(num.Numcell, "prova")
if result != "201 CREATED" {
t.Skip("Bisogna settare le variabili")
}
if err != nil {
t.Skip(fmt.Println(err.Error()))
}
}
} | explode_data.jsonl/72722 | {
"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,
15174,
3473,
1011,
1155,
353,
8840,
836,
8,
341,
13158,
3561,
72,
3056,
1235,
341,
197,
197,
4651,
5873,
914,
198,
197,
197,
4088,
78,
220,
1807,
198,
197,
630,
2405,
7857,
72,
3561,
72,
198,
22431,
30703,
284,
3561,
72,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestParsePrometheusRules(t *testing.T) {
prometheusRules, err := parsePrometheusRule(localPrometheusRules)
assert.NilError(t, err)
assert.Equal(t, 11, len(prometheusRules.Spec.Groups))
prometheusRules, err = parsePrometheusRule(externalPrometheusRules)
assert.NilError(t, err)
assert.Equal(t, 1, len(prometheusRules.Spec.Groups))
} | explode_data.jsonl/16371 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
14463,
35186,
39705,
26008,
1155,
353,
8840,
836,
8,
341,
3223,
441,
39705,
26008,
11,
1848,
1669,
4715,
35186,
39705,
11337,
18082,
35186,
39705,
26008,
340,
6948,
59678,
1454,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestServicependant(t *testing.T) {
convey.Convey("pendant", t, func() {
err := s.pendant(context.Background(), nil, 0, "", nil)
convey.So(err, convey.ShouldBeNil)
})
} | explode_data.jsonl/21131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
1860,
3740,
517,
1155,
353,
8840,
836,
8,
341,
37203,
5617,
4801,
5617,
445,
3740,
517,
497,
259,
11,
2915,
368,
341,
197,
9859,
1669,
274,
556,
20372,
5378,
19047,
1507,
2092,
11,
220,
15,
11,
7342,
2092,
340,
197,
3720... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatPort(t *testing.T) {
require.Equal(t, ":3000", FormatPort(3000))
require.Equal(t, ":6739", FormatPort(6739))
require.Equal(t, ":8080", FormatPort(8080))
} | explode_data.jsonl/6910 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
4061,
7084,
1155,
353,
8840,
836,
8,
341,
17957,
12808,
1155,
11,
13022,
18,
15,
15,
15,
497,
15042,
7084,
7,
18,
15,
15,
15,
1171,
17957,
12808,
1155,
11,
13022,
21,
22,
18,
24,
497,
15042,
7084,
7,
21,
22,
18,
24,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWithTracesUnmarshalers(t *testing.T) {
unmarshaler := &customTracesUnmarshaler{}
f := NewFactory(WithTracesUnmarshalers(unmarshaler))
cfg := createDefaultConfig().(*Config)
// disable contacting broker
cfg.Metadata.Full = false
cfg.ProtocolVersion = "2.0.0"
t.Run("custom_encoding", func(t *testing.T) {
cfg.Encoding = unmarshaler.Encoding()
receiver, err := f.CreateTracesReceiver(context.Background(), componenttest.NewNopReceiverCreateSettings(), cfg, nil)
require.NoError(t, err)
require.NotNil(t, receiver)
})
t.Run("default_encoding", func(t *testing.T) {
cfg.Encoding = defaultEncoding
receiver, err := f.CreateTracesReceiver(context.Background(), componenttest.NewNopReceiverCreateSettings(), cfg, nil)
require.NoError(t, err)
assert.NotNil(t, receiver)
})
} | explode_data.jsonl/70855 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
2354,
1282,
2434,
1806,
27121,
388,
1155,
353,
8840,
836,
8,
341,
20479,
27121,
261,
1669,
609,
9163,
1282,
2434,
1806,
27121,
261,
16094,
1166,
1669,
1532,
4153,
7,
2354,
1282,
2434,
1806,
27121,
388,
18364,
27121,
261,
117... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVendorAppSdkVersion(t *testing.T) {
testCases := []struct {
name string
sdkVersion string
platformSdkInt int
platformSdkCodename string
platformSdkFinal bool
deviceCurrentApiLevelForVendorModules string
expectedMinSdkVersion string
}{
{
name: "current final SDK",
sdkVersion: "current",
platformSdkInt: 29,
platformSdkCodename: "REL",
platformSdkFinal: true,
deviceCurrentApiLevelForVendorModules: "29",
expectedMinSdkVersion: "29",
},
{
name: "current final SDK",
sdkVersion: "current",
platformSdkInt: 29,
platformSdkCodename: "REL",
platformSdkFinal: true,
deviceCurrentApiLevelForVendorModules: "28",
expectedMinSdkVersion: "28",
},
{
name: "current final SDK",
sdkVersion: "current",
platformSdkInt: 29,
platformSdkCodename: "Q",
platformSdkFinal: false,
deviceCurrentApiLevelForVendorModules: "28",
expectedMinSdkVersion: "28",
},
}
for _, moduleType := range []string{"android_app", "android_library"} {
for _, sdkKind := range []string{"", "system_"} {
for _, test := range testCases {
t.Run(moduleType+" "+test.name, func(t *testing.T) {
bp := fmt.Sprintf(`%s {
name: "foo",
srcs: ["a.java"],
sdk_version: "%s%s",
vendor: true,
}`, moduleType, sdkKind, test.sdkVersion)
result := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Platform_sdk_version = &test.platformSdkInt
variables.Platform_sdk_codename = &test.platformSdkCodename
variables.Platform_sdk_final = &test.platformSdkFinal
variables.DeviceCurrentApiLevelForVendorModules = &test.deviceCurrentApiLevelForVendorModules
variables.DeviceSystemSdkVersions = []string{"28", "29"}
}),
FixtureWithPrebuiltApis(map[string][]string{
"28": {"foo"},
"29": {"foo"},
"current": {"foo"},
}),
).RunTestWithBp(t, bp)
checkSdkVersion(t, result, test.expectedMinSdkVersion)
})
}
}
}
} | explode_data.jsonl/58488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1457
} | [
2830,
3393,
44691,
2164,
57175,
5637,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
6656,
914,
198,
197,
1903,
7584,
5637,
999,
914,
198,
197,
197,
15734,
57175,
1072,
664,
526,
198,
197,
197,
15734,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSigningBad(t *testing.T) {
msp, err := setup("testdata/idemix/MSP1OU1", "MSP1OU1")
assert.NoError(t, err)
id, err := getDefaultSigner(msp)
assert.NoError(t, err)
msg := []byte("TestMessage")
sig := []byte("barf")
err = id.Verify(msg, sig)
assert.Error(t, err)
assert.Contains(t, err.Error(), "error unmarshalling signature")
} | explode_data.jsonl/46031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
93358,
17082,
1155,
353,
8840,
836,
8,
341,
47691,
79,
11,
1848,
1669,
6505,
445,
92425,
38146,
336,
941,
10270,
4592,
16,
11922,
16,
497,
330,
44,
4592,
16,
11922,
16,
1138,
6948,
35699,
1155,
11,
1848,
692,
15710,
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 TestPreAuthorizeContentTypeFailure(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte(`{"hello":"world"}`))
require.NoError(t, err, "write auth response")
}))
defer ts.Close()
runPreAuthorizeHandler(
t, ts, "/authorize",
regexp.MustCompile(`/authorize\z`),
"",
200, 200)
} | explode_data.jsonl/2403 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
4703,
37483,
29504,
17507,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
197,
6878,
1848,
1669,
289,
4073,
10556,
3782,
58... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFuncArg(t *testing.T) {
f1 := func(i int, f func(int) int) int { return f(i) }
f2 := func(i int) int { return i + 1 }
r := ValueOf(f1).Call([]Value{ValueOf(100), ValueOf(f2)})
if r[0].Int() != 101 {
t.Errorf("function returned %d, want 101", r[0].Int())
}
} | explode_data.jsonl/29581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
9626,
2735,
1155,
353,
8840,
836,
8,
341,
1166,
16,
1669,
2915,
1956,
526,
11,
282,
2915,
1548,
8,
526,
8,
526,
314,
470,
282,
1956,
8,
456,
1166,
17,
1669,
2915,
1956,
526,
8,
526,
314,
470,
600,
488,
220,
16,
456,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCompactionTombstones(t *testing.T) {
var d *DB
defer func() {
if d != nil {
require.NoError(t, d.Close())
}
}()
var compactInfo *CompactionInfo // protected by d.mu
compactionString := func() string {
for d.mu.compact.compactingCount > 0 {
d.mu.compact.cond.Wait()
}
s := "(none)"
if compactInfo != nil {
// JobID's aren't deterministic, especially w/ table stats
// enabled. Use a fixed job ID for data-driven test output.
compactInfo.JobID = 100
s = compactInfo.String()
compactInfo = nil
}
return s
}
datadriven.RunTest(t, "testdata/compaction_tombstones",
func(td *datadriven.TestData) string {
switch td.Cmd {
case "define":
if d != nil {
compactInfo = nil
if err := d.Close(); err != nil {
return err.Error()
}
}
opts := &Options{
FS: vfs.NewMem(),
DebugCheck: DebugCheckLevels,
EventListener: EventListener{
CompactionEnd: func(info CompactionInfo) {
compactInfo = &info
},
},
}
var err error
d, err = runDBDefineCmd(td, opts)
if err != nil {
return err.Error()
}
d.mu.Lock()
t := time.Now()
d.timeNow = func() time.Time {
t = t.Add(time.Second)
return t
}
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
d.mu.Unlock()
return s
case "maybe-compact":
d.mu.Lock()
d.opts.private.disableAutomaticCompactions = false
d.maybeScheduleCompaction()
s := compactionString()
d.mu.Unlock()
return s
case "wait-pending-table-stats":
return runTableStatsCmd(td, d)
case "close-snapshot":
seqNum, err := strconv.ParseUint(strings.TrimSpace(td.Input), 0, 64)
if err != nil {
return err.Error()
}
d.mu.Lock()
var s *Snapshot
l := &d.mu.snapshots
for i := l.root.next; i != &l.root; i = i.next {
if i.seqNum == seqNum {
s = i
}
}
d.mu.Unlock()
if s == nil {
return "(not found)"
} else if err := s.Close(); err != nil {
return err.Error()
}
d.mu.Lock()
// Closing the snapshot may have triggered a compaction.
str := compactionString()
d.mu.Unlock()
return str
case "version":
d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
d.mu.Unlock()
return s
default:
return fmt.Sprintf("unknown command: %s", td.Cmd)
}
})
} | explode_data.jsonl/51408 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1128
} | [
2830,
3393,
13552,
1311,
51,
2855,
32510,
1155,
353,
8840,
836,
8,
341,
2405,
294,
353,
3506,
198,
16867,
2915,
368,
341,
197,
743,
294,
961,
2092,
341,
298,
17957,
35699,
1155,
11,
294,
10421,
2398,
197,
197,
532,
197,
66816,
2405,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppLogLevel(t *testing.T) {
dbfile := tests.Tempfile()
defer os.Remove(dbfile)
levels := []string{
"none",
"critical",
"error",
"warning",
"info",
"debug",
}
logger.SetLevel(logging.LEVEL_DEBUG)
for _, level := range levels {
conf := &GlusterFSConfig{
Executor: "mock",
Allocator: "simple",
DBfile: dbfile,
Loglevel: level,
}
app := NewApp(conf)
tests.Assert(t, app != nil, "expected app != nil, got:", app)
switch level {
case "none":
tests.Assert(t, logger.Level() == logging.LEVEL_NOLOG)
case "critical":
tests.Assert(t, logger.Level() == logging.LEVEL_CRITICAL)
case "error":
tests.Assert(t, logger.Level() == logging.LEVEL_ERROR)
case "warning":
tests.Assert(t, logger.Level() == logging.LEVEL_WARNING)
case "info":
tests.Assert(t, logger.Level() == logging.LEVEL_INFO)
case "debug":
tests.Assert(t, logger.Level() == logging.LEVEL_DEBUG)
}
app.Close()
}
// Test that an unknown value does not change the loglevel
logger.SetLevel(logging.LEVEL_NOLOG)
conf := &GlusterFSConfig{
Executor: "mock",
Allocator: "simple",
DBfile: dbfile,
Loglevel: "blah",
}
app := NewApp(conf)
defer app.Close()
tests.Assert(t, app != nil)
tests.Assert(t, logger.Level() == logging.LEVEL_NOLOG)
} | explode_data.jsonl/51870 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 550
} | [
2830,
3393,
2164,
72676,
1155,
353,
8840,
836,
8,
341,
20939,
1192,
1669,
7032,
65009,
1192,
741,
16867,
2643,
13270,
9791,
1192,
692,
197,
42564,
1669,
3056,
917,
515,
197,
197,
1,
6697,
756,
197,
197,
1,
41541,
756,
197,
197,
1,
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... | 8 |
func TestExportFixedPointValuesFromScript(t *testing.T) {
t.Parallel()
test := func(fixedPointType sema.Type) {
t.Run(fixedPointType.String(), func(t *testing.T) {
t.Parallel()
script := fmt.Sprintf(
`
pub fun main(): %s {
return 1.23
}
`,
fixedPointType,
)
assert.NotPanics(t, func() {
exportValueFromScript(t, script)
})
})
}
for _, fixedPointType := range sema.AllFixedPointTypes {
test(fixedPointType)
}
} | explode_data.jsonl/4622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
16894,
13520,
2609,
6227,
3830,
5910,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
18185,
1669,
2915,
955,
3286,
2609,
929,
5234,
64,
10184,
8,
1476,
197,
3244,
16708,
955,
3286,
2609,
929,
6431,
1507,
2915,
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 TestJoin(t *testing.T) {
s := &mock.Snap{
CA: "CA CERTIFICATE DATA",
ServiceArguments: map[string]string{
"etcd": "--listen-client-urls=https://0.0.0.0:12379",
"kube-apiserver": "--secure-port 16443",
"kubelet": "kubelet arguments\n",
},
ClusterTokens: []string{"valid-cluster-token", "valid-other-token"},
KnownTokens: map[string]string{
"admin": "admin-token",
"system:kube-proxy": "kube-proxy-token",
},
}
apiv1 := &v1.API{
Snap: s,
LookupIP: net.LookupIP,
}
t.Run("InvalidToken", func(t *testing.T) {
resp, err := apiv1.Join(context.Background(), v1.JoinRequest{
ClusterToken: "invalid-token",
})
if resp != nil {
t.Fatalf("Expected a nil response due to invalid token, but got %#v\n", resp)
}
if err == nil {
t.Fatal("Expected an error due to invalid token, but did not get any")
}
if !reflect.DeepEqual(s.ConsumeClusterTokenCalledWith, []string{"invalid-token"}) {
t.Fatalf("Expected ConsumeClusterToken to be called with %v, but it was called with %v instead", []string{"invalid-token"}, s.ConsumeClusterTokenCalledWith)
}
})
t.Run("Dqlite", func(t *testing.T) {
s.DqliteLock = true
resp, err := apiv1.Join(context.Background(), v1.JoinRequest{
ClusterToken: "valid-other-token",
})
if resp != nil {
t.Fatalf("Expected a nil response due to kubelite lock, but got %#v\n", resp)
}
if err == nil {
t.Fatal("Expected an error due to kubelite lock, but did not get any")
}
s.DqliteLock = false
})
t.Run("Success", func(t *testing.T) {
s.ConsumeClusterTokenCalledWith = nil
resp, err := apiv1.Join(context.Background(), v1.JoinRequest{
ClusterToken: "valid-cluster-token",
HostName: "my-hostname",
ClusterAgentPort: "25000",
RemoteAddress: "10.10.10.10:41422",
CallbackToken: "callback-token",
})
if err != nil {
t.Fatalf("Expected no errors, but got %s", err)
}
if resp == nil {
t.Fatal("Expected non-nil response")
}
expectedResponse := &v1.JoinResponse{
CertificateAuthority: "CA CERTIFICATE DATA",
EtcdEndpoint: "https://0.0.0.0:12379",
APIServerPort: "16443",
KubeProxyToken: "kube-proxy-token",
KubeletArgs: "kubelet arguments\n\n--hostname-override=10.10.10.10",
KubeletToken: resp.KubeletToken,
HostNameOverride: "10.10.10.10",
}
if *resp != *expectedResponse {
t.Fatalf("Expected response %#v, but it was %#v", expectedResponse, resp)
}
if len(resp.KubeletToken) != 32 {
t.Fatalf("Expected kubelet token %q to have length 32", resp.KubeletToken)
}
if !reflect.DeepEqual(s.ConsumeClusterTokenCalledWith, []string{"valid-cluster-token"}) {
t.Fatalf("Expected ConsumeClusterToken to be called with %v, but it was called with %v instead", []string{"valid-cluster-token"}, s.ConsumeClusterTokenCalledWith)
}
if !reflect.DeepEqual(s.RestartServiceCalledWith, []string{"apiserver"}) {
t.Fatalf("Expected API server restart command, but got %v instead", s.RestartServiceCalledWith)
}
kubeletToken, err := s.GetOrCreateKubeletToken("10.10.10.10")
if err != nil {
t.Fatalf("Expected no error when retrieving kubelet token, but received %q", err)
}
if kubeletToken != resp.KubeletToken {
t.Fatalf("Expected kubelet known token to match response, but they do not (%q != %q)", kubeletToken, resp.KubeletToken)
}
if !reflect.DeepEqual(s.AddCallbackTokenCalledWith, []string{"10.10.10.10:25000 callback-token"}) {
t.Fatal("Expected callback-token to be a valid callback token, but it is not")
}
if !reflect.DeepEqual(s.AddCertificateRequestTokenCalledWith, []string{"valid-cluster-token"}) {
t.Fatal("Expected valid-cluster-token to be a valid certificate request token, but it is not")
}
if len(s.CreateNoCertsReissueLockCalledWith) != 1 {
t.Fatal("Expected certificate reissue lock to be in place after successful join, but it is not")
}
})
} | explode_data.jsonl/80543 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1636
} | [
2830,
3393,
12292,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
609,
16712,
808,
6861,
515,
197,
197,
5049,
25,
330,
5049,
62357,
82023,
14112,
756,
197,
91619,
19139,
25,
2415,
14032,
30953,
515,
298,
197,
1,
295,
4385,
788,
1843,
14482... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchemaParser_UnionWithTwoTypes(t *testing.T) {
body := `union Hello = Wo | Rld`
astDoc := parse(t, body)
expected := &ast.Document{
Loc: testLoc(0, 22),
Definitions: []ast.Node{
&ast.UnionDefinition{
Loc: testLoc(0, 22),
Name: &ast.Name{
Value: "Hello",
Loc: testLoc(6, 11),
},
Types: []*ast.Named{
{
Loc: testLoc(14, 16),
Name: &ast.Name{
Value: "Wo",
Loc: testLoc(14, 16),
},
},
{
Loc: testLoc(19, 22),
Name: &ast.Name{
Value: "Rld",
Loc: testLoc(19, 22),
},
},
},
},
},
}
if !reflect.DeepEqual(astDoc, expected) {
t.Fatalf("unexpected document, expected: %v, got: %v", expected, astDoc)
}
} | explode_data.jsonl/51230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
8632,
6570,
62,
32658,
2354,
11613,
4173,
1155,
353,
8840,
836,
8,
341,
35402,
1669,
1565,
16192,
21927,
284,
27258,
760,
431,
507,
3989,
88836,
9550,
1669,
4715,
1155,
11,
2487,
340,
42400,
1669,
609,
559,
26256,
515,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestValidate_AnonymousOperationMustBeAlone_AnonOperationWithAMutation(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.LoneAnonymousOperationRule, `
{
fieldA
}
mutation Foo {
fieldB
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`This anonymous operation must be the only defined operation.`, 2, 7),
})
} | explode_data.jsonl/78447 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
17926,
1566,
6280,
89392,
8432,
31776,
3430,
2101,
603,
1566,
6280,
8432,
2354,
1402,
22705,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
81893,
37,
6209,
11337,
1155,
11,
48865,
1214,
603,
32684,
8432,
11337,
11,
22074,
414,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDelete(t *testing.T) {
parent, _ := zfs.GetDataset("test/volumes")
p := NewZFSProvisioner(parent, "rw=@127.0.0.1", "", "Retain")
options := controller.VolumeOptions{
PersistentVolumeReclaimPolicy: v1.PersistentVolumeReclaimDelete,
PVName: "pv-testdelete",
PVC: newClaim(resource.MustParse("1G"), []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce, v1.ReadOnlyMany}, nil),
}
pv, _ := p.Provision(options)
err := p.Delete(pv)
assert.NoError(t, err, "Delete should not return an error")
_, err = os.Stat(pv.Spec.PersistentVolumeSource.NFS.Path)
assert.Error(t, err, "The volume should not exist on disk")
} | explode_data.jsonl/75475 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
6435,
1155,
353,
8840,
836,
8,
341,
24804,
11,
716,
1669,
1147,
3848,
2234,
33363,
445,
1944,
5457,
19705,
1138,
3223,
1669,
1532,
57,
8485,
1336,
13013,
261,
12489,
11,
330,
31768,
33678,
16,
17,
22,
13,
15,
13,
15,
13,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGrantMultipleMixed(t *testing.T) {
assert := assert.New(t)
interceptor := stubs.NewInterceptor()
interceptor.AddStub(&stubs.Stub{
Method: "GET",
Path: fmt.Sprintf("/v2/auth/grant/sub-key/%s", pamConfig.SubscribeKey),
Query: "auth=my-auth-key-1%2Cmy-auth-key-2&channel=ch1%2Cch2%2Cch3&channel-group=cg1%2Ccg2%2Ccg3&r=1&m=1&w=1&d=0",
ResponseBody: `{"message":"Success","payload":{"level":"channel-group+auth","subscribe_key":"sub-c-b9ab9508-43cf-11e8-9967-869954283fb4","ttl":1440,"channels":{"ch1":{"auths":{"my-auth-key-1":{"r":1,"w":1,"m":1,"d":0},"my-auth-key-2":{"r":1,"w":1,"m":1,"d":0}}},"ch2":{"auths":{"my-auth-key-1":{"r":1,"w":1,"m":1,"d":0},"my-auth-key-2":{"r":1,"w":1,"m":1,"d":0}}},"ch3":{"auths":{"my-auth-key-1":{"r":1,"w":1,"m":1,"d":0},"my-auth-key-2":{"r":1,"w":1,"m":1,"d":0}}}},"channel-groups":{"cg1":{"auths":{"my-auth-key-1":{"r":1,"w":1,"m":1,"d":0},"my-auth-key-2":{"r":1,"w":1,"m":1,"d":0}}},"cg2":{"auths":{"my-auth-key-1":{"r":1,"w":1,"m":1,"d":0},"my-auth-key-2":{"r":1,"w":1,"m":1,"d":0}}},"cg3":{"auths":{"my-auth-key-1":{"r":1,"w":1,"m":1,"d":0},"my-auth-key-2":{"r":1,"w":1,"m":1,"d":0}}}}},"service":"Access Manager","status":200}`,
IgnoreQueryKeys: []string{"uuid", "pnsdk", "timestamp", "signature"},
ResponseStatusCode: 200,
})
pn := pubnub.NewPubNub(pamConfigCopy())
pn.SetClient(interceptor.GetClient())
if enableDebuggingInTests {
pn.Config.Log = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
}
res, _, err := pn.Grant().
Read(true).Write(true).Manage(true).
AuthKeys([]string{"my-auth-key-1", "my-auth-key-2"}).
Channels([]string{"ch1", "ch2", "ch3"}).
ChannelGroups([]string{"cg1", "cg2", "cg3"}).
Execute()
assert.Nil(err)
assert.NotNil(res)
} | explode_data.jsonl/43190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 878
} | [
2830,
3393,
67971,
32089,
86433,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
58915,
15349,
1669,
13633,
82,
7121,
32786,
741,
58915,
15349,
1904,
33838,
2099,
267,
15738,
7758,
392,
515,
197,
84589,
25,
1797,
330,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCronV2Pipeline(t *testing.T) {
runner := new(pipelinemocks.Runner)
config := cltest.NewTestEVMConfig(t)
store, cleanup := cltest.NewStoreWithConfig(t, config)
t.Cleanup(cleanup)
db := store.DB
orm, eventBroadcaster, cleanupPipeline := cltest.NewPipelineORM(t, config, db)
t.Cleanup(cleanupPipeline)
jobORM := job.NewORM(db, config, orm, eventBroadcaster, &postgres.NullAdvisoryLocker{})
spec := &job.Job{
Type: job.Cron,
SchemaVersion: 1,
CronSpec: &job.CronSpec{CronSchedule: "@every 1s"},
PipelineSpec: &pipeline.Spec{},
ExternalJobID: uuid.NewV4(),
}
delegate := cron.NewDelegate(runner)
jb, err := jobORM.CreateJob(context.Background(), spec, spec.Pipeline)
require.NoError(t, err)
serviceArray, err := delegate.ServicesForSpec(jb)
require.NoError(t, err)
assert.Len(t, serviceArray, 1)
service := serviceArray[0]
err = service.Start()
require.NoError(t, err)
defer service.Close()
} | explode_data.jsonl/64098 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 385
} | [
2830,
3393,
34,
2248,
53,
17,
34656,
1155,
353,
8840,
836,
8,
341,
197,
41736,
1669,
501,
1295,
573,
32730,
336,
25183,
16708,
1194,
340,
25873,
1669,
1185,
1944,
7121,
2271,
36,
11187,
2648,
1155,
340,
57279,
11,
21290,
1669,
1185,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetadataURLGeneration(t *testing.T) {
metadata := NewInstanceMetadata()
fullPath := metadata.makeMetadataURL("some/path")
if fullPath != "http://169.254.169.254/metadata/some/path" {
t.Errorf("Expected http://169.254.169.254/metadata/some/path saw %s", fullPath)
}
} | explode_data.jsonl/50418 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
14610,
3144,
37138,
1155,
353,
8840,
836,
8,
341,
2109,
7603,
1669,
1532,
2523,
14610,
741,
94042,
1820,
1669,
11160,
10117,
14610,
3144,
445,
14689,
50976,
1138,
743,
85844,
961,
330,
1254,
1110,
16,
21,
24,
13,
17,
20,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewMappingRuleSnapshotFromFieldsValidationError(t *testing.T) {
badFilters := []string{
"tag3:",
"tag3:*a*b*c*d",
"ab[cd",
}
for _, f := range badFilters {
_, err := newMappingRuleSnapshotFromFields(
"bar",
12345000000,
nil,
f,
aggregation.DefaultID,
nil,
policy.DropNone,
nil,
1234,
"test_user",
)
require.Error(t, err)
_, ok := err.(errors.ValidationError)
require.True(t, ok)
}
} | explode_data.jsonl/64570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 215
} | [
2830,
3393,
3564,
6807,
11337,
15009,
3830,
8941,
80553,
1155,
353,
8840,
836,
8,
341,
2233,
329,
28351,
1669,
3056,
917,
515,
197,
197,
1,
4578,
18,
55120,
197,
197,
1,
4578,
18,
53386,
64,
33279,
39091,
32714,
756,
197,
197,
1,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParseVersionRow(t *testing.T) {
tests := []struct {
row string
want row
}{
{
row: "# comment",
},
{
row: "",
},
{
row: "pkg archive/tar, type Writer struct",
want: row{
pkg: "archive/tar",
kind: "type",
name: "Writer",
},
},
{
row: "pkg archive/tar, type Header struct, AccessTime time.Time",
want: row{
pkg: "archive/tar",
kind: "field",
structName: "Header",
name: "AccessTime",
},
},
{
row: "pkg archive/tar, method (*Reader) Read([]uint8) (int, error)",
want: row{
pkg: "archive/tar",
kind: "method",
name: "Read",
recv: "*Reader",
},
},
{
row: "pkg archive/zip, func FileInfoHeader(os.FileInfo) (*FileHeader, error)",
want: row{
pkg: "archive/zip",
kind: "func",
name: "FileInfoHeader",
},
},
{
row: "pkg encoding/base32, method (Encoding) WithPadding(int32) *Encoding",
want: row{
pkg: "encoding/base32",
kind: "method",
name: "WithPadding",
recv: "Encoding",
},
},
}
for i, tt := range tests {
got, ok := parseRow(tt.row)
if !ok {
got = row{}
}
if got != tt.want {
t.Errorf("%d. parseRow(%q) = %+v; want %+v", i, tt.row, got, tt.want)
}
}
} | explode_data.jsonl/42991 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 630
} | [
2830,
3393,
14463,
5637,
3102,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
33967,
220,
914,
198,
197,
50780,
2802,
198,
197,
59403,
197,
197,
515,
298,
33967,
25,
5869,
3980,
756,
197,
197,
1583,
197,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestExampleServer(t *testing.T) {
mockProxy()
server, err := NewServer("./example")
require.NoError(t, err)
listener, err := net.Listen("tcp", ":9069")
require.NoError(t, err)
go server.Start(listener)
resp, err := sendReq("GET", "http://localhost:9069/test.json")
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
require.Equal(t, "DENY", resp.Header.Get("X-Frame-Options"))
require.Equal(t, "1; mode=block", resp.Header.Get("X-XSS-Protection"))
body, _ := ioutil.ReadAll(resp.Body)
require.Equal(t, "{\"foo\": \"bar\"}\n", string(body))
resp, err = sendReq("GET", "http://localhost:9069/")
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
require.Equal(t, "", resp.Header.Get("X-TEST-HEADER"))
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "{\"foo\": \"bar\"}\n", string(body))
resp, err = sendReq("GET", "http://localhost:9069/notFound.json")
require.NoError(t, err)
require.Equal(t, 404, resp.StatusCode)
resp, err = sendReq("GET", "http://localhost:9069/foo")
require.NoError(t, err)
require.Equal(t, 301, resp.StatusCode)
require.Equal(t, "", resp.Header.Get("X-TEST-HEADER"))
require.Equal(t, "/test.json", resp.Header.Get("Location"))
resp, err = sendReq("GET", "http://localhost:9069/bar?id=2")
require.NoError(t, err)
require.Equal(t, 301, resp.StatusCode)
require.Equal(t, "/test-2.json", resp.Header.Get("Location"))
resp, err = sendReq("GET", "http://localhost:9069/bar?page=2")
require.NoError(t, err)
require.Equal(t, 301, resp.StatusCode)
require.Equal(t, "/test-2.json", resp.Header.Get("Location"))
resp, err = sendReq("GET", "http://localhost:9069/bar")
require.NoError(t, err)
require.Equal(t, 301, resp.StatusCode)
require.Equal(t, "/test.json", resp.Header.Get("Location"))
resp, err = sendReq("GET", "http://localhost:9069/test-2.json")
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
require.Equal(t, "SiteXID", resp.Header.Get("X-TEST-HEADER"))
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "{\"foo\": \"bar2\"}\n", string(body))
resp, err = sendReq("GET", "http://localhost:9069/google")
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
require.Equal(t, "", resp.Header.Get("X-TEST-HEADER"))
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "proxy!", string(body))
resp, err = sendReq("GET", "http://localhost:9069/secret.json")
require.Equal(t, "", resp.Header.Get("Basic-Auth"))
require.Equal(t, 401, resp.StatusCode)
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "Unauthorized.\n", string(body))
resp, err = sendReqAuth("GET", "http://localhost:9069/secret.json", "user", "pass")
require.Equal(t, "", resp.Header.Get("Basic-Auth"))
require.Equal(t, 200, resp.StatusCode)
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "{\n \"secret\": true\n}", string(body))
resp, err = sendReqAuth("GET", "http://localhost:9069/secret.json", "foo", "pass")
require.Equal(t, "", resp.Header.Get("Basic-Auth"))
require.Equal(t, 401, resp.StatusCode)
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "Unauthorized.\n", string(body))
resp, err = sendReq("GET", "http://localhost:9069/shadowed.json")
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
require.Equal(t, "", resp.Header.Get("X-TEST-HEADER"))
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "{\"foo\": \"bar\"}\n", string(body))
resp, err = sendReq("GET", "http://localhost:9069/notShadowed.json")
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode)
require.Equal(t, "", resp.Header.Get("X-TEST-HEADER"))
body, _ = ioutil.ReadAll(resp.Body)
require.Equal(t, "{\n \"shadowed\": false\n}", string(body))
} | explode_data.jsonl/20106 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1515
} | [
2830,
3393,
13314,
5475,
1155,
353,
8840,
836,
8,
341,
77333,
16219,
2822,
41057,
11,
1848,
1669,
1532,
5475,
13988,
8687,
1138,
17957,
35699,
1155,
11,
1848,
340,
14440,
798,
11,
1848,
1669,
4179,
68334,
445,
27161,
497,
13022,
24,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestObject(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionWithObjectHeaders(t)
defer rollback()
object, headers, err := c.Object(ctx, CONTAINER, OBJECT)
if err != nil {
t.Fatal(err)
}
compareMaps(t, headers.ObjectMetadata(), map[string]string{"hello": "1", "potato-salad": "2"})
if object.Name != OBJECT || object.Bytes != CONTENT_SIZE || object.ContentType != "application/octet-stream" || object.Hash != CONTENT_MD5 || object.PseudoDirectory != false || object.SubDir != "" {
t.Error("Bad object info", object)
}
checkTime(t, object.LastModified, -10, 10)
} | explode_data.jsonl/12691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
1190,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
2354,
1190,
10574,
1155,
340,
16867,
60414,
741,
35798,
11,
7102,
11,
1848,
1669,
272,
8348,
7502,
11,
16120,
34521,
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... | 8 |
func TestAddSequencedLeaves(t *testing.T) {
ctx := context.Background()
for _, tc := range []struct {
desc string
dataByIndex map[int64][]byte
wantErr bool
}{
{desc: "empty", dataByIndex: nil},
{desc: "non-contiguous", dataByIndex: map[int64][]byte{
0: []byte("A"),
2: []byte("C"),
}, wantErr: true},
} {
t.Run(tc.desc, func(t *testing.T) {
c := &LogClient{LogVerifier: &LogVerifier{Hasher: rfc6962.DefaultHasher}}
err := c.AddSequencedLeaves(ctx, tc.dataByIndex)
if gotErr := err != nil; gotErr != tc.wantErr {
t.Errorf("AddSequencedLeaves(): %v, wantErr: %v", err, tc.wantErr)
}
})
}
} | explode_data.jsonl/54606 | {
"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,
2212,
1514,
446,
5767,
2304,
4693,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
41653,
286,
914,
198,
197,
8924,
1359,
1552,
2415,
18640,
21,
19,
45725,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWebServiceDesc_String(t *testing.T) {
testCases := map[string]struct {
wantedHumanString string
wantedJSONString string
}{
"correct output": {
wantedHumanString: `About
Application my-app
Name my-svc
Type Load Balanced Web Service
Configurations
Environment Tasks CPU (vCPU) Memory (MiB) Port
test 1 0.25 512 80
prod 3 0.5 1024 5000
Routes
Environment URL
test http://my-pr-Publi.us-west-2.elb.amazonaws.com/frontend
prod http://my-pr-Publi.us-west-2.elb.amazonaws.com/backend
Service Discovery
Environment Namespace
test, prod http://my-svc.my-app.local:5000
Variables
Name Environment Value
COPILOT_ENVIRONMENT_NAME prod prod
- test test
Resources
test
AWS::EC2::SecurityGroup sg-0758ed6b233743530
prod
AWS::EC2::SecurityGroupIngress ContainerSecurityGroupIngressFromPublicALB
`,
wantedJSONString: "{\"service\":\"my-svc\",\"type\":\"Load Balanced Web Service\",\"application\":\"my-app\",\"configurations\":[{\"environment\":\"test\",\"port\":\"80\",\"tasks\":\"1\",\"cpu\":\"256\",\"memory\":\"512\"},{\"environment\":\"prod\",\"port\":\"5000\",\"tasks\":\"3\",\"cpu\":\"512\",\"memory\":\"1024\"}],\"routes\":[{\"environment\":\"test\",\"url\":\"http://my-pr-Publi.us-west-2.elb.amazonaws.com/frontend\"},{\"environment\":\"prod\",\"url\":\"http://my-pr-Publi.us-west-2.elb.amazonaws.com/backend\"}],\"serviceDiscovery\":[{\"environment\":[\"test\",\"prod\"],\"namespace\":\"http://my-svc.my-app.local:5000\"}],\"variables\":[{\"environment\":\"prod\",\"name\":\"COPILOT_ENVIRONMENT_NAME\",\"value\":\"prod\"},{\"environment\":\"test\",\"name\":\"COPILOT_ENVIRONMENT_NAME\",\"value\":\"test\"}],\"resources\":{\"prod\":[{\"type\":\"AWS::EC2::SecurityGroupIngress\",\"physicalID\":\"ContainerSecurityGroupIngressFromPublicALB\"}],\"test\":[{\"type\":\"AWS::EC2::SecurityGroup\",\"physicalID\":\"sg-0758ed6b233743530\"}]}}\n",
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
config := []*ServiceConfig{
{
CPU: "256",
Environment: "test",
Memory: "512",
Port: "80",
Tasks: "1",
},
{
CPU: "512",
Environment: "prod",
Memory: "1024",
Port: "5000",
Tasks: "3",
},
}
envVars := []*EnvVars{
{
Environment: "prod",
Name: "COPILOT_ENVIRONMENT_NAME",
Value: "prod",
},
{
Environment: "test",
Name: "COPILOT_ENVIRONMENT_NAME",
Value: "test",
},
}
routes := []*WebServiceRoute{
{
Environment: "test",
URL: "http://my-pr-Publi.us-west-2.elb.amazonaws.com/frontend",
},
{
Environment: "prod",
URL: "http://my-pr-Publi.us-west-2.elb.amazonaws.com/backend",
},
}
sds := []*ServiceDiscovery{
{
Environment: []string{"test", "prod"},
Namespace: "http://my-svc.my-app.local:5000",
},
}
resources := map[string][]*CfnResource{
"test": []*CfnResource{
{
PhysicalID: "sg-0758ed6b233743530",
Type: "AWS::EC2::SecurityGroup",
},
},
"prod": []*CfnResource{
{
Type: "AWS::EC2::SecurityGroupIngress",
PhysicalID: "ContainerSecurityGroupIngressFromPublicALB",
},
},
}
webSvc := &webSvcDesc{
Service: "my-svc",
Type: "Load Balanced Web Service",
Configurations: config,
App: "my-app",
Variables: envVars,
Routes: routes,
ServiceDiscovery: sds,
Resources: resources,
}
human := webSvc.HumanString()
json, _ := webSvc.JSONString()
require.Equal(t, tc.wantedHumanString, human)
require.Equal(t, tc.wantedJSONString, json)
})
}
} | explode_data.jsonl/42401 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2074
} | [
2830,
3393,
94388,
11065,
31777,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
6692,
7566,
33975,
703,
914,
198,
197,
6692,
7566,
5370,
703,
220,
914,
198,
197,
59403,
197,
197,
1,
19928,
2550,
788... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_write_uint32(t *testing.T) {
vals := []uint32{0, 1, 11, 111, 255, 999999, 0xfff, 0xffff, 0xfffff, 0xffffff, 0xfffffff, 0xffffffff}
for _, val := range vals {
t.Run(fmt.Sprintf("%v", val), func(t *testing.T) {
stream := jsoniter.NewStream()
stream.WriteUint32(val)
if strconv.FormatUint(uint64(val), 10) != string(stream.Buffer()) {
t.Fatal()
}
})
t.Run(fmt.Sprintf("%v", val), func(t *testing.T) {
stream := jsoniter.NewStream()
stream.WriteInterface(val)
if strconv.FormatUint(uint64(val), 10) != string(stream.Buffer()) {
t.Fatal()
}
})
}
} | explode_data.jsonl/34814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
9165,
15807,
18,
17,
1155,
353,
8840,
836,
8,
341,
19302,
82,
1669,
3056,
2496,
18,
17,
90,
15,
11,
220,
16,
11,
220,
16,
16,
11,
220,
16,
16,
16,
11,
220,
17,
20,
20,
11,
220,
24,
24,
24,
24,
24,
24,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLargeNumberLiteral(t *testing.T) {
const SCRIPT = `
var x = 0x800000000000000000000;
x.toString();
`
testScript1(SCRIPT, asciiString("9.671406556917033e+24"), t)
} | explode_data.jsonl/75311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
34253,
2833,
17350,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
856,
284,
220,
15,
87,
23,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
280,
10225,
5070,
543,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeIntoNothing(t *testing.T) {
Register(new(NewType0))
for i, test := range ignoreTests {
b := new(bytes.Buffer)
enc := NewEncoder(b)
err := enc.Encode(test.in)
if err != nil {
t.Errorf("%d: encode error %s:", i, err)
continue
}
dec := NewDecoder(b)
err = dec.Decode(test.out)
if err != nil {
t.Errorf("%d: decode error: %s", i, err)
continue
}
// Now see if the encoder and decoder are in a consistent state.
str := fmt.Sprintf("Value %d", i)
err = enc.Encode(&NewType0{str})
if err != nil {
t.Fatalf("%d: NewType0 encode error: %s", i, err)
}
ns := new(NewType0)
err = dec.Decode(ns)
if err != nil {
t.Fatalf("%d: NewType0 decode error: %s", i, err)
}
if ns.S != str {
t.Fatalf("%d: expected %q got %q", i, str, ns.S)
}
}
} | explode_data.jsonl/43395 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 370
} | [
2830,
3393,
32564,
26591,
23780,
1155,
353,
8840,
836,
8,
341,
79096,
1755,
35063,
929,
15,
1171,
2023,
600,
11,
1273,
1669,
2088,
10034,
18200,
341,
197,
2233,
1669,
501,
23158,
22622,
340,
197,
197,
954,
1669,
1532,
19921,
1883,
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... | 7 |
func TestAcquire(t *testing.T) {
FakeNow := time.Now()
var testcases = []struct {
name string
resources []common.Resource
owner string
rtype string
state string
dest string
expectErr error
}{
{
name: "ranch has no resource",
resources: []common.Resource{},
owner: "user",
rtype: "t",
state: "s",
dest: "d",
expectErr: &ResourceNotFound{"t"},
},
{
name: "no match type",
resources: []common.Resource{
{
Name: "res",
Type: "wrong",
State: "s",
Owner: "",
LastUpdate: FakeNow,
},
},
owner: "user",
rtype: "t",
state: "s",
dest: "d",
expectErr: &ResourceNotFound{"t"},
},
{
name: "no match state",
resources: []common.Resource{
{
Name: "res",
Type: "t",
State: "wrong",
Owner: "",
LastUpdate: FakeNow,
},
},
owner: "user",
rtype: "t",
state: "s",
dest: "d",
expectErr: &ResourceNotFound{"t"},
},
{
name: "busy",
resources: []common.Resource{
{
Name: "res",
Type: "t",
State: "s",
Owner: "foo",
LastUpdate: FakeNow,
},
},
owner: "user",
rtype: "t",
state: "s",
dest: "d",
expectErr: &ResourceNotFound{"t"},
},
{
name: "ok",
resources: []common.Resource{
{
Name: "res",
Type: "t",
State: "s",
Owner: "",
LastUpdate: FakeNow,
},
},
owner: "user",
rtype: "t",
state: "s",
dest: "d",
expectErr: nil,
},
}
for _, tc := range testcases {
c := MakeTestRanch(tc.resources)
res, err := c.Acquire(tc.rtype, tc.state, tc.dest, tc.owner)
if !AreErrorsEqual(err, tc.expectErr) {
t.Errorf("%s - Got error %v, expect error %v", tc.name, err, tc.expectErr)
continue
}
if err == nil {
if res.State != tc.dest {
t.Errorf("%s - Wrong final state. Got %v, expect %v", tc.name, res.State, tc.dest)
}
if *res != c.Resources[0] {
t.Errorf("%s - Wrong resource. Got %v, expect %v", tc.name, res, c.Resources[0])
} else if !res.LastUpdate.After(FakeNow) {
t.Errorf("%s - LastUpdate did not update.", tc.name)
}
} else {
for _, res := range c.Resources {
if res.LastUpdate != FakeNow {
t.Errorf("%s - LastUpdate should not update. Got %v, expect %v", tc.name, c.Resources[0].LastUpdate, FakeNow)
}
}
}
}
} | explode_data.jsonl/12946 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1354
} | [
2830,
3393,
11654,
984,
1155,
353,
8840,
836,
8,
341,
12727,
726,
7039,
1669,
882,
13244,
741,
2405,
1273,
23910,
284,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
10202,
2360,
3056,
5464,
20766,
198,
197,
197,
8118,
257,
914,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestValidate(t *testing.T) {
type spec struct {
name string
config *v1alpha2.ImageSetConfiguration
expError string
}
cases := []spec{
{
name: "Valid/HeadsOnlyFalse",
config: &v1alpha2.ImageSetConfiguration{
ImageSetConfigurationSpec: v1alpha2.ImageSetConfigurationSpec{
Mirror: v1alpha2.Mirror{
Operators: []v1alpha2.Operator{
{
Catalog: "test-catalog",
IncludeConfig: v1alpha2.IncludeConfig{
Packages: []v1alpha2.IncludePackage{{Name: "foo"}},
},
Full: true,
},
},
},
},
},
expError: "",
},
{
name: "Valid/NoIncludePackages",
config: &v1alpha2.ImageSetConfiguration{
ImageSetConfigurationSpec: v1alpha2.ImageSetConfigurationSpec{
Mirror: v1alpha2.Mirror{
Operators: []v1alpha2.Operator{
{
Catalog: "test-catalog",
IncludeConfig: v1alpha2.IncludeConfig{},
Full: false,
},
},
},
},
},
},
{
name: "Valid/HeadsOnlyFalse",
config: &v1alpha2.ImageSetConfiguration{
ImageSetConfigurationSpec: v1alpha2.ImageSetConfigurationSpec{
Mirror: v1alpha2.Mirror{
Operators: []v1alpha2.Operator{
{
Catalog: "test-catalog",
IncludeConfig: v1alpha2.IncludeConfig{
Packages: []v1alpha2.IncludePackage{{Name: "foo"}},
},
Full: true,
},
},
},
},
},
},
{
name: "Valid/UniqueReleaseChannels",
config: &v1alpha2.ImageSetConfiguration{
ImageSetConfigurationSpec: v1alpha2.ImageSetConfigurationSpec{
Mirror: v1alpha2.Mirror{
OCP: v1alpha2.OCP{
Channels: []v1alpha2.ReleaseChannel{
{
Name: "channel1",
},
{
Name: "channel2",
},
},
},
},
},
},
},
{
name: "Invalid/HeadsOnlyTrue",
config: &v1alpha2.ImageSetConfiguration{
ImageSetConfigurationSpec: v1alpha2.ImageSetConfigurationSpec{
Mirror: v1alpha2.Mirror{
Operators: []v1alpha2.Operator{
{
Catalog: "test-catalog",
IncludeConfig: v1alpha2.IncludeConfig{
Packages: []v1alpha2.IncludePackage{{Name: "foo"}},
},
Full: false,
},
},
},
},
},
expError: "invalid configuration: catalog \"test-catalog\": cannot define packages with full key set to false",
},
{
name: "Invalid/DuplicateChannels",
config: &v1alpha2.ImageSetConfiguration{
ImageSetConfigurationSpec: v1alpha2.ImageSetConfigurationSpec{
Mirror: v1alpha2.Mirror{
OCP: v1alpha2.OCP{
Channels: []v1alpha2.ReleaseChannel{
{
Name: "channel",
},
{
Name: "channel",
},
},
},
},
},
},
expError: "invalid configuration: release channel \"channel\": duplicate found in configuration",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
err := Validate(c.config)
if c.expError != "" {
require.EqualError(t, err, c.expError)
} else {
require.NoError(t, err)
}
})
}
} | explode_data.jsonl/6800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1564
} | [
2830,
3393,
17926,
1155,
353,
8840,
836,
8,
1476,
13158,
1398,
2036,
341,
197,
11609,
257,
914,
198,
197,
25873,
256,
353,
85,
16,
7141,
17,
7528,
1649,
7688,
198,
197,
48558,
1454,
914,
198,
197,
630,
1444,
2264,
1669,
3056,
9535,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_wordBreak2(t *testing.T) {
assert.Equal(t, []string{
"pine apple pen apple", "pineapple pen apple", "pine applepen apple",
}, wordBreak("pineapplepenapple", []string{"apple", "pen", "applepen", "pine", "pineapple"}))
} | explode_data.jsonl/37693 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
13533,
22524,
17,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
3056,
917,
515,
197,
197,
1,
38038,
23268,
5750,
23268,
497,
330,
38038,
22377,
5750,
23268,
497,
330,
38038,
23268,
2752,
23268,
756,
197,
2137,
3409,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScaleTri(t *testing.T) {
t.Parallel()
for _, f := range []float64{0.5, 1, 3} {
method := func(receiver, a Matrix) {
type ScaleTrier interface {
ScaleTri(f float64, a Triangular)
}
rd := receiver.(ScaleTrier)
rd.ScaleTri(f, a.(Triangular))
}
denseComparison := func(receiver, a *Dense) {
receiver.Scale(f, a)
}
testOneInput(t, "ScaleTriUpper", NewTriDense(3, Upper, nil), method, denseComparison, legalTypeTriUpper, isSquare, 1e-14)
testOneInput(t, "ScaleTriLower", NewTriDense(3, Lower, nil), method, denseComparison, legalTypeTriLower, isSquare, 1e-14)
}
} | explode_data.jsonl/25863 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
6947,
21884,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2023,
8358,
282,
1669,
2088,
3056,
3649,
21,
19,
90,
15,
13,
20,
11,
220,
16,
11,
220,
18,
92,
341,
197,
42257,
1669,
2915,
78126,
11,
264,
11631,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOCMProvider_ScaleDown(t *testing.T) {
type fields struct {
ocmClient ocm.Client
}
type args struct {
clusterSpec *types.ClusterSpec
decrement int
}
internalId := "test-internal-id"
spec := &types.ClusterSpec{
InternalID: internalId,
ExternalID: "",
Status: "",
AdditionalInfo: nil,
}
tests := []struct {
name string
fields fields
args args
want *types.ClusterSpec
wantErr bool
}{
{
name: "should scale down",
fields: fields{
ocmClient: &ocm.ClientMock{
ScaleDownComputeNodesFunc: func(clusterID string, decrement int) (*clustersmgmtv1.Cluster, error) {
return nil, nil
},
},
},
args: args{
clusterSpec: spec,
decrement: 3,
},
want: spec,
wantErr: false,
},
{
name: "should return error when failed to scale up",
fields: fields{
ocmClient: &ocm.ClientMock{
ScaleDownComputeNodesFunc: func(clusterID string, decrement int) (*clustersmgmtv1.Cluster, error) {
return nil, errors.Errorf("failed to scale up")
},
},
},
args: args{
clusterSpec: spec,
decrement: 3,
},
wantErr: true,
want: nil,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
RegisterTestingT(t)
p := newOCMProvider(test.fields.ocmClient, nil, &ocm.OCMConfig{})
resp, err := p.ScaleDown(test.args.clusterSpec, test.args.decrement)
Expect(resp).To(Equal(test.want))
if test.wantErr {
Expect(err).NotTo(BeNil())
}
})
}
} | explode_data.jsonl/4837 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 709
} | [
2830,
3393,
7612,
44,
5179,
1098,
2246,
4454,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
509,
76,
2959,
297,
6226,
11716,
198,
197,
532,
13158,
2827,
2036,
341,
197,
197,
18855,
8327,
353,
9242,
72883,
8327,
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 TestFnv32(t *testing.T) {
key := []byte("ABC")
hasher := fnv.New32()
_, err := hasher.Write(key)
if err != nil {
t.Errorf(err.Error())
}
if fnv32(string(key)) != hasher.Sum32() {
t.Errorf("Bundled fnv32 produced %d, expected result from hash/fnv32 is %d", fnv32(string(key)), hasher.Sum32())
}
} | explode_data.jsonl/77838 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
24911,
85,
18,
17,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
3056,
3782,
445,
25411,
5130,
50333,
261,
1669,
5168,
85,
7121,
18,
17,
741,
197,
6878,
1848,
1669,
90819,
4073,
4857,
340,
743,
1848,
961,
2092,
341,
197,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInvalidAppProject(t *testing.T) {
Given(t).
Path(guestbookPath).
Project("does-not-exist").
When().
IgnoreErrors().
Create().
Then().
Expect(Error("", "application references project does-not-exist which does not exist"))
} | explode_data.jsonl/66668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
7928,
2164,
7849,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
69640,
3268,
3045,
2190,
1820,
4292,
197,
197,
7849,
445,
27057,
29169,
10187,
380,
38609,
197,
197,
4498,
25829,
197,
197,
12497,
13877,
25829,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGroupDeleteIntegration(t *testing.T) {
c := client()
gs, err := c.Groups()
if err != nil {
t.Error(err)
}
g := gs[0].ID
_, err = c.GroupDelete(g)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/12131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
2808,
6435,
52464,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2943,
741,
3174,
82,
11,
1848,
1669,
272,
59800,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
532,
3174,
1669,
28081,
58,
15,
936,
915,
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... | 3 |
func TestColIdentSize(t *testing.T) {
size := unsafe.Sizeof(NewColIdent(""))
want := 2 * unsafe.Sizeof("")
if size != want {
t.Errorf("Size of ColIdent: %d, want 32", want)
}
} | explode_data.jsonl/3384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
6127,
28301,
1695,
1155,
353,
8840,
836,
8,
341,
13832,
1669,
19860,
2465,
1055,
35063,
6127,
28301,
73303,
50780,
1669,
220,
17,
353,
19860,
2465,
1055,
31764,
743,
1379,
961,
1366,
341,
197,
3244,
13080,
445,
1695,
315,
42... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestHandlerWellKnown(t *testing.T) {
h := &oauth2.Handler{
H: herodot.NewJSONWriter(nil),
ScopeStrategy: fosite.HierarchicScopeStrategy,
IssuerURL: "http://hydra.localhost",
SubjectTypes: []string{"pairwise", "public"},
}
AuthPathT := "/oauth2/auth"
TokenPathT := "/oauth2/token"
JWKPathT := "/.well-known/jwks.json"
r := httprouter.New()
h.SetRoutes(r, r)
ts := httptest.NewServer(r)
res, err := http.Get(ts.URL + "/.well-known/openid-configuration")
require.NoError(t, err)
defer res.Body.Close()
trueConfig := oauth2.WellKnown{
Issuer: strings.TrimRight(h.IssuerURL, "/") + "/",
AuthURL: strings.TrimRight(h.IssuerURL, "/") + AuthPathT,
TokenURL: strings.TrimRight(h.IssuerURL, "/") + TokenPathT,
JWKsURI: strings.TrimRight(h.IssuerURL, "/") + JWKPathT,
RegistrationEndpoint: strings.TrimRight(h.IssuerURL, "/") + client.ClientsHandlerPath,
SubjectTypes: []string{"pairwise", "public"},
ResponseTypes: []string{"code", "code id_token", "id_token", "token id_token", "token", "token id_token code"},
ClaimsSupported: []string{"sub"},
ScopesSupported: []string{"offline", "openid"},
UserinfoEndpoint: strings.TrimRight(h.IssuerURL, "/") + oauth2.UserinfoPath,
TokenEndpointAuthMethodsSupported: []string{"client_secret_post", "client_secret_basic", "private_key_jwt", "none"},
GrantTypesSupported: []string{"authorization_code", "implicit", "client_credentials", "refresh_token"},
ResponseModesSupported: []string{"query", "fragment"},
IDTokenSigningAlgValuesSupported: []string{"RS256"},
UserinfoSigningAlgValuesSupported: []string{"none", "RS256"},
RequestParameterSupported: true,
RequestURIParameterSupported: true,
RequireRequestURIRegistration: true,
}
var wellKnownResp oauth2.WellKnown
err = json.NewDecoder(res.Body).Decode(&wellKnownResp)
require.NoError(t, err, "problem decoding wellknown json response: %+v", err)
assert.EqualValues(t, trueConfig, wellKnownResp)
h.ScopesSupported = "foo,bar"
h.ClaimsSupported = "baz,oof"
h.UserinfoEndpoint = "bar"
res, err = http.Get(ts.URL + "/.well-known/openid-configuration")
require.NoError(t, err)
defer res.Body.Close()
require.NoError(t, json.NewDecoder(res.Body).Decode(&wellKnownResp))
assert.EqualValues(t, wellKnownResp.ClaimsSupported, []string{"sub", "baz", "oof"})
assert.EqualValues(t, wellKnownResp.ScopesSupported, []string{"offline", "openid", "foo", "bar"})
assert.Equal(t, wellKnownResp.UserinfoEndpoint, "bar")
} | explode_data.jsonl/25996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1185
} | [
2830,
3393,
3050,
11395,
48206,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
609,
34363,
17,
31010,
515,
197,
13292,
25,
1797,
1059,
347,
354,
7121,
5370,
6492,
27907,
1326,
197,
7568,
2417,
19816,
25,
48390,
632,
3839,
1268,
1113,
292,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGrantSingleChannelWithAuth(t *testing.T) {
assert := assert.New(t)
interceptor := stubs.NewInterceptor()
interceptor.AddStub(&stubs.Stub{
Method: "GET",
Path: fmt.Sprintf("/v2/auth/grant/sub-key/%s", pamConfig.SubscribeKey),
Query: "auth=my-pam-key&channel=ch1&m=0&r=1&w=1&d=0",
ResponseBody: `{"message":"Success","payload":{"level":"user","subscribe_key":"sub-c-b9ab9508-43cf-11e8-9967-869954283fb4","ttl":1440,"channel":"ch1","auths":{"my-pam-key":{"r":1,"w":1,"m":0,"d":0}}},"service":"Access Manager","status":200}`,
IgnoreQueryKeys: []string{"uuid", "pnsdk", "signature", "timestamp"},
ResponseStatusCode: 200,
})
pn := pubnub.NewPubNub(pamConfigCopy())
pn.SetClient(interceptor.GetClient())
res, _, err := pn.Grant().
Read(true).Write(true).Manage(false).
AuthKeys([]string{"my-pam-key"}).
Channels([]string{"ch1"}).
Execute()
assert.Nil(err)
assert.NotNil(res)
assert.True(res.Channels["ch1"].AuthKeys["my-pam-key"].WriteEnabled)
assert.True(res.Channels["ch1"].AuthKeys["my-pam-key"].ReadEnabled)
assert.False(res.Channels["ch1"].AuthKeys["my-pam-key"].ManageEnabled)
} | explode_data.jsonl/43192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 520
} | [
2830,
3393,
67971,
10888,
9629,
2354,
5087,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
58915,
15349,
1669,
13633,
82,
7121,
32786,
741,
58915,
15349,
1904,
33838,
2099,
267,
15738,
7758,
392,
515,
197,
84589,
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... | 1 |
func TestDB(t *testing.T) {
var (
messages = messageChannel{make(chan *engine.Message)}
eng, err = engine.New(&backend{
sampleRate: sampleRate,
frameSize: frameSize,
}, frameSize, engine.WithMessageChannel(messages))
logger = log.New(os.Stdout, "", -1)
)
require.NoError(t, err)
run, err := New(eng, logger)
require.NoError(t, err)
v, err := run.Eval([]byte(`(db 0)`))
require.NoError(t, err)
require.Equal(t, 1.0, v)
v, err = run.Eval([]byte(`(db -6)`))
require.NoError(t, err)
require.Equal(t, 0.5011872336272722, v)
v, err = run.Eval([]byte(`(db -6.0)`))
require.NoError(t, err)
require.Equal(t, 0.5011872336272722, v)
v, err = run.Eval([]byte(`(db -12)`))
require.Equal(t, 0.25118864315095796, v)
_, err = run.Eval([]byte(`(db "0")`))
require.Error(t, err)
_, err = run.Eval([]byte(`(db)`))
require.Error(t, err)
} | explode_data.jsonl/57809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 406
} | [
2830,
3393,
3506,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
2109,
3737,
284,
1943,
9629,
90,
6927,
35190,
353,
8512,
8472,
10569,
197,
197,
826,
11,
1848,
284,
4712,
7121,
2099,
20942,
515,
298,
1903,
1516,
11564,
25,
6077,
11564... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeInstances(t *testing.T) {
m := &mockEC2{}
c := &client{
clients: map[string]*regionalClient{"us-east-1": {region: "us-east-1", ec2: m}},
}
results, err := c.DescribeInstances(context.Background(), "us-east-1", nil)
assert.NoError(t, err)
assert.Len(t, results, 0)
m.instances = []*ec2.Instance{testInstance}
results, err = c.DescribeInstances(context.Background(), "us-east-1", []string{"i-12345"})
assert.NoError(t, err)
assert.Len(t, results, 1)
assert.Equal(t, testInstanceProto, results[0])
m.instancesErr = errors.New("whoops")
_, err = c.DescribeInstances(context.Background(), "us-east-1", nil)
assert.EqualError(t, err, "whoops")
} | explode_data.jsonl/3404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
74785,
42725,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
609,
16712,
7498,
17,
16094,
1444,
1669,
609,
2972,
515,
197,
197,
31869,
25,
2415,
14032,
8465,
1580,
3914,
2959,
4913,
355,
39507,
12,
16,
788,
314,
3943,
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 TestSetAddContainsLen(t *testing.T) {
tests := []struct {
add []string
expected []string
}{
{[]string{`null`, `null`}, []string{`null`}},
{[]string{`true`, `true`, `false`}, []string{`true`, `false`}},
{[]string{`0`, `1`, `1`, `1.5`}, []string{`0`, `1`, `1.5`}},
{[]string{`"string"`, `"string"`}, []string{`"string"`}},
{[]string{`["other"]`, `["other"]`}, []string{`["other"]`}},
}
for _, tc := range tests {
s := NewSet()
for _, v := range tc.add {
x := MustParseTerm(v)
s.Add(x)
if !s.Contains(x) {
t.Errorf("Expected the set to contain %v", v)
}
}
if s.Len() != len(tc.expected) {
t.Errorf("Expected the set to have %v entries", len(tc.expected))
}
for _, v := range tc.expected {
if !s.Contains(MustParseTerm(v)) {
t.Errorf("Expected the set to contain %v", v)
}
}
}
} | explode_data.jsonl/2927 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
1649,
2212,
23805,
11271,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
12718,
414,
3056,
917,
198,
197,
42400,
3056,
917,
198,
197,
59403,
197,
197,
90,
1294,
917,
90,
63,
2921,
7808,
1565,
2921,
63,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestLookupService(t *testing.T) {
cache := func(objs ...interface{}) *KubernetesCache {
cache := KubernetesCache{
FieldLogger: fixture.NewTestLogger(t),
}
for _, o := range objs {
cache.Insert(o)
}
return &cache
}
service := func(ns, name string, ports ...v1.ServicePort) *v1.Service {
return &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
},
Spec: v1.ServiceSpec{
Ports: ports,
},
}
}
port := func(name string, port int32, protocol v1.Protocol) v1.ServicePort {
return v1.ServicePort{
Name: name,
Port: port,
Protocol: protocol,
}
}
tests := map[string]struct {
cache *KubernetesCache
meta types.NamespacedName
port intstr.IntOrString
wantSvc *v1.Service
wantPort v1.ServicePort
wantErr error
}{
"service and port exist with valid service protocol, lookup by port num": {
cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))),
meta: types.NamespacedName{Namespace: "default", Name: "service-1"},
port: intstr.FromInt(80),
wantSvc: service("default", "service-1", port("http", 80, v1.ProtocolTCP)),
wantPort: port("http", 80, v1.ProtocolTCP),
},
"service and port exist with valid service protocol, lookup by port name": {
cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))),
meta: types.NamespacedName{Namespace: "default", Name: "service-1"},
port: intstr.FromString("http"),
wantSvc: service("default", "service-1", port("http", 80, v1.ProtocolTCP)),
wantPort: port("http", 80, v1.ProtocolTCP),
},
"service and port exist with valid service protocol, lookup by wrong port num": {
cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))),
meta: types.NamespacedName{Namespace: "default", Name: "service-1"},
port: intstr.FromInt(9999),
wantErr: errors.New(`port "9999" on service "default/service-1" not matched`),
},
"service and port exist with valid service protocol, lookup by wrong port name": {
cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))),
meta: types.NamespacedName{Namespace: "default", Name: "service-1"},
port: intstr.FromString("wrong-port-name"),
wantErr: errors.New(`port "wrong-port-name" on service "default/service-1" not matched`),
},
"service and port exist, invalid service protocol": {
cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolUDP))),
meta: types.NamespacedName{Namespace: "default", Name: "service-1"},
port: intstr.FromString("http"),
wantSvc: service("default", "service-1", port("http", 80, v1.ProtocolTCP)),
wantErr: errors.New(`unsupported service protocol "UDP"`),
},
"service does not exist": {
cache: cache(service("default", "service-1", port("http", 80, v1.ProtocolTCP))),
meta: types.NamespacedName{Namespace: "default", Name: "nonexistent-service"},
port: intstr.FromInt(80),
wantErr: errors.New(`service "default/nonexistent-service" not found`),
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
gotSvc, gotPort, gotErr := tc.cache.LookupService(tc.meta, tc.port)
switch {
case tc.wantErr != nil:
require.Error(t, gotErr)
assert.EqualError(t, tc.wantErr, gotErr.Error())
default:
assert.Nil(t, gotErr)
assert.Equal(t, tc.wantSvc, gotSvc)
assert.Equal(t, tc.wantPort, gotPort)
}
})
}
} | explode_data.jsonl/66532 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1432
} | [
2830,
3393,
34247,
1860,
1155,
353,
8840,
836,
8,
341,
52680,
1669,
2915,
6779,
82,
2503,
4970,
28875,
353,
42,
29827,
8233,
341,
197,
52680,
1669,
66374,
8233,
515,
298,
94478,
7395,
25,
12507,
7121,
2271,
7395,
1155,
1326,
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... | 2 |
func TestFlushableIterator(t *testing.T) {
assertar := assert.New(t)
disk := dbProducer("TestFlushableIterator")
leveldb, _ := disk.OpenDB("1")
defer leveldb.Drop()
defer leveldb.Close()
flushable1 := Wrap(leveldb)
flushable2 := Wrap(leveldb)
allkeys := [][]byte{
{0x11, 0x00},
{0x12, 0x00},
{0x13, 0x00},
{0x14, 0x00},
{0x15, 0x00},
{0x16, 0x00},
{0x17, 0x00},
{0x18, 0x00},
{0x19, 0x00},
{0x1a, 0x00},
{0x1b, 0x00},
{0x1c, 0x00},
{0x1d, 0x00},
{0x1e, 0x00},
{0x1f, 0x00},
}
veryFirstKey := allkeys[0]
veryLastKey := allkeys[len(allkeys)-1]
expected := allkeys[1 : len(allkeys)-1]
for _, key := range expected {
leveldb.Put(key, []byte("in-order"))
}
flushable2.Put(veryFirstKey, []byte("first"))
flushable2.Put(veryLastKey, []byte("last"))
it := flushable1.NewIterator(nil, nil)
defer it.Release()
err := flushable2.Flush()
if !assertar.NoError(err) {
return
}
for i := 0; it.Next(); i++ {
if !assertar.Equal(expected[i], it.Key()) ||
!assertar.Equal([]byte("in-order"), it.Value()) {
break
}
}
} | explode_data.jsonl/18347 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 534
} | [
2830,
3393,
46874,
480,
11951,
1155,
353,
8840,
836,
8,
341,
6948,
277,
1669,
2060,
7121,
1155,
692,
2698,
3187,
1669,
2927,
45008,
445,
2271,
46874,
480,
11951,
5130,
197,
3449,
783,
65,
11,
716,
1669,
13364,
12953,
3506,
445,
16,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestIssue13566(t *testing.T) {
skipSpecialPlatforms(t)
// This package only handles gc export data.
if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
}
// On windows, we have to set the -D option for the compiler to avoid having a drive
// letter and an illegal ':' in the import path - just skip it (see also issue #3483).
if runtime.GOOS == "windows" {
t.Skip("avoid dealing with relative paths/drive letters on windows")
}
tmpdir := mktmpdir(t)
defer os.RemoveAll(tmpdir)
testoutdir := filepath.Join(tmpdir, "testdata")
// b.go needs to be compiled from the output directory so that the compiler can
// find the compiled package a. We pass the full path to compile() so that we
// don't have to copy the file to that directory.
bpath, err := filepath.Abs(filepath.Join("testdata", "b.go"))
if err != nil {
t.Fatal(err)
}
compile(t, "testdata", "a.go", testoutdir)
compile(t, testoutdir, bpath, testoutdir)
// import must succeed (test for issue at hand)
pkg := importPkg(t, "./testdata/b", tmpdir)
// make sure all indirectly imported packages have names
for _, imp := range pkg.Imports() {
if imp.Name() == "" {
t.Errorf("no name for %s package", imp.Path())
}
}
} | explode_data.jsonl/30566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 432
} | [
2830,
3393,
42006,
16,
18,
20,
21,
21,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
20366,
87268,
1155,
692,
197,
322,
1096,
6328,
1172,
13469,
22122,
7485,
821,
624,
743,
15592,
35952,
961,
330,
20669,
1,
341,
197,
3244,
57776,
69,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestIsSignatureContractBadNoCheckSig2(t *testing.T) {
prog := make([]byte, 35)
prog[0] = byte(PUSHBYTES33)
prog[34] = byte(CHECKMULTISIG)
assert.Equal(t, false, IsSignatureContract(prog))
} | explode_data.jsonl/40583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
3872,
25088,
14067,
17082,
2753,
3973,
47246,
17,
1155,
353,
8840,
836,
8,
341,
197,
32992,
1669,
1281,
10556,
3782,
11,
220,
18,
20,
340,
197,
32992,
58,
15,
60,
284,
4922,
5304,
19518,
97849,
18,
18,
340,
197,
32992,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewRemoveAllPushChannelsForDeviceBuilder(t *testing.T) {
assert := assert.New(t)
o := newRemoveAllPushChannelsForDeviceBuilder(pubnub)
o.DeviceIDForPush("deviceId")
o.PushType(PNPushTypeAPNS)
str, err := o.opts.buildPath()
assert.Equal("/v1/push/sub-key/sub_key/devices/deviceId/remove", str)
assert.Nil(err)
} | explode_data.jsonl/51093 | {
"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,
3564,
13021,
2403,
16644,
35925,
2461,
6985,
3297,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
22229,
1669,
501,
13021,
2403,
16644,
35925,
2461,
6985,
3297,
74186,
77,
392,
340,
22229,
43995,
915,
2461,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAppend(t *testing.T) {
dir := testutils.InitTestEnv(ModuleName, t)
c, mgr, driver := initTestContext(t, dir)
defer driver.Close()
defer c.Close()
defer mgr.Stop()
schema := catalog.MockSchemaAll(3)
schema.BlockMaxRows = 10000
schema.SegmentMaxBlocks = 10
schema.PrimaryKey = 1
txn := mgr.StartTxn(nil)
db, _ := txn.CreateDatabase("db")
rel, _ := db.CreateRelation(schema)
table, _ := txn.GetStore().(*txnStore).getOrSetTable(rel.ID())
tbl := table.(*txnTable)
rows := uint64(txnbase.MaxNodeRows) / 8 * 3
brows := rows / 3
bat := compute.MockBatch(tbl.GetSchema().Types(), rows, int(tbl.GetSchema().PrimaryKey), nil)
bats := compute.SplitBatch(bat, 3)
err := tbl.BatchDedupLocal(bats[0])
assert.Nil(t, err)
err = tbl.Append(bats[0])
assert.Nil(t, err)
assert.Equal(t, int(brows), int(tbl.Rows()))
assert.Equal(t, int(brows), int(tbl.index.Count()))
err = tbl.BatchDedupLocal(bats[0])
assert.NotNil(t, err)
err = tbl.BatchDedupLocal(bats[1])
assert.Nil(t, err)
err = tbl.Append(bats[1])
assert.Nil(t, err)
assert.Equal(t, 2*int(brows), int(tbl.Rows()))
assert.Equal(t, 2*int(brows), int(tbl.index.Count()))
err = tbl.BatchDedupLocal(bats[2])
assert.Nil(t, err)
err = tbl.Append(bats[2])
assert.Nil(t, err)
assert.Equal(t, 3*int(brows), int(tbl.Rows()))
assert.Equal(t, 3*int(brows), int(tbl.index.Count()))
} | explode_data.jsonl/14641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 619
} | [
2830,
3393,
23877,
1155,
353,
8840,
836,
8,
341,
48532,
1669,
1273,
6031,
26849,
2271,
14359,
75295,
675,
11,
259,
340,
1444,
11,
57897,
11,
5579,
1669,
2930,
2271,
1972,
1155,
11,
5419,
340,
16867,
5579,
10421,
741,
16867,
272,
10421,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestModel_RequestStateSync(t *testing.T) {
syncRequestedPath := []string{
"/interfaces/interface/state/counters",
"/interfaces/interface/state/enabled",
"/interfaces/interface/config/enabled",
}
tss := newTestStateSync(syncRequestedPath...)
m, err := NewModel(nil, nil, tss)
if err != nil {
t.Error("failed to create a model")
}
datablock, _ := ydb.OpenWithSync("gnmi_target", m)
defer datablock.Close()
r, err := os.Open("data/sample.yaml")
defer r.Close()
if err != nil {
t.Fatalf("test data load failed: %v", err)
}
dec := datablock.NewDecoder(r)
dec.Decode()
// gdump.Print(m.Root)
// flag.Set("alsologtostderr", "true")
// flag.Set("v", "100")
// flag.Parse()
type args struct {
prefix *gnmipb.Path
paths []*gnmipb.Path
}
tests := []struct {
name string
args args
want []string
}{
{
name: "RequestStateSync 1",
args: args{
paths: []*gnmipb.Path{
&gnmipb.Path{
Elem: []*gnmipb.PathElem{
&gnmipb.PathElem{
Name: "interfaces",
},
},
},
},
},
want: []string{
"/interfaces/interface[name=eth0]/config/enabled",
"/interfaces/interface[name=eth1]/config/enabled",
"/interfaces/interface[name=eth0]/state/counters",
},
},
{
name: "RequestStateSync 2",
args: args{
prefix: &gnmipb.Path{
Elem: []*gnmipb.PathElem{
&gnmipb.PathElem{
Name: "interfaces",
},
},
},
paths: []*gnmipb.Path{
&gnmipb.Path{
Elem: []*gnmipb.PathElem{
&gnmipb.PathElem{
Name: "interface",
},
&gnmipb.PathElem{
Name: "config",
},
},
},
},
},
want: []string{
"/interfaces/interface[name=eth0]/config/enabled",
"/interfaces/interface[name=eth1]/config/enabled",
},
},
{
name: "RequestStateSync 3",
args: args{
prefix: &gnmipb.Path{
Elem: []*gnmipb.PathElem{
&gnmipb.PathElem{
Name: "interfaces",
},
},
},
paths: []*gnmipb.Path{
&gnmipb.Path{
Elem: []*gnmipb.PathElem{
&gnmipb.PathElem{
Name: "interface",
Key: map[string]string{
"name": "eth1",
},
},
&gnmipb.PathElem{
Name: "config",
},
},
},
},
},
want: []string{
"/interfaces/interface[name=eth1]/config/enabled",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m.RequestStateSync(tt.args.prefix, tt.args.paths)
if !test.IsEqualList(tss.updatedPath, tt.want) {
t.Errorf("FindAllDataNodes() got = %v, want %v", tss.updatedPath, tt.want)
for _, g := range tss.updatedPath {
t.Log("tss.updatedPath::", g)
}
for _, g := range tt.want {
t.Log("tt.want::", g)
}
}
tss.updatedPath = []string{}
})
}
} | explode_data.jsonl/21149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1485
} | [
2830,
3393,
1712,
44024,
1397,
12154,
1155,
353,
8840,
836,
8,
341,
1903,
1721,
37630,
1820,
1669,
3056,
917,
515,
197,
197,
3115,
28965,
47122,
63796,
81043,
388,
756,
197,
197,
3115,
28965,
47122,
63796,
13606,
2312,
756,
197,
197,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestNode_Graphify(t *testing.T) {
exp := `3a64c13ffc8d22739538f49d901d909754e4ca185cf128ce7e64c8482f0cd8c6
├── a26df13b366b0fc0e7a96ec9a1658d691d7640668de633333098d7952ce0c50b
│ ├── 28b5a66c8c61ee13ad5f708a561d758b24d10abe5a0e72133c85d59821539e05
│ │ ├── 3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d
│ │ └── 3f79bb7b435b05321651daefd374cdc681dc06faa65e374e38337b88ca046dea
│ └── 800e03ddb2432933692401d1631850c0af91953fd9c8f3874488c0541dfcf413
│ ├── 18ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4
│ └── 2e7d2c03a9507ae265ecf5b5356885a53393a2029d241394997265a1a25aefc6
└── ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb
`
sb := strings.Builder{}
oddLeavesTree.Root().Graphify(&sb)
if act := sb.String(); act != exp {
t.Errorf("expected graphed tree to be : \n %s \n got \n %s", exp, act)
}
} | explode_data.jsonl/57980 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 494
} | [
2830,
3393,
1955,
2646,
1935,
1437,
1155,
353,
8840,
836,
8,
341,
48558,
1669,
1565,
18,
64,
21,
19,
66,
16,
18,
77887,
23,
67,
17,
17,
22,
18,
24,
20,
18,
23,
69,
19,
24,
67,
24,
15,
16,
67,
24,
15,
24,
22,
20,
19,
68,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestServerKeepAlivesEnabled(t *testing.T) {
defer afterTest(t)
ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {}))
ts.Config.SetKeepAlivesEnabled(false)
ts.Start()
defer ts.Close()
res, err := Get(ts.URL)
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()
if !res.Close {
t.Errorf("Body.Close == false; want true")
}
} | explode_data.jsonl/22473 | {
"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,
5475,
19434,
2101,
1886,
5462,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
57441,
1669,
54320,
70334,
7121,
1806,
46723,
5475,
7,
3050,
9626,
18552,
3622,
5949,
6492,
11,
435,
353,
1900,
8,
4687,
1171,
57441,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestService_RenderManifest(t *testing.T) {
createValuesTestFile()
hash := getValuesHash()
stringifiedManifest := "{\"url\":\"/charts/manifests/stable/app-deploy/v0.0.1/"+hash+"\",\"manifests\":[{\"name\":\"deployment.yaml\",\"content\":\"kind: Deployment\"}]}"
rawManifest := "---\nkind: Deployment\n"
manifest := model.ManifestResponse{
URL: "/charts/manifests/stable/app-deploy/v0.0.1/" + hash,
Manifests: []model.Manifest{
{
Name: "deployment.yaml",
Content: "kind: Deployment",
},
},
}
repository := new(repoMock.Repository)
helm := new(helmMock.Helm)
repository.On("Get", "manifests-stable-app-deploy-v0.0.1-" + hash).Return(stringifiedManifest)
repository.On("Set", "manifests-stable-app-deploy-v0.0.1-"+hash, rawManifest)
helm.On("RenderManifest", "stable", "app-deploy", "v0.0.1", []string{"/tmp/values.yaml"}).Return(manifest)
svc := service.NewService(helm, repository)
err, manifest := svc.RenderManifest("stable", "app-deploy", "v0.0.1", []string{"/tmp/values.yaml"})
assert.NoError(t, err)
expectedManifests := model.ManifestResponse{
URL: "/charts/manifests/stable/app-deploy/v0.0.1/" + hash,
Manifests: []model.Manifest{
{
Name: "deployment.yaml",
Content: "kind: Deployment",
},
},
}
assert.Equal(t, expectedManifests, manifest)
} | explode_data.jsonl/15367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 554
} | [
2830,
3393,
1860,
42102,
38495,
1155,
353,
8840,
836,
8,
341,
39263,
6227,
2271,
1703,
741,
50333,
1669,
633,
6227,
6370,
2822,
11357,
1870,
38495,
1669,
54734,
1085,
23488,
14,
36584,
14,
42315,
82,
14272,
480,
10640,
6810,
2693,
5457,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScrollWithMaxResponseSize(t *testing.T) {
client := setupTestClientAndCreateIndex(t)
tweet1 := tweet{User: "sandrae", Message: "Cycling is fun.", Retweets: 3}
tweet2 := tweet{User: "olivere", Message: "Welcome to Golang and Elasticsearch.", Retweets: 4}
// Add all documents
_, err := client.Index().Index(testIndexName).Id("1").BodyJson(&tweet1).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
_, err = client.Index().Index(testIndexName).Id("2").BodyJson(&tweet2).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
_, err = client.Refresh().Index(testIndexName).Do(context.TODO())
if err != nil {
t.Fatal(err)
}
// Test response size error on first scroll request (first response is 418 bytes)
svc := client.Scroll(testIndexName).Size(1).MaxResponseSize(400)
_, err = svc.Do(context.TODO())
if err != ErrResponseSize {
t.Fatalf("expected response size error")
}
// Test response size error on second scroll request (first response is 418 bytes, second is 439 bytes)
svc = client.Scroll(testIndexName).Size(1).MaxResponseSize(420)
_, err = svc.Do(context.TODO())
if err != nil {
t.Fatal(err)
}
_, err = svc.Do(context.TODO())
if err != ErrResponseSize {
t.Fatalf("expected response size error")
}
} | explode_data.jsonl/59402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 463
} | [
2830,
3393,
8425,
2354,
5974,
2582,
1695,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
6505,
2271,
2959,
3036,
4021,
1552,
1155,
692,
3244,
4488,
16,
1669,
11809,
90,
1474,
25,
330,
82,
23274,
68,
497,
4856,
25,
330,
34,
16021,
374,
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... | 7 |
func TestModifyingRequestWithExistingQueryParameters(t *testing.T) {
r, err := Prepare(
mocks.NewRequestForURL("https://bing.com"),
WithPath("search"),
WithQueryParameters(map[string]interface{}{"q": "golang the best"}),
WithQueryParameters(map[string]interface{}{"pq": "golang+encoded"}),
)
if err != nil {
t.Fatalf("autorest: Preparing an existing request returned an error (%v)", err)
}
if r.URL.Host != "bing.com" {
t.Fatalf("autorest: Preparing an existing request failed when setting the host (%s)", r.URL)
}
if r.URL.Path != "/search" {
t.Fatalf("autorest: Preparing an existing request failed when setting the path (%s)", r.URL.Path)
}
if r.URL.RawQuery != "pq=golang+encoded&q=golang+the+best" {
t.Fatalf("autorest: Preparing an existing request failed when setting the query parameters (%s)", r.URL.RawQuery)
}
} | explode_data.jsonl/20978 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 326
} | [
2830,
3393,
4459,
7766,
1900,
2354,
53067,
2859,
9706,
1155,
353,
8840,
836,
8,
972,
7000,
11,
1848,
1669,
31166,
7805,
197,
2109,
25183,
75274,
2461,
3144,
445,
2428,
1110,
7132,
905,
28978,
197,
197,
89534,
445,
1836,
28978,
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... | 5 |
func TestRouterFromMuxWith(t *testing.T) {
t.Parallel()
r := NewRouter()
with := r.With(func(next Handler) Handler {
return HandlerFunc(func(ctx context.Context, rc *fasthttp.RequestCtx) {
next.ServeHTTP(ctx, rc)
})
})
with.Get("/with_middleware", HandlerFunc(func(ctx context.Context, rc *fasthttp.RequestCtx) {}))
ts := NewTestServer(with)
defer ts.Close()
// Without the fix this test was committed with, this causes a panic.
testRequest(t, ts, http.MethodGet, "/with_middleware", nil)
} | explode_data.jsonl/47948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
9523,
3830,
44,
2200,
2354,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
7000,
1669,
1532,
9523,
2822,
46948,
1669,
435,
26124,
18552,
16913,
19954,
8,
19954,
341,
197,
853,
19954,
9626,
18552,
7502,
2266,
9328,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_default_flag_source_will_find_no_values(t *testing.T) {
var actualErr error
fn := builder.NewFlagSource(nil, func(e error) { actualErr = e })
assert.NoError(t, actualErr)
assert.Equal(t, "", fn("any"))
} | explode_data.jsonl/39393 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
9993,
10933,
10347,
1670,
483,
21814,
6536,
9146,
1155,
353,
8840,
836,
8,
341,
2405,
5042,
7747,
1465,
271,
40095,
1669,
7363,
7121,
12135,
3608,
27907,
11,
2915,
2026,
1465,
8,
314,
5042,
7747,
284,
384,
9568,
6948,
35699,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCopyPipeIntoTCP(t *testing.T) {
ln, err := newLocalListener("tcp")
if err != nil {
t.Fatal(err)
}
defer ln.Close()
errc := make(chan error, 1)
defer func() {
if err := <-errc; err != nil {
t.Error(err)
}
}()
go func() {
c, err := ln.Accept()
if err != nil {
errc <- err
return
}
defer c.Close()
buf := make([]byte, 100)
n, err := io.ReadFull(c, buf)
if err != io.ErrUnexpectedEOF || n != 2 {
errc <- fmt.Errorf("got err=%q n=%v; want err=%q n=2", err, n, io.ErrUnexpectedEOF)
return
}
errc <- nil
}()
c, err := Dial("tcp", ln.Addr().String())
if err != nil {
t.Fatal(err)
}
defer c.Close()
r, w, err := os.Pipe()
if err != nil {
t.Fatal(err)
}
defer r.Close()
errc2 := make(chan error, 1)
defer func() {
if err := <-errc2; err != nil {
t.Error(err)
}
}()
defer w.Close()
go func() {
_, err := io.Copy(c, r)
errc2 <- err
}()
// Split write into 2 packets. That makes Windows TransmitFile
// drop second packet.
packet := make([]byte, 1)
_, err = w.Write(packet)
if err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)
_, err = w.Write(packet)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/18979 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 571
} | [
2830,
3393,
12106,
34077,
26591,
49896,
1155,
353,
8840,
836,
8,
341,
197,
2261,
11,
1848,
1669,
501,
7319,
2743,
445,
27161,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
29390,
10421,
2822,
9859,
66,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFatalThrowBreakpoint(t *testing.T) {
runTest(t, "fatalerror", func(client *daptest.Client, fixture protest.Fixture) {
runDebugSessionWithBPs(t, client, "launch",
// Launch
func() {
client.LaunchRequest("exec", fixture.Path, !stopOnEntry)
},
// Set breakpoints
fixture.Source, []int{3},
[]onBreakpoint{{
execute: func() {
checkStop(t, client, 1, "main.main", 3)
client.ContinueRequest(1)
client.ExpectContinueResponse(t)
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != 1 || se.Body.Reason != "exception" || se.Body.Description != "fatal error" {
t.Errorf("\ngot %#v\nwant ThreadId=1 Reason=\"exception\" Description=\"fatal error\"", se)
}
// TODO(suzmue): Enable this test for 1.17 when https://github.com/golang/go/issues/46425 is fixed.
errorPrefix := "\"go of nil func value\""
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 16) {
errorPrefix = "Throw reason unavailable, see https://github.com/golang/go/issues/46425"
}
client.ExceptionInfoRequest(1)
eInfo := client.ExpectExceptionInfoResponse(t)
if eInfo.Body.ExceptionId != "fatal error" || !strings.HasPrefix(eInfo.Body.Description, errorPrefix) {
t.Errorf("\ngot %#v\nwant ExceptionId=\"runtime error\" Text=%s", eInfo, errorPrefix)
}
},
disconnect: true,
}})
})
runTest(t, "testdeadlock", func(client *daptest.Client, fixture protest.Fixture) {
runDebugSessionWithBPs(t, client, "launch",
// Launch
func() {
client.LaunchRequest("exec", fixture.Path, !stopOnEntry)
},
// Set breakpoints
fixture.Source, []int{3},
[]onBreakpoint{{
execute: func() {
checkStop(t, client, 1, "main.main", 3)
client.ContinueRequest(1)
client.ExpectContinueResponse(t)
se := client.ExpectStoppedEvent(t)
if se.Body.Reason != "exception" || se.Body.Description != "fatal error" {
t.Errorf("\ngot %#v\nwant Reason=\"exception\" Description=\"fatal error\"", se)
}
// TODO(suzmue): Get the exception info for the thread and check the description
// includes "all goroutines are asleep - deadlock!".
// Stopped events with no selected goroutines need to be supported to test deadlock.
},
disconnect: true,
}})
})
} | explode_data.jsonl/17344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 931
} | [
2830,
3393,
62396,
23079,
22524,
2768,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
1155,
11,
330,
74394,
841,
497,
2915,
12805,
353,
91294,
1944,
11716,
11,
12507,
8665,
991,
12735,
8,
341,
197,
56742,
7939,
5283,
2354,
33,
20420,
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 TestClone_CheckoutMergeNoReclone(t *testing.T) {
// Initialize the git repo.
repoDir, cleanup := initRepo(t)
defer cleanup()
// Add a commit to branch 'branch' that's not on master.
runCmd(t, repoDir, "git", "checkout", "branch")
runCmd(t, repoDir, "touch", "branch-file")
runCmd(t, repoDir, "git", "add", "branch-file")
runCmd(t, repoDir, "git", "commit", "-m", "branch-commit")
// Now switch back to master and advance the master branch by another commit.
runCmd(t, repoDir, "git", "checkout", "master")
runCmd(t, repoDir, "touch", "master-file")
runCmd(t, repoDir, "git", "add", "master-file")
runCmd(t, repoDir, "git", "commit", "-m", "master-commit")
// Run the clone for the first time.
dataDir, cleanup2 := TempDir(t)
defer cleanup2()
overrideURL := fmt.Sprintf("file://%s", repoDir)
wd := &events.FileWorkspace{
DataDir: dataDir,
CheckoutMerge: true,
TestingOverrideHeadCloneURL: overrideURL,
TestingOverrideBaseCloneURL: overrideURL,
}
_, err := wd.Clone(nil, models.Repo{}, models.Repo{}, models.PullRequest{
HeadBranch: "branch",
BaseBranch: "master",
}, "default")
Ok(t, err)
// Create a file that we can use to check if the repo was recloned.
runCmd(t, dataDir, "touch", "repos/0/default/proof")
// Now run the clone again.
cloneDir, err := wd.Clone(nil, models.Repo{}, models.Repo{}, models.PullRequest{
HeadBranch: "branch",
BaseBranch: "master",
}, "default")
Ok(t, err)
// Check that our proof file is still there, proving that we didn't reclone.
_, err = os.Stat(filepath.Join(cloneDir, "proof"))
Ok(t, err)
} | explode_data.jsonl/17058 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 632
} | [
2830,
3393,
37677,
28188,
411,
52096,
2753,
693,
19982,
1155,
353,
8840,
836,
8,
341,
197,
322,
9008,
279,
16345,
15867,
624,
17200,
5368,
6184,
11,
21290,
1669,
2930,
25243,
1155,
340,
16867,
21290,
2822,
197,
322,
2691,
264,
5266,
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... | 1 |
func TestGossipMock(t *testing.T) {
g := GossipMock{}
mkChan := func() <-chan *proto.GossipMessage {
c := make(chan *proto.GossipMessage, 1)
c <- &proto.GossipMessage{}
return c
}
g.On("Accept", mock.Anything, false).Return(mkChan(), nil)
a, b := g.Accept(func(o interface{}) bool {
return true
}, false)
assert.Nil(t, b)
assert.NotNil(t, a)
assert.Panics(t, func() {
g.SuspectPeers(func(identity api.PeerIdentityType) bool { return false })
})
assert.Panics(t, func() {
g.Send(nil, nil)
})
assert.Panics(t, func() {
g.Peers()
})
assert.Empty(t, g.PeersOfChannel(common.ChainID("A")))
assert.Panics(t, func() {
g.UpdateMetadata([]byte{})
})
assert.Panics(t, func() {
g.Gossip(nil)
})
assert.NotPanics(t, func() {
g.UpdateChannelMetadata([]byte{}, common.ChainID("A"))
g.Stop()
g.JoinChan(nil, common.ChainID("A"))
})
} | explode_data.jsonl/17978 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 383
} | [
2830,
3393,
38,
41473,
11571,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
479,
41473,
11571,
16094,
2109,
74,
46019,
1669,
2915,
368,
9119,
5658,
353,
15110,
1224,
41473,
2052,
341,
197,
1444,
1669,
1281,
35190,
353,
15110,
1224,
41473,
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 Test001(t *testing.T) {
b := &TB{}
fmt.Println(reflect.TypeOf(b).AssignableTo(reflect.TypeOf(t01).In(0)))
fmt.Println(reflect.TypeOf(b).AssignableTo(reflect.TypeOf(t02).In(0)))
fmt.Println(reflect.TypeOf(*b).AssignableTo(reflect.TypeOf(t03).In(0)))
fmt.Println(reflect.TypeOf(*b).AssignableTo(reflect.TypeOf(t04).In(0)))
fmt.Println(reflect.TypeOf(b).ConvertibleTo(reflect.TypeOf(t01).In(0)))
fmt.Println(reflect.TypeOf(b).ConvertibleTo(reflect.TypeOf(t02).In(0)))
fmt.Println(reflect.TypeOf(*b).ConvertibleTo(reflect.TypeOf(t03).In(0)))
fmt.Println(reflect.TypeOf(*b).ConvertibleTo(reflect.TypeOf(t04).In(0)))
fmt.Println(reflect.TypeOf(b).ConvertibleTo(reflect.TypeOf(t05).In(0)))
t.Fail()
} | explode_data.jsonl/26891 | {
"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,
15,
15,
16,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
609,
31160,
16094,
11009,
12419,
13321,
767,
73921,
1883,
568,
59029,
1249,
13321,
767,
73921,
1155,
15,
16,
568,
641,
7,
15,
5929,
11009,
12419,
13321,
767,
73921,
188... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerWatchGameServers(t *testing.T) {
c, mocks := newFakeController()
fixture := v1alpha1.GameServer{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"}, Spec: newSingleContainerSpec()}
fixture.ApplyDefaults()
pod, err := fixture.Pod()
assert.Nil(t, err)
pod.ObjectMeta.Name = pod.ObjectMeta.GenerateName + "-pod"
gsWatch := watch.NewFake()
podWatch := watch.NewFake()
mocks.AgonesClient.AddWatchReactor("gameservers", k8stesting.DefaultWatchReactor(gsWatch, nil))
mocks.KubeClient.AddWatchReactor("pods", k8stesting.DefaultWatchReactor(podWatch, nil))
mocks.ExtClient.AddReactor("get", "customresourcedefinitions", func(action k8stesting.Action) (bool, runtime.Object, error) {
return true, agtesting.NewEstablishedCRD(), nil
})
received := make(chan string)
defer close(received)
c.workerqueue.SyncHandler = func(name string) error {
assert.Equal(t, "default/test", name)
received <- name
return nil
}
stop, cancel := agtesting.StartInformers(mocks, c.gameServerSynced)
defer cancel()
go func() {
err := c.Run(1, stop)
assert.Nil(t, err, "Run should not error")
}()
logrus.Info("Adding first fixture")
gsWatch.Add(&fixture)
assert.Equal(t, "default/test", <-received)
podWatch.Add(pod)
// no state change
gsWatch.Modify(&fixture)
select {
case <-received:
assert.Fail(t, "Should not be queued")
case <-time.After(time.Second):
}
copyFixture := fixture.DeepCopy()
copyFixture.Status.State = v1alpha1.Starting
logrus.Info("modify copyFixture")
gsWatch.Modify(copyFixture)
assert.Equal(t, "default/test", <-received)
podWatch.Delete(pod)
assert.Equal(t, "default/test", <-received)
} | explode_data.jsonl/25424 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 602
} | [
2830,
3393,
2051,
14247,
4868,
78139,
1155,
353,
8840,
836,
8,
341,
1444,
11,
68909,
1669,
501,
52317,
2051,
741,
1166,
12735,
1669,
348,
16,
7141,
16,
20940,
5475,
90,
1190,
12175,
25,
77520,
16,
80222,
63121,
25,
330,
1944,
497,
419... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCoprocessorOOMAction(t *testing.T) {
// Assert Coprocessor OOMAction
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`set @@tidb_wait_split_region_finish=1`)
// create table for non keep-order case
tk.MustExec("drop table if exists t5")
tk.MustExec("create table t5(id int)")
tk.MustQuery(`split table t5 between (0) and (10000) regions 10`).Check(testkit.Rows("9 1"))
// create table for keep-order case
tk.MustExec("drop table if exists t6")
tk.MustExec("create table t6(id int, index(id))")
tk.MustQuery(`split table t6 between (0) and (10000) regions 10`).Check(testkit.Rows("10 1"))
tk.MustQuery("split table t6 INDEX id between (0) and (10000) regions 10;").Check(testkit.Rows("10 1"))
count := 10
for i := 0; i < count; i++ {
tk.MustExec(fmt.Sprintf("insert into t5 (id) values (%v)", i))
tk.MustExec(fmt.Sprintf("insert into t6 (id) values (%v)", i))
}
testcases := []struct {
name string
sql string
}{
{
name: "keep Order",
sql: "select id from t6 order by id",
},
{
name: "non keep Order",
sql: "select id from t5",
},
}
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/copr/testRateLimitActionMockConsumeAndAssert", `return(true)`))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/copr/testRateLimitActionMockConsumeAndAssert"))
}()
enableOOM := func(tk *testkit.TestKit, name, sql string) {
t.Logf("enable OOM, testcase: %v", name)
// larger than 4 copResponse, smaller than 5 copResponse
quota := 5*copr.MockResponseSizeForTest - 100
defer tk.MustExec("SET GLOBAL tidb_mem_oom_action = DEFAULT")
tk.MustExec("SET GLOBAL tidb_mem_oom_action='CANCEL'")
tk.MustExec("use test")
tk.MustExec("set @@tidb_distsql_scan_concurrency = 10")
tk.MustExec(fmt.Sprintf("set @@tidb_mem_quota_query=%v;", quota))
var expect []string
for i := 0; i < count; i++ {
expect = append(expect, fmt.Sprintf("%v", i))
}
tk.MustQuery(sql).Sort().Check(testkit.Rows(expect...))
// assert oom action worked by max consumed > memory quota
require.Greater(t, tk.Session().GetSessionVars().StmtCtx.MemTracker.MaxConsumed(), int64(quota))
}
disableOOM := func(tk *testkit.TestKit, name, sql string) {
t.Logf("disable OOM, testcase: %v", name)
quota := 5*copr.MockResponseSizeForTest - 100
tk.MustExec("use test")
tk.MustExec("set @@tidb_distsql_scan_concurrency = 10")
tk.MustExec(fmt.Sprintf("set @@tidb_mem_quota_query=%v;", quota))
err := tk.QueryToErr(sql)
require.Error(t, err)
require.Regexp(t, "Out Of Memory Quota.*", err)
}
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/copr/testRateLimitActionMockWaitMax", `return(true)`))
// assert oom action and switch
for _, testcase := range testcases {
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
tk.SetSession(se)
enableOOM(tk, testcase.name, testcase.sql)
tk.MustExec("set @@tidb_enable_rate_limit_action = 0")
disableOOM(tk, testcase.name, testcase.sql)
tk.MustExec("set @@tidb_enable_rate_limit_action = 1")
enableOOM(tk, testcase.name, testcase.sql)
se.Close()
}
globaltk := testkit.NewTestKit(t, store)
globaltk.MustExec("use test")
globaltk.MustExec("set global tidb_enable_rate_limit_action= 0")
for _, testcase := range testcases {
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
tk.SetSession(se)
disableOOM(tk, testcase.name, testcase.sql)
se.Close()
}
globaltk.MustExec("set global tidb_enable_rate_limit_action= 1")
for _, testcase := range testcases {
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
tk.SetSession(se)
enableOOM(tk, testcase.name, testcase.sql)
se.Close()
}
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/copr/testRateLimitActionMockWaitMax"))
// assert oom fallback
for _, testcase := range testcases {
t.Log(testcase.name)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
tk.SetSession(se)
tk.MustExec("use test")
tk.MustExec("set tidb_distsql_scan_concurrency = 1")
tk.MustExec("set @@tidb_mem_quota_query=1;")
err = tk.QueryToErr(testcase.sql)
require.Error(t, err)
require.Regexp(t, "Out Of Memory Quota.*", err)
se.Close()
}
} | explode_data.jsonl/5742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1765
} | [
2830,
3393,
56277,
40848,
269,
57751,
2512,
1155,
353,
8840,
836,
8,
341,
197,
322,
5319,
24946,
40848,
269,
506,
1898,
2512,
198,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLang_English_ToWeekString(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-08-01", "Saturday"},
{"2020-08-02", "Sunday"},
{"2020-08-03", "Monday"},
{"2020-08-04", "Tuesday"},
{"2020-08-05", "Wednesday"},
{"2020-08-06", "Thursday"},
{"2020-08-07", "Friday"},
}
for index, test := range tests {
c := SetTimezone(PRC).Parse(test.input).SetLocale(english)
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToWeekString(), "test index id is "+strconv.Itoa(index))
}
} | explode_data.jsonl/29475 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
26223,
2089,
968,
1672,
38346,
17053,
703,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
78216,
1669,
3056,
1235,
341,
197,
22427,
262,
914,
442,
69058,
25511,
198,
197,
42400,
914,
442,
220,
106076,
25511... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNamespaceGet(t *testing.T) {
r, _ := http.NewRequest("GET", "/v1/user", nil)
w := httptest.NewRecorder()
ns := NewNamespace("/v1")
ns.Get("/user", func(ctx *context.Context) {
ctx.Output.Body([]byte("v1_user"))
})
AddNamespace(ns)
BeeApp.Handlers.ServeHTTP(w, r)
if w.Body.String() != "v1_user" {
t.Errorf("TestNamespaceGet can't run, get the response is " + w.Body.String())
}
} | explode_data.jsonl/12604 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
22699,
1949,
1155,
353,
8840,
836,
8,
341,
7000,
11,
716,
1669,
1758,
75274,
445,
3806,
497,
3521,
85,
16,
11739,
497,
2092,
340,
6692,
1669,
54320,
70334,
7121,
47023,
2822,
84041,
1669,
1532,
22699,
4283,
85,
16,
1138,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReconcileTimeouts(t *testing.T) {
type testCase struct {
taskRun *v1alpha1.TaskRun
expectedStatus *apis.Condition
wantEvents []string
}
testcases := []testCase{
{
taskRun: tb.TaskRun("test-taskrun-timeout",
tb.TaskRunNamespace("foo"),
tb.TaskRunSpec(
tb.TaskRunTaskRef(simpleTask.Name),
tb.TaskRunTimeout(10*time.Second),
),
tb.TaskRunStatus(tb.StatusCondition(apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown}),
tb.TaskRunStartTime(time.Now().Add(-15*time.Second)))),
expectedStatus: &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: "TaskRunTimeout",
Message: `TaskRun "test-taskrun-timeout" failed to finish within "10s"`,
},
wantEvents: []string{
"Warning Failed ",
},
}, {
taskRun: tb.TaskRun("test-taskrun-default-timeout-60-minutes",
tb.TaskRunNamespace("foo"),
tb.TaskRunSpec(
tb.TaskRunTaskRef(simpleTask.Name),
),
tb.TaskRunStatus(tb.StatusCondition(apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown}),
tb.TaskRunStartTime(time.Now().Add(-61*time.Minute)))),
expectedStatus: &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: "TaskRunTimeout",
Message: `TaskRun "test-taskrun-default-timeout-60-minutes" failed to finish within "1h0m0s"`,
},
wantEvents: []string{
"Warning Failed ",
},
}, {
taskRun: tb.TaskRun("test-taskrun-nil-timeout-default-60-minutes",
tb.TaskRunNamespace("foo"),
tb.TaskRunSpec(
tb.TaskRunTaskRef(simpleTask.Name),
tb.TaskRunNilTimeout,
),
tb.TaskRunStatus(tb.StatusCondition(apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown}),
tb.TaskRunStartTime(time.Now().Add(-61*time.Minute)))),
expectedStatus: &apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionFalse,
Reason: "TaskRunTimeout",
Message: `TaskRun "test-taskrun-nil-timeout-default-60-minutes" failed to finish within "1h0m0s"`,
},
wantEvents: []string{
"Warning Failed ",
},
}}
for _, tc := range testcases {
d := test.Data{
TaskRuns: []*v1alpha1.TaskRun{tc.taskRun},
Tasks: []*v1alpha1.Task{simpleTask},
}
testAssets, cancel := getTaskRunController(t, d)
defer cancel()
c := testAssets.Controller
clients := testAssets.Clients
reconciler := c.Reconciler.(*Reconciler)
fr := reconciler.Recorder.(*record.FakeRecorder)
if err := c.Reconciler.Reconcile(context.Background(), getRunName(tc.taskRun)); err != nil {
t.Fatalf("Unexpected error when reconciling completed TaskRun : %v", err)
}
newTr, err := clients.Pipeline.TektonV1alpha1().TaskRuns(tc.taskRun.Namespace).Get(tc.taskRun.Name, metav1.GetOptions{})
if err != nil {
t.Fatalf("Expected completed TaskRun %s to exist but instead got error when getting it: %v", tc.taskRun.Name, err)
}
condition := newTr.Status.GetCondition(apis.ConditionSucceeded)
if d := cmp.Diff(tc.expectedStatus, condition, ignoreLastTransitionTime); d != "" {
t.Fatalf("Did not get expected condition (-want, +got): %v", d)
}
err = checkEvents(fr, tc.taskRun.Name, tc.wantEvents)
if !(err == nil) {
t.Errorf(err.Error())
}
}
} | explode_data.jsonl/884 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1442
} | [
2830,
3393,
693,
40446,
457,
7636,
82,
1155,
353,
8840,
836,
8,
341,
13158,
54452,
2036,
341,
197,
49115,
6727,
286,
353,
85,
16,
7141,
16,
28258,
6727,
198,
197,
42400,
2522,
353,
13725,
75134,
198,
197,
50780,
7900,
257,
3056,
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 TestDockerGetContainerIDSuccess(t *testing.T) {
composeMock, docker, _ := getComposeMocks()
composeMock.On("Ps", mock.Anything, mock.Anything, mock.Anything).Return([]api.ContainerSummary{{ID: "testID", Name: "test", State: "running", Publishers: api.PortPublishers{api.PortPublisher{PublishedPort: 8888}}}}, nil)
id, err := docker.GetContainerID("test")
assert.NoError(t, err)
assert.Contains(t, id, "testID")
} | explode_data.jsonl/50548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
35,
13659,
1949,
4502,
915,
7188,
1155,
353,
8840,
836,
8,
341,
32810,
2900,
11571,
11,
26588,
11,
716,
1669,
633,
70492,
72577,
741,
32810,
2900,
11571,
8071,
445,
20420,
497,
7860,
13311,
1596,
11,
7860,
13311,
1596,
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 TestSplit002(t *testing.T) {
var inText string
var got, want []string
inText = `bla, bla: bla`
want = []string{"bla", "bla", "bla"}
got = stringToCleanSlice(inText)
if !equalSlice(got, want) {
t.Errorf("stringToCleanSlice(inText) == %q, want %q", got, want)
}
} | explode_data.jsonl/59195 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
20193,
15,
15,
17,
1155,
353,
8840,
836,
8,
341,
2405,
304,
1178,
914,
198,
2405,
2684,
11,
1366,
3056,
917,
271,
17430,
1178,
284,
1565,
64726,
11,
84541,
25,
84541,
3989,
50780,
284,
3056,
917,
4913,
64726,
497,
330,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCheckMessages(t *testing.T) {
fmt.Print("Starting unit tests\n")
messageService := MockMessageService{}
_, err := CheckMessages(messageService, "user")
if err != nil {
t.Errorf("TestCheckMessages: Got an error: %v\n", err)
}
} | explode_data.jsonl/13348 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
3973,
15820,
1155,
353,
8840,
836,
8,
341,
11009,
7918,
445,
24617,
4982,
7032,
1699,
1138,
24753,
1860,
1669,
14563,
2052,
1860,
16094,
197,
6878,
1848,
1669,
4248,
15820,
7333,
1860,
11,
330,
872,
1138,
743,
1848,
961,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHistogramBucketExemplar_Attachments(t *testing.T) {
ms := NewHistogramBucketExemplar()
ms.InitEmpty()
assert.EqualValues(t, NewStringMap(), ms.Attachments())
fillTestStringMap(ms.Attachments())
testValAttachments := generateTestStringMap()
assert.EqualValues(t, testValAttachments, ms.Attachments())
} | explode_data.jsonl/19568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
77210,
36018,
840,
25892,
277,
81797,
610,
1368,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
77210,
36018,
840,
25892,
277,
741,
47691,
26849,
3522,
741,
6948,
12808,
6227,
1155,
11,
1532,
703,
2227,
1507,
9829,
88284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGrpcLogger(t *testing.T) {
closedCalled := setupExitCounter()
defer resetExitFns()
closeFn := func() {
*closedCalled++
}
var ew eventWriter
logger.Start(&ew)
tags := logger.Tags{"TestGrpcLogger"}
logTime := time.Now()
grpclog.SetLogger(CreateLogger(tags, closeFn))
expectedEvents := callGrpcLogger(tags)
if err := logger.Close(); err != nil {
t.Fatal("Unexpected error closing logger: " + err.Error())
}
if expectedN, got := len(expectedEvents), len(ew.events); expectedN != got {
t.Fatalf("Expected %d events, but got got %d", expectedN, got)
}
for i, event := range ew.events {
expected, got := expectedEvents[i], event
expected.Timestamp = logTime
if err := compareEvents(i, expected, got); err != nil {
t.Error(err)
}
}
if *closedCalled != 6 {
t.Fatalf("Expected the exit and close function to be called three times, but got %d",
*closedCalled/2)
}
} | explode_data.jsonl/28007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
6464,
3992,
7395,
1155,
353,
8840,
836,
8,
341,
1444,
9259,
20960,
1669,
6505,
15339,
14099,
741,
16867,
7585,
15339,
37,
4412,
741,
27873,
24911,
1669,
2915,
368,
341,
197,
197,
9,
34087,
20960,
22940,
197,
630,
2405,
36890... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Query_Keeper_Asset(t *testing.T) {
context, keepers := CreateTestInput2(t)
immutableProperties, Error := base.ReadProperties("defaultImmutable1:S|defaultImmutable1")
require.Equal(t, nil, Error)
mutableProperties, Error2 := base.ReadProperties("burn:S|100")
require.Equal(t, nil, Error2)
classificationID := base.NewID("ClassificationID")
assetID := key.NewAssetID(classificationID, immutableProperties)
keepers.(queryKeeper).mapper.NewCollection(context).Add(mappable.NewAsset(assetID, immutableProperties, mutableProperties))
testQueryRequest := newQueryRequest(assetID)
require.Equal(t, queryResponse{Success: true, Error: nil, List: keepers.(queryKeeper).mapper.NewCollection(context).Fetch(key.FromID(assetID)).GetList()}, keepers.(queryKeeper).Enquire(context, testQueryRequest))
} | explode_data.jsonl/22762 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
48042,
10102,
43031,
62741,
746,
1155,
353,
8840,
836,
8,
1476,
28413,
11,
2506,
388,
1669,
4230,
2271,
2505,
17,
1155,
340,
197,
91240,
7903,
11,
4600,
1669,
2331,
6503,
7903,
445,
2258,
58890,
16,
75369,
91,
2258,
58890,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVariables_ObjectsAndNullability_UsingInlineStructs_DoesNotUseIncorrectValue(t *testing.T) {
doc := `
{
fieldWithObjectInput(input: ["foo", "bar", "baz"])
}
`
expected := &graphql.Result{
Data: map[string]interface{}{
"fieldWithObjectInput": nil,
},
}
// parse query
ast := testutil.TestParse(t, doc)
// execute
ep := graphql.ExecuteParams{
Schema: variablesTestSchema,
AST: ast,
}
result := testutil.TestExecute(t, ep)
if len(result.Errors) > 0 {
t.Fatalf("wrong result, unexpected errors: %v", result.Errors)
}
if !reflect.DeepEqual(expected, result) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, result))
}
} | explode_data.jsonl/6430 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
22678,
62,
11543,
3036,
3280,
2897,
62,
16429,
25324,
9422,
82,
1557,
7072,
2623,
10253,
40468,
1130,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
22074,
286,
341,
688,
2070,
2354,
1190,
2505,
5384,
25,
4383,
7975,
497,
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... | 3 |
func TestOwners_Claim(t *testing.T) {
m := NewClient(os.Getenv("MNUBO_CLIENT_ID"), os.Getenv("MNUBO_CLIENT_SECRET"), os.Getenv("MNUBO_HOST"))
ob, ow := uuid.New().String(), uuid.New().String()
var results []ClaimResult
err := m.Owners.Claim([]ObjectOwnerPair{
{
XDeviceID: ob,
Username: ow,
},
}, &results)
if err != nil {
t.Errorf("client call failed: %+v", err)
}
} | explode_data.jsonl/81389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
57762,
85110,
2640,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
2959,
9638,
64883,
445,
44,
3926,
4677,
22521,
3450,
3975,
2643,
64883,
445,
44,
3926,
4677,
22521,
31408,
3975,
2643,
64883,
445,
44,
3926,
4677,
17213,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMats_RolePolicy(t *testing.T) {
sName := "TestMats_RolePolicy"
sType := pms.TypeApplication
rpName := "role-policy1"
rpName1 := "role-policy2"
context := &testutil.TestContext{
NameIDMap: make(map[string]string),
NameObjectMap: make(map[string]interface{}),
}
data := &[]testutil.TestCase{
{
Name: "TestCreateService1",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_CREATE_SERVICE,
Data: &testutil.CmdTestData{
Param: param.CREATE_SERVICE(sName, sType),
ExpectedMsg: msg.OUTPUT_SERVICE_CREATED(),
OutputBody: &pms.Service{},
ExpectedBody: &pms.Service{
Name: sName,
Type: sType,
},
},
},
{
Name: "TestGetService1",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_GET_SERVICE,
Data: &testutil.CmdTestData{
Param: param.GET_SERVICE(sName),
OutputBody: &pms.Service{},
ExpectedBody: &pms.Service{
Name: sName,
Type: sType,
},
},
},
{
Name: "TestCreateRolePolicy1",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_CREATE_ROLEPOLICY,
Data: &testutil.CmdTestData{
Param: param.CREATE_ROLEPOLICY(sName, rpName, "grant user user1 role1 on res1"),
ExpectedMsg: msg.OUTPUT_ROLEPOLICY_CREATED(),
OutputBody: &pms.RolePolicy{},
ExpectedBody: &pms.RolePolicy{
Name: rpName,
Effect: pms.Grant,
Roles: []string{"role1"},
Principals: []string{"user:user1"},
Resources: []string{"res1"},
},
},
},
{
Name: "TestCreateRolePolicy2",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_CREATE_ROLEPOLICY,
Data: &testutil.CmdTestData{
Param: param.CREATE_ROLEPOLICY(sName, rpName1, "grant user User1,role Role2 Role1,Role2 on res2"),
ExpectedMsg: msg.OUTPUT_ROLEPOLICY_CREATED(),
OutputBody: &pms.RolePolicy{},
ExpectedBody: &pms.RolePolicy{
Name: rpName1,
Effect: pms.Grant,
Roles: []string{"Role1", "Role2"},
Principals: []string{"user:User1", "role:Role2"},
Resources: []string{"res2"},
},
},
},
{
Name: "TestGetRolePolicy1",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_GET_ROLEPOLICY,
Data: &testutil.CmdTestData{
Param: "TO be init in PreTestFunc with id",
OutputBody: &pms.RolePolicy{},
ExpectedBody: &pms.RolePolicy{
Name: rpName,
Effect: pms.Grant,
Roles: []string{"role1"},
Principals: []string{"user:user1"},
Resources: []string{"res1"},
},
},
PreTestFunc: func(data interface{}, context *testutil.TestContext) {
cmdTD := data.(*testutil.CmdTestData)
id, ok := context.NameIDMap[rpName]
if ok {
cmdTD.Param = param.GET_ROLEPOLICY(sName, id)
testutil.TestLog.Log(id)
}
},
},
{
Name: "TestGetRolePolicyAll",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_QUERY_ROLEPOLICY,
Data: &testutil.CmdTestData{
Param: param.GET_ROLEPOLICY_ALL(sName),
OutputBody: &[]*pms.RolePolicy{},
ExpectedBody: &[]*pms.RolePolicy{
{
Name: rpName,
Effect: pms.Grant,
Roles: []string{"role1"},
Principals: []string{"user:user1"},
Resources: []string{"res1"},
},
{
Name: rpName1,
Effect: pms.Grant,
Roles: []string{"Role1", "Role2"},
Principals: []string{"user:User1", "role:Role2"},
Resources: []string{"res2"},
},
},
},
},
{
Name: "TestDeleteRolePolicy1",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_DELETE_ROLEPOLICY,
Data: &testutil.CmdTestData{
Param: "to be init in preTestFun",
ExpectedMsg: "to be init in preTestFun",
},
PreTestFunc: func(data interface{}, context *testutil.TestContext) {
cmdTD := data.(*testutil.CmdTestData)
id, ok := context.NameIDMap[rpName]
if ok {
cmdTD.Param = param.DELETE_ROLEPOLICY(sName, id)
cmdTD.ExpectedMsg = msg.OUTPUT_ROLEPOLICY_DELETED(id)
testutil.TestLog.Log(id)
}
},
},
{
Name: "TestGetRolePolicy1-NotExisting",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_GET_ROLEPOLICY,
Data: &testutil.CmdTestData{
Param: "TO be init in PreTestFunc with id",
ExpectedMsg: "TO be init in PreTestFunc with id",
},
PreTestFunc: func(data interface{}, context *testutil.TestContext) {
cmdTD := data.(*testutil.CmdTestData)
id, ok := context.NameIDMap[rpName]
if ok {
cmdTD.Param = param.GET_ROLEPOLICY(sName, id)
cmdTD.ExpectedMsg = msg.OUTPUT_ROLEPOLICY_NOTFOUND(sName, id)
testutil.TestLog.Log(id)
}
},
},
{
Name: "TestDeleteService1",
Enabled: true,
Executer: testutil.NewCmdTest,
Method: testutil.METHOD_DELETE_SERVICE,
Data: &testutil.CmdTestData{
Param: param.DELETE_SERVICE(sName),
ExpectedMsg: msg.OUTPUT_SERVICE_DELETED(sName),
},
},
}
testutil.RunTestCases(t, data, context)
} | explode_data.jsonl/580 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2545
} | [
2830,
3393,
44,
1862,
2568,
1263,
13825,
1155,
353,
8840,
836,
8,
1476,
1903,
675,
1669,
330,
2271,
44,
1862,
2568,
1263,
13825,
698,
1903,
929,
1669,
281,
1011,
10184,
4988,
271,
7000,
79,
675,
1669,
330,
5778,
66420,
16,
698,
7000,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPrintPriorityClass(t *testing.T) {
tests := []struct {
pc scheduling.PriorityClass
expected []metav1.TableRow
}{
{
pc: scheduling.PriorityClass{
ObjectMeta: metav1.ObjectMeta{
Name: "pc1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Value: 1,
},
expected: []metav1.TableRow{{Cells: []interface{}{"pc1", int64(1), bool(false), "0s"}}},
},
{
pc: scheduling.PriorityClass{
ObjectMeta: metav1.ObjectMeta{
Name: "pc2",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Value: 1000000000,
GlobalDefault: true,
},
expected: []metav1.TableRow{{Cells: []interface{}{"pc2", int64(1000000000), bool(true), "5m"}}},
},
}
for i, test := range tests {
rows, err := printPriorityClass(&test.pc, printers.GenerateOptions{})
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 516
} | [
2830,
3393,
8994,
20555,
1957,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
82013,
981,
37852,
83590,
1957,
198,
197,
42400,
3056,
4059,
402,
16,
18257,
3102,
198,
197,
59403,
197,
197,
515,
298,
82013,
25,
37852,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestADS1x15DriverAnalogReadInvalidPin(t *testing.T) {
d, _ := initTestADS1015DriverWithStubbedAdaptor()
_, err := d.AnalogRead("99")
gobottest.Assert(t, err, errors.New("Invalid channel, must be between 0 and 3"))
} | explode_data.jsonl/42586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
49541,
16,
87,
16,
20,
11349,
2082,
30951,
4418,
7928,
19861,
1155,
353,
8840,
836,
8,
341,
2698,
11,
716,
1669,
2930,
2271,
49541,
16,
15,
16,
20,
11349,
2354,
33838,
2721,
2589,
32657,
2822,
197,
6878,
1848,
1669,
294,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetFilteredAutoscalingGroupsWithInvalidVMType(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ngdo := cloudprovider.NodeGroupDiscoveryOptions{
NodeGroupAutoDiscoverySpecs: []string{"label:fake-tag=fake-value"},
}
manager := newTestAzureManager(t)
expectedScaleSets := []compute.VirtualMachineScaleSet{}
mockVMSSClient := mockvmssclient.NewMockInterface(ctrl)
mockVMSSClient.EXPECT().List(gomock.Any(), manager.config.ResourceGroup).Return(expectedScaleSets, nil).AnyTimes()
manager.azClient.virtualMachineScaleSetsClient = mockVMSSClient
manager.config.VMType = vmTypeAKS
specs, err := parseLabelAutoDiscoverySpecs(ngdo)
assert.NoError(t, err)
asgs1, err1 := manager.getFilteredAutoscalingGroups(specs)
assert.Nil(t, asgs1)
assert.Nil(t, err1)
manager.config.VMType = "invalidVMType"
expectedErr := fmt.Errorf("vmType \"invalidVMType\" not supported")
asgs, err2 := manager.getFilteredAutoscalingGroups(specs)
assert.Nil(t, asgs)
assert.Equal(t, expectedErr, err2, "Not match, expected: %v, actual: %v", expectedErr, err2)
} | explode_data.jsonl/12796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 390
} | [
2830,
3393,
1949,
67310,
19602,
436,
81552,
2808,
16056,
7928,
11187,
929,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
968,
2982,
1669,
9437,
19979,
21714,
2808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsEastAsian(t *testing.T) {
testcases := []struct {
locale string
want bool
}{
{"foo@cjk_narrow", false},
{"foo@cjk", false},
{"utf-8@cjk", false},
{"ja_JP.CP932", true},
}
for _, tt := range testcases {
got := isEastAsian(tt.locale)
if got != tt.want {
t.Fatalf("isEastAsian(%q) should be %v", tt.locale, tt.want)
}
}
} | explode_data.jsonl/66383 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
3872,
36340,
67440,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
197,
14484,
914,
198,
197,
50780,
256,
1807,
198,
197,
59403,
197,
197,
4913,
7975,
89916,
41808,
1089,
6044,
497,
895,
1583,
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 TestValidate_UniqueOperationNames_MultipleOperationsOfSameNameOfDifferentTypes_Mutation(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.UniqueOperationNamesRule, `
query Foo {
fieldA
}
mutation Foo {
fieldB
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`There can only be one operation named "Foo".`, 2, 13, 5, 16),
})
} | explode_data.jsonl/23174 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
17926,
62,
22811,
8432,
7980,
1245,
12229,
35120,
2124,
19198,
675,
2124,
69123,
4173,
1245,
22705,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
81893,
37,
6209,
11337,
1155,
11,
48865,
87443,
8432,
7980,
11337,
11,
22074,
414,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseName(t *testing.T) {
const bzzHash = "89c17d0d8018a19057314aa035e61c9d23c47581a61dd3a79a7839692c617e4d"
log := logging.New(ioutil.Discard, 0)
testCases := []struct {
desc string
name string
res resolver.Interface
noResolver bool
wantAdr swarm.Address
wantErr error
}{
{
desc: "empty name",
name: "",
wantErr: api.ErrInvalidNameOrAddress,
},
{
desc: "bzz hash",
name: bzzHash,
wantAdr: swarm.MustParseHexAddress(bzzHash),
},
{
desc: "no resolver connected with bzz hash",
name: bzzHash,
noResolver: true,
wantAdr: swarm.MustParseHexAddress(bzzHash),
},
{
desc: "no resolver connected with name",
name: "itdoesntmatter.eth",
noResolver: true,
wantErr: api.ErrNoResolver,
},
{
desc: "name not resolved",
name: "not.good",
res: resolverMock.NewResolver(
resolverMock.WithResolveFunc(func(string) (swarm.Address, error) {
return swarm.ZeroAddress, errors.New("failed to resolve")
}),
),
wantErr: api.ErrInvalidNameOrAddress,
},
{
desc: "name resolved",
name: "everything.okay",
wantAdr: swarm.MustParseHexAddress("89c17d0d8018a19057314aa035e61c9d23c47581a61dd3a79a7839692c617e4d"),
},
}
for _, tC := range testCases {
if tC.res == nil && !tC.noResolver {
tC.res = resolverMock.NewResolver(
resolverMock.WithResolveFunc(func(string) (swarm.Address, error) {
return tC.wantAdr, nil
}))
}
pk, _ := crypto.GenerateSecp256k1Key()
signer := crypto.NewDefaultSigner(pk)
mockPostage := mockpost.New()
s := api.New(nil, nil, tC.res, nil, nil, nil, nil, mockPostage, nil, signer, log, nil, api.Options{}).(*api.Server)
t.Run(tC.desc, func(t *testing.T) {
got, err := s.ResolveNameOrAddress(tC.name)
if err != nil && !errors.Is(err, tC.wantErr) {
t.Fatalf("bad error: %v", err)
}
if !got.Equal(tC.wantAdr) {
t.Errorf("got %s, want %s", got, tC.wantAdr)
}
})
}
} | explode_data.jsonl/28014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 989
} | [
2830,
3393,
14463,
675,
1155,
353,
8840,
836,
8,
341,
4777,
293,
10400,
6370,
284,
330,
23,
24,
66,
16,
22,
67,
15,
67,
23,
15,
16,
23,
64,
16,
24,
15,
20,
22,
18,
16,
19,
5305,
15,
18,
20,
68,
21,
16,
66,
24,
67,
17,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCancelAllLeases(t *testing.T) {
to, path, err := createBalances()
assert.NoError(t, err, "createBalances() failed")
defer func() {
to.stor.close(t)
err = common.CleanTemporaryDirs(path)
assert.NoError(t, err, "failed to clean test data dirs")
}()
to.stor.addBlock(t, blockID0)
to.stor.addBlock(t, blockID1)
tests := []struct {
addr string
profile balanceProfile
blockID proto.BlockID
}{
{addr0, balanceProfile{100, 1, 1}, blockID0},
{addr1, balanceProfile{2500, 2, 0}, blockID0},
{addr2, balanceProfile{10, 0, 10}, blockID1},
{addr3, balanceProfile{10, 5, 3}, blockID1},
}
for _, tc := range tests {
addr, err := proto.NewAddressFromString(tc.addr)
assert.NoError(t, err, "NewAddressFromString() failed")
err = to.balances.setWavesBalance(addr.ID(), newWavesValueFromProfile(tc.profile), tc.blockID)
assert.NoError(t, err, "setWavesBalance() failed")
}
err = to.balances.cancelAllLeases(blockID1)
assert.NoError(t, err, "cancelAllLeases() failed")
to.stor.flush(t)
for _, tc := range tests {
addr, err := proto.NewAddressFromString(tc.addr)
assert.NoError(t, err, "NewAddressFromString() failed")
profile, err := to.balances.wavesBalance(addr.ID(), true)
assert.NoError(t, err, "wavesBalance() failed")
assert.Equal(t, profile.balance, tc.profile.balance)
assert.Equal(t, profile.leaseIn, int64(0))
assert.Equal(t, profile.leaseOut, int64(0))
}
} | explode_data.jsonl/37801 | {
"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,
9269,
2403,
2304,
2264,
1155,
353,
8840,
836,
8,
341,
31709,
11,
1815,
11,
1848,
1669,
1855,
37889,
3020,
741,
6948,
35699,
1155,
11,
1848,
11,
330,
3182,
37889,
3020,
368,
4641,
5130,
16867,
2915,
368,
341,
197,
31709,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.