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 TestJetStream_ClusterPlacement(t *testing.T) {
size := 3
t.Run("default cluster", func(t *testing.T) {
cluster := "PLC1"
withJSCluster(t, cluster, size, func(t *testing.T, nodes ...*jsServer) {
srvA := nodes[0]
nc, err := nats.Connect(srvA.ClientURL())
if err != nil {
t.Error(err)
}
defer nc.Close()
js, err := nc.JetStream()
if err != nil {
t.Fatal(err)
}
stream := &nats.StreamConfig{
Name: "TEST",
Placement: &nats.Placement{
Tags: []string{"NODE_0"},
},
}
_, err = js.AddStream(stream)
if err != nil {
t.Errorf("Unexpected error placing stream: %v", err)
}
})
})
t.Run("known cluster", func(t *testing.T) {
cluster := "PLC2"
withJSCluster(t, cluster, size, func(t *testing.T, nodes ...*jsServer) {
srvA := nodes[0]
nc, err := nats.Connect(srvA.ClientURL())
if err != nil {
t.Error(err)
}
defer nc.Close()
js, err := nc.JetStream()
if err != nil {
t.Fatal(err)
}
stream := &nats.StreamConfig{
Name: "TEST",
Placement: &nats.Placement{
Cluster: cluster,
Tags: []string{"NODE_0"},
},
}
_, err = js.AddStream(stream)
if err != nil {
t.Errorf("Unexpected error placing stream: %v", err)
}
})
})
t.Run("unknown cluster", func(t *testing.T) {
cluster := "PLC3"
withJSCluster(t, cluster, size, func(t *testing.T, nodes ...*jsServer) {
srvA := nodes[0]
nc, err := nats.Connect(srvA.ClientURL())
if err != nil {
t.Error(err)
}
defer nc.Close()
js, err := nc.JetStream()
if err != nil {
t.Fatal(err)
}
stream := &nats.StreamConfig{
Name: "TEST",
Placement: &nats.Placement{
Cluster: "UNKNOWN",
},
}
_, err = js.AddStream(stream)
if err == nil {
t.Error("Unexpected success creating stream in unknown cluster")
}
expected := `insufficient resources`
if err != nil && err.Error() != expected {
t.Errorf("Expected %q error, got: %v", expected, err)
}
})
})
} | explode_data.jsonl/29181 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 956
} | [
2830,
3393,
35641,
3027,
85110,
4993,
28237,
1155,
353,
8840,
836,
8,
341,
13832,
1669,
220,
18,
271,
3244,
16708,
445,
2258,
10652,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197,
18855,
1669,
330,
2916,
34,
16,
698,
197,
46948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreate_SeedError(t *testing.T) {
cfg := &testConfigSeedError{}
got, err := New(cfg).Create()
assert.NoError(t, err)
assert.NotNil(t, got)
ctx, cnl := context.WithCancel(context.Background())
defer cnl()
err = got.Harvest(ctx)
assert.Error(t, err)
} | explode_data.jsonl/47207 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
4021,
1098,
12051,
1454,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
609,
1944,
2648,
41471,
1454,
16094,
3174,
354,
11,
1848,
1669,
1532,
28272,
568,
4021,
741,
6948,
35699,
1155,
11,
1848,
340,
6948,
93882,
1155,
11,
2684,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSearch__fedwireNameOnlySearchRequest(t *testing.T) {
u, _ := url.Parse("https://moov.io/fed/wire/search?name=MIDWest")
req := readFEDSearchRequest(u)
if req.Name != "MIDWEST" {
t.Errorf("req.Name=%s", req.Name)
}
if !req.nameOnly() {
t.Error("req is not name only")
}
} | explode_data.jsonl/71097 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
5890,
563,
51123,
35531,
675,
7308,
5890,
1900,
1155,
353,
8840,
836,
8,
341,
10676,
11,
716,
1669,
2515,
8937,
445,
2428,
1110,
6355,
859,
4245,
6663,
291,
6324,
554,
23167,
30,
606,
49682,
915,
23306,
1138,
24395,
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 TestWriter_Write(t *testing.T) {
for _, v := range writerWriteTests {
w := new(bytes.Buffer)
e, err := NewWriter(w, v.LineBreak, v.Encoding)
if err != nil {
if v.Error == "" {
t.Errorf("%s: unexpected error %q", v.Name, err.Error())
} else if v.Error != err.Error() {
t.Errorf("%s: error %q, want error %q", v.Name, err.Error(), v.Error)
}
continue
}
e.Delimiter = v.Delimiter
for _, r := range v.Records {
_ = e.Write(r)
}
_ = e.Flush()
result := w.String()
if result != v.Expect {
t.Errorf("%s:\n"+
" result = %q\n"+
" want = %q", v.Name, result, v.Expect)
}
}
} | explode_data.jsonl/50133 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 306
} | [
2830,
3393,
6492,
31825,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
348,
1669,
2088,
6916,
7985,
18200,
341,
197,
6692,
1669,
501,
23158,
22622,
692,
197,
7727,
11,
1848,
1669,
1532,
6492,
3622,
11,
348,
16420,
22524,
11,
348,
58764,
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... | 7 |
func TestSetTerminalReason(t *testing.T) {
expectedTerminalReason := "Failed to provision resource"
overrideTerminalReason := "should not override terminal reason"
task := &Task{}
// set terminal reason string
task.SetTerminalReason(expectedTerminalReason)
assert.Equal(t, expectedTerminalReason, task.GetTerminalReason())
// try to override terminal reason string, should not overwrite
task.SetTerminalReason(overrideTerminalReason)
assert.Equal(t, expectedTerminalReason, task.GetTerminalReason())
} | explode_data.jsonl/37233 | {
"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,
1649,
47890,
25139,
1155,
353,
8840,
836,
8,
1476,
42400,
47890,
25139,
1669,
330,
9408,
311,
17136,
5101,
698,
50284,
47890,
25139,
1669,
330,
5445,
537,
2812,
15022,
2874,
1837,
49115,
1669,
609,
6262,
31483,
197,
322,
738,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileInterfaceDoesntExist(t *testing.T) {
fcmd := exec.FakeCmd{
CombinedOutputScript: []exec.FakeCombinedOutputAction{
func() ([]byte, error) { return []byte("\n"), nil },
func() ([]byte, error) { return []byte("\n"), nil },
},
}
fexec := exec.FakeExec{
CommandScript: []exec.FakeCommandAction{
func(cmd string, args ...string) exec.Cmd { return exec.InitFakeCmd(&fcmd, cmd, args...) },
func(cmd string, args ...string) exec.Cmd { return exec.InitFakeCmd(&fcmd, cmd, args...) },
},
}
iface := "cbr0"
shaper := &tcShaper{e: &fexec, iface: iface}
err := shaper.ReconcileInterface()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if fcmd.CombinedOutputCalls != 2 {
t.Errorf("unexpected number of calls: %d", fcmd.CombinedOutputCalls)
}
for ix, output := range fcmd.CombinedOutputLog {
if output[0] != "tc" {
t.Errorf("unexpected command: %s", output[0])
}
if output[4] != iface {
t.Errorf("unexpected interface: %s, expected %s", output[4], iface)
}
if ix == 0 {
if len(output) != 5 {
t.Errorf("unexpected command: %v", output)
}
if output[2] != "show" {
t.Errorf("unexpected action: %s", output[2])
}
}
if ix == 1 {
if len(output) != 11 {
t.Errorf("unexpected command: %v", output)
}
if output[2] != "add" {
t.Errorf("unexpected action: %s", output[2])
}
if output[7] != "1:" {
t.Errorf("unexpected root class: %s", output[7])
}
if output[8] != "htb" {
t.Errorf("unexpected qdisc algo: %s", output[8])
}
}
}
} | explode_data.jsonl/5412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 671
} | [
2830,
3393,
693,
40446,
457,
5051,
21468,
406,
25613,
1155,
353,
8840,
836,
8,
341,
1166,
8710,
1669,
3883,
991,
726,
15613,
515,
197,
197,
94268,
5097,
5910,
25,
3056,
11748,
991,
726,
94268,
5097,
2512,
515,
298,
29244,
368,
34923,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_RedisEnterprise_Spec_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip of RedisEnterprise_Spec via JSON returns original",
prop.ForAll(RunJSONSerializationTestForRedisEnterpriseSpec, RedisEnterpriseSpecGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
} | explode_data.jsonl/44557 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
2568,
41825,
85647,
1098,
992,
62,
4498,
77521,
78967,
98054,
2848,
4756,
2121,
2993,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
220,
16,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHyphenAsPositional(t *testing.T) {
var args struct {
Foo string `arg:"positional"`
}
err := parse("-", &args)
require.NoError(t, err)
assert.Equal(t, "-", args.Foo)
} | explode_data.jsonl/13068 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
30816,
14769,
2121,
3812,
278,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
12727,
2624,
914,
1565,
858,
2974,
966,
3005,
8805,
197,
532,
9859,
1669,
4715,
68046,
609,
2116,
340,
17957,
35699,
1155,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestLoggingServiceV2DeleteLogError(t *testing.T) {
errCode := codes.Internal
mockLogging.err = grpc.Errorf(errCode, "test error")
var formattedLogName string = LoggingLogPath("[PROJECT]", "[LOG]")
var request = &loggingpb.DeleteLogRequest{
LogName: formattedLogName,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
err = c.DeleteLog(context.Background(), request)
if c := grpc.Code(err); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
} | explode_data.jsonl/77758 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
34575,
1860,
53,
17,
6435,
2201,
1454,
1155,
353,
8840,
836,
8,
341,
9859,
2078,
1669,
13912,
32579,
198,
77333,
34575,
18441,
284,
47900,
13080,
3964,
2078,
11,
330,
1944,
1465,
5130,
2405,
23126,
2201,
675,
914,
284,
41706... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMemberAdd(t *testing.T) {
h := newHelper(t)
helpers.AllowMe(h, types.RoleRbacResource(0), "members.manage")
r := h.repoMakeRole(h.randEmail())
u := h.createUserWithEmail(h.randEmail())
h.apiInit().
Post(fmt.Sprintf("/roles/%d/member/%d", r.ID, u.ID)).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
} | explode_data.jsonl/8350 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
9366,
2212,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
5511,
1155,
340,
197,
21723,
29081,
7823,
3203,
11,
4494,
35955,
49,
55877,
4783,
7,
15,
701,
330,
22974,
50821,
5130,
7000,
1669,
305,
46169,
8078,
9030,
3203,
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 TestCatalogError_Http(t *testing.T) {
tc := testutils.Setup(t)
testutils.LoadFixtures(t, tc.FixturePath())
// User with catalog:refresh scope
agent, token, err := tc.AgentWithScopes("agent-001", "catalog:refresh")
assert.Equal(t, agent.AgentName, "agent-001")
assert.NoError(t, err)
CatalogErrorChecker(tc).Test(t, http.MethodGet, "/catalog/catalog-official/error").
WithHeader("Authorization", token).Check().
HasStatus(200).Cb(func(r *http.Response) {
b, readErr := ioutil.ReadAll(r.Body)
assert.NoError(t, readErr)
defer r.Body.Close()
res, err := testutils.FormatJSON(b)
assert.NoError(t, err)
golden.Assert(t, res, fmt.Sprintf("%s.golden", t.Name()))
})
} | explode_data.jsonl/73431 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
41606,
1454,
2039,
1209,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
1273,
6031,
39820,
1155,
340,
18185,
6031,
13969,
25958,
18513,
1155,
11,
17130,
991,
12735,
1820,
12367,
197,
322,
2657,
448,
16403,
25,
17168,
6891,
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 TestPageHelper2(t *testing.T) {
pFac := New(gobatis.NewFactory(
gobatis.SetMaxConn(100),
gobatis.SetMaxIdleConn(50),
gobatis.SetDataSource(&datasource.MysqlDataSource{
Host: "localhost",
Port: 3306,
DBName: "test",
Username: "test",
Password: "test",
Charset: "utf8",
})))
sessMgr := gobatis.NewSessionManager(pFac)
session := sessMgr.NewSession()
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
ctx = StartPage(ctx, 1, 2)
session.SetContext(ctx)
var ret []TestTable
session.Select("SELECT * FROM test_table").Param().Result(&ret)
t.Log(ret)
} | explode_data.jsonl/64343 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 256
} | [
2830,
3393,
2665,
5511,
17,
1155,
353,
8840,
836,
8,
341,
3223,
28702,
1669,
1532,
3268,
674,
3605,
7121,
4153,
1006,
197,
3174,
674,
3605,
4202,
5974,
9701,
7,
16,
15,
15,
1326,
197,
3174,
674,
3605,
4202,
5974,
41370,
9701,
7,
20,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewContext(t *testing.T) {
New([]config.Client{
{
Serial: "12FF9503829A3A0DDE9CB87191A472D4",
Scopes: []string{"READ", "WRITE"},
},
})
c := new(big.Int)
c.SetString("12FF9503829A3A0DDE9CB87191A472D4", 16)
ctx1 := NewContext(context.Background(), c)
if _, ok := FromContext(ctx1); !ok {
t.Fatal()
}
ctxbg := context.Background()
ctx2 := NewContext(ctxbg, nil)
if !reflect.DeepEqual(ctx2, ctxbg) {
t.Fatal()
}
} | explode_data.jsonl/65814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
3564,
1972,
1155,
353,
8840,
836,
8,
341,
197,
3564,
10556,
1676,
11716,
515,
197,
197,
515,
298,
93658,
25,
330,
16,
17,
1748,
24,
20,
15,
18,
23,
17,
24,
32,
18,
32,
15,
35,
1150,
24,
12979,
23,
22,
16,
24,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInstallation(t *testing.T) {
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true), zap.Level(uzap.NewAtomicLevelAt(uzap.DebugLevel))))
RegisterFailHandler(Fail)
junitReporter := reporters.NewJUnitReporter("../../../report/installation_controller_suite.xml")
RunSpecsWithDefaultAndCustomReporters(t, "pkg/controller/installation Suite", []Reporter{junitReporter})
} | explode_data.jsonl/51707 | {
"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,
55453,
1155,
353,
8840,
836,
8,
341,
6725,
69,
4202,
7395,
13174,
391,
7121,
13174,
391,
4073,
1249,
6699,
766,
3346,
6492,
701,
32978,
9046,
14592,
3636,
3715,
701,
32978,
25259,
7,
5197,
391,
7121,
65857,
4449,
1655,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUCompositeIndexInfo(t *testing.T) {
t.Parallel()
cp, err := currency.NewPairFromString("DEFI-USDT")
if err != nil {
t.Error(err)
}
_, err = b.UCompositeIndexInfo(context.Background(), cp)
if err != nil {
t.Error(err)
}
_, err = b.UCompositeIndexInfo(context.Background(), currency.EMPTYPAIR)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
52,
41685,
1552,
1731,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
52018,
11,
1848,
1669,
11413,
7121,
12443,
44491,
445,
13649,
40,
32340,
10599,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCheckRetryClosesBody(t *testing.T) {
count := 0
ch := make(chan struct{})
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
count++
t.Logf("attempt %d", count)
if count >= 5 {
w.WriteHeader(http.StatusOK)
close(ch)
return
}
w.Header().Set("Retry-After", "1")
http.Error(w, "Too many requests, please try again later.", http.StatusTooManyRequests)
}))
defer testServer.Close()
backoffMgr := &testBackoffManager{}
expectedSleeps := []time.Duration{0, time.Second, 0, time.Second, 0, time.Second, 0, time.Second, 0}
c := testRESTClient(t, testServer)
c.createBackoffMgr = func() BackoffManager { return backoffMgr }
_, err := c.Verb("POST").
Prefix("foo", "bar").
Suffix("baz").
Timeout(time.Second).
Body([]byte(strings.Repeat("abcd", 1000))).
DoRaw()
if err != nil {
t.Fatalf("Unexpected error: %v %#v", err, err)
}
<-ch
if count != 5 {
t.Errorf("unexpected retries: %d", count)
}
if !reflect.DeepEqual(backoffMgr.sleeps, expectedSleeps) {
t.Errorf("unexpected sleeps, expected: %v, got: %v", expectedSleeps, backoffMgr.sleeps)
}
} | explode_data.jsonl/13272 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 461
} | [
2830,
3393,
3973,
51560,
34,
49341,
5444,
1155,
353,
8840,
836,
8,
341,
18032,
1669,
220,
15,
198,
23049,
1669,
1281,
35190,
2036,
37790,
18185,
5475,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
4232,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEditHistoryRenameParentAcrossDirs(t *testing.T) {
// Bob writes one file, and alice renames the parent dir into a
// different subdirectory.
expectedEdits := []expectedEdit{
{
"alice,bob",
keybase1.FolderType_PRIVATE,
"bob",
[]string{"/keybase/private/alice,bob/d/c/b"},
nil,
},
}
expectedEdits2 := []expectedEdit{
{
"alice,bob",
keybase1.FolderType_PRIVATE,
"alice",
nil,
[]string{"/keybase/private/alice,bob/d/c/b"},
},
}
test(t,
users("alice", "bob"),
as(alice,
mkdir("a"),
mkdir("d"),
),
as(bob,
mkfile("a/b", "hello"),
),
as(alice,
addTime(1*time.Minute),
rename("a", "d/c"),
),
as(alice,
checkUserEditHistory(expectedEdits),
),
as(bob,
checkUserEditHistory(expectedEdits),
),
as(alice,
addTime(1*time.Minute),
rm("d/c/b"),
),
as(alice,
checkUserEditHistory(expectedEdits2),
),
as(bob,
checkUserEditHistory(expectedEdits2),
),
)
} | explode_data.jsonl/54762 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 475
} | [
2830,
3393,
4036,
13424,
88757,
8387,
91931,
97384,
1155,
353,
8840,
836,
8,
341,
197,
322,
14261,
13914,
825,
1034,
11,
323,
70433,
5672,
971,
279,
2681,
5419,
1119,
264,
198,
197,
322,
2155,
1186,
23037,
624,
42400,
2715,
1199,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConsulDiscovery_Register(t *testing.T) {
t.Parallel()
c, s := testConsulServer(t)
defer closecs(s)
d := testNewConsulDiscovery(c)
type args struct {
rs RegisterService
}
tests := []struct {
name string
args args
panic bool
}{
{
name: "Register a service",
args: args{
rs: ConvertToRS(config.Server{
ID: "123",
Address: "127.0.0.1",
Port: 8080,
TypeNode: "worker",
}, "ns"),
},
panic: false,
},
{
name: "GraphID empty",
args: args{
rs: ConvertToRS(config.Server{}, ""),
},
panic: true,
},
{
name: "Address equal is empty",
args: args{
rs: ConvertToRS(config.Server{
Address: "",
Port: 2020,
}, "gi"),
},
panic: true,
},
{
name: "Port equal to zero",
args: args{
rs: ConvertToRS(config.Server{
Address: "127.0.0.1",
Port: 0,
}, "gi"),
},
panic: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.panic {
assert.Panics(t, func() { d.Register(tt.args.rs) }, "Panics")
return
}
d.Register(tt.args.rs)
rs, _, err := c.Agent().Service(tt.args.rs.ID, &api.QueryOptions{})
if assert.NoError(t, err, "Error getting service info") {
assert.Equal(t, tt.args.rs.ID, rs.ID, "ID")
assert.Equal(t, tt.args.rs.Port, rs.Port, "Port")
assert.Equal(t, tt.args.rs.TypeNode, rs.Tags[0], "TypeNode")
assert.Equal(t, tt.args.rs.GraphID, rs.Service, "GraphID")
}
})
}
} | explode_data.jsonl/69056 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 750
} | [
2830,
3393,
15220,
360,
67400,
73124,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1444,
11,
274,
1669,
1273,
15220,
360,
5475,
1155,
340,
16867,
3265,
4837,
1141,
340,
2698,
1669,
1273,
3564,
15220,
360,
67400,
1337,
692,
131... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilePoolCloseError(t *testing.T) {
dir, err := ioutil.TempDir("", "fastzip-filepool")
require.NoError(t, err)
defer os.RemoveAll(dir)
fp, err := New(dir, 16, -1)
require.NoError(t, err)
for _, file := range fp.files {
f := fp.Get()
_, err := f.Write([]byte("foobar"))
assert.NoError(t, err)
fp.Put(f)
require.NoError(t, file.f.Close())
}
err = fp.Close()
require.Error(t, err, "expected already closed error")
assert.Contains(t, err.Error(), "file already closed\n")
count := 0
for {
count++
if err = errors.Unwrap(err); err == nil {
break
}
}
assert.Equal(t, 16, count)
} | explode_data.jsonl/60248 | {
"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,
1703,
10551,
7925,
1454,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
9349,
9964,
14203,
10285,
1138,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
84427,
14161,
692,
65219,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
loadBalancer := NewLoadBalancerRR()
fooServiceP := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "testnamespace", Name: "foo"}, Port: "p"}
barServiceP := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "testnamespace", Name: "bar"}, Port: "p"}
endpoint, err := loadBalancer.NextEndpoint(fooServiceP, nil, false)
if err == nil || len(endpoint) != 0 {
t.Errorf("Didn't fail with non-existent service")
}
endpoints := make([]api.Endpoints, 2)
endpoints[0] = api.Endpoints{
ObjectMeta: api.ObjectMeta{Name: fooServiceP.Name, Namespace: fooServiceP.Namespace},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{{IP: "endpoint1"}, {IP: "endpoint2"}, {IP: "endpoint3"}},
Ports: []api.EndpointPort{{Name: "p", Port: 123}},
},
},
}
endpoints[1] = api.Endpoints{
ObjectMeta: api.ObjectMeta{Name: barServiceP.Name, Namespace: barServiceP.Namespace},
Subsets: []api.EndpointSubset{
{
Addresses: []api.EndpointAddress{{IP: "endpoint4"}, {IP: "endpoint5"}, {IP: "endpoint6"}},
Ports: []api.EndpointPort{{Name: "p", Port: 456}},
},
},
}
loadBalancer.OnEndpointsUpdate(endpoints)
shuffledFooEndpoints := loadBalancer.services[fooServiceP].endpoints
expectEndpoint(t, loadBalancer, fooServiceP, shuffledFooEndpoints[0], nil)
expectEndpoint(t, loadBalancer, fooServiceP, shuffledFooEndpoints[1], nil)
expectEndpoint(t, loadBalancer, fooServiceP, shuffledFooEndpoints[2], nil)
expectEndpoint(t, loadBalancer, fooServiceP, shuffledFooEndpoints[0], nil)
expectEndpoint(t, loadBalancer, fooServiceP, shuffledFooEndpoints[1], nil)
shuffledBarEndpoints := loadBalancer.services[barServiceP].endpoints
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[0], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[1], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[2], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[0], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[1], nil)
// Then update the configuration by removing foo
loadBalancer.OnEndpointsUpdate(endpoints[1:])
endpoint, err = loadBalancer.NextEndpoint(fooServiceP, nil, false)
if err == nil || len(endpoint) != 0 {
t.Errorf("Didn't fail with non-existent service")
}
// but bar is still there, and we continue RR from where we left off.
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[2], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[0], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[1], nil)
expectEndpoint(t, loadBalancer, barServiceP, shuffledBarEndpoints[2], nil)
} | explode_data.jsonl/66178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1013
} | [
2830,
3393,
5879,
21190,
6776,
16056,
1860,
6590,
13516,
1155,
353,
8840,
836,
8,
341,
49386,
93825,
1669,
1532,
5879,
93825,
8106,
741,
197,
7975,
1860,
47,
1669,
13291,
13860,
7084,
675,
90,
7980,
68552,
675,
25,
4494,
98932,
68552,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestRouter_StaticFiles_ServerStaticFileFromDir(t *testing.T) {
mainRouter := Router{}
_ = mainRouter.StaticFiles("/path1", "./fixtures")
req, _ := http.NewRequest("GET", "/path1/test.html", nil)
res := httptest.NewRecorder()
mainRouter.ServeHTTP(res, req)
assertEqual(t, 200, res.Code)
file, _ := ioutil.ReadFile("./fixtures/test.html")
if res.Body.String() != string(file) {
t.Errorf("Invalid file %s", file)
}
req, _ = http.NewRequest("GET", "/path1/index.html", nil)
res = httptest.NewRecorder()
mainRouter.ServeHTTP(res, req)
assertEqual(t, 301, res.Code)
req, _ = http.NewRequest("GET", "/path1/not-found.html", nil)
res = httptest.NewRecorder()
mainRouter.ServeHTTP(res, req)
assertEqual(t, 404, res.Code)
} | explode_data.jsonl/31742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
9523,
27049,
10809,
62320,
11690,
1703,
3830,
6184,
1155,
353,
8840,
836,
8,
341,
36641,
9523,
1669,
10554,
31483,
197,
62,
284,
1887,
9523,
58826,
10809,
4283,
2343,
16,
497,
5924,
45247,
5130,
24395,
11,
716,
1669,
1758,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFilter_SingleMatchingProcess_SingleOHIRecipe(t *testing.T) {
r := []types.OpenInstallationRecipe{
{
ID: "1",
Name: "cassandra-open-source-integration",
ProcessMatch: []string{"cassandra", "cassandradaemon", "cqlsh"},
},
}
processes := []types.GenericProcess{
mockProcess{
name: "cassandra",
cmdline: "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.272.b10-1.amzn2.0.1.x86_64/jre/bin/java -Xloggc:/var/log/cassandra/gc.log -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:StringTableSize=1000003 -XX:+AlwaysPreTouch -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+UseNUMA -XX:+PerfDisableSharedMem -Djava.net.preferIPv4Stack=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSWaitDuration=10000 -XX:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M -Xms977M -Xmx977M -Xmn200M -XX:+UseCondCardMark -XX:CompileCommandFile=/etc/cassandra/conf/hotspot_compiler -javaagent:/usr/share/cassandra/lib/jamm-0.3.0.jar -Dcassandra.jmx.local.port=7199 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password -Djava.library.path=/usr/share/cassandra/lib/sigar-bin -XX:OnOutOfMemoryError=kill -9 %p -Dlogback.configurationFile=logback.xml -Dcassandra.logdir=/var/log/cassandra -Dcassandra.storagedir= -Dcassandra-pidfile=/var/run/cassandra/cassandra.pid -cp /etc/cassandra/conf:/usr/share/cassandra/lib/airline-0.6.jar:/usr/share/cassandra/lib/antlr-runtime-3.5.2.jar:/usr/share/cassandra/lib/asm-5.0.4.jar:/usr/share/cassandra/lib/caffeine-2.2.6.jar:/usr/share/cassandra/lib/cassandra-driver-core-3.0.1-shaded.jar:/usr/share/cassandra/lib/commons-cli-1.1.jar:/usr/share/cassandra/lib/commons-codec-1.9.jar:/usr/share/cassandra/lib/commons-lang3-3.1.jar:/usr/share/cassandra/lib/commons-math3-3.2.jar:/usr/share/cassandra/lib/compress-lzf-0.8.4.jar:/usr/share/cassandra/lib/concurrentlinkedhashmap-lru-1.4.jar:/usr/share/cassandra/lib/concurrent-trees-2.4.0.jar:/usr/share/cassandra/lib/disruptor-3.0.1.jar:/usr/share/cassandra/lib/ecj-4.4.2.jar:/usr/share/cassandra/lib/guava-18.0.jar:/usr/share/cassandra/lib/HdrHistogram-2.1.9.jar:/usr/share/cassandra/lib/high-scale-lib-1.0.6.jar:/usr/share/cassandra/lib/hppc-0.5.4.jar:/usr/share/cassandra/lib/jackson-annotations-2.9.10.jar:/usr/share/cassandra/lib/jackson-core-2.9.10.jar:/usr/share/cassandra/lib/jackson-databind-2.9.10.4.jar:/usr/share/cassandra/lib/jamm-0.3.0.jar:/usr/share/cassandra/lib/javax.inject.jar:/usr/share/cassandra/lib/jbcrypt-0.3m.jar:/usr/share/cassandra/lib/jcl-over-slf4j-1.7.7.jar:/usr/share/cassandra/lib/jctools-core-1.2.1.jar:/usr/share/cassandra/lib/jflex-1.6.0.jar:/usr/share/cassandra/lib/jna-4.2.2.jar:/usr/share/cassandra/lib/joda-time-2.4.jar:/usr/share/cassandra/lib/json-simple-1.1.jar:/usr/share/cassandra/lib/jstackjunit-0.0.1.jar:/usr/share/cassandra/lib/libthrift-0.9.2.jar:/usr/share/cassandra/lib/log4j-over-slf4j-1.7.7.jar:/usr/share/cassandra/lib/logback-classic-1.1.3.jar:/usr/share/cassandra/lib/logback-core-1.1.3.jar:/usr/share/cassandra/lib/lz4-1.3.0.jar:/usr/share/cassandra/lib/metrics-core-3.1.5.jar:/usr/share/cassandra/lib/metrics-jvm-3.1.5.jar:/usr/share/cassandra/lib/metrics-logback-3.1.5.jar:/usr/share/cassandra/lib/netty-all-4.0.44.Final.jar:/usr/share/cassandra/lib/ohc-core-0.4.4.jar:/usr/share/cassandra/lib/ohc-core-j8-0.4.4.jar:/usr/share/cassandra/lib/reporter-config3-3.0.3.jar:/usr/share/cassandra/lib/reporter-config-base-3.0.3.jar:/usr/share/cassandra/lib/sigar-1.6.4.jar:/usr/share/cassandra/lib/slf4j-api-1.7.7.jar:/usr/share/cassandra/lib/snakeyaml-1.11.jar:/usr/share/cassandra/lib/snappy-java-1.1.1.7.jar:/usr/share/cassandra/lib/snowball-stemmer-1.3.0.581.1.jar:/usr/share/cassandra/lib/ST4-4.0.8.jar:/usr/share/cassandra/lib/stream-2.5.2.jar:/usr/share/cassandra/lib/thrift-server-0.3.7.jar:/usr/share/cassandra/apache-cassandra-3.11.10.jar:/usr/share/cassandra/apache-cassandra-thrift-3.11.10.jar:/usr/share/cassandra/stress.jar: org.apache.cassandra.service.CassandraDaemon",
},
mockProcess{
name: "somethingElse",
cmdline: "somethingElse",
},
}
mockRecipeFetcher := recipes.NewMockRecipeFetcher()
mockRecipeFetcher.FetchRecipesVal = r
f := NewRegexProcessFilterer(mockRecipeFetcher)
filtered, err := f.filter(context.Background(), processes, types.DiscoveryManifest{})
require.NoError(t, err)
require.NotNil(t, filtered)
require.NotEmpty(t, filtered)
require.Equal(t, 1, len(filtered))
require.Equal(t, filtered[0].MatchingPattern, "cassandra")
} | explode_data.jsonl/15737 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2241
} | [
2830,
3393,
5632,
1098,
2173,
64430,
7423,
1098,
2173,
46,
23913,
28780,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
3056,
9242,
12953,
55453,
28780,
515,
197,
197,
515,
298,
29580,
25,
1843,
330,
16,
756,
298,
21297,
25,
260,
330,
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... | 1 |
func TestSample2(t *testing.T) {
L, H := 3, 5
S := "baaaababababbababbab"
a, b := 6, 3
runSample(t, L, H, S, a, b)
} | explode_data.jsonl/74393 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
17571,
17,
1155,
353,
8840,
836,
8,
341,
15070,
11,
472,
1669,
220,
18,
11,
220,
20,
198,
7568,
1669,
330,
4645,
5305,
370,
370,
370,
12523,
370,
12523,
370,
698,
11323,
11,
293,
1669,
220,
21,
11,
220,
18,
198,
56742,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestComplexDeleteWithoutAllPrimarykeys(t *testing.T) {
ranInt := rand.Intn(writerComplexDeletePkTestData.InsertCount)
w := newWriter()
c, err := NewClient(WithURI(fmt.Sprintf("postgres://127.0.0.1:5432/%s?sslmode=disable", writerComplexDeletePkTestData.DB)))
if err != nil {
t.Fatalf("unable to initialize connection to postgres, %s", err)
}
defer c.Close()
s, err := c.Connect()
if err != nil {
t.Fatalf("unable to obtain session to postgres, %s", err)
}
msg := message.From(ops.Delete, fmt.Sprintf("public.%s", writerComplexDeletePkTestData.Table), data.Data{"id": ranInt})
if _, err := w.Write(msg)(s); err == nil {
t.Fatalf("Did not receive anticipated error from postgres.writeMessage")
}
var id int
if err := s.(*Session).pqSession.
QueryRow(fmt.Sprintf("SELECT id FROM %s WHERE id = %d AND colvar = '%s'", writerComplexDeletePkTestData.Table,
ranInt,
randomHeros[ranInt])).
Scan(&id); err != nil {
t.Fatalf("Expected to find values, but none were found: %v", err)
}
} | explode_data.jsonl/32015 | {
"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,
31137,
6435,
26040,
2403,
15972,
10563,
1155,
353,
8840,
836,
8,
341,
197,
6576,
1072,
1669,
10382,
7371,
77,
38356,
31137,
6435,
58415,
83920,
23142,
2507,
340,
6692,
1669,
501,
6492,
741,
1444,
11,
1848,
1669,
1532,
2959,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestRollingUpdater_extractMaxValue(t *testing.T) {
tests := []struct {
field intstr.IntOrString
original int
expected int
valid bool
}{
{
field: intstr.FromInt(1),
original: 100,
expected: 1,
valid: true,
},
{
field: intstr.FromInt(0),
original: 100,
expected: 0,
valid: true,
},
{
field: intstr.FromInt(-1),
original: 100,
valid: false,
},
{
field: intstr.FromString("10%"),
original: 100,
expected: 10,
valid: true,
},
{
field: intstr.FromString("100%"),
original: 100,
expected: 100,
valid: true,
},
{
field: intstr.FromString("200%"),
original: 100,
expected: 200,
valid: true,
},
{
field: intstr.FromString("0%"),
original: 100,
expected: 0,
valid: true,
},
{
field: intstr.FromString("-1%"),
original: 100,
valid: false,
},
}
for i, test := range tests {
t.Logf("evaluating test %d", i)
max, err := extractMaxValue(test.field, "field", test.original)
if test.valid && err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !test.valid && err == nil {
t.Fatalf("expected an error")
}
if e, a := test.expected, max; e != a {
t.Fatalf("expected max %d, got %d", e, a)
}
}
} | explode_data.jsonl/52540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 631
} | [
2830,
3393,
32355,
287,
79854,
39123,
5974,
1130,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
39250,
262,
526,
495,
7371,
2195,
703,
198,
197,
197,
9889,
526,
198,
197,
42400,
526,
198,
197,
56322,
262,
1807,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestPessimisticConflictRetryAutoID(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t;")
tk.MustExec("create table t (id int not null auto_increment unique key, idx int unique key, c int);")
concurrency := 2
var wg sync.WaitGroup
var err []error
wg.Add(concurrency)
err = make([]error, concurrency)
for i := 0; i < concurrency; i++ {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set tidb_txn_mode = 'pessimistic'")
tk.MustExec("set autocommit = 1")
go func(idx int) {
for i := 0; i < 10; i++ {
sql := fmt.Sprintf("insert into t(idx, c) values (1, %[1]d) on duplicate key update c = %[1]d", i)
_, e := tk.Exec(sql)
if e != nil {
err[idx] = e
wg.Done()
return
}
}
wg.Done()
}(i)
}
wg.Wait()
for _, e := range err {
require.NoError(t, e)
}
} | explode_data.jsonl/38149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 429
} | [
2830,
3393,
47,
66733,
4532,
57974,
51560,
13253,
915,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateUpsertSQL(t *testing.T) {
Convey("Given a datapoint and a known shape", t, func() {
longKeyValue := ""
for index := 0; index < 32; index++ {
longKeyValue = longKeyValue + "12345678"
}
expectedLongKeyValue := longKeyValue[:255]
dp := pipeline.DataPoint{
Entity: "Products",
Source: "Test",
Shape: pipeline.Shape{
KeyNames: []string{"ID", "LongKey"},
Properties: []string{"NextDateAvailable:date", "ID:integer", "Name:string", "Price:float", "LongKey:string", "LongText:text"},
},
Data: map[string]interface{}{
"Name": "First",
"Price": 42.2,
"ID": 1,
"NextDateAvailable": "2017-10-11",
"LongKey": longKeyValue,
"LongText": longText,
},
}
shape := shapeutils.NewKnownShape(dp)
Convey("When we generate upsert SQL for the first time", func() {
nowDateStr := time.Now().UTC().Format("2006-01-02")
actual, params, err := createUpsertSQL(dp, shape)
Convey("Then there should be no error", nil)
So(err, ShouldBeNil)
Convey("Then the SQL should be correct", nil)
So(actual, ShouldEqual, e(`INSERT INTO "Test.Products" ("ID", "LongKey", "LongText", "Name", "NextDateAvailable", "Price",
"naveegoPublisher", "naveegoPublishedAt", "naveegoShapeVersion")
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
"LongText" = VALUES("LongText"),
"Name" = VALUES("Name"),
"NextDateAvailable" = VALUES("NextDateAvailable"),
"Price" = VALUES("Price"),
"naveegoPublisher" = VALUES("naveegoPublisher"),
"naveegoPublishedAt" = VALUES("naveegoPublishedAt"),
"naveegoShapeVersion" = VALUES("naveegoShapeVersion");`))
Convey("Then the parameters should be in the correct order", nil)
So(params[0], ShouldEqual, 1)
So(params[1], ShouldEqual, expectedLongKeyValue)
So(params[2], ShouldEqual, longText)
So(params[3], ShouldEqual, "First")
So(params[4], ShouldEqual, "2017-10-11")
So(params[5], ShouldEqual, 42.2)
So(params[6], ShouldEqual, "UNKNOWN")
So(params[7], ShouldStartWith, nowDateStr)
So(params[8], ShouldEqual, "UNKNOWN")
// Convey("Then the cache should be populated", func() {
// _, ok := shape.Get(keyUpsertSQL)
// So(ok, ShouldBeTrue)
// _, ok = shape.Get(keyParameterOrderer)
// So(ok, ShouldBeTrue)
// })
})
// Convey("When we generate upsert SQL on a shape we've seen before", func() {
// expectedParameters := []interface{}{"ok"}
// expectedSQL := "OK"
// shape.Set(keyUpsertSQL, expectedSQL)
// shape.Set(keyParameterOrderer, func(datapoint pipeline.DataPoint) []interface{} {
// return expectedParameters
// })
// actual, params, err := createUpsertSQL(dp, shape)
// Convey("Then there should be no error", nil)
// So(err, ShouldBeNil)
// Convey("Then the cached SQL should be reused", nil)
// So(actual, ShouldEqual, expectedSQL)
// Convey("Then the cache parameter orderer should be used", nil)
// So(params, ShouldResemble, expectedParameters)
// })
})
} | explode_data.jsonl/23286 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1326
} | [
2830,
3393,
4021,
98778,
529,
6688,
1155,
353,
8840,
836,
8,
8022,
93070,
5617,
445,
22043,
264,
61723,
781,
323,
264,
3881,
6083,
497,
259,
11,
2915,
368,
8022,
197,
17514,
72082,
1669,
51946,
197,
2023,
1922,
1669,
220,
15,
26,
1922... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPostHookWhenShutDown(t *testing.T) {
done := make(chan bool)
p := pipeline.New(
pipeline.Node(&NoOpProcessor{}),
)
p.AddPostProcessingHook(func(ctx context.Context, err error) error {
assert.Equal(t, pipeline.ErrShutdown, err)
done <- true
return nil
})
go p.Process(&SimpleReader{})
time.Sleep(100 * time.Millisecond)
p.Shutdown()
<-done
} | explode_data.jsonl/64700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
4133,
31679,
4498,
2016,
332,
4454,
1155,
353,
8840,
836,
8,
341,
40495,
1669,
1281,
35190,
1807,
340,
3223,
1669,
15301,
7121,
1006,
197,
3223,
8790,
21714,
2099,
2753,
7125,
22946,
6257,
1326,
197,
692,
3223,
1904,
4133,
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 TestTCPResetsSentIncrement(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
stats := c.Stack().Stats()
wq := &waiter.Queue{}
ep, err := c.Stack().NewEndpoint(tcp.ProtocolNumber, ipv4.ProtocolNumber, wq)
if err != nil {
t.Fatalf("NewEndpoint failed: %s", err)
}
want := stats.TCP.SegmentsSent.Value() + 1
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %s", err)
}
if err := ep.Listen(10); err != nil {
t.Fatalf("Listen failed: %s", err)
}
// Send a SYN request.
iss := seqnum.Value(context.TestInitialSequenceNumber)
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagSyn,
SeqNum: iss,
})
// Receive the SYN-ACK reply.
b := c.GetPacket()
tcpHdr := header.TCP(header.IPv4(b).Payload())
c.IRS = seqnum.Value(tcpHdr.SequenceNumber())
ackHeaders := &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagAck,
SeqNum: iss + 1,
// If the AckNum is not the increment of the last sequence number, a RST
// segment is sent back in response.
AckNum: c.IRS + 2,
}
// Send ACK.
c.SendPacket(nil, ackHeaders)
c.GetPacket()
metricPollFn := func() error {
if got := stats.TCP.ResetsSent.Value(); got != want {
return fmt.Errorf("got stats.TCP.ResetsSent.Value() = %d, want = %d", got, want)
}
return nil
}
if err := testutil.Poll(metricPollFn, 1*time.Second); err != nil {
t.Error(err)
}
} | explode_data.jsonl/75922 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 640
} | [
2830,
3393,
49896,
1061,
1415,
31358,
38311,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
741,
79659,
1669,
272,
58646,
1005,
16635,
741,
6692,
80,
1669,
609,
11489,
261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCachedConn_GetCache(t *testing.T) {
resetStats()
r, clean, err := redistest.CreateRedis()
assert.Nil(t, err)
defer clean()
c := NewNodeConn(dummySqlConn{}, r, cache.WithExpiry(time.Second*10))
var value string
err = c.GetCache("any", &value)
assert.Equal(t, ErrNotFound, err)
r.Set("any", `"value"`)
err = c.GetCache("any", &value)
assert.Nil(t, err)
assert.Equal(t, "value", value)
} | explode_data.jsonl/64120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
70293,
9701,
13614,
8233,
1155,
353,
8840,
836,
8,
341,
70343,
16635,
741,
7000,
11,
4240,
11,
1848,
1669,
2518,
380,
477,
7251,
48137,
741,
6948,
59678,
1155,
11,
1848,
340,
16867,
4240,
2822,
1444,
1669,
1532,
1955,
9701,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntMaxMin(t *testing.T) {
cases := []struct {
nums []int
min int
max int
}{
{[]int{1}, 1, 1},
{[]int{1, 2, 3, 4, 5}, 1, 5},
}
for _, c := range cases {
assert.Equal(t, c.min, MinInt(c.nums...))
assert.Equal(t, c.max, MaxInt(c.nums...))
}
} | explode_data.jsonl/24827 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
1072,
5974,
6217,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
22431,
82,
3056,
396,
198,
197,
25320,
220,
526,
198,
197,
22543,
220,
526,
198,
197,
59403,
197,
197,
90,
1294,
396,
90,
16,
2137,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerSyncGameServerRequestReadyState(t *testing.T) {
t.Parallel()
t.Run("GameServer with ReadyRequest State", func(t *testing.T) {
c, m := newFakeController()
gsFixture := &v1alpha1.GameServer{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"},
Spec: newSingleContainerSpec(), Status: v1alpha1.GameServerStatus{State: v1alpha1.RequestReady}}
gsFixture.ApplyDefaults()
pod, err := gsFixture.Pod()
assert.Nil(t, err)
gsUpdated := false
m.KubeClient.AddReactor("list", "pods", func(action k8stesting.Action) (bool, runtime.Object, error) {
return true, &corev1.PodList{Items: []corev1.Pod{*pod}}, nil
})
m.AgonesClient.AddReactor("update", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) {
gsUpdated = true
ua := action.(k8stesting.UpdateAction)
gs := ua.GetObject().(*v1alpha1.GameServer)
assert.Equal(t, v1alpha1.Ready, gs.Status.State)
return true, gs, nil
})
_, cancel := agtesting.StartInformers(m, c.gameServerSynced)
defer cancel()
gs, err := c.syncGameServerRequestReadyState(gsFixture)
assert.Nil(t, err, "should not error")
assert.True(t, gsUpdated, "GameServer wasn't updated")
assert.Equal(t, v1alpha1.Ready, gs.Status.State)
agtesting.AssertEventContains(t, m.FakeRecorder.Events, "SDK.Ready() executed")
})
for _, s := range []v1alpha1.State{"Unknown", v1alpha1.Unhealthy} {
name := fmt.Sprintf("GameServer with %s state", s)
t.Run(name, func(t *testing.T) {
testNoChange(t, s, func(c *Controller, fixture *v1alpha1.GameServer) (*v1alpha1.GameServer, error) {
return c.syncGameServerCreatingState(fixture)
})
})
}
t.Run("GameServer with non zero deletion datetime", func(t *testing.T) {
testWithNonZeroDeletionTimestamp(t, func(c *Controller, fixture *v1alpha1.GameServer) (*v1alpha1.GameServer, error) {
return c.syncGameServerRequestReadyState(fixture)
})
})
} | explode_data.jsonl/25432 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 738
} | [
2830,
3393,
2051,
12154,
4868,
5475,
1900,
19202,
1397,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3244,
16708,
445,
4868,
5475,
448,
30982,
1900,
3234,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1444,
11,
296,
1669,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLexMaxElements(t *testing.T) {
l := lex("max-elements 100;", nil)
if !l.acceptToken(kywd_max_elements) {
t.Errorf("expected max-elements")
}
if !l.acceptNumber(token_number) {
t.Errorf("expected number")
}
l.popToken()
token := l.popToken()
if token.val != "100" {
t.Errorf("expected 100, got '%s'", token.val)
}
} | explode_data.jsonl/81030 | {
"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,
47778,
5974,
11868,
1155,
353,
8840,
836,
8,
341,
8810,
1669,
22429,
445,
2810,
64445,
220,
16,
15,
15,
32503,
2092,
340,
743,
753,
75,
28562,
3323,
5969,
88,
6377,
6345,
22801,
8,
341,
197,
3244,
13080,
445,
7325,
1932,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMeasurement_StdDevLatency(t *testing.T) {
m := NewMeasurementWithTestData()
got := m.StdDevLatency()
want := 10.46
if got == want {
t.Fatalf("got %.2f, want %.2f", got, want)
}
} | explode_data.jsonl/2468 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
76548,
62,
22748,
14592,
23140,
2251,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
76548,
2354,
83920,
2822,
3174,
354,
1669,
296,
36086,
14592,
23140,
2251,
741,
50780,
1669,
220,
16,
15,
13,
19,
21,
271,
743,
2684,
62... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckTransferWithSig(t *testing.T) {
to, path := createCheckerTestObjects(t)
defer func() {
to.stor.close(t)
err := common.CleanTemporaryDirs(path)
assert.NoError(t, err, "failed to clean test data dirs")
}()
tx := createTransferWithSig(t)
info := defaultCheckerInfo(t)
assetId := tx.FeeAsset.ID
_, err := to.tc.checkTransferWithSig(tx, info)
assert.Error(t, err, "checkTransferWithSig did not fail with invalid transfer asset")
to.stor.createAsset(t, assetId)
_, err = to.tc.checkTransferWithSig(tx, info)
assert.NoError(t, err, "checkTransferWithSig failed with valid transfer tx")
// Check that smart assets are detected properly.
to.stor.createSmartAsset(t, tx.AmountAsset.ID)
smartAssets, err := to.tc.checkTransferWithSig(tx, info)
assert.NoError(t, err)
assert.Equal(t, 1, len(smartAssets))
assert.Equal(t, tx.AmountAsset.ID, smartAssets[0])
// Sponsorship checks.
to.stor.activateSponsorship(t)
_, err = to.tc.checkTransferWithSig(tx, info)
assert.Error(t, err, "checkTransferWithSig did not fail with unsponsored asset")
assert.EqualError(t, err, fmt.Sprintf("checkFee(): asset %s is not sponsored", assetId.String()))
err = to.stor.entities.sponsoredAssets.sponsorAsset(assetId, 10, info.blockID)
assert.NoError(t, err, "sponsorAsset() failed")
_, err = to.tc.checkTransferWithSig(tx, info)
assert.NoError(t, err, "checkTransferWithSig failed with valid sponsored asset")
tx.Timestamp = 0
_, err = to.tc.checkTransferWithSig(tx, info)
assert.Error(t, err, "checkTransferWithSig did not fail with invalid timestamp")
} | explode_data.jsonl/63075 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 573
} | [
2830,
3393,
3973,
21970,
2354,
47246,
1155,
353,
8840,
836,
8,
341,
31709,
11,
1815,
1669,
1855,
35188,
2271,
11543,
1155,
692,
16867,
2915,
368,
341,
197,
31709,
1236,
269,
4653,
1155,
692,
197,
9859,
1669,
4185,
727,
2675,
59362,
9738... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPeerDistanceHeap_In(t *testing.T) {
rng := rand.New(rand.NewSource(int64(0)))
target := id.NewPseudoRandom(rng)
cp := NewClosestPeers(target, 8)
for _, p := range peer.NewTestPeers(rng, 8) {
assert.False(t, cp.In(p.ID()))
cp.SafePush(p)
assert.True(t, cp.In(p.ID()))
}
} | explode_data.jsonl/41124 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
30888,
14778,
27909,
25972,
1155,
353,
8840,
836,
8,
341,
7000,
968,
1669,
10382,
7121,
37595,
7121,
3608,
1548,
21,
19,
7,
15,
5929,
28861,
1669,
877,
7121,
47,
21952,
13999,
87597,
340,
52018,
1669,
1532,
7925,
267,
10197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeploymentScale(t *testing.T) {
g, requests, cancel, mgrStopped := setUp(t)
defer func() {
clean(g, c)
cancel()
mgrStopped.Wait()
}()
caseName := "test-deployment-scale"
instance := &appsv1alpha1.UnitedDeployment{
ObjectMeta: metav1.ObjectMeta{
Name: caseName,
Namespace: "default",
},
Spec: appsv1alpha1.UnitedDeploymentSpec{
Replicas: &one,
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"name": caseName,
},
},
Template: appsv1alpha1.SubsetTemplate{
DeploymentTemplate: &appsv1alpha1.DeploymentTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"name": caseName,
},
},
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"name": caseName,
},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "container-a",
Image: "nginx:1.0",
},
},
},
},
},
},
},
Topology: appsv1alpha1.Topology{
Subsets: []appsv1alpha1.Subset{
{
Name: "subset-a",
NodeSelectorTerm: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "node-name",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"nodeA"},
},
},
},
},
{
Name: "subset-b",
NodeSelectorTerm: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "node-name",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"nodeB"},
},
},
},
},
},
},
RevisionHistoryLimit: &ten,
},
}
// Create the UnitedDeployment object and expect the Reconcile and Deployment to be created
err := c.Create(context.TODO(), instance)
// The instance object may not be a valid object because it might be missing some required fields.
// Please modify the instance object by adding required fields and then remove the following if statement.
if apierrors.IsInvalid(err) {
t.Logf("failed to create object, got an invalid object error: %v", err)
return
}
g.Expect(err).NotTo(gomega.HaveOccurred())
defer c.Delete(context.TODO(), instance)
waitReconcilerProcessFinished(g, requests, 3)
deploymentList := expectedDeploymentCount(g, instance, 2)
g.Expect(*deploymentList.Items[0].Spec.Replicas + *deploymentList.Items[1].Spec.Replicas).Should(gomega.BeEquivalentTo(1))
var two int32 = 2
g.Expect(c.Get(context.TODO(), client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}, instance)).Should(gomega.BeNil())
instance.Spec.Replicas = &two
g.Expect(c.Update(context.TODO(), instance)).Should(gomega.BeNil())
waitReconcilerProcessFinished(g, requests, 2)
deploymentList = expectedDeploymentCount(g, instance, 2)
g.Expect(*deploymentList.Items[0].Spec.Replicas).Should(gomega.BeEquivalentTo(1))
g.Expect(*deploymentList.Items[1].Spec.Replicas).Should(gomega.BeEquivalentTo(1))
g.Expect(c.Get(context.TODO(), client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}, instance)).Should(gomega.BeNil())
g.Expect(instance.Status.SubsetReplicas).Should(gomega.BeEquivalentTo(map[string]int32{
"subset-a": 1,
"subset-b": 1,
}))
var five int32 = 6
g.Expect(c.Get(context.TODO(), client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}, instance)).Should(gomega.BeNil())
instance.Spec.Replicas = &five
g.Expect(c.Update(context.TODO(), instance)).Should(gomega.BeNil())
waitReconcilerProcessFinished(g, requests, 2)
deploymentList = expectedDeploymentCount(g, instance, 2)
g.Expect(*deploymentList.Items[0].Spec.Replicas).Should(gomega.BeEquivalentTo(3))
g.Expect(*deploymentList.Items[1].Spec.Replicas).Should(gomega.BeEquivalentTo(3))
g.Expect(c.Get(context.TODO(), client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}, instance)).Should(gomega.BeNil())
g.Expect(instance.Status.SubsetReplicas).Should(gomega.BeEquivalentTo(map[string]int32{
"subset-a": 3,
"subset-b": 3,
}))
var four int32 = 4
g.Expect(c.Get(context.TODO(), client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}, instance)).Should(gomega.BeNil())
instance.Spec.Replicas = &four
g.Expect(c.Update(context.TODO(), instance)).Should(gomega.BeNil())
waitReconcilerProcessFinished(g, requests, 2)
deploymentList = expectedDeploymentCount(g, instance, 2)
g.Expect(*deploymentList.Items[0].Spec.Replicas).Should(gomega.BeEquivalentTo(2))
g.Expect(*deploymentList.Items[1].Spec.Replicas).Should(gomega.BeEquivalentTo(2))
g.Expect(c.Get(context.TODO(), client.ObjectKey{Namespace: instance.Namespace, Name: instance.Name}, instance)).Should(gomega.BeNil())
g.Expect(instance.Status.SubsetReplicas).Should(gomega.BeEquivalentTo(map[string]int32{
"subset-a": 2,
"subset-b": 2,
}))
} | explode_data.jsonl/59548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2141
} | [
2830,
3393,
75286,
6947,
1155,
353,
8840,
836,
8,
341,
3174,
11,
7388,
11,
9121,
11,
57897,
59803,
1669,
18620,
1155,
340,
16867,
2915,
368,
341,
197,
1444,
2675,
3268,
11,
272,
340,
197,
84441,
741,
197,
2109,
901,
59803,
28384,
741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOLMWithoutCSVCRD(t *testing.T) {
ns := "controller"
f := mocks.NewFake(t, ns)
client := f.FakeDynClient()
gvr := olmv1alpha1.SchemeGroupVersion.WithResource(csvResource)
// the original FakeDynClient would not return error for unknown resource
// prepend our reactor to mock a not found error like a real API server
client.PrependReactor("*", "*", func(action k8stesting.Action) (bool, runtime.Object, error) {
if gvr.String() == action.GetResource().String() {
return true, nil, errors.NewNotFound(gvr.GroupResource(), "the server could not find the requested resource")
}
return false, nil, nil
})
olm := NewOLM(client, ns)
t.Run("listCSVs without CSV CRD installed", func(t *testing.T) {
resourceClient := client.Resource(gvr).Namespace(ns)
objs, err := resourceClient.List(metav1.ListOptions{})
require.Error(t, err)
require.True(t, errors.IsNotFound(err))
require.Nil(t, objs)
csvs, err := olm.listCSVs()
require.NoError(t, err)
require.Len(t, csvs, 0)
})
} | explode_data.jsonl/2857 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 368
} | [
2830,
3393,
1930,
44,
26040,
44209,
8973,
35,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
330,
7152,
698,
1166,
1669,
68909,
7121,
52317,
1155,
11,
12268,
340,
25291,
1669,
282,
991,
726,
95709,
2959,
741,
3174,
18920,
1669,
8328,
26002,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIdentifyAppSourceTypeByAppDirWithKustomizations(t *testing.T) {
sourceType, err := GetAppSourceType(&argoappv1.ApplicationSource{}, "./testdata/kustomization_yaml", "testapp")
assert.Nil(t, err)
assert.Equal(t, argoappv1.ApplicationSourceTypeKustomize, sourceType)
sourceType, err = GetAppSourceType(&argoappv1.ApplicationSource{}, "./testdata/kustomization_yml", "testapp")
assert.Nil(t, err)
assert.Equal(t, argoappv1.ApplicationSourceTypeKustomize, sourceType)
sourceType, err = GetAppSourceType(&argoappv1.ApplicationSource{}, "./testdata/Kustomization", "testapp")
assert.Nil(t, err)
assert.Equal(t, argoappv1.ApplicationSourceTypeKustomize, sourceType)
} | explode_data.jsonl/58033 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
28301,
1437,
2164,
93363,
1359,
2164,
6184,
2354,
42,
1450,
8040,
1155,
353,
8840,
836,
8,
341,
47418,
929,
11,
1848,
1669,
2126,
2164,
93363,
2099,
12088,
676,
85,
16,
17521,
3608,
22655,
5924,
92425,
14109,
1450,
2022,
643... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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(t *testing.T) {
treeArray := []int{1, 2, 3, 4, 5}
input := utils.IntArrayToTreeNode(treeArray)
sum := sumOfLeftLeaves(input)
assert.Equal(t, 4, sum)
} | explode_data.jsonl/54013 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
1155,
353,
8840,
836,
8,
341,
51968,
1857,
1669,
3056,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
532,
22427,
1669,
12439,
7371,
1857,
1249,
26597,
21298,
1857,
340,
31479,
1669,
2629,
2124,
5415,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrphanDependentsFailure(t *testing.T) {
testHandler := &fakeActionHandler{
response: map[string]FakeResponse{
"PATCH" + "/api/v1/namespaces/ns1/pods/pod": {
409,
[]byte{},
},
},
}
srv, clientConfig := testServerAndClientConfig(testHandler.ServeHTTP)
defer srv.Close()
gc := setupGC(t, clientConfig)
defer close(gc.stop)
dependents := []*node{
{
identity: objectReference{
OwnerReference: metav1.OwnerReference{
Kind: "Pod",
APIVersion: "v1",
Name: "pod",
},
Namespace: "ns1",
},
},
}
err := gc.orphanDependents(objectReference{}, dependents)
expected := `the server reported a conflict`
if err == nil || !strings.Contains(err.Error(), expected) {
if err != nil {
t.Errorf("expected error contains text %q, got %q", expected, err.Error())
} else {
t.Errorf("expected error contains text %q, got nil", expected)
}
}
} | explode_data.jsonl/62006 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 382
} | [
2830,
3393,
2195,
9943,
7839,
408,
805,
17507,
1155,
353,
8840,
836,
8,
341,
18185,
3050,
1669,
609,
30570,
2512,
3050,
515,
197,
21735,
25,
2415,
14032,
60,
52317,
2582,
515,
298,
197,
1,
31165,
1,
488,
3521,
2068,
5457,
16,
9612,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_Hoverfly_GetMiddleware_ReturnsRemotefJustRemoteSet(t *testing.T) {
RegisterTestingT(t)
unit := NewHoverflyWithConfiguration(&Configuration{})
unit.Cfg.Middleware.Remote = "test.com"
binary, script, remote := unit.GetMiddleware()
Expect(binary).To(Equal(""))
Expect(script).To(Equal(""))
Expect(remote).To(Equal("test.com"))
} | explode_data.jsonl/45384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
2039,
1975,
21642,
13614,
24684,
53316,
82,
6590,
354,
823,
9952,
24703,
1649,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
692,
81189,
1669,
1532,
34379,
21642,
2354,
7688,
2099,
7688,
37790,
81189,
727,
4817,
1321,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNPGroupAssign(t *testing.T) {
ncf := cniNetConfig{Subnet: cnitypes.IPNet{IP: net.ParseIP("10.128.2.0"), Mask: net.CIDRMask(24, 32)}}
hcf := &HostAgentConfig{
NodeName: "node1",
EpRpcSock: "/tmp/aci-containers-ep-rpc.sock",
NetConfig: []cniNetConfig{ncf},
AciPrefix: "it",
GroupDefaults: GroupDefaults{
DefaultEg: metadata.OpflexGroup{
PolicySpace: "tenantA",
Name: "defaultEPG",
},
},
}
it := SetupInteg(t, hcf)
it.setupNode(itIpam, true)
defer it.tearDown()
// add an annotated namespace
it.ta.fakeNamespaceSource.Add(mkNamespace("annNS", testEgAnnot3, ""))
// add a default network policy
it.ta.fakeNetworkPolicySource.Add(mkNetPol("annNS", "np1",
&metav1.LabelSelector{}, nil, nil, nil))
// add a selector based network policy
it.ta.fakeNetworkPolicySource.Add(mkNetPol("annNS", "np2",
&metav1.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"},
}, nil, nil, nil))
// Add pods intf via cni
it.cniAddParallel(0, 1)
it.testNS = "annNS"
it.cniAddParallel(1, 3)
time.Sleep(10 * time.Millisecond)
it.addPodObj(0, testPodNS, "", "", nil)
p1Labels := map[string]string{
"foo": "rod",
"tier": "sample-tier",
}
it.addPodObj(1, "annNS", "", "", p1Labels)
p2Labels := map[string]string{
"foo": "bar",
"tier": "sample-tier",
}
it.addPodObj(2, "annNS", "", "", p2Labels)
// verify ep file
it.checkEpGroups(0, "defaultEPG", emptyJSON)
it.checkEpGroups(1, "test-prof|ann-ns-eg", sgAnnotNP1)
it.checkEpGroups(2, "test-prof|ann-ns-eg", sgAnnotNP2)
it.cniDelParallel(1, 3)
it.testNS = testPodNS
it.cniDelParallel(0, 1)
} | explode_data.jsonl/53274 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 731
} | [
2830,
3393,
26227,
2808,
28933,
1155,
353,
8840,
836,
8,
341,
197,
1016,
69,
1669,
272,
7751,
6954,
2648,
90,
3136,
4711,
25,
13665,
487,
20352,
46917,
6954,
90,
3298,
25,
4179,
8937,
3298,
445,
16,
15,
13,
16,
17,
23,
13,
17,
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 TestImmutableNilValue(t *testing.T) {
t.Parallel()
key := serializeUint32(0)
//将该键的值设为零。
testTreap := NewImmutable()
testTreap = testTreap.Put(key, nil)
//确保键存在并且是空字节片。
if gotVal := testTreap.Has(key); !gotVal {
t.Fatalf("Has: unexpected result - got %v, want true", gotVal)
}
if gotVal := testTreap.Get(key); gotVal == nil {
t.Fatalf("Get: unexpected result - got nil, want empty slice")
}
if gotVal := testTreap.Get(key); len(gotVal) != 0 {
t.Fatalf("Get: unexpected result - got %x, want empty slice",
gotVal)
}
} | explode_data.jsonl/6140 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
58890,
19064,
1130,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
23634,
1669,
24235,
21570,
18,
17,
7,
15,
692,
322,
44063,
75882,
60949,
9370,
25511,
29635,
17714,
99822,
8997,
18185,
65775,
391,
1669,
1532,
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... | 4 |
func TestExpr(t *testing.T) {
user := &User{}
qs := dORM.QueryTable(user)
qs = dORM.QueryTable((*User)(nil))
qs = dORM.QueryTable("User")
qs = dORM.QueryTable("user")
num, err := qs.Filter("UserName", "slene").Filter("user_name", "slene").Filter("profile__Age", 28).Count()
throwFail(t, err)
throwFail(t, AssertIs(num, 1))
num, err = qs.Filter("created", time.Now()).Count()
throwFail(t, err)
throwFail(t, AssertIs(num, 3))
// num, err = qs.Filter("created", time.Now().Format(format_Date)).Count()
// throwFail(t, err)
// throwFail(t, AssertIs(num, 3))
} | explode_data.jsonl/18127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
16041,
1155,
353,
8840,
836,
8,
341,
19060,
1669,
609,
1474,
16094,
18534,
82,
1669,
294,
4365,
15685,
2556,
4277,
340,
18534,
82,
284,
294,
4365,
15685,
2556,
26609,
1474,
2376,
8385,
1171,
18534,
82,
284,
294,
4365,
15685,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_MergeTextStatsValueResponses(t *testing.T) {
mct := newMemcacheTest(defaultConfig)
msg1 := textParseNoFail(t, "STAT name1 value1\r\n")
msg2 := textParseNoFail(t, "STAT name2 value2\r\n")
msg3 := textParseNoFail(t, "END\r\n")
b, err := tryMergeResponses(mct.mc, msg1, msg2)
assert.True(t, b)
assert.Nil(t, err)
assert.False(t, msg1.isComplete)
b, err = tryMergeResponses(mct.mc, msg1, msg3)
assert.True(t, b)
assert.Nil(t, err)
assert.True(t, msg1.isComplete)
} | explode_data.jsonl/15055 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
1245,
10080,
1178,
16635,
1130,
70743,
1155,
353,
8840,
836,
8,
341,
2109,
302,
1669,
501,
18816,
9360,
2271,
18978,
2648,
340,
21169,
16,
1669,
1467,
14463,
2753,
19524,
1155,
11,
330,
22595,
829,
16,
897,
16,
12016,
1699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStyledSegment(t *testing.T) {
Test(t,
That("print (styled (styled-segment abc &fg-color=cyan) bold)").
Prints("\033[1;36mabc\033[m"),
That("print (styled (styled-segment (styled-segment abc &fg-color=magenta) &dim=$true) cyan)").
Prints("\033[2;36mabc\033[m"),
That("print (styled (styled-segment abc &inverse=$true) inverse)").
Prints("\033[7mabc\033[m"),
That("print (styled (styled-segment abc) toggle-inverse)").
Prints("\033[7mabc\033[m"),
That("print (styled (styled-segment abc &inverse=$true) no-inverse)").
Prints("abc"),
That("print (styled (styled-segment abc &inverse=$true) toggle-inverse)").
Prints("abc"),
)
} | explode_data.jsonl/6982 | {
"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,
34180,
21086,
1155,
353,
8840,
836,
8,
341,
73866,
1155,
345,
197,
197,
4792,
445,
1350,
320,
22849,
320,
22849,
7806,
9070,
39022,
609,
4817,
7889,
19535,
8339,
8,
13939,
8,
38609,
298,
58702,
82,
4921,
15,
18,
18,
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 TestGetMetadata(t *testing.T) {
cases := map[string]struct {
NewServer func(t *testing.T) *httptest.Server
expectedData string
expectedError string
expectedOperationsPerformed []string
}{
"Insecure server success case": {
NewServer: func(t *testing.T) *httptest.Server {
testType := InsecureTestType
Ts := &testServer{
t: t,
data: "IMDSProfileForGoSDK",
}
return newTestServer(t, testType, Ts)
},
expectedData: "IMDSProfileForGoSDK",
expectedOperationsPerformed: []string{"GetToken", "GetMetadata", "GetMetadata"},
},
"Secure server success case": {
NewServer: func(t *testing.T) *httptest.Server {
testType := SecureTestType
Ts := &testServer{
t: t,
tokens: []string{"firstToken", "secondToken", "thirdToken"},
data: "IMDSProfileForGoSDK",
}
return newTestServer(t, testType, Ts)
},
expectedData: "IMDSProfileForGoSDK",
expectedError: "",
expectedOperationsPerformed: []string{"GetToken", "GetMetadata", "GetMetadata"},
},
"Bad request case": {
NewServer: func(t *testing.T) *httptest.Server {
testType := BadRequestTestType
Ts := &testServer{
t: t,
tokens: []string{"firstToken", "secondToken", "thirdToken"},
data: "IMDSProfileForGoSDK",
}
return newTestServer(t, testType, Ts)
},
expectedError: "400",
expectedOperationsPerformed: []string{"GetToken", "GetMetadata", "GetToken", "GetMetadata"},
},
"ServerErrorForTokenTestType": {
NewServer: func(t *testing.T) *httptest.Server {
testType := ServerErrorForTokenTestType
Ts := &testServer{
t: t,
tokens: []string{},
data: "IMDSProfileForGoSDK",
}
return newTestServer(t, testType, Ts)
},
expectedData: "IMDSProfileForGoSDK",
expectedOperationsPerformed: []string{"GetToken", "GetMetadata", "GetMetadata"},
},
}
for name, x := range cases {
t.Run(name, func(t *testing.T) {
server := x.NewServer(t)
defer server.Close()
op := &operationListProvider{}
c := ec2metadata.New(unit.Session, &aws.Config{
Endpoint: aws.String(server.URL),
})
c.Handlers.Complete.PushBack(op.addToOperationPerformedList)
resp, err := c.GetMetadata("some/path")
// token should stay alive, since default duration is 26000 seconds
resp, err = c.GetMetadata("some/path")
if len(x.expectedError) != 0 {
if err == nil {
t.Fatalf("expect %v error, got none", x.expectedError)
}
if e, a := x.expectedError, err.Error(); !strings.Contains(a, e) {
t.Fatalf("expect %v error, got %v", e, a)
}
} else if err != nil {
t.Fatalf("expect no error, got %v", err)
}
if e, a := x.expectedData, resp; e != a {
t.Fatalf("expect %v, got %v", e, a)
}
if e, a := x.expectedOperationsPerformed, op.operationsPerformed; !reflect.DeepEqual(e, a) {
t.Errorf("expect %v operations, got %v", e, a)
}
})
}
} | explode_data.jsonl/17836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1368
} | [
2830,
3393,
1949,
14610,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
3564,
5475,
4293,
2915,
1155,
353,
8840,
836,
8,
353,
96336,
70334,
22997,
198,
197,
42400,
1043,
394,
914,
198,
197,
42400... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateObject(t *testing.T) {
const SCRIPT = `
inst instanceof C;
`
r := New()
c := r.ToValue(func(call ConstructorCall) *Object {
return nil
})
proto := c.(*Object).Get("prototype").(*Object)
inst := r.CreateObject(proto)
r.Set("C", c)
r.Set("inst", inst)
prg := MustCompile("test.js", SCRIPT, false)
res, err := r.RunProgram(prg)
if err != nil {
t.Fatal(err)
}
if !res.StrictEquals(valueTrue) {
t.Fatalf("Unexpected result: %v", res)
}
} | explode_data.jsonl/10502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
4021,
1190,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
88656,
8083,
356,
280,
197,
19324,
7000,
1669,
1532,
741,
1444,
1669,
435,
3274,
1130,
18552,
32691,
16786,
7220,
8,
353,
1190,
341,
197,
853,
2092,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDepends(t *testing.T) {
s := Step{}
if len(s.Depends()) != 1 && s.Depends()[0] != docker.StepName && s.Depends()[1] != manifest.StepName {
t.Errorf("Wrong dependency list %v expected %v", s.Depends(), []string{docker.StepName, manifest.StepName})
}
} | explode_data.jsonl/56741 | {
"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,
7839,
1412,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
14822,
31483,
743,
2422,
1141,
34848,
1412,
2140,
961,
220,
16,
1009,
274,
34848,
1412,
10116,
15,
60,
961,
26588,
68402,
675,
1009,
274,
34848,
1412,
10116,
16,
60,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestConfig(t *testing.T) {
example := config.Config{
Logging: config.Logging{
Level: "debug or info or warn or warning(warn) or error or err(error) or critical or dev(debug) or prod(info)",
FileName: "",
LogFormat: "short or standard or long",
TimeFormat: "date or datetime or millisec",
},
Port: 8080,
SslCertificate: "ssl/sever.crt",
SslCertificateKey: "ssl/sever.key",
Servers: []*config.Servers{
{
Login: "/oauth2/login",
Callback: "/oauth2/callback",
Logout: "/oauth2/logout",
ServerName: "virtual sever name",
Logging: config.Logging{
Level: "debug or info or warn or warning(warn) or error or err(error) or critical or dev(debug) or prod(info)",
FileName: "",
LogFormat: "short or standard or long",
TimeFormat: "date or datetime or millisec",
},
Oidc: config.Oidc{
Scopes: []string{"email", "openid", "offline_access", "profile"},
Provider: "https://keycloak/",
ClientId: "xxx",
ClientSecret: "xxx",
Logout: "https://keycloak/logout?returnTo=http://localhost:8080/oauth2/login",
RedirectUrl: "http://localhost:8080/oauth2/callback",
},
Locations: []config.Locations{
{
ProxyPass: "http://localhost",
ProxySSLVerify: "off",
Urls: []config.Urls{
{
Path: "/",
Token: "id_token",
},
},
},
},
Session: config.Session{
Name: "memory or etcd",
Codecs: []string{},
Args: map[string]interface{}{
"ttl": 30,
},
},
},
},
}
tests := []struct {
name string
fn func(t *testing.T)
}{}
exts := []string{".yaml", ".yml", ".json", ".toml"}
for _, ext := range exts {
filename := "test" + ext
os.Remove(filename)
tests = append(tests, struct {
name string
fn func(t *testing.T)
}{
name: fmt.Sprintf("write config to %s", filename),
fn: func(t *testing.T) {
err := example.Output(filename)
assert.NoError(t, err)
isExists := fileIsExists(filename)
assert.Equal(t, true, isExists)
},
})
tests = append(tests, struct {
name string
fn func(t *testing.T)
}{
name: fmt.Sprintf("read config of %s", filename),
fn: func(t *testing.T) {
_, err := config.ReadConfig(filename)
assert.NoError(t, err)
},
})
}
for _, tt := range tests {
t.Run(tt.name, tt.fn)
}
for _, ext := range exts {
filename := "test" + ext
os.Remove(filename)
}
} | explode_data.jsonl/6218 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1170
} | [
2830,
3393,
2648,
1155,
353,
8840,
836,
8,
341,
8122,
1516,
1669,
2193,
10753,
515,
197,
24201,
3173,
25,
2193,
41945,
515,
298,
197,
4449,
25,
414,
330,
8349,
476,
3546,
476,
8809,
476,
9958,
3622,
1885,
8,
476,
1465,
476,
1848,
63... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRecover_completeHandlerFunc_POST_ValidationFails(t *testing.T) {
t.Parallel()
rec, _, _ := testSetup()
ctx, w, r, _ := testRequest(rec.Authboss, "POST", "token", testURLBase64Token)
if err := rec.completeHandlerFunc(ctx, w, r); err != nil {
t.Error("Unexpected error:", err)
}
if w.Code != http.StatusOK {
t.Error("Unexpected status:", w.Code)
}
if !strings.Contains(w.Body.String(), "Cannot be blank") {
t.Error("Expected error about password being blank")
}
} | explode_data.jsonl/61504 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
693,
3688,
27675,
3050,
9626,
20506,
62,
13799,
37,
6209,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
67904,
11,
8358,
716,
1669,
1273,
21821,
741,
20985,
11,
289,
11,
435,
11,
716,
1669,
1273,
1900,
20635,
2523... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCloseWhileSleep(t *testing.T) {
testCloseWhileSleep(t, blockDelivererConsumerWithRecv)
testCloseWhileSleep(t, blockDelivererConsumerWithSend)
assert.Equal(t, 0, connNumber)
} | explode_data.jsonl/38322 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
7925,
7983,
41745,
1155,
353,
8840,
836,
8,
341,
18185,
7925,
7983,
41745,
1155,
11,
2504,
16532,
1524,
261,
29968,
2354,
63483,
340,
18185,
7925,
7983,
41745,
1155,
11,
2504,
16532,
1524,
261,
29968,
2354,
11505,
340,
6948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestValidateSpecialVariable(t *testing.T) {
specialVars := []string{"arg_username", "arg_user_name", "http_header_name", "cookie_cookie_name"}
for _, v := range specialVars {
allErrs := validateSpecialVariable(v, field.NewPath("variable"))
if len(allErrs) != 0 {
t.Errorf("validateSpecialVariable(%v) returned errors for valid case: %v", v, allErrs)
}
}
} | explode_data.jsonl/65912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
17926,
20366,
7827,
1155,
353,
8840,
836,
8,
341,
1903,
2964,
28305,
1669,
3056,
917,
4913,
858,
21588,
497,
330,
858,
3317,
1269,
497,
330,
1254,
8757,
1269,
497,
330,
16236,
38663,
1269,
16707,
2023,
8358,
348,
1669,
2088,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetMongoCollection(t *testing.T) {
_, client, _, err := ConnectToMongo(mongoTestsHostURL, "", "")
if err != nil {
log.Fatal(err)
}
mongoCollection := GetMongoCollection(client, mongoDatabaseForTests, mongoCollectionForTests)
if mongoCollection.Name() != mongoCollectionForTests {
log.Fatal(errors.New("mongoCollections obtained are not equal"))
}
} | explode_data.jsonl/71137 | {
"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,
54998,
6482,
1155,
353,
8840,
836,
8,
341,
197,
6878,
2943,
11,
8358,
1848,
1669,
13015,
1249,
54998,
1255,
6363,
18200,
9296,
3144,
11,
7342,
14676,
743,
1848,
961,
2092,
341,
197,
6725,
26133,
3964,
340,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateOpenFail(t *testing.T) {
// bogusCreateDB is a function which acts as a bogus create and open driver function that intentionally returns a failure which can be detected.
dbType := "createopenfail"
openError := fmt.Errorf("failed to create or open database for "+
"database type [%v]", dbType)
bogusCreateDB := func(args ...interface{}) (database.DB, error) {
return nil, openError
}
// Create and add driver that intentionally fails when created or opened to ensure errors on database open and create are handled properly.
driver := database.Driver{
DbType: dbType,
Create: bogusCreateDB,
Open: bogusCreateDB,
}
database.RegisterDriver(driver)
// Ensure creating a database with the new type fails with the expected error.
_, err := database.Create(dbType)
if err != openError {
t.Errorf("expected error not received - got: %v, want %v", err,
openError)
return
}
// Ensure opening a database with the new type fails with the expected error.
_, err = database.Open(dbType)
if err != openError {
t.Errorf("expected error not received - got: %v, want %v", err,
openError)
return
}
} | explode_data.jsonl/1917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 347
} | [
2830,
3393,
4021,
5002,
19524,
1155,
353,
8840,
836,
8,
341,
197,
322,
59920,
4021,
3506,
374,
264,
729,
892,
14056,
438,
264,
59920,
1855,
323,
1787,
5579,
729,
429,
36204,
4675,
264,
7901,
892,
646,
387,
16507,
624,
20939,
929,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGRPCReplicationClient_Connect(t *testing.T) {
// --- given ---
t.Parallel()
client := replication.NewGRPCReplicationClient(&mock.ReplicationClient{})
// --- when ---
err := client.Connect(context.Background())
// --- then ---
if err != nil {
t.Error("Connect should succeed")
}
} | explode_data.jsonl/7159 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
8626,
4872,
18327,
1693,
2959,
15100,
2321,
1155,
353,
8840,
836,
8,
341,
197,
322,
12448,
2661,
53923,
3244,
41288,
7957,
741,
25291,
1669,
47791,
7121,
8626,
4872,
18327,
1693,
2959,
2099,
16712,
2817,
79,
1693,
2959,
6257,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetRequest_ErrorFromSetRequest(t *testing.T) {
t.Parallel()
ctx := flow.TestContextWithPulse(
inslogger.TestContext(t),
insolar.GenesisPulse.PulseNumber+10,
)
var (
msg payload.Meta
err error
handler *handle.SetIncomingRequest
)
t.Run("SetRequest procedure returns err", func(t *testing.T) {
t.Run("creation request", func(t *testing.T) {
f := flow.NewFlowMock(t)
f.ProcedureMock.Set(func(ctx context.Context, p flow.Procedure, passed bool) (r error) {
switch p.(type) {
case *proc.CalculateID:
return nil
case *proc.FetchJet:
return nil
case *proc.WaitHot:
return nil
case *proc.SetRequest:
return errors.New("error from SetRequest")
default:
panic("unknown procedure")
}
})
// Creation incoming request.
msg = metaRequestMsg(t, true)
handler = handle.NewSetIncomingRequest(proc.NewDependenciesMock(), msg, false)
err = handler.Present(ctx, f)
assert.EqualError(t, err, "error from SetRequest")
})
t.Run("non-creation request", func(t *testing.T) {
f := flow.NewFlowMock(t)
f.ProcedureMock.Set(func(ctx context.Context, p flow.Procedure, passed bool) (r error) {
switch p.(type) {
case *proc.CalculateID:
return nil
case *proc.FetchJet:
return nil
case *proc.WaitHot:
return nil
case *proc.EnsureIndex:
return nil
case *proc.SetRequest:
return errors.New("error from SetRequest")
default:
panic("unknown procedure")
}
})
// Creation incoming request.
msg = metaRequestMsg(t, false)
handler = handle.NewSetIncomingRequest(proc.NewDependenciesMock(), msg, false)
err = handler.Present(ctx, f)
assert.EqualError(t, err, "error from SetRequest")
})
})
// Happy path, everything is fine.
t.Run("SetRequest procedure returns nil err", func(t *testing.T) {
t.Run("creation request", func(t *testing.T) {
f := flow.NewFlowMock(t)
f.ProcedureMock.Set(func(ctx context.Context, p flow.Procedure, passed bool) (r error) {
switch p.(type) {
case *proc.CalculateID:
return nil
case *proc.FetchJet:
return nil
case *proc.WaitHot:
return nil
case *proc.SetRequest:
return nil
default:
panic("unknown procedure")
}
})
// Creation incoming request.
msg = metaRequestMsg(t, true)
handler = handle.NewSetIncomingRequest(proc.NewDependenciesMock(), msg, false)
err = handler.Present(ctx, f)
require.NoError(t, err)
})
t.Run("non-creation request", func(t *testing.T) {
f := flow.NewFlowMock(t)
f.ProcedureMock.Set(func(ctx context.Context, p flow.Procedure, passed bool) (r error) {
switch p.(type) {
case *proc.CalculateID:
return nil
case *proc.FetchJet:
return nil
case *proc.WaitHot:
return nil
case *proc.EnsureIndex:
return nil
case *proc.SetRequest:
return nil
default:
panic("unknown procedure")
}
})
// Non-creation incoming request.
msg = metaRequestMsg(t, false)
handler = handle.NewSetIncomingRequest(proc.NewDependenciesMock(), msg, false)
err = handler.Present(ctx, f)
require.NoError(t, err)
})
})
} | explode_data.jsonl/49676 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1341
} | [
2830,
3393,
1649,
1900,
28651,
3830,
1649,
1900,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
6396,
8787,
1972,
2354,
47,
17217,
1006,
197,
197,
1330,
9786,
8787,
1972,
1155,
1326,
197,
197,
1330,
7417,
65384,
1377... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTopicThrottleHelpers(t *testing.T) {
topics := []TopicInfo{
{
Name: "topic1",
Config: map[string]string{
"leader.replication.throttled.replicas": "1:2,3:4",
},
},
{
Name: "topic2",
Config: map[string]string{
"follower.replication.throttled.replicas": "1:2,3:4",
},
},
{
Name: "topic3",
Config: map[string]string{
"leader.replication.throttled.replicas": "1:2,3:4",
"follower.replication.throttled.replicas": "1:2,3:4",
},
},
{
Name: "topic4",
Config: map[string]string{},
},
}
throttledTopicNames := ThrottledTopicNames(topics)
assert.Equal(
t,
[]string{
"topic1",
"topic2",
"topic3",
},
throttledTopicNames,
)
} | explode_data.jsonl/70030 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 356
} | [
2830,
3393,
26406,
1001,
27535,
28430,
1155,
353,
8840,
836,
8,
341,
42118,
1211,
1669,
3056,
26406,
1731,
515,
197,
197,
515,
298,
21297,
25,
330,
16411,
16,
756,
298,
66156,
25,
2415,
14032,
30953,
515,
571,
197,
1,
37391,
68225,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGoFuzzCrashers(t *testing.T) {
if testing.Short() {
t.Skip("excessive allocation")
}
testData := []string{
"\b000000",
"\x02\x16\x10�[��\t\xbdui�" + "\x10\x01\x00\xff\xbf\xef\xbfサn\x99\x00\x10r",
"\x0300\x00\x00\x00\x040000",
}
for idx, testStr := range testData {
r := Reader{strings.NewReader(testStr)}
frame, err := r.ReadFrame()
if err != nil && frame != nil {
t.Errorf("%d. frame is not nil: %#v err = %v", idx, frame, err)
}
}
} | explode_data.jsonl/13732 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
10850,
37,
8889,
16001,
988,
388,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
327,
86628,
23757,
1138,
197,
630,
18185,
1043,
1669,
3056,
917,
515,
197,
197,
11934,
65,
15,
15,
15,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestIncoming(t *testing.T) {
graphSpec := types.GraphSpec{
Edges: []types.Edge{
{Source: "n1", Target: "n2"},
{Source: "n1", Target: "n3"},
{Source: "n2", Target: "n4"},
{Source: "n3", Target: "n4"},
},
}
incoming := Incoming(&graphSpec, "n4")
if !compare(incoming, []string{"n2", "n3"}) {
t.Error("")
}
incoming = Incoming(&graphSpec, "n2")
if !compare(incoming, []string{"n1"}) {
t.Error("")
}
incoming = Incoming(&graphSpec, "n1")
if !compare(incoming, []string{}) {
t.Error("")
}
} | explode_data.jsonl/62518 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
97564,
1155,
353,
8840,
836,
8,
341,
66616,
8327,
1669,
4494,
40237,
8327,
515,
197,
197,
41122,
25,
3056,
9242,
13,
11656,
515,
298,
197,
90,
3608,
25,
330,
77,
16,
497,
13483,
25,
330,
77,
17,
7115,
298,
197,
90,
360... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLs(t *testing.T) {
dirname := createDir("test-dir", "", t)
var files []string
for i := 0; i < 1; i++ {
f := createFile("test-file-", "test file", dirname, t)
filename := filename(f.Name())
files = append(files, filename)
}
if filenames := Ls(dirname); !equal(filenames, files) {
t.Fatalf("expect %q\ngot: %q\n", filenames, files)
}
} | explode_data.jsonl/81237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
43,
82,
1155,
353,
8840,
836,
8,
341,
48532,
606,
1669,
1855,
6184,
445,
1944,
45283,
497,
7342,
259,
692,
2405,
3542,
3056,
917,
271,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
26,
600,
1027,
341,
197,
1166,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestBytes_ToFloat32(t *testing.T) {
tests := []struct {
name string
e Bytes
want Float32
}{
{name: "", e: Bytes{[]byte("123")}, want: Float32{123}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.e.ToFloat32(); !got.Equal(tt.want) {
t.Errorf("Bytes.ToFloat32() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/34766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
7078,
38346,
5442,
18,
17,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
30024,
198,
197,
50780,
13001,
18,
17,
198,
197,
59403,
197,
197,
47006,
25,
7342,
384,
25,
300... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSnmpTableCache_miss(t *testing.T) {
snmpTableCaches = nil
oid := ".1.0.0.0"
mibName, oidNum, oidText, fields, err := snmpTable(oid)
require.Len(t, snmpTableCaches, 1)
stc := snmpTableCaches[oid]
require.NotNil(t, stc)
require.Equal(t, mibName, stc.mibName)
require.Equal(t, oidNum, stc.oidNum)
require.Equal(t, oidText, stc.oidText)
require.Equal(t, fields, stc.fields)
require.Equal(t, err, stc.err)
} | explode_data.jsonl/50799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
20720,
1307,
2556,
8233,
67722,
1155,
353,
8840,
836,
8,
341,
48251,
1307,
2556,
34,
14242,
284,
2092,
198,
197,
588,
1669,
5933,
16,
13,
15,
13,
15,
13,
15,
698,
2109,
59344,
11,
48766,
4651,
11,
48766,
1178,
11,
5043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConvertBoolsRequiredToOptional(t *testing.T) {
lines, err := convertTypes(
"Foo", "Bar",
`struct Foo {
1: optional bool one
}
struct Bar {
1: required bool one
}`,
nil,
nil,
)
assert.NoError(t, err)
assertPrettyEqual(t, trim(`
if in.One != nil {
out.One = *(in.One)
}
`), lines)
} | explode_data.jsonl/62027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
12012,
1233,
3069,
8164,
1249,
15309,
1155,
353,
8840,
836,
8,
341,
78390,
11,
1848,
1669,
5508,
4173,
1006,
197,
197,
1,
40923,
497,
330,
3428,
756,
197,
197,
63,
1235,
33428,
341,
298,
197,
16,
25,
10101,
1807,
825,
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 TestSingleArrayValue(t *testing.T) {
var data = []byte(`{"key": "value","key2":[1,2,3,4,"A"]}`)
array, _ := get(string(data), "key2").Array()
if len(array) != 5 {
t.Fatalf("got '%v', expected '%v'", len(array), 5)
}
_, e := Get(data, "key3")
if e == nil {
t.Fatalf("got '%v', expected '%v'", e, nil)
}
} | explode_data.jsonl/62349 | {
"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,
10888,
1857,
1130,
1155,
353,
8840,
836,
8,
341,
262,
762,
821,
284,
3056,
3782,
5809,
4913,
792,
788,
330,
957,
2198,
792,
17,
8899,
16,
11,
17,
11,
18,
11,
19,
1335,
32,
1341,
27085,
262,
1334,
11,
716,
1669,
633,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccessQuery(t *testing.T) {
if base.UnitTestUrlIsWalrus() || base.TestsDisableGSI() {
t.Skip("This test is Couchbase Server and UseViews=false only")
}
db := setupTestDB(t)
defer db.Close()
db.ChannelMapper = channels.NewChannelMapper(`function(doc, oldDoc) {
access(doc.accessUser, doc.accessChannel)
}`)
// Add docs with access grants assignment
for i := 1; i <= 5; i++ {
_, _, err := db.Put(fmt.Sprintf("accessTest%d", i), Body{"accessUser": "user1", "accessChannel": fmt.Sprintf("channel%d", i)})
assert.NoError(t, err, "Put accessTest doc")
}
// Standard query
username := "user1"
results, queryErr := db.QueryAccess(username)
assert.NoError(t, queryErr, "Query error")
var row map[string]interface{}
rowCount := 0
for results.Next(&row) {
rowCount++
}
assert.Equal(t, 5, rowCount)
// Attempt to introduce syntax error. Should return zero rows for user `user1'`, and not return error
username = "user1'"
results, queryErr = db.QueryAccess(username)
assert.NoError(t, queryErr, "Query error")
rowCount = 0
for results.Next(&row) {
rowCount++
}
assert.Equal(t, 0, rowCount)
// Attempt to introduce syntax error. Should return zero rows for user `user1`AND`, and not return error.
// Validates select clause protection
username = "user1`AND"
results, queryErr = db.QueryAccess(username)
assert.NoError(t, queryErr, "Query error")
rowCount = 0
for results.Next(&row) {
rowCount++
}
assert.Equal(t, 0, rowCount)
} | explode_data.jsonl/2709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 530
} | [
2830,
3393,
6054,
2859,
1155,
353,
8840,
836,
8,
341,
743,
2331,
25159,
2271,
2864,
3872,
88298,
20341,
368,
1369,
2331,
37133,
25479,
38,
13817,
368,
341,
197,
3244,
57776,
445,
1986,
1273,
374,
61128,
3152,
8422,
323,
5443,
23217,
122... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestrestartOss(t *testing.T) {
var req restartOssRequest
req.Init()
req.SetFormat("JSON")
req.SetRegionId("cn-shenzhen")
var accessId = "Ie65kUInu5GeAsma"
var accessSecret = "8cCqoxdYU9zKUihwXFXiN1HEACBDwB"
resp, err := restartOss(&req, accessId, accessSecret)
if err != nil {
t.Errorf("Error: %s", err.Error())
}
fmt.Printf("Success: %v\n", resp)
} | explode_data.jsonl/73756 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
50215,
46,
778,
1155,
353,
8840,
836,
8,
341,
2405,
4232,
17024,
46,
778,
1900,
198,
24395,
26849,
741,
24395,
4202,
4061,
445,
5370,
1138,
24395,
4202,
14091,
764,
445,
14271,
7514,
78411,
1138,
2405,
2615,
764,
284,
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... | 2 |
func TestCRUDMethods(t *testing.T) {
a := assert.New(t)
tx, err := Default().Begin()
a.Nil(err)
defer tx.Rollback()
seedErr := seedObjects(100, tx)
a.Nil(seedErr)
objs := []benchObj{}
queryErr := Default().QueryInTx("select * from bench_object", tx).OutMany(&objs)
a.Nil(queryErr)
a.NotEmpty(objs)
all := []benchObj{}
allErr := Default().GetAllInTx(&all, tx)
a.Nil(allErr)
a.Equal(len(objs), len(all))
sampleObj := all[0]
getTest := benchObj{}
getTestErr := Default().GetInTx(&getTest, tx, sampleObj.ID)
a.Nil(getTestErr)
a.Equal(sampleObj.ID, getTest.ID)
exists, existsErr := Default().ExistsInTx(&getTest, tx)
a.Nil(existsErr)
a.True(exists)
getTest.Name = "not_a_test_object"
updateErr := Default().UpdateInTx(&getTest, tx)
a.Nil(updateErr)
verify := benchObj{}
verifyErr := Default().GetInTx(&verify, tx, getTest.ID)
a.Nil(verifyErr)
a.Equal(getTest.Name, verify.Name)
deleteErr := Default().DeleteInTx(&verify, tx)
a.Nil(deleteErr)
delVerify := benchObj{}
delVerifyErr := Default().GetInTx(&delVerify, tx, getTest.ID)
a.Nil(delVerifyErr)
} | explode_data.jsonl/33837 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
8973,
4656,
17856,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
340,
46237,
11,
1848,
1669,
7899,
1005,
11135,
741,
11323,
59678,
3964,
340,
16867,
9854,
88918,
2822,
197,
22602,
7747,
1669,
10320,
11543,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMigration_String(t *testing.T) {
v := Migration{
ID: Int64(0),
GUID: String(""),
State: String(""),
LockRepositories: Bool(false),
ExcludeAttachments: Bool(false),
URL: String(""),
CreatedAt: String(""),
UpdatedAt: String(""),
}
want := `github.Migration{ID:0, GUID:"", State:"", LockRepositories:false, ExcludeAttachments:false, URL:"", CreatedAt:"", UpdatedAt:""}`
if got := v.String(); got != want {
t.Errorf("Migration.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33259 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
20168,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
21248,
515,
197,
29580,
25,
338,
1333,
21,
19,
7,
15,
1326,
197,
9600,
6463,
25,
2290,
923,
445,
4461,
197,
76424,
25,
1060,
923,
445,
4461,
197,
197,
11989,
44814,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_EndpointSliceReadyAndTerminatingLocal(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ProxyTerminatingEndpoints, true)()
ipt := iptablestest.NewFake()
ipvs := ipvstest.NewFake()
ipset := ipsettest.NewFake(testIPSetVersion)
fp := NewFakeProxier(ipt, ipvs, ipset, nil, nil, v1.IPv4Protocol)
fp.servicesSynced = true
// fp.endpointsSynced = true
fp.endpointSlicesSynced = true
clusterInternalTrafficPolicy := v1.ServiceInternalTrafficPolicyCluster
serviceName := "svc1"
// Add initial service
namespaceName := "ns1"
fp.OnServiceAdd(&v1.Service{
ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: namespaceName},
Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"},
Type: v1.ServiceTypeNodePort,
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyTypeLocal,
InternalTrafficPolicy: &clusterInternalTrafficPolicy,
ExternalIPs: []string{
"1.2.3.4",
},
Ports: []v1.ServicePort{
{
Name: "",
Port: 80,
TargetPort: intstr.FromInt(80),
Protocol: v1.ProtocolTCP,
},
},
},
})
// Add initial endpoint slice
tcpProtocol := v1.ProtocolTCP
endpointSlice := &discovery.EndpointSlice{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-1", serviceName),
Namespace: namespaceName,
Labels: map[string]string{discovery.LabelServiceName: serviceName},
},
Ports: []discovery.EndpointPort{{
Name: utilpointer.StringPtr(""),
Port: utilpointer.Int32Ptr(80),
Protocol: &tcpProtocol,
}},
AddressType: discovery.AddressTypeIPv4,
Endpoints: []discovery.Endpoint{
{
Addresses: []string{"10.0.1.1"},
Conditions: discovery.EndpointConditions{
Ready: utilpointer.BoolPtr(true),
Serving: utilpointer.BoolPtr(true),
Terminating: utilpointer.BoolPtr(false),
},
NodeName: utilpointer.StringPtr(testHostname),
},
{
Addresses: []string{"10.0.1.2"},
Conditions: discovery.EndpointConditions{
Ready: utilpointer.BoolPtr(true),
Serving: utilpointer.BoolPtr(true),
Terminating: utilpointer.BoolPtr(false),
},
NodeName: utilpointer.StringPtr(testHostname),
},
{
Addresses: []string{"10.0.1.3"},
Conditions: discovery.EndpointConditions{
Ready: utilpointer.BoolPtr(false),
Serving: utilpointer.BoolPtr(true),
Terminating: utilpointer.BoolPtr(true),
},
NodeName: utilpointer.StringPtr(testHostname),
},
{
Addresses: []string{"10.0.1.4"},
Conditions: discovery.EndpointConditions{
Ready: utilpointer.BoolPtr(false),
Serving: utilpointer.BoolPtr(false),
Terminating: utilpointer.BoolPtr(true),
},
NodeName: utilpointer.StringPtr(testHostname),
},
{
Addresses: []string{"10.0.1.5"},
Conditions: discovery.EndpointConditions{
Ready: utilpointer.BoolPtr(true),
Serving: utilpointer.BoolPtr(true),
Terminating: utilpointer.BoolPtr(false),
},
NodeName: utilpointer.StringPtr("another-host"),
},
},
}
fp.OnEndpointSliceAdd(endpointSlice)
fp.syncProxyRules()
// Ensure that Proxier updates ipvs appropriately after EndpointSlice update
assert.NotNil(t, fp.ipsetList["KUBE-LOOP-BACK"])
activeEntries1 := fp.ipsetList["KUBE-LOOP-BACK"].activeEntries
assert.Equal(t, 4, activeEntries1.Len(), "Expected 3 active entry in KUBE-LOOP-BACK")
assert.Equal(t, true, activeEntries1.Has("10.0.1.1,tcp:80,10.0.1.1"), "Expected activeEntries to reference first (local) pod")
assert.Equal(t, true, activeEntries1.Has("10.0.1.2,tcp:80,10.0.1.2"), "Expected activeEntries to reference second (local) pod")
assert.Equal(t, true, activeEntries1.Has("10.0.1.3,tcp:80,10.0.1.3"), "Expected activeEntries to reference second (local) pod")
assert.Equal(t, true, activeEntries1.Has("10.0.1.4,tcp:80,10.0.1.4"), "Expected activeEntries to reference second (local) pod")
virtualServers, vsErr := ipvs.GetVirtualServers()
assert.Nil(t, vsErr, "Expected no error getting virtual servers")
assert.Len(t, virtualServers, 2, "Expected 2 virtual server")
var clusterIPServer, externalIPServer *utilipvs.VirtualServer
for _, virtualServer := range virtualServers {
if virtualServer.Address.String() == "172.20.1.1" {
clusterIPServer = virtualServer
}
if virtualServer.Address.String() == "1.2.3.4" {
externalIPServer = virtualServer
}
}
// clusterIP should route to cluster-wide ready endpoints
realServers1, rsErr1 := ipvs.GetRealServers(clusterIPServer)
assert.Nil(t, rsErr1, "Expected no error getting real servers")
assert.Len(t, realServers1, 3, "Expected 3 real servers")
assert.Equal(t, realServers1[0].String(), "10.0.1.1:80")
assert.Equal(t, realServers1[1].String(), "10.0.1.2:80")
assert.Equal(t, realServers1[2].String(), "10.0.1.5:80")
// externalIP should route to local ready + non-terminating endpoints if they exist
realServers2, rsErr2 := ipvs.GetRealServers(externalIPServer)
assert.Nil(t, rsErr2, "Expected no error getting real servers")
assert.Len(t, realServers2, 2, "Expected 2 real servers")
assert.Equal(t, realServers2[0].String(), "10.0.1.1:80")
assert.Equal(t, realServers2[1].String(), "10.0.1.2:80")
fp.OnEndpointSliceDelete(endpointSlice)
fp.syncProxyRules()
// Ensure that Proxier updates ipvs appropriately after EndpointSlice delete
assert.NotNil(t, fp.ipsetList["KUBE-LOOP-BACK"])
activeEntries2 := fp.ipsetList["KUBE-LOOP-BACK"].activeEntries
assert.Equal(t, 0, activeEntries2.Len(), "Expected 0 active entries in KUBE-LOOP-BACK")
virtualServers, vsErr = ipvs.GetVirtualServers()
assert.Nil(t, vsErr, "Expected no error getting virtual servers")
assert.Len(t, virtualServers, 2, "Expected 1 virtual server")
for _, virtualServer := range virtualServers {
if virtualServer.Address.String() == "172.20.1.1" {
clusterIPServer = virtualServer
}
if virtualServer.Address.String() == "1.2.3.4" {
externalIPServer = virtualServer
}
}
realServers1, rsErr1 = ipvs.GetRealServers(clusterIPServer)
assert.Nil(t, rsErr1, "Expected no error getting real servers")
assert.Len(t, realServers1, 0, "Expected 0 real servers")
realServers2, rsErr2 = ipvs.GetRealServers(externalIPServer)
assert.Nil(t, rsErr2, "Expected no error getting real servers")
assert.Len(t, realServers2, 0, "Expected 0 real servers")
} | explode_data.jsonl/44383 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2641
} | [
2830,
3393,
49953,
2768,
33236,
19202,
3036,
21209,
64283,
7319,
1155,
353,
8840,
836,
8,
341,
16867,
4565,
70,
266,
57824,
287,
4202,
13859,
42318,
16014,
2271,
1155,
11,
4094,
12753,
13275,
13859,
42318,
11,
4419,
75200,
21209,
64283,
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... | 7 |
func TestWatchBatchUnsynced(t *testing.T) {
b, tmpPath := backend.NewDefaultTmpBackend()
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, nil, StoreConfig{})
oldMaxRevs := watchBatchMaxRevs
defer func() {
watchBatchMaxRevs = oldMaxRevs
s.store.Close()
os.Remove(tmpPath)
}()
batches := 3
watchBatchMaxRevs = 4
v := []byte("foo")
for i := 0; i < watchBatchMaxRevs*batches; i++ {
s.Put(v, v, lease.NoLease)
}
w := s.NewWatchStream()
w.Watch(0, v, nil, 1)
for i := 0; i < batches; i++ {
if resp := <-w.Chan(); len(resp.Events) != watchBatchMaxRevs {
t.Fatalf("len(events) = %d, want %d", len(resp.Events), watchBatchMaxRevs)
}
}
s.store.revMu.Lock()
defer s.store.revMu.Unlock()
if size := s.synced.size(); size != 1 {
t.Errorf("synced size = %d, want 1", size)
}
} | explode_data.jsonl/67209 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
14247,
21074,
1806,
12996,
291,
1155,
353,
8840,
836,
8,
341,
2233,
11,
4174,
1820,
1669,
19163,
7121,
3675,
35986,
29699,
741,
1903,
1669,
501,
14247,
480,
6093,
13174,
391,
7121,
13314,
1507,
293,
11,
609,
1623,
991,
726,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReadFieldFromObject(t *testing.T) {
t.Parallel()
ctx := NewIsolate().NewContext()
res, err := ctx.Eval(`({foo:"bar"})`, "my_file.js")
if err != nil {
t.Fatalf("Error evaluating javascript, err: %v", err)
}
val, err := res.Get("foo")
if err != nil {
t.Fatalf("Error trying to get field: %v", err)
}
if str := val.String(); str != "bar" {
t.Errorf("Expected 'bar', got %q", str)
}
} | explode_data.jsonl/81549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
4418,
1877,
3830,
1190,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
1532,
3872,
33066,
1005,
3564,
1972,
741,
10202,
11,
1848,
1669,
5635,
5142,
831,
5809,
2306,
7975,
2974,
2257,
80154,
7808,
330,
240... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCluster_Owners(t *testing.T) {
c := cluster{
nodes: []*Node{
{URI: NewTestURIFromHostPort("serverA", 1000)},
{URI: NewTestURIFromHostPort("serverB", 1000)},
{URI: NewTestURIFromHostPort("serverC", 1000)},
},
Hasher: NewTestModHasher(),
ReplicaN: 2,
}
// Verify nodes are distributed.
if a := c.partitionNodes(0); !reflect.DeepEqual(a, []*Node{c.nodes[0], c.nodes[1]}) {
t.Fatalf("unexpected owners: %s", spew.Sdump(a))
}
// Verify nodes go around the ring.
if a := c.partitionNodes(2); !reflect.DeepEqual(a, []*Node{c.nodes[2], c.nodes[0]}) {
t.Fatalf("unexpected owners: %s", spew.Sdump(a))
}
} | explode_data.jsonl/59875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
28678,
2232,
1522,
388,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
10652,
515,
197,
79756,
25,
29838,
1955,
515,
298,
197,
90,
10301,
25,
1532,
2271,
1511,
2773,
441,
9296,
7084,
445,
4030,
32,
497,
220,
16,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestWorkerReady(t *testing.T) {
f := newFixture(t)
startTime := metav1.Now()
completionTime := metav1.Now()
var replicas int32 = 16
mpiJob := newMPIJob("test", &replicas, 1, gpuResourceName, &startTime, &completionTime)
f.setUpMPIJob(mpiJob)
f.setUpRbac(mpiJob, replicas)
var runningPodList []*corev1.Pod
for i := 0; i < 16; i++ {
name := fmt.Sprintf("%s-%d", mpiJob.Name+workerSuffix, i)
worker := newWorker(mpiJob, name, "")
worker.Status.Phase = corev1.PodRunning
runningPodList = append(runningPodList, worker)
f.setUpWorker(worker)
}
configMap := newConfigMap(mpiJob, replicas, isGPULauncher(mpiJob))
updateDiscoverHostsInConfigMap(configMap, mpiJob, runningPodList, isGPULauncher(mpiJob))
f.setUpConfigMap(configMap)
fmjc := f.newFakeMPIJobController()
expLauncher := fmjc.newLauncher(mpiJob, "kubectl-delivery", isGPULauncher(mpiJob))
f.expectCreateJobAction(expLauncher)
mpiJobCopy := mpiJob.DeepCopy()
mpiJobCopy.Status.ReplicaStatuses = map[common.ReplicaType]*common.ReplicaStatus{
common.ReplicaType(kubeflow.MPIReplicaTypeLauncher): {
Active: 0,
Succeeded: 0,
Failed: 0,
},
common.ReplicaType(kubeflow.MPIReplicaTypeWorker): {
Active: 16,
Succeeded: 0,
Failed: 0,
},
}
setUpMPIJobTimestamp(mpiJobCopy, &startTime, &completionTime)
f.expectUpdateMPIJobStatusAction(mpiJobCopy)
f.run(getKey(mpiJob, t))
} | explode_data.jsonl/29962 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 595
} | [
2830,
3393,
21936,
19202,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
21375,
1462,
1669,
77520,
16,
13244,
741,
32810,
14386,
1462,
1669,
77520,
16,
13244,
2822,
2405,
80801,
526,
18,
17,
284,
220,
16,
21,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUpdate(t *testing.T) {
files := []string{"fixtures/rules.yaml"}
expected := map[string]labels.Labels{
"test": labels.FromStrings("name", "value"),
}
ruleManager := NewManager(&ManagerOptions{
Context: context.Background(),
Logger: log.NewNopLogger(),
})
ruleManager.Run()
err := ruleManager.Update(10*time.Second, files)
testutil.Ok(t, err)
testutil.Assert(t, len(ruleManager.groups) > 0, "expected non-empty rule groups")
for _, g := range ruleManager.groups {
g.seriesInPreviousEval = []map[string]labels.Labels{
expected,
}
}
err = ruleManager.Update(10*time.Second, files)
testutil.Ok(t, err)
for _, g := range ruleManager.groups {
for _, actual := range g.seriesInPreviousEval {
testutil.Equals(t, expected, actual)
}
}
} | explode_data.jsonl/40289 | {
"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,
4289,
1155,
353,
8840,
836,
8,
341,
74075,
1669,
3056,
917,
4913,
45247,
95489,
33406,
16707,
42400,
1669,
2415,
14032,
60,
16873,
4679,
82,
515,
197,
197,
1,
1944,
788,
9201,
11439,
20859,
445,
606,
497,
330,
957,
4461,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetBrowserOnMacOsxChrome(t *testing.T) {
if browser, ok := GetBrowser(TestMacOsxChromeAgent); !ok {
t.Error("Browser not found")
} else if browser.Browser != "Chrome" {
t.Errorf("Expected Chrome but got %q", browser.Browser)
} else if browser.Platform != "MacOSX" {
t.Errorf("Expected MacOSX but got %q", browser.Platform)
} else if browser.BrowserVersion != "37.0" {
t.Errorf("Expected 37.0 but got %q", browser.BrowserVersion)
} else if browser.RenderingEngineName != "Blink" {
t.Errorf("Expected Blink but got %q", browser.RenderingEngineName)
} else if browser.Crawler != "false" {
t.Errorf("Expected false but got %q", browser.Crawler)
}
} | explode_data.jsonl/35270 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
1949,
17878,
1925,
19552,
28867,
87,
49070,
1155,
353,
8840,
836,
8,
341,
743,
6929,
11,
5394,
1669,
2126,
17878,
31159,
19552,
28867,
87,
49070,
16810,
1215,
753,
562,
341,
197,
3244,
6141,
445,
17878,
537,
1730,
1138,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestRemoveLocalDots_Normalize(t *testing.T) {
tests := []struct {
domains []string
email string
want string
}{
{
domains: []string{"email.com"},
email: "a.b.c@email.com",
want: "abc@email.com",
},
{
domains: []string{"email.com"},
email: "a..b..c..@email.com",
want: "abc@email.com",
},
{
domains: []string{"email.com"},
email: "a.b.c@cmail.com",
want: "a.b.c@cmail.com",
},
}
for i, tt := range tests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
ea := NewEmailAddress(tt.email)
NewRemoveLocalDots(tt.domains...).Normalize(ea)
if got := ea.String(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("RemoveLocalDots.Normalize() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/57365 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
13021,
7319,
35,
2412,
74900,
551,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
2698,
316,
1735,
3056,
917,
198,
197,
57549,
256,
914,
198,
197,
50780,
262,
914,
198,
197,
59403,
197,
197,
515,
298,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetMigNodesBasic(t *testing.T) {
server := NewHttpServerMock()
defer server.Close()
g := newTestGceManager(t, server.URL, false)
server.On("handle", "/project1/zones/us-central1-b/instanceGroupManagers/extra-pool-323233232/listManagedInstances").Return(buildFourRunningInstancesOnDefaultMigManagedInstancesResponse(zoneB)).Once()
mig := &gceMig{
gceRef: GceRef{
Project: projectId,
Zone: zoneB,
Name: "extra-pool-323233232",
},
gceManager: g,
minSize: 0,
maxSize: 1000,
}
nodes, err := g.GetMigNodes(mig)
assert.NoError(t, err)
assert.Equal(t, 4, len(nodes))
assert.Equal(t, "gce://project1/us-central1-b/gke-cluster-1-default-pool-f7607aac-9j4g", nodes[0].Id)
assert.Equal(t, "gce://project1/us-central1-b/gke-cluster-1-default-pool-f7607aac-c63g", nodes[1].Id)
assert.Equal(t, "gce://project1/us-central1-b/gke-cluster-1-default-pool-f7607aac-dck1", nodes[2].Id)
assert.Equal(t, "gce://project1/us-central1-b/gke-cluster-1-default-pool-f7607aac-f1hm", nodes[3].Id)
for i := 0; i < 4; i++ {
assert.Nil(t, nodes[i].Status.ErrorInfo)
assert.Equal(t, cloudprovider.InstanceRunning, nodes[i].Status.State)
}
} | explode_data.jsonl/27612 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 527
} | [
2830,
3393,
1949,
44,
343,
12288,
15944,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
1532,
2905,
5475,
11571,
741,
16867,
3538,
10421,
741,
3174,
1669,
501,
2271,
38,
346,
2043,
1155,
11,
3538,
20893,
11,
895,
692,
41057,
8071,
445,
81... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMaintainer(t *testing.T) {
maintainerEntry := "Some Maintainer <maintainer@example.com>"
b := &Builder{flags: &BFlags{}, runConfig: &container.Config{}, disableCommit: true}
if err := maintainer(b, []string{maintainerEntry}, nil, ""); err != nil {
t.Fatalf("Error when executing maintainer: %s", err.Error())
}
if b.maintainer != maintainerEntry {
t.Fatalf("Maintainer in builder should be set to %s. Got: %s", maintainerEntry, b.maintainer)
}
} | explode_data.jsonl/28274 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
66734,
1743,
1155,
353,
8840,
836,
8,
341,
2109,
1641,
1743,
5874,
1669,
330,
8373,
42887,
1743,
366,
66813,
1743,
35487,
905,
29,
1837,
2233,
1669,
609,
3297,
90,
11161,
25,
609,
33,
9195,
22655,
1598,
2648,
25,
609,
3586... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateStringNoVariablesFails(t *testing.T) {
tests := []string{
"$var",
"abcйй$й",
"$$",
}
for _, test := range tests {
allErrs := validateStringNoVariables(test, field.NewPath("rewritePath"))
if len(allErrs) == 0 {
t.Errorf("validateStringNoVariables(%v) returned no errors for invalid input", test)
}
}
} | explode_data.jsonl/65907 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
17926,
703,
2753,
22678,
37,
6209,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
917,
515,
197,
197,
33732,
947,
756,
197,
197,
1,
13683,
12141,
12141,
3,
12141,
756,
197,
197,
1,
14085,
756,
197,
630,
2023,
8358,
127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRateBreakerTripping(t *testing.T) {
cb := NewRateBreaker(0.5, 4)
cb.Success()
cb.Success()
cb.Fail()
cb.Fail()
if !cb.Tripped() {
t.Fatal("expected rate breaker to be tripped")
}
if er := cb.ErrorRate(); er != 0.5 {
t.Fatalf("expected error rate to be 0.5, got %f", er)
}
} | explode_data.jsonl/60806 | {
"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,
11564,
22524,
261,
21884,
10732,
1155,
353,
8840,
836,
8,
341,
63810,
1669,
1532,
11564,
22524,
261,
7,
15,
13,
20,
11,
220,
19,
340,
63810,
33320,
741,
63810,
33320,
741,
63810,
57243,
741,
63810,
57243,
2822,
743,
753,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMachineSetToDeployments(t *testing.T) {
machineDeployment := clusterv1.MachineDeployment{
ObjectMeta: metav1.ObjectMeta{
Name: "withMatchingLabels",
Namespace: "test",
},
Spec: clusterv1.MachineDeploymentSpec{
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"foo": "bar",
clusterv1.ClusterLabelName: "test-cluster",
},
},
},
}
machineDeplopymentList := &clusterv1.MachineDeploymentList{
TypeMeta: metav1.TypeMeta{
Kind: "MachineDeploymentList",
},
Items: []clusterv1.MachineDeployment{machineDeployment},
}
ms1 := clusterv1.MachineSet{
TypeMeta: metav1.TypeMeta{
Kind: "MachineSet",
},
ObjectMeta: metav1.ObjectMeta{
Name: "withOwnerRef",
Namespace: "test",
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(&machineDeployment, machineDeploymentKind),
},
Labels: map[string]string{
clusterv1.ClusterLabelName: "test-cluster",
},
},
}
ms2 := clusterv1.MachineSet{
TypeMeta: metav1.TypeMeta{
Kind: "MachineSet",
},
ObjectMeta: metav1.ObjectMeta{
Name: "noOwnerRefNoLabels",
Namespace: "test",
Labels: map[string]string{
clusterv1.ClusterLabelName: "test-cluster",
},
},
}
ms3 := clusterv1.MachineSet{
TypeMeta: metav1.TypeMeta{
Kind: "MachineSet",
},
ObjectMeta: metav1.ObjectMeta{
Name: "withMatchingLabels",
Namespace: "test",
Labels: map[string]string{
"foo": "bar",
clusterv1.ClusterLabelName: "test-cluster",
},
},
}
testsCases := []struct {
machineSet clusterv1.MachineSet
mapObject handler.MapObject
expected []reconcile.Request
}{
{
machineSet: ms1,
mapObject: handler.MapObject{
Meta: ms1.GetObjectMeta(),
Object: &ms1,
},
expected: []reconcile.Request{},
},
{
machineSet: ms2,
mapObject: handler.MapObject{
Meta: ms2.GetObjectMeta(),
Object: &ms2,
},
expected: nil,
},
{
machineSet: ms3,
mapObject: handler.MapObject{
Meta: ms3.GetObjectMeta(),
Object: &ms3,
},
expected: []reconcile.Request{
{NamespacedName: client.ObjectKey{Namespace: "test", Name: "withMatchingLabels"}},
},
},
}
err := clusterv1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())
r := &MachineDeploymentReconciler{
Client: fake.NewFakeClient(machineDeplopymentList),
Log: log.Log,
recorder: record.NewFakeRecorder(32),
}
for _, tc := range testsCases {
got := r.MachineSetToDeployments(tc.mapObject)
if !reflect.DeepEqual(got, tc.expected) {
t.Errorf("Case %s. Got: %v, expected: %v", tc.machineSet.Name, got, tc.expected)
}
}
} | explode_data.jsonl/62420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1213
} | [
2830,
3393,
21605,
1649,
1249,
69464,
1368,
1155,
353,
8840,
836,
8,
341,
2109,
3814,
75286,
1669,
1185,
590,
648,
16,
1321,
3814,
75286,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
4197,
64430,
23674,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHashJsonValidation(t *testing.T) {
var tests = []struct {
Prefix string
Size int
Error string
}{
{"", 62, "json: cannot unmarshal hex string without 0x prefix into Go value of type common.Hash"},
{"0x", 66, "hex string has length 66, want 64 for common.Hash"},
{"0x", 63, "json: cannot unmarshal hex string of odd length into Go value of type common.Hash"},
{"0x", 0, "hex string has length 0, want 64 for common.Hash"},
{"0x", 64, ""},
{"0X", 64, ""},
}
for _, test := range tests {
input := `"` + test.Prefix + strings.Repeat("0", test.Size) + `"`
var v Hash
err := json.Unmarshal([]byte(input), &v)
if err == nil {
if test.Error != "" {
t.Errorf("%s: error mismatch: have nil, want %q", input, test.Error)
}
} else {
if err.Error() != test.Error {
t.Errorf("%s: error mismatch: have %q, want %q", input, err, test.Error)
}
}
}
} | explode_data.jsonl/35495 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
6370,
5014,
13799,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
10025,
5060,
914,
198,
197,
91224,
256,
526,
198,
197,
58421,
220,
914,
198,
197,
59403,
197,
197,
4913,
497,
220,
21,
17,
11,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_CurrentPackageLoggerNameGenerator(t *testing.T) {
assert.ToBeEqual(t, "github.com/echocat/slf4g/names", forPackageSomethingFromInit)
assert.ToBeEqual(t, "github.com/echocat/slf4g/names", (&someStruct{}).somethingFromAMethodInAStruct())
assert.ToBeEqual(t, "github.com/echocat/slf4g/names", someStruct{}.somethingFromAMethodInAStruct())
assert.ToBeEqual(t, "github.com/echocat/slf4g/names", CurrentPackageLoggerNameGenerator(0))
} | explode_data.jsonl/57925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
40735,
13100,
7395,
675,
12561,
1155,
353,
8840,
836,
8,
341,
6948,
3274,
3430,
2993,
1155,
11,
330,
5204,
905,
14,
4737,
509,
266,
2687,
11008,
19,
70,
9612,
971,
497,
369,
13100,
23087,
3830,
3803,
340,
6948,
3274,
3430,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientSelectConnDeadAndHealthy(t *testing.T) {
client, err := NewClient(
SetSniff(false),
SetHealthcheck(false),
SetURL("http://127.0.0.1:9200", "http://127.0.0.1:9201"))
if err != nil {
t.Fatal(err)
}
// 1st is dead, 2nd is healthy
client.conns[0].MarkAsDead()
client.conns[1].MarkAsHealthy()
// #1: Return 2nd
c, err := client.next()
if err != nil {
t.Fatal(err)
}
if c.URL() != client.conns[1].URL() {
t.Fatalf("expected %s; got: %s", c.URL(), client.conns[1].URL())
}
// #2: Return 2nd again
c, err = client.next()
if err != nil {
t.Fatal(err)
}
if c.URL() != client.conns[1].URL() {
t.Fatalf("expected %s; got: %s", c.URL(), client.conns[1].URL())
}
// #3: Return 2nd again and again
c, err = client.next()
if err != nil {
t.Fatal(err)
}
if c.URL() != client.conns[1].URL() {
t.Fatalf("expected %s; got: %s", c.URL(), client.conns[1].URL())
}
} | explode_data.jsonl/38013 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 412
} | [
2830,
3393,
2959,
3379,
9701,
28320,
3036,
96113,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
1532,
2959,
1006,
197,
22212,
20720,
3092,
3576,
1326,
197,
22212,
14542,
2028,
3576,
1326,
197,
22212,
3144,
445,
1254,
1110,
16,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestFirstVolumeRecovery(t *testing.T) {
const (
backendName = "firstRecoveryBackend"
scName = "firstRecoveryBackendSC"
txOnlyVolumeName = "firstRecoveryVolumeTxOnly"
)
orchestrator := getOrchestrator(t)
prepRecoveryTest(t, orchestrator, backendName, scName)
txOnlyVolumeConfig := tu.GenerateVolumeConfig(txOnlyVolumeName, 50, scName, config.File)
// BEGIN actual test
runRecoveryTests(
t, orchestrator, backendName, storage.AddVolume, []recoveryTest{
{
name: "firstTXOnly", volumeConfig: txOnlyVolumeConfig,
expectDestroy: true,
},
},
)
cleanup(t, orchestrator)
} | explode_data.jsonl/62732 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
5338,
18902,
693,
7449,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
197,
20942,
675,
414,
284,
330,
3896,
693,
7449,
29699,
698,
197,
29928,
675,
1843,
284,
330,
3896,
693,
7449,
29699,
3540,
698,
197,
46237,
7308,
1890... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldIncludeUser(t *testing.T) {
for _, testCase := range gShouldIncludeTestCases {
/*
* Call
*/
fmt.Printf("%v\n", testCase.InputPrefs)
fmt.Printf("%v\n", testCase.InputUser)
result :=
testCase.InputPrefs.ShouldIncludeUser(&testCase.InputUser)
/*
* Test
*/
require.Equal(t, testCase.Output, result)
}
} | explode_data.jsonl/65248 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
14996,
22283,
1474,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
54452,
1669,
2088,
342,
14996,
22283,
2271,
37302,
341,
197,
197,
3284,
298,
353,
7143,
198,
298,
735,
197,
11009,
19367,
4430,
85,
1699,
497,
54452,
16130,
31434... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Loading_keys(t *testing.T) {
pkey := os.Getenv("HOME")+"/.ssh"
band := os.Getenv("HOME")+"/.ssh/band_memory_ed25519"
if got := Startup( pkey, band, "Anonymous", true, true, false); got != nil {
t.Errorf("Startup( /ed25519/ ) = %q, expected error(nil)", got.Error())
}
want:=error(nil)
if got := recallFromFile(band); got != want {
t.Errorf("recallFromFile( /ed25519/ ) = %q, want %q", got, want)
}
} | explode_data.jsonl/74031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 237
} | [
2830,
3393,
2351,
78,
2228,
12631,
1155,
353,
8840,
836,
8,
341,
3223,
792,
1669,
2643,
64883,
445,
27546,
899,
27569,
13,
25537,
698,
286,
7055,
1669,
2643,
64883,
445,
27546,
899,
27569,
13,
25537,
3470,
437,
19195,
32370,
17,
20,
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... | 3 |
func TestValidateDeck(t *testing.T) {
boolTrue := true
boolFalse := false
cases := []struct {
name string
deck Deck
expectedErr string
}{
{
name: "empty Deck is valid",
deck: Deck{},
expectedErr: "",
},
{
name: "AdditionalAllowedBuckets has items, SkipStoragePathValidation is false => no errors",
deck: Deck{SkipStoragePathValidation: &boolFalse, AdditionalAllowedBuckets: []string{"foo", "bar", "batz"}},
expectedErr: "",
},
{
name: "AdditionalAllowedBuckets has items, SkipStoragePathValidation is default value => no error",
deck: Deck{AdditionalAllowedBuckets: []string{"hello", "world"}},
expectedErr: "",
},
{
name: "AdditionalAllowedBuckets has items, SkipStoragePathValidation is true => error",
deck: Deck{SkipStoragePathValidation: &boolTrue, AdditionalAllowedBuckets: []string{"hello", "world"}},
expectedErr: "skip_storage_path_validation is enabled",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
expectingErr := len(tc.expectedErr) > 0
err := tc.deck.Validate()
if expectingErr && err == nil {
t.Fatalf("expecting error (%v), but did not get an error", tc.expectedErr)
}
if !expectingErr && err != nil {
t.Fatalf("not expecting error, but got an error: %v", err)
}
if expectingErr && err != nil && !strings.Contains(err.Error(), tc.expectedErr) {
t.Fatalf("expected error (%v), but got unknown error, instead: %v", tc.expectedErr, err)
}
})
}
} | explode_data.jsonl/41016 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 636
} | [
2830,
3393,
17926,
39368,
1155,
353,
8840,
836,
8,
341,
7562,
2514,
1669,
830,
198,
7562,
4049,
1669,
895,
198,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
197,
33425,
286,
28416,
198,
197,
42400,
7747,
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... | 8 |
func TestSaveBlock(t *testing.T) {
defer os.RemoveAll("temp")
testDB := dbm.NewDB("testdb", "leveldb", "temp")
store := NewStore(testDB)
block := config.GenesisBlock()
status := &bc.TransactionStatus{VerifyStatus: []*bc.TxVerifyResult{{StatusFail: true}}}
if err := store.SaveBlock(block, status); err != nil {
t.Fatal(err)
}
blockHash := block.Hash()
gotBlock, err := store.GetBlock(&blockHash)
if err != nil {
t.Fatal(err)
}
gotBlock.Transactions[0].Tx.SerializedSize = 0
gotBlock.Transactions[0].SerializedSize = 0
if !testutil.DeepEqual(block, gotBlock) {
t.Errorf("got block:%v, expect block:%v", gotBlock, block)
}
gotStatus, err := store.GetTransactionStatus(&blockHash)
if err != nil {
t.Fatal(err)
}
if !testutil.DeepEqual(status, gotStatus) {
t.Errorf("got status:%v, expect status:%v", gotStatus, status)
}
data := store.db.Get(CalcBlockHeaderKey(block.Height, &blockHash))
gotBlockHeader := types.BlockHeader{}
if err := gotBlockHeader.UnmarshalText(data); err != nil {
t.Fatal(err)
}
if !testutil.DeepEqual(block.BlockHeader, gotBlockHeader) {
t.Errorf("got block header:%v, expect block header:%v", gotBlockHeader, block.BlockHeader)
}
} | explode_data.jsonl/49977 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 454
} | [
2830,
3393,
8784,
4713,
1155,
353,
8840,
836,
8,
341,
16867,
2643,
84427,
445,
3888,
1138,
18185,
3506,
1669,
2927,
76,
7121,
3506,
445,
1944,
1999,
497,
330,
3449,
783,
65,
497,
330,
3888,
1138,
57279,
1669,
1532,
6093,
8623,
3506,
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... | 8 |
func TestGetUsagePercentile(t *testing.T) {
reqs, hSource := newSource(t)
usage, samples, err := hSource.GetUsagePercentile(api.ResourceCPU, 90, testImageWithVersion(), "16a8884e4c155457ee38a8901df6b536", true, time.Now(), time.Now())
assert.NoError(t, err)
assert.Equal(t, 1, len(reqs))
assert.Equal(t, "", reqs["unknown"])
assert.Equal(t, int64(123456), int64(samples))
assert.Equal(t, int64(7896), usage) // float64 -> int64
} | explode_data.jsonl/55852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
1949,
14783,
32010,
457,
1155,
353,
8840,
836,
8,
341,
24395,
82,
11,
305,
3608,
1669,
501,
3608,
1155,
692,
88777,
11,
10469,
11,
1848,
1669,
305,
3608,
2234,
14783,
32010,
457,
24827,
20766,
31615,
11,
220,
24,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGroupConventions(t *testing.T) {
for _, g := range cfg.Groups {
// groups are easier to reason about if email and name match
expectedEmailId := g.Name + "@knative.team"
if g.EmailId != expectedEmailId {
t.Errorf("group '%s': expected email '%s', got '%s'", g.Name, expectedEmailId, g.EmailId)
}
}
} | explode_data.jsonl/24790 | {
"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,
2808,
1109,
30659,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
342,
1669,
2088,
13286,
59800,
341,
197,
197,
322,
5203,
525,
8661,
311,
2874,
911,
421,
2551,
323,
829,
2432,
198,
197,
42400,
4781,
764,
1669,
342,
2967,
488,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_etcdRepository_CreateDetectorLink(t *testing.T) {
r := &etcdRepository{}
assert.Panics(t, func() { _ = r.CreateDetectorLink(context.Background(), "a", "b", 5) })
} | explode_data.jsonl/11281 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 67
} | [
2830,
3393,
45668,
4385,
4624,
34325,
31606,
3939,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
609,
295,
4385,
4624,
16094,
6948,
1069,
276,
1211,
1155,
11,
2915,
368,
314,
716,
284,
435,
7251,
31606,
3939,
5378,
19047,
1507,
330,
64,
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 |
func TestExprSemanticsCheckerUpdateSteps(t *testing.T) {
c := NewExprSemanticsChecker(false)
ty := NewEmptyObjectType()
prev := c.vars["steps"]
c.UpdateSteps(ty)
if c.vars["steps"] == prev {
t.Fatalf("Global variables map was not copied")
}
prev = c.vars["steps"]
c.UpdateSteps(ty)
if c.vars["steps"] != prev {
t.Fatalf("Global variables map was copied when calling UpdateSteps again")
}
} | explode_data.jsonl/43653 | {
"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,
16041,
29499,
36233,
35188,
4289,
33951,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
16041,
29499,
36233,
35188,
3576,
340,
197,
1881,
1669,
1532,
3522,
49530,
741,
50728,
1669,
272,
59628,
1183,
24080,
7026,
1444,
16689,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMoveTile(t *testing.T) {
pos := [][]int{[]int{0, 0}, []int{0, 1}}
game := Game{gridSize: 4}
game.setup(GameInfo{TileState: createTileState(4, pos)})
game.moveTile(&Tile{x: 0, y: 0, value: 4}, &Tile{x: 3, y: 3})
if game.grid.cells[3][3].value != 4 {
t.Error("Moved cell should be equal to 4")
}
} | explode_data.jsonl/59004 | {
"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,
9860,
15628,
1155,
353,
8840,
836,
8,
341,
28164,
1669,
52931,
396,
90,
1294,
396,
90,
15,
11,
220,
15,
2137,
3056,
396,
90,
15,
11,
220,
16,
11248,
30677,
1669,
4050,
90,
4203,
1695,
25,
220,
19,
532,
30677,
25338,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestJoinFederatedRoomWithUnverifiableEvents(t *testing.T) {
deployment := Deploy(t, b.BlueprintAlice)
defer deployment.Destroy(t)
srv := federation.NewServer(t, deployment,
federation.HandleKeyRequests(),
federation.HandleMakeSendJoinRequests(),
federation.HandleTransactionRequests(nil, nil),
)
srv.UnexpectedRequestsAreErrors = false
cancel := srv.Listen()
defer cancel()
ver := gomatrixserverlib.RoomVersionV6
charlie := srv.UserID("charlie")
// We explicitly do not run these in parallel in order to help debugging when these
// tests fail. It doesn't appear to save us much time either!
t.Run("/send_join response missing signatures shouldn't block room join", func(t *testing.T) {
//t.Parallel()
room := srv.MustMakeRoom(t, ver, federation.InitialRoomEvents(ver, charlie))
roomAlias := srv.MakeAliasMapping("MissingSignatures", room.RoomID)
// create a normal event then remove the signatures key
signedEvent := srv.MustCreateEvent(t, room, b.Event{
Sender: charlie,
StateKey: b.Ptr(""),
Type: "m.room.name",
Content: map[string]interface{}{
"name": "This event has no signature",
},
})
raw := signedEvent.JSON()
raw, err := sjson.SetRawBytes(raw, "signatures", []byte(`{}`))
must.NotError(t, "failed to strip signatures key from event", err)
unsignedEvent, err := gomatrixserverlib.NewEventFromTrustedJSON(raw, false, ver)
must.NotError(t, "failed to make Event from unsigned event JSON", err)
room.AddEvent(unsignedEvent)
alice := deployment.Client(t, "hs1", "@alice:hs1")
alice.JoinRoom(t, roomAlias, nil)
})
t.Run("/send_join response with bad signatures shouldn't block room join", func(t *testing.T) {
//t.Parallel()
room := srv.MustMakeRoom(t, ver, federation.InitialRoomEvents(ver, charlie))
roomAlias := srv.MakeAliasMapping("BadSignatures", room.RoomID)
// create a normal event then modify the signatures
signedEvent := srv.MustCreateEvent(t, room, b.Event{
Sender: charlie,
StateKey: b.Ptr(""),
Type: "m.room.name",
Content: map[string]interface{}{
"name": "This event has a bad signature",
},
})
newSignaturesBlock := map[string]interface{}{
docker.HostnameRunningComplement: map[string]string{
string(srv.KeyID): "/3z+pJjiJXWhwfqIEzmNksvBHCoXTktK/y0rRuWJXw6i1+ygRG/suDCKhFuuz6gPapRmEMPVILi2mJqHHXPKAg",
},
}
rawSig, err := json.Marshal(newSignaturesBlock)
must.NotError(t, "failed to marshal bad signature block", err)
raw := signedEvent.JSON()
raw, err = sjson.SetRawBytes(raw, "signatures", rawSig)
must.NotError(t, "failed to modify signatures key from event", err)
unsignedEvent, err := gomatrixserverlib.NewEventFromTrustedJSON(raw, false, ver)
must.NotError(t, "failed to make Event from unsigned event JSON", err)
room.AddEvent(unsignedEvent)
alice := deployment.Client(t, "hs1", "@alice:hs1")
alice.JoinRoom(t, roomAlias, nil)
})
t.Run("/send_join response with unobtainable keys shouldn't block room join", func(t *testing.T) {
//t.Parallel()
room := srv.MustMakeRoom(t, ver, federation.InitialRoomEvents(ver, charlie))
roomAlias := srv.MakeAliasMapping("UnobtainableKeys", room.RoomID)
// create a normal event then modify the signatures to have a bogus key ID which Complement does
// not have the keys for
signedEvent := srv.MustCreateEvent(t, room, b.Event{
Sender: charlie,
StateKey: b.Ptr(""),
Type: "m.room.name",
Content: map[string]interface{}{
"name": "This event has an unobtainable key ID",
},
})
newSignaturesBlock := map[string]interface{}{
docker.HostnameRunningComplement: map[string]string{
string(srv.KeyID) + "bogus": "/3z+pJjiJXWhwfqIEzmNksvBHCoXTktK/y0rRuWJXw6i1+ygRG/suDCKhFuuz6gPapRmEMPVILi2mJqHHXPKAg",
},
}
rawSig, err := json.Marshal(newSignaturesBlock)
must.NotError(t, "failed to marshal bad signature block", err)
raw := signedEvent.JSON()
raw, err = sjson.SetRawBytes(raw, "signatures", rawSig)
must.NotError(t, "failed to modify signatures key from event", err)
unsignedEvent, err := gomatrixserverlib.NewEventFromTrustedJSON(raw, false, ver)
must.NotError(t, "failed to make Event from unsigned event JSON", err)
room.AddEvent(unsignedEvent)
alice := deployment.Client(t, "hs1", "@alice:hs1")
alice.JoinRoom(t, roomAlias, nil)
})
t.Run("/send_join response with state with unverifiable auth events shouldn't block room join", func(t *testing.T) {
runtime.SkipIf(t, runtime.Dendrite) // https://github.com/matrix-org/dendrite/issues/2028
room := srv.MustMakeRoom(t, ver, federation.InitialRoomEvents(ver, charlie))
roomAlias := srv.MakeAliasMapping("UnverifiableAuthEvents", room.RoomID)
// create a normal event then modify the signatures
rawEvent := srv.MustCreateEvent(t, room, b.Event{
Sender: charlie,
StateKey: &charlie,
Type: "m.room.member",
Content: map[string]interface{}{
"membership": "join",
"name": "This event has a bad signature",
},
}).JSON()
rawSig, err := json.Marshal(map[string]interface{}{
docker.HostnameRunningComplement: map[string]string{
string(srv.KeyID): "/3z+pJjiJXWhwfqIEzmNksvBHCoXTktK/y0rRuWJXw6i1+ygRG/suDCKhFuuz6gPapRmEMPVILi2mJqHHXPKAg",
},
})
must.NotError(t, "failed to marshal bad signature block", err)
rawEvent, err = sjson.SetRawBytes(rawEvent, "signatures", rawSig)
must.NotError(t, "failed to modify signatures key from event", err)
badlySignedEvent, err := gomatrixserverlib.NewEventFromTrustedJSON(rawEvent, false, ver)
must.NotError(t, "failed to make Event from badly signed event JSON", err)
room.AddEvent(badlySignedEvent)
t.Logf("Created badly signed auth event %s", badlySignedEvent.EventID())
// and now add another event which will use it as an auth event.
goodEvent := srv.MustCreateEvent(t, room, b.Event{
Sender: charlie,
StateKey: &charlie,
Type: "m.room.member",
Content: map[string]interface{}{
"membership": "leave",
},
})
// double-check that the bad event is in its auth events
containsEvent := false
for _, authEventID := range goodEvent.AuthEventIDs() {
if authEventID == badlySignedEvent.EventID() {
containsEvent = true
break
}
}
if !containsEvent {
t.Fatalf("Bad event didn't appear in auth events of state event")
}
room.AddEvent(goodEvent)
t.Logf("Created state event %s", goodEvent.EventID())
alice := deployment.Client(t, "hs1", "@alice:hs1")
alice.JoinRoom(t, roomAlias, nil)
})
} | explode_data.jsonl/37599 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2478
} | [
2830,
3393,
12292,
37,
7294,
657,
14003,
2354,
1806,
423,
22619,
7900,
1155,
353,
8840,
836,
8,
341,
197,
82213,
1669,
70595,
1155,
11,
293,
60159,
1350,
61686,
340,
16867,
23172,
57011,
1155,
692,
1903,
10553,
1669,
79275,
7121,
5475,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestToValueNilValue(t *testing.T) {
r := New()
var a Value
r.Set("a", a)
ret, err := r.RunString(`
""+a;
`)
if err != nil {
t.Fatal(err)
}
if !asciiString("null").SameAs(ret) {
t.Fatalf("ret: %v", ret)
}
} | explode_data.jsonl/10517 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
1249,
1130,
19064,
1130,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
741,
2405,
264,
5162,
198,
7000,
4202,
445,
64,
497,
264,
340,
11262,
11,
1848,
1669,
435,
16708,
703,
61528,
197,
3014,
10,
64,
280,
197,
24183,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNasTypeRequestedNSSAI(t *testing.T) {
for i, table := range RequestedNSSAITestTable {
t.Logf("Test Cnt:%d", i)
a := nasType.NewRequestedNSSAI(nasMessage.RegistrationRequestRequestedNSSAIType)
a.SetIei(table.in.GetIei())
a.SetLen(table.in.Len)
a.SetSNSSAIValue(table.in.Buffer)
assert.Equalf(t, table.out.Iei, a.Iei, "in(%v): out %v, actual %x", table.in.Iei, table.out.Iei, a.Iei)
assert.Equalf(t, table.out.Len, a.Len, "in(%v): out %v, actual %x", table.in.Len, table.out.Len, a.Len)
assert.Equalf(t, table.out.Buffer, a.Buffer, "in(%v): out %v, actual %x", table.in.Buffer, table.out.Buffer, a.Buffer)
}
} | explode_data.jsonl/38095 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
45,
300,
929,
37630,
53302,
15469,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1965,
1669,
2088,
6145,
291,
53302,
18587,
477,
2556,
341,
197,
3244,
98954,
445,
2271,
356,
406,
7533,
67,
497,
600,
340,
197,
11323,
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... | 2 |
func TestEqual(t *testing.T) {
dp1 := newBasicNodeWithLen(nil)
dp2 := newBasicNodeWithLen(nil)
dp3 := newBasicNodeWithLen([]int{1, 2, 3})
if !Equal(dp1, dp2) {
t.Errorf("Expected dp1 and dp2 to be equal.\n")
}
if Equal(dp1, dp3) {
t.Errorf("Expected dp1 and dp3 to be unequal.\n")
}
} | explode_data.jsonl/9176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
2993,
1155,
353,
8840,
836,
8,
341,
55256,
16,
1669,
501,
15944,
1955,
2354,
11271,
27907,
340,
55256,
17,
1669,
501,
15944,
1955,
2354,
11271,
27907,
340,
55256,
18,
1669,
501,
15944,
1955,
2354,
11271,
10556,
396,
90,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.