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 TestIgnoreBadResetOnSynSent(t *testing.T) {
// Send SYN.
tcp := make(header.TCP, header.TCPMinimumSize)
tcp.Encode(&header.TCPFields{
SeqNum: 1234,
AckNum: 0,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagSyn,
WindowSize: 30000,
})
tcb := tcpconntrack.TCB{}
tcb.Init(tcp)
// Receive a RST with a bad ACK, it should not cause the connection to
// be reset.
acks := []uint32{1234, 1236, 1000, 5000}
flags := []uint8{header.TCPFlagRst, header.TCPFlagRst | header.TCPFlagAck}
for _, a := range acks {
for _, f := range flags {
tcp.Encode(&header.TCPFields{
SeqNum: 789,
AckNum: a,
DataOffset: header.TCPMinimumSize,
Flags: f,
WindowSize: 50000,
})
if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultConnecting {
t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive)
}
}
}
// Complete the handshake.
// Receive SYN-ACK.
tcp.Encode(&header.TCPFields{
SeqNum: 789,
AckNum: 1235,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagSyn | header.TCPFlagAck,
WindowSize: 50000,
})
if r := tcb.UpdateStateInbound(tcp); r != tcpconntrack.ResultAlive {
t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive)
}
// Send ACK.
tcp.Encode(&header.TCPFields{
SeqNum: 1235,
AckNum: 790,
DataOffset: header.TCPMinimumSize,
Flags: header.TCPFlagAck,
WindowSize: 30000,
})
if r := tcb.UpdateStateOutbound(tcp); r != tcpconntrack.ResultAlive {
t.Fatalf("Bad result: got %v, want %v", r, tcpconntrack.ResultAlive)
}
} | explode_data.jsonl/17728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 747
} | [
2830,
3393,
12497,
17082,
14828,
1925,
37134,
31358,
1155,
353,
8840,
836,
8,
341,
197,
322,
11000,
61694,
624,
3244,
4672,
1669,
1281,
25534,
836,
7123,
11,
4247,
836,
7123,
28695,
1695,
340,
3244,
4672,
50217,
2099,
2708,
836,
7123,
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... | 6 |
func TestV(t *testing.T) {
setFlags()
defer logging.swap(logging.newBuffers())
logging.verbosity.Set("2")
defer logging.verbosity.Set("0")
V(2).Info("test")
if !contains(infoLog, "I", t) {
t.Errorf("Info has wrong character: %q", contents(infoLog))
}
if !contains(infoLog, "test", t) {
t.Error("Info failed")
}
} | explode_data.jsonl/8431 | {
"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,
53,
1155,
353,
8840,
836,
8,
341,
8196,
9195,
741,
16867,
8392,
54537,
51687,
4618,
36219,
2398,
90085,
13,
65210,
4202,
445,
17,
1138,
16867,
8392,
13,
65210,
4202,
445,
15,
1138,
17446,
7,
17,
568,
1731,
445,
1944,
1138,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAbsCollection_Every(t *testing.T) {
intColl := NewIntCollection([]int{1, 2, 3, 4})
if intColl.Every(func(item interface{}, key int) bool {
i := item.(int)
return i > 1
}) != false {
t.Fatal("Every错误")
}
if intColl.Every(func(item interface{}, key int) bool {
i := item.(int)
return i > 0
}) != true {
t.Fatal("Every错误")
}
} | explode_data.jsonl/66441 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
27778,
6482,
2089,
1204,
1155,
353,
8840,
836,
8,
341,
2084,
15265,
1669,
1532,
1072,
6482,
10556,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
3518,
743,
526,
15265,
5142,
1204,
18552,
5393,
3749,
22655,
1376,
52... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateHints(t *testing.T) {
t.Parallel()
alphabet := []rune("abc")
tests := []struct {
desc string
text string
matches []Range
want []hint
}{
{
desc: "no matches",
text: "foo",
want: []hint{},
},
{
desc: "single match",
text: "foo bar",
matches: []Range{
{1, 3}, // f(oo)
},
want: []hint{
{
Label: "a",
Text: "oo",
Matches: []Range{
{1, 3}, // f(oo)
},
},
},
},
{
desc: "duplicated match",
text: "foo bar baz qux",
matches: []Range{
{4, 6}, // (ba)r
{8, 10}, // (ba)z
},
want: []hint{
{
Label: "a",
Text: "ba",
Matches: []Range{
{4, 6}, // (ba)r
{8, 10}, // (ba)z
},
},
},
},
{
desc: "multiple matches",
text: "foo bar baz qux",
matches: []Range{
{0, 3}, // (foo)
{4, 6}, // (ba)r
{8, 10}, // (ba)z
{13, 15}, // q(ux)
},
want: []hint{
{
Label: "c",
Text: "ba",
Matches: []Range{
{4, 6}, // (ba)r
{8, 10}, // (ba)z
},
},
{
Label: "a",
Text: "foo",
Matches: []Range{
{0, 3}, // (foo)
},
},
{
Label: "b",
Text: "ux",
Matches: []Range{
{13, 15}, // q(ux)
},
},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.desc, func(t *testing.T) {
t.Parallel()
got := generateHints(alphabet, tt.text, tt.matches)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/70476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 898
} | [
2830,
3393,
31115,
74933,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
69571,
18485,
1669,
3056,
81,
2886,
445,
13683,
5130,
78216,
1669,
3056,
1235,
341,
197,
41653,
262,
914,
198,
197,
15425,
262,
914,
198,
197,
2109,
9118,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDelegateCoins(t *testing.T) {
input := setupTestInput()
now := tmtime.Now()
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
endTime := now.Add(24 * time.Hour)
origCoins := sdk.NewCoins(sdk.NewInt64Coin("hsn", 100))
delCoins := sdk.NewCoins(sdk.NewInt64Coin("hsn", 50))
addr1 := sdk.AccAddress([]byte("addr1"))
addr2 := sdk.AccAddress([]byte("addr2"))
addrModule := sdk.AccAddress([]byte("moduleAcc"))
bacc := auth.NewBaseAccountWithAddress(addr1)
bacc.SetCoins(origCoins)
macc := input.ak.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing
vacc := auth.NewContinuousVestingAccount(&bacc, ctx.BlockHeader().Time.Unix(), endTime.Unix())
acc := input.ak.NewAccountWithAddress(ctx, addr2)
input.ak.SetAccount(ctx, vacc)
input.ak.SetAccount(ctx, acc)
input.ak.SetAccount(ctx, macc)
input.k.SetCoins(ctx, addr2, origCoins)
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
// require the ability for a non-vesting account to delegate
err := input.k.DelegateCoins(ctx, addr2, addrModule, delCoins)
acc = input.ak.GetAccount(ctx, addr2)
macc = input.ak.GetAccount(ctx, addrModule)
require.NoError(t, err)
require.Equal(t, origCoins.Sub(delCoins), acc.GetCoins())
require.Equal(t, delCoins, macc.GetCoins())
// require the ability for a vesting account to delegate
err = input.k.DelegateCoins(ctx, addr1, addrModule, delCoins)
vacc = input.ak.GetAccount(ctx, addr1).(*auth.ContinuousVestingAccount)
require.NoError(t, err)
require.Equal(t, delCoins, vacc.GetCoins())
} | explode_data.jsonl/3534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 591
} | [
2830,
3393,
9381,
69602,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
6505,
2271,
2505,
741,
80922,
1669,
17333,
1678,
13244,
741,
20985,
1669,
1946,
30608,
26124,
4713,
4047,
56085,
5855,
15753,
90,
1462,
25,
1431,
3518,
6246,
1462,
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 TestConnServers(t *testing.T) {
opts := GetDefaultOptions()
c := &Conn{Opts: opts}
c.ps = &parseState{}
c.setupServerPool()
validateURLs := func(serverUrls []string, expectedUrls ...string) {
var found bool
if len(serverUrls) != len(expectedUrls) {
stackFatalf(t, "Array should have %d elements, has %d", len(expectedUrls), len(serverUrls))
}
for _, ev := range expectedUrls {
found = false
for _, av := range serverUrls {
if ev == av {
found = true
break
}
}
if !found {
stackFatalf(t, "array is missing %q in %v", ev, serverUrls)
}
}
}
// check the default url
validateURLs(c.Servers(), "nats://localhost:4222")
if len(c.DiscoveredServers()) != 0 {
t.Fatalf("Expected no discovered servers")
}
// Add a new URL
err := c.parse([]byte("INFO {\"connect_urls\":[\"localhost:5222\"]}\r\n"))
if err != nil {
t.Fatalf("Unexpected: %d : %v\n", c.ps.state, err)
}
// Server list should now contain both the default and the new url.
validateURLs(c.Servers(), "nats://localhost:4222", "nats://localhost:5222")
// Discovered servers should only contain the new url.
validateURLs(c.DiscoveredServers(), "nats://localhost:5222")
// verify user credentials are stripped out.
opts.Servers = []string{"nats://user:pass@localhost:4333", "nats://token@localhost:4444"}
c = &Conn{Opts: opts}
c.ps = &parseState{}
c.setupServerPool()
validateURLs(c.Servers(), "nats://localhost:4333", "nats://localhost:4444")
} | explode_data.jsonl/44919 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 582
} | [
2830,
3393,
9701,
78139,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
2126,
3675,
3798,
741,
1444,
1669,
609,
9701,
90,
43451,
25,
12185,
532,
1444,
57328,
284,
609,
6400,
1397,
16094,
1444,
25338,
5475,
10551,
2822,
197,
7067,
3144,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestAttributeValue(t *testing.T) {
v := NewAttributeValueString("abc")
assert.EqualValues(t, AttributeValueSTRING, v.Type())
assert.EqualValues(t, "abc", v.StringVal())
v = NewAttributeValueInt(123)
assert.EqualValues(t, AttributeValueINT, v.Type())
assert.EqualValues(t, 123, v.IntVal())
v = NewAttributeValueDouble(3.4)
assert.EqualValues(t, AttributeValueDOUBLE, v.Type())
assert.EqualValues(t, 3.4, v.DoubleVal())
v = NewAttributeValueBool(true)
assert.EqualValues(t, AttributeValueBOOL, v.Type())
assert.EqualValues(t, true, v.BoolVal())
v = NewAttributeValueNull()
assert.EqualValues(t, AttributeValueNULL, v.Type())
v.SetStringVal("abc")
assert.EqualValues(t, AttributeValueSTRING, v.Type())
assert.EqualValues(t, "abc", v.StringVal())
v.SetIntVal(123)
assert.EqualValues(t, AttributeValueINT, v.Type())
assert.EqualValues(t, 123, v.IntVal())
v.SetDoubleVal(3.4)
assert.EqualValues(t, AttributeValueDOUBLE, v.Type())
assert.EqualValues(t, 3.4, v.DoubleVal())
v.SetBoolVal(true)
assert.EqualValues(t, AttributeValueBOOL, v.Type())
assert.EqualValues(t, true, v.BoolVal())
} | explode_data.jsonl/38191 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
78554,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
1532,
78554,
703,
445,
13683,
1138,
6948,
12808,
6227,
1155,
11,
16752,
1130,
16468,
11,
348,
10184,
2398,
6948,
12808,
6227,
1155,
11,
330,
13683,
497,
348,
6431,
2208,
12367... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPerformRequestWithLoggerAndTracer(t *testing.T) {
var lw bytes.Buffer
lout := log.New(&lw, "LOGGER ", log.LstdFlags)
var tw bytes.Buffer
tout := log.New(&tw, "TRACER ", log.LstdFlags)
client, err := NewClient(SetInfoLog(lout), SetTraceLog(tout), SetSniff(false))
if err != nil {
t.Fatal(err)
}
res, err := client.PerformRequest(context.TODO(), "GET", "/", nil, nil)
if err != nil {
t.Fatal(err)
}
if res == nil {
t.Fatal("expected response to be != nil")
}
ret := new(PingResult)
if err := json.Unmarshal(res.Body, ret); err != nil {
t.Fatalf("expected no error on decode; got: %v", err)
}
if ret.ClusterName == "" {
t.Errorf("expected cluster name; got: %q", ret.ClusterName)
}
lgot := lw.String()
if lgot == "" {
t.Errorf("expected logger output; got: %q", lgot)
}
tgot := tw.String()
if tgot == "" {
t.Errorf("expected tracer output; got: %q", tgot)
}
} | explode_data.jsonl/38020 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
46951,
1900,
2354,
7395,
3036,
1282,
9584,
1155,
353,
8840,
836,
8,
341,
2405,
41073,
5820,
22622,
198,
8810,
411,
1669,
1487,
7121,
2099,
57053,
11,
330,
82400,
3670,
1487,
1214,
1834,
9195,
692,
2405,
4384,
5820,
22622,
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... | 8 |
func TestPerm_MustPlatformAdmin(t *testing.T) {
// setup types
secret := "superSecret"
u := new(library.User)
u.SetID(1)
u.SetName("foo")
u.SetToken("bar")
u.SetHash("baz")
u.SetAdmin(true)
tok, _ := token.CreateAccessToken(u, accessTokenDuration)
// setup database
db, _ := database.NewTest()
defer func() {
db.Database.Exec("delete from users;")
db.Database.Close()
}()
_ = db.CreateUser(u)
// setup context
gin.SetMode(gin.TestMode)
resp := httptest.NewRecorder()
context, engine := gin.CreateTestContext(resp)
context.Request, _ = http.NewRequest(http.MethodGet, "/admin/users", nil)
context.Request.Header.Add("Authorization", fmt.Sprintf("Bearer %s", tok))
// setup github mock server
engine.GET("/api/v3/user", func(c *gin.Context) {
c.String(http.StatusOK, userPayload)
})
s := httptest.NewServer(engine)
defer s.Close()
// setup client
client, _ := github.NewTest(s.URL)
// setup vela mock server
engine.Use(func(c *gin.Context) { c.Set("secret", secret) })
engine.Use(func(c *gin.Context) { database.ToContext(c, db) })
engine.Use(func(c *gin.Context) { source.ToContext(c, client) })
engine.Use(user.Establish())
engine.Use(MustPlatformAdmin())
engine.GET("/admin/users", func(c *gin.Context) {
c.Status(http.StatusOK)
})
s1 := httptest.NewServer(engine)
defer s1.Close()
// run test
engine.ServeHTTP(context.Writer, context.Request)
if resp.Code != http.StatusOK {
t.Errorf("MustPlatAdmin returned %v, want %v", resp.Code, http.StatusOK)
}
} | explode_data.jsonl/8185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 577
} | [
2830,
3393,
81245,
1245,
590,
17296,
7210,
1155,
353,
8840,
836,
8,
341,
197,
322,
6505,
4494,
198,
197,
20474,
1669,
330,
9522,
19773,
1837,
10676,
1669,
501,
93299,
7344,
340,
10676,
4202,
915,
7,
16,
340,
10676,
4202,
675,
445,
797... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestError(t *testing.T) {
t.Parallel()
tests := []struct {
in database.Error
want string
}{
{
database.Error{Description: "some error"},
"some error",
},
{
database.Error{Description: "human-readable error"},
"human-readable error",
},
{
database.Error{
ErrorCode: database.ErrDriverSpecific,
Description: "some error",
Err: errors.New("driver-specific error"),
},
"some error: driver-specific error",
},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
result := test.in.Error()
if result != test.want {
t.Errorf("Error #%d\n got: %s want: %s", i, result,
test.want)
continue
}
}
} | explode_data.jsonl/7153 | {
"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,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
4625,
6141,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
2698,
2211,
6141,
90,
5009,
25,
330,
14689,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListRepoTeams(t *testing.T) {
expectedTeams := []Team{
{ID: 1, Slug: "foo", Permission: RepoPull},
{ID: 2, Slug: "bar", Permission: RepoPush},
{ID: 3, Slug: "foobar", Permission: RepoAdmin},
}
ts := simpleTestServer(t, "/repos/org/repo/teams", expectedTeams)
defer ts.Close()
c := getClient(ts.URL)
teams, err := c.ListRepoTeams("org", "repo")
if err != nil {
t.Errorf("Didn't expect error: %v", err)
} else if len(teams) != 3 {
t.Errorf("Expected three teams, found %d: %v", len(teams), teams)
return
}
if !reflect.DeepEqual(teams, expectedTeams) {
t.Errorf("Wrong list of teams, expected: %v, got: %v", expectedTeams, teams)
}
} | explode_data.jsonl/6290 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
852,
25243,
60669,
1155,
353,
8840,
836,
8,
341,
42400,
60669,
1669,
3056,
14597,
515,
197,
197,
90,
915,
25,
220,
16,
11,
93613,
25,
330,
7975,
497,
18135,
25,
71509,
36068,
1583,
197,
197,
90,
915,
25,
220,
17,
11,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientStoreConfig(t *testing.T) {
var err error
config := &StoreConfig{}
config.DriverName = DriverNameClientStore
config.ClientStoreKey = "test"
config.TokenLifetime = "1h"
config.TokenMaxLifetime = "168h"
config.TokenContextName = "token"
config.CookieName = "cookiename"
config.CookiePath = "/"
config.CookieSecure = true
config.UpdateActiveIntervalInSecond = 100
store := New()
err = config.ApplyTo(store)
if err != nil {
panic(err)
}
if store.TokenLifetime != 1*time.Hour {
t.Fatal(store.TokenLifetime)
}
if store.TokenMaxLifetime != 7*24*time.Hour {
t.Fatal(store.TokenMaxLifetime)
}
if store.CookieName != "cookiename" {
t.Fatal(store.CookieName)
}
if store.CookiePath != "/" {
t.Fatal(store.CookiePath)
}
if store.CookieSecure != true {
t.Fatal(store.CookieSecure)
}
if store.UpdateActiveInterval != 100*time.Second {
t.Fatal(store.UpdateActiveInterval)
}
} | explode_data.jsonl/17577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 362
} | [
2830,
3393,
2959,
6093,
2648,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
25873,
1669,
609,
6093,
2648,
16094,
25873,
41768,
675,
284,
14577,
675,
2959,
6093,
198,
25873,
11716,
6093,
1592,
284,
330,
1944,
698,
25873,
32277,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestStringBuilder_Empty(t *testing.T) {
mem := memory.NewCheckedAllocator(memory.NewGoAllocator())
defer mem.AssertSize(t, 0)
want := []string{"hello", "世界", "", "bye"}
ab := array.NewStringBuilder(mem)
defer ab.Release()
stringValues := func(a *array.String) []string {
vs := make([]string, a.Len())
for i := range vs {
vs[i] = a.Value(i)
}
return vs
}
ab.AppendValues([]string{}, nil)
a := ab.NewStringArray()
assert.Zero(t, a.Len())
a.Release()
ab.AppendValues(nil, nil)
a = ab.NewStringArray()
assert.Zero(t, a.Len())
a.Release()
ab.AppendValues([]string{}, nil)
ab.AppendValues(want, nil)
a = ab.NewStringArray()
assert.Equal(t, want, stringValues(a))
a.Release()
ab.AppendValues(want, nil)
ab.AppendValues([]string{}, nil)
a = ab.NewStringArray()
assert.Equal(t, want, stringValues(a))
a.Release()
} | explode_data.jsonl/4257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 355
} | [
2830,
3393,
69412,
76060,
1595,
1155,
353,
8840,
836,
8,
341,
14145,
1669,
4938,
7121,
12666,
42730,
63230,
7121,
10850,
42730,
2398,
16867,
1833,
11711,
1695,
1155,
11,
220,
15,
692,
50780,
1669,
3056,
917,
4913,
14990,
497,
330,
99489,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunner(t *testing.T) {
t.Run("example input", func(t *testing.T) {
data, err := file.ReadFullData("../example.txt")
if err != nil {
t.Fatal(err)
}
want := 739785
got := Runner(data)
if got != want {
t.Errorf("got %v want %v", got, want)
}
})
t.Run("full input", func(t *testing.T) {
data, err := file.ReadFullData("../input.txt")
if err != nil {
t.Fatal(err)
}
got := Runner(data)
fmt.Println(got, "is the answer")
})
} | explode_data.jsonl/17925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
19486,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
8687,
1946,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
8924,
11,
1848,
1669,
1034,
6503,
9432,
1043,
17409,
8687,
3909,
1138,
197,
743,
1848,
961,
2092,
341,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBatchError(t *testing.T) {
testCases := []struct {
req [2]string
errMsg string
}{
{
req: [2]string{"\xff\xff\xff\xff", "a"},
errMsg: "must be less than KeyMax",
},
{
req: [2]string{"a", "\xff\xff\xff\xff"},
errMsg: "must be less than or equal to KeyMax",
},
}
for i, c := range testCases {
var ba roachpb.BatchRequest
ba.Add(&roachpb.ScanRequest{RequestHeader: roachpb.RequestHeader{
Key: roachpb.Key(c.req[0]), EndKey: roachpb.Key(c.req[1]),
}})
if _, err := Range(ba.Requests); !testutils.IsError(err, c.errMsg) {
t.Errorf("%d: unexpected error %v", i, err)
}
}
// Test a case where a non-range request has an end key.
var ba roachpb.BatchRequest
ba.Add(&roachpb.GetRequest{RequestHeader: roachpb.RequestHeader{
Key: roachpb.Key("a"), EndKey: roachpb.Key("b"),
}})
if _, err := Range(ba.Requests); !testutils.IsError(err, "end key specified for non-range operation") {
t.Errorf("unexpected error %v", err)
}
} | explode_data.jsonl/56598 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
21074,
1454,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
24395,
262,
508,
17,
30953,
198,
197,
9859,
6611,
914,
198,
197,
59403,
197,
197,
515,
298,
24395,
25,
262,
508,
17,
30953,
4913,
59,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFKVSWithCustomKeySerializer(t *testing.T) {
keySerializer := func(key interface{}) (string, error) {
keyString, ok := key.(string)
if !ok {
return "", errors.New("converting key to string failed")
}
return filepath.Join(storePath, fmt.Sprintf("mypath/%s/valuefile", keyString)), nil
}
testFKVS(t, keySerializer)
} | explode_data.jsonl/12215 | {
"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,
26998,
26050,
2354,
10268,
1592,
13909,
1155,
353,
8840,
836,
8,
341,
23634,
13909,
1669,
2915,
4857,
3749,
28875,
320,
917,
11,
1465,
8,
341,
197,
23634,
703,
11,
5394,
1669,
1376,
12832,
917,
340,
197,
743,
753,
562,
341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDecimalMul(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("USE test")
tk.MustExec("create table t(a decimal(38, 17));")
tk.MustExec("insert into t select 0.5999991229316*0.918755041726043;")
res := tk.MustQuery("select * from t;")
res.Check(testkit.Rows("0.55125221922461136"))
} | explode_data.jsonl/65468 | {
"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,
11269,
59155,
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,
3244,
74,
50463,
10216,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAdoption(t *testing.T) {
var trueVar = true
testCases := []struct {
name string
existingOwnerReferences func(rs *v1beta1.ReplicaSet) []v1.OwnerReference
expectedOwnerReferences func(rs *v1beta1.ReplicaSet) []v1.OwnerReference
}{
{
"pod refers rs as an owner, not a controller",
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet"}}
},
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet", Controller: &trueVar}}
},
},
{
"pod doesn't have owner references",
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{}
},
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet", Controller: &trueVar}}
},
},
{
"pod refers rs as a controller",
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet", Controller: &trueVar}}
},
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet", Controller: &trueVar}}
},
},
{
"pod refers other rs as the controller, refers the rs as an owner",
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{
{UID: "1", Name: "anotherRS", APIVersion: "extensions/v1beta1", Kind: "ReplicaSet", Controller: &trueVar},
{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet"},
}
},
func(rs *v1beta1.ReplicaSet) []v1.OwnerReference {
return []v1.OwnerReference{
{UID: "1", Name: "anotherRS", APIVersion: "extensions/v1beta1", Kind: "ReplicaSet", Controller: &trueVar},
{UID: rs.UID, Name: rs.Name, APIVersion: "extensions/v1beta1", Kind: "ReplicaSet"},
}
},
},
}
for i, tc := range testCases {
s, rm, rsInformer, podInformer, clientSet := rmSetup(t, true)
ns := framework.CreateTestingNamespace(fmt.Sprintf("rs-adoption-%d", i), s, t)
defer framework.DeleteTestingNamespace(ns, s, t)
rsClient := clientSet.Extensions().ReplicaSets(ns.Name)
podClient := clientSet.Core().Pods(ns.Name)
const rsName = "rs"
rs, err := rsClient.Create(newRS(rsName, ns.Name, 1))
if err != nil {
t.Fatalf("Failed to create replica set: %v", err)
}
podName := fmt.Sprintf("pod%d", i)
pod := newMatchingPod(podName, ns.Name)
pod.OwnerReferences = tc.existingOwnerReferences(rs)
_, err = podClient.Create(pod)
if err != nil {
t.Fatalf("Failed to create Pod: %v", err)
}
stopCh := make(chan struct{})
go rsInformer.Run(stopCh)
go podInformer.Run(stopCh)
waitToObservePods(t, podInformer, 1)
go rm.Run(5, stopCh)
if err := wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) {
updatedPod, err := podClient.Get(pod.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
if e, a := tc.expectedOwnerReferences(rs), updatedPod.OwnerReferences; reflect.DeepEqual(e, a) {
return true, nil
} else {
t.Logf("ownerReferences don't match, expect %v, got %v", e, a)
return false, nil
}
}); err != nil {
t.Fatal(err)
}
close(stopCh)
}
} | explode_data.jsonl/73258 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1465
} | [
2830,
3393,
2589,
2047,
1155,
353,
8840,
836,
8,
341,
2405,
830,
3962,
284,
830,
198,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
503,
914,
198,
197,
8122,
11083,
13801,
31712,
2915,
17027,
353,
85,
16,
19127,
16,
2817,
79,
15317... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoGoPrefixArgOrRule(t *testing.T) {
dir, err := createFiles([]fileSpec{
{path: "WORKSPACE", content: ""},
})
if err != nil {
t.Fatal(err)
}
want := "-go_prefix not set"
if err := runGazelle(dir, nil); err == nil {
t.Fatalf("got success; want %q", want)
} else if !strings.Contains(err.Error(), want) {
t.Fatalf("got %q; want %q", err, want)
}
} | explode_data.jsonl/40383 | {
"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,
2753,
10850,
14335,
2735,
2195,
11337,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
1855,
10809,
10556,
1192,
8327,
515,
197,
197,
90,
2343,
25,
330,
18470,
44641,
497,
2213,
25,
77496,
197,
3518,
743,
1848,
961,
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... | 4 |
func TestMetricsServiceV2GetLogMetricError(t *testing.T) {
errCode := codes.Internal
mockMetrics.err = grpc.Errorf(errCode, "test error")
var formattedMetricName string = MetricsMetricPath("[PROJECT]", "[METRIC]")
var request = &loggingpb.GetLogMetricRequest{
MetricName: formattedMetricName,
}
c, err := NewMetricsClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.GetLogMetric(context.Background(), request)
if c := grpc.Code(err); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
_ = resp
} | explode_data.jsonl/77780 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
27328,
1860,
53,
17,
1949,
2201,
54310,
1454,
1155,
353,
8840,
836,
8,
341,
9859,
2078,
1669,
13912,
32579,
198,
77333,
27328,
18441,
284,
47900,
13080,
3964,
2078,
11,
330,
1944,
1465,
5130,
2405,
23126,
54310,
675,
914,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCyclomatic(t *testing.T) {
testRule(t, "cyclomatic", &rule.CyclomaticRule{}, &lint.RuleConfig{
Arguments: []interface{}{int64(1)},
})
testRule(t, "cyclomatic-2", &rule.CyclomaticRule{}, &lint.RuleConfig{
Arguments: []interface{}{int64(3)},
})
} | explode_data.jsonl/32421 | {
"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,
34,
6179,
13487,
1155,
353,
8840,
836,
8,
341,
18185,
11337,
1155,
11,
330,
97484,
13487,
497,
609,
12937,
727,
6179,
13487,
11337,
22655,
609,
14957,
63961,
2648,
515,
197,
197,
19139,
25,
3056,
4970,
6257,
90,
396,
21,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListenerFilter_Verify(t *testing.T) {
tests := []struct {
desc string
inFilter *ListenerFilter
inListener *listener.Listener
expect bool
}{
{
desc: "filter-fields-empty",
inFilter: &ListenerFilter{
Address: "",
Port: 0,
Type: "",
},
inListener: &listener.Listener{},
expect: true,
},
{
desc: "addrs-dont-match",
inFilter: &ListenerFilter{
Address: "0.0.0.0",
},
inListener: &listener.Listener{
Address: &v3.Address{
Address: &v3.Address_SocketAddress{
SocketAddress: &v3.SocketAddress{Address: "1.1.1.1"},
},
},
},
expect: false,
},
{
desc: "ports-dont-match",
inFilter: &ListenerFilter{
Port: 10,
},
inListener: &listener.Listener{
Address: &v3.Address{
Address: &v3.Address_SocketAddress{
SocketAddress: &v3.SocketAddress{
PortSpecifier: &v3.SocketAddress_PortValue{
PortValue: 11,
},
},
},
},
},
expect: false,
},
{
desc: "http-type-match",
inFilter: &ListenerFilter{
Type: "HTTP",
},
inListener: &listener.Listener{
FilterChains: []*listener.FilterChain{
{
Filters: []*listener.Filter{
{
Name: wellknown.HTTPConnectionManager,
},
},
},
},
},
expect: true,
},
{
desc: "http-tcp-type-match",
inFilter: &ListenerFilter{
Type: "HTTP+TCP",
},
inListener: &listener.Listener{
FilterChains: []*listener.FilterChain{{
Filters: []*listener.Filter{
{
Name: wellknown.TCPProxy,
},
{
Name: wellknown.TCPProxy,
},
{
Name: wellknown.HTTPConnectionManager,
},
},
}},
},
expect: true,
},
{
desc: "tcp-type-match",
inFilter: &ListenerFilter{
Type: "TCP",
},
inListener: &listener.Listener{
FilterChains: []*listener.FilterChain{{
Filters: []*listener.Filter{{
Name: wellknown.TCPProxy,
}},
}},
},
expect: true,
},
{
desc: "unknown-type",
inFilter: &ListenerFilter{
Type: "UNKNOWN",
},
inListener: &listener.Listener{
FilterChains: []*listener.FilterChain{{
Filters: []*listener.Filter{},
}},
},
expect: true,
},
{
desc: "listener-pipe",
inFilter: &ListenerFilter{
Address: "",
Port: 0,
Type: "",
},
inListener: &listener.Listener{
Address: &v3.Address{
Address: &v3.Address_Pipe{
Pipe: &v3.Pipe{Path: "unix:///dev/shm/uds.socket"},
},
},
},
expect: true,
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
if got := tt.inFilter.Verify(tt.inListener); got != tt.expect {
t.Errorf("%s: expect %v got %v", tt.desc, tt.expect, got)
}
})
}
} | explode_data.jsonl/60718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1437
} | [
2830,
3393,
2743,
5632,
2334,
261,
1437,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
981,
914,
198,
197,
17430,
5632,
256,
353,
2743,
5632,
198,
197,
17430,
2743,
353,
35039,
64091,
198,
197,
24952,
257,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConnect(t *testing.T) {
t.Parallel()
connString := os.Getenv("PGX_TEST_DATABASE")
config := mustParseConfig(t, connString)
conn, err := pgx.ConnectConfig(context.Background(), config)
if err != nil {
t.Fatalf("Unable to establish connection: %v", err)
}
assertConfigsEqual(t, config, conn.Config(), "Conn.Config() returns original config")
var currentDB string
err = conn.QueryRow(context.Background(), "select current_database()").Scan(¤tDB)
if err != nil {
t.Fatalf("QueryRow Scan unexpectedly failed: %v", err)
}
if currentDB != config.Config.Database {
t.Errorf("Did not connect to specified database (%v)", config.Config.Database)
}
var user string
err = conn.QueryRow(context.Background(), "select current_user").Scan(&user)
if err != nil {
t.Fatalf("QueryRow Scan unexpectedly failed: %v", err)
}
if user != config.Config.User {
t.Errorf("Did not connect as specified user (%v)", config.Config.User)
}
err = conn.Close(context.Background())
if err != nil {
t.Fatal("Unable to close connection")
}
} | explode_data.jsonl/39996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 355
} | [
2830,
3393,
14611,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
32917,
703,
1669,
2643,
64883,
445,
11383,
55,
11641,
45510,
1138,
25873,
1669,
1969,
14463,
2648,
1155,
11,
4534,
703,
692,
32917,
11,
1848,
1669,
17495,
87,
438... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSourceStatus_GetErrors(t *testing.T) {
t.Run("None", func(t *testing.T) {
x := SourceStatus{}
assert.Equal(t, uint64(0), x.GetErrors())
})
t.Run("NotRecent", func(t *testing.T) {
x := SourceStatus{
LastError: &Error{Time: metav1.Time{}},
Metrics: map[string]Metrics{"": {Errors: 1}},
}
assert.Equal(t, uint64(1), x.GetErrors())
assert.False(t, x.RecentErrors())
})
t.Run("Recent", func(t *testing.T) {
x := SourceStatus{
LastError: &Error{Time: metav1.Now()},
Metrics: map[string]Metrics{"": {Errors: 1}},
}
assert.Equal(t, uint64(1), x.GetErrors())
assert.True(t, x.RecentErrors())
})
} | explode_data.jsonl/49606 | {
"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,
3608,
2522,
13614,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4064,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
10225,
1669,
8748,
2522,
16094,
197,
6948,
12808,
1155,
11,
2622,
21,
19,
7,
15,
701,
856,
223... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetSetIP6(t *testing.T) {
ip := IP6{0x20, 0x01, 0x48, 0x60, 0, 0, 0x20, 0x01, 0, 0, 0, 0, 0, 0, 0x00, 0x68}
var r Record
r.Set(ip)
var ip2 IP6
require.NoError(t, r.Load(&ip2))
assert.Equal(t, ip, ip2)
} | explode_data.jsonl/39486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
1949,
1649,
3298,
21,
1155,
353,
8840,
836,
8,
341,
46531,
1669,
6790,
21,
90,
15,
87,
17,
15,
11,
220,
15,
87,
15,
16,
11,
220,
15,
87,
19,
23,
11,
220,
15,
87,
21,
15,
11,
220,
15,
11,
220,
15,
11,
220,
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 TestMutateTime(t *testing.T) {
source := sourceImage(t)
want := time.Time{}
result, err := mutate.Time(source, want)
if err != nil {
t.Fatalf("failed to mutate a config: %v", err)
}
if configDigestsAreEqual(t, source, result) {
t.Fatal("mutating the created time MUST mutate the config digest")
}
got := getConfigFile(t, result).Created.Time
if got != want {
t.Fatalf("mutating the created time MUST mutate the time from %v to %v", got, want)
}
} | explode_data.jsonl/3096 | {
"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,
51440,
349,
1462,
1155,
353,
8840,
836,
8,
341,
47418,
1669,
2530,
1906,
1155,
340,
50780,
1669,
882,
16299,
16094,
9559,
11,
1848,
1669,
67182,
16299,
12437,
11,
1366,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestPairEscrowAddress(t *testing.T) {
for _, tc := range []struct {
pairId uint64
expected string
}{
{1, "cosmos17u9nx0h9cmhypp6cg9lf4q8ku9l3k8mz232su7m28m39lkz25dgqzkypxs"},
{2, "cosmos1dsm56ejte5wsvptgtlq8qy3qvw6vpgz8w3z77f7cyjkmayzq3fxsdtsn2d"},
} {
t.Run("", func(t *testing.T) {
require.Equal(t, tc.expected, types.PairEscrowAddress(tc.pairId).String())
})
}
} | explode_data.jsonl/7246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
12443,
36121,
651,
4286,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
3223,
1310,
764,
256,
2622,
21,
19,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
90,
16,
11,
330,
9407,
8631... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSqrt2HighPrecision(t *testing.T) {
prec := uint(100/math.Log10(2)) + 1 // 100 decimal digits
x := new(big.Float).SetPrec(prec).SetInt64(2)
out := new(big.Float).SetPrec(prec)
pslq := New(prec)
pslq.Sqrt(x, out)
result := fmt.Sprintf("%.100f", out)
expected := "1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727"
if result != expected {
t.Errorf("100 digits of Sqrt(2) wrong\nExpected %q\nActual %q", expected, result)
}
} | explode_data.jsonl/66839 | {
"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,
50,
8140,
17,
11976,
55501,
1155,
353,
8840,
836,
8,
341,
197,
10645,
1669,
2622,
7,
16,
15,
15,
59705,
5247,
16,
15,
7,
17,
593,
488,
220,
16,
442,
220,
16,
15,
15,
12122,
18509,
198,
10225,
1669,
501,
75616,
29794,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnsupportedMethod(t *testing.T) {
router := MakeRouter()
router.GET("/zello/yes", printHello)
router.GET("/hello", printHello)
router.GET("/activity/:user", writeData)
RunRequest(router, "HEAD", "/activity/", 405, "Method Not Allowed", t)
} | explode_data.jsonl/15101 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
41884,
3523,
1155,
353,
8840,
836,
8,
1476,
67009,
1669,
7405,
9523,
741,
67009,
17410,
4283,
89,
4791,
14,
9693,
497,
1173,
9707,
340,
67009,
17410,
4283,
14990,
497,
1173,
9707,
340,
67009,
17410,
4283,
7175,
11315,
872,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRemovePathIfPresent(t *testing.T) {
for _, tt := range []struct {
input string
expected string
}{
{input: "http://foo.com", expected: "http://foo.com"},
{input: "http://foo.com/", expected: "http://foo.com"},
{input: "http://foo.com/api/v1", expected: "http://foo.com"},
{input: "http://foo.com?foo", expected: "http://foo.com"},
{input: "http://foo.com/api/v1/?foo", expected: "http://foo.com"},
{input: "http://foo.com/api/v1?foo", expected: "http://foo.com"},
{input: "http://foo.com:8080", expected: "http://foo.com:8080"},
{input: "http://foo.com:8080/", expected: "http://foo.com:8080"},
{input: "http://foo.com:8080/api/v1", expected: "http://foo.com:8080"},
} {
u, err := url.Parse(tt.input)
require.NoError(t, err)
assert.Equal(t, tt.expected, removePathIfPresent(u))
}
} | explode_data.jsonl/50776 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 345
} | [
2830,
3393,
13021,
1820,
2679,
21195,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
22427,
262,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
90,
1355,
25,
330,
1254,
1110,
7975,
905,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkerWait(t *testing.T) {
db, cleanup := storageTestEnv(t)
defer cleanup()
ctx := context.Background()
executor := &mockExecutor{t: t, dependencies: NewDependencyManager()}
worker := newWorker(db, executor, &testPublisherProvider{})
reporter := statusReporterFunc(func(ctx context.Context, taskID string, status *api.TaskStatus) error {
log.G(ctx).WithFields(logrus.Fields{"task.id": taskID, "status": status}).Info("status update received")
return nil
})
worker.Listen(ctx, reporter)
changeSet := []*api.AssignmentChange{
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-2"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
}
expectedTasks := []*api.Task{
{ID: "task-1"},
{ID: "task-2"},
}
expectedSecrets := []*api.Secret{
{ID: "secret-1"},
}
expectedConfigs := []*api.Config{
{ID: "config-1"},
}
expectedAssigned := []*api.Task{
{ID: "task-1"},
{ID: "task-2"},
}
var (
tasks []*api.Task
assigned []*api.Task
)
assert.NoError(t, worker.Assign(ctx, changeSet))
assert.NoError(t, worker.db.View(func(tx *bolt.Tx) error {
return WalkTasks(tx, func(task *api.Task) error {
tasks = append(tasks, task)
if TaskAssigned(tx, task.ID) {
assigned = append(assigned, task)
}
return nil
})
}))
assert.Equal(t, expectedTasks, tasks)
assert.Equal(t, expectedAssigned, assigned)
for _, secret := range expectedSecrets {
secret, err := executor.Secrets().Get(secret.ID)
assert.NoError(t, err)
assert.NotNil(t, secret)
}
for _, config := range expectedConfigs {
config, err := executor.Configs().Get(config.ID)
assert.NoError(t, err)
assert.NotNil(t, config)
}
err := worker.Assign(ctx, nil)
assert.Nil(t, err)
err = worker.Wait(ctx)
assert.Nil(t, err)
assigned = assigned[:0]
assert.NoError(t, worker.db.View(func(tx *bolt.Tx) error {
return WalkTasks(tx, func(task *api.Task) error {
if TaskAssigned(tx, task.ID) {
assigned = append(assigned, task)
}
return nil
})
}))
assert.Equal(t, len(assigned), 0)
} | explode_data.jsonl/11418 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1122
} | [
2830,
3393,
21936,
14190,
1155,
353,
8840,
836,
8,
341,
20939,
11,
21290,
1669,
5819,
2271,
14359,
1155,
340,
16867,
21290,
2822,
20985,
1669,
2266,
19047,
741,
67328,
4831,
1669,
609,
16712,
25255,
90,
83,
25,
259,
11,
19543,
25,
1532,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMapProxy_ExecuteOnEntriesWithPredicate(t *testing.T) {
config := hazelcast.NewHazelcastConfig()
expectedValue := "newValue"
processor := newSimpleEntryProcessor(expectedValue)
config.SerializationConfig().AddDataSerializableFactory(processor.identifiedFactory.factoryId, processor.identifiedFactory)
client, _ := hazelcast.NewHazelcastClientWithConfig(config)
mp2, _ := client.GetMap("testMap2")
for i := 0; i < 10; i++ {
testKey := "testingKey" + strconv.Itoa(i)
testValue := int32(i)
mp2.Put(testKey, testValue)
}
result, err := mp2.ExecuteOnEntriesWithPredicate(processor, GreaterThan("this", int32(6)))
if len(result) != 3 {
t.Fatal("ExecuteOnEntriesWithPredicate failed")
}
for _, pair := range result {
AssertEqualf(t, err, pair.Value(), expectedValue, "ExecuteOnEntriesWithPredicate failed")
newValue, err := mp2.Get(pair.Key())
AssertEqualf(t, err, newValue, expectedValue, "ExecuteOnEntriesWithPredicate failed")
}
mp.Clear()
client.Shutdown()
} | explode_data.jsonl/57040 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
2227,
16219,
83453,
1925,
24533,
2354,
36329,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
20144,
301,
3829,
7121,
39,
68326,
3829,
2648,
741,
42400,
1130,
1669,
330,
52830,
698,
197,
29474,
1669,
501,
16374,
5874,
22946,
15253,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateBucketIfNotExist(t *testing.T) {
err = testdb.CreateBucketIfNotExist("test")
if err != nil {
t.Fatalf("Could not create bucket. %v", err)
}
// Should not fail if we create bucket again
err = testdb.CreateBucketIfNotExist("test")
if err != nil {
t.Fatalf("Could not create bucket. %v", err)
}
} | explode_data.jsonl/51082 | {
"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,
4021,
36018,
2679,
45535,
1155,
353,
8840,
836,
8,
341,
9859,
284,
1273,
1999,
7251,
36018,
2679,
45535,
445,
1944,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
12895,
537,
1855,
15621,
13,
1018,
85,
497,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTopDownTime(t *testing.T) {
ast.RegisterBuiltin(&ast.Builtin{
Name: "test_sleep",
Decl: types.NewFunction(
types.Args(types.S),
nil,
),
})
RegisterFunctionalBuiltinVoid1("test_sleep", func(a ast.Value) error {
duration, err := time.ParseDuration(string(a.(ast.String)))
if err != nil {
panic(err)
}
time.Sleep(duration)
return nil
})
data := loadSmallTestData()
runTopDownTestCase(t, data, "time caching", []string{`
p { time.now_ns(t0); test_sleep("10ms"); time.now_ns(t1); t1 = t2 }
`}, "true")
runTopDownTestCase(t, data, "parse nanos", []string{`
p = ns { time.parse_ns("2006-01-02T15:04:05Z07:00", "2017-06-02T19:00:00-07:00", ns) }
`}, "1496455200000000000")
runTopDownTestCase(t, data, "parse rfc3339 nanos", []string{`
p = ns { time.parse_rfc3339_ns("2017-06-02T19:00:00-07:00", ns) }
`}, "1496455200000000000")
runTopDownTestCase(t, data, "parse duration nanos", []string{`
p = ns { time.parse_duration_ns("100ms", ns) }
`}, "100000000")
} | explode_data.jsonl/25217 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 435
} | [
2830,
3393,
5366,
4454,
1462,
1155,
353,
8840,
836,
8,
1476,
88836,
19983,
33,
25628,
2099,
559,
1785,
25628,
515,
197,
21297,
25,
330,
1944,
49393,
756,
197,
197,
21629,
25,
4494,
7121,
5152,
1006,
298,
98785,
51015,
52613,
808,
1326,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJobRunsController_Create_ExternalInitiator_Success(t *testing.T) {
t.Parallel()
ethClient, _, assertMocksCalled := cltest.NewEthMocksWithStartupAssertions(t)
defer assertMocksCalled()
app, cleanup := cltest.NewApplication(t,
ethClient,
)
defer cleanup()
app.Start()
url := cltest.WebURL(t, "http://localhost:8888")
eia := auth.NewToken()
eir := &models.ExternalInitiatorRequest{
Name: "bitcoin",
URL: &url,
}
ei, err := models.NewExternalInitiator(eia, eir)
require.NoError(t, err)
assert.NoError(t, app.Store.CreateExternalInitiator(ei))
j := cltest.NewJobWithExternalInitiator(ei)
assert.NoError(t, app.Store.CreateJob(&j))
jr := cltest.CreateJobRunViaExternalInitiator(
t, app,
j, *eia, `{"result":"100"}`,
)
jr = cltest.WaitForJobRunToComplete(t, app.Store, jr)
value := cltest.MustResultString(t, jr.Result)
assert.Equal(t, "100", value)
} | explode_data.jsonl/49844 | {
"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,
12245,
73920,
2051,
34325,
62,
25913,
3803,
36122,
87161,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
769,
2959,
11,
8358,
2060,
72577,
20960,
1669,
1185,
1944,
7121,
65390,
11571,
16056,
39076,
90206,
1155,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBiWeekly(t *testing.T) {
doTestNWeekly(t, "[] bla (every 2nd thursday)", moment.RecurBiWeekly, 2, tu.DtUtc("18.10.2019"), tu.DtUtc("17.10.2019"))
} | explode_data.jsonl/67519 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
36096,
80516,
1155,
353,
8840,
836,
8,
341,
19935,
2271,
45,
80516,
1155,
11,
330,
1294,
84541,
320,
29015,
220,
17,
303,
270,
7181,
11583,
4445,
2817,
2352,
36096,
80516,
11,
220,
17,
11,
9765,
909,
83,
97768,
445,
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 TestController_GetUsers_200(t *testing.T) {
// prepare request
req := httptest.NewRequest(http.MethodGet, "/", nil)
rec := httptest.NewRecorder()
// prepare echo context
e := echo.New()
ctx := e.NewContext(req, rec)
// prepare controller
c := NewController()
err := c.GetUsers(ctx, "aaa")
if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code)
assert.NotEmpty(t, rec.Body.String())
}
} | explode_data.jsonl/46228 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
2051,
13614,
7137,
62,
17,
15,
15,
1155,
353,
8840,
836,
8,
341,
197,
322,
10549,
1681,
198,
24395,
1669,
54320,
70334,
75274,
19886,
20798,
1949,
11,
64657,
2092,
340,
67904,
1669,
54320,
70334,
7121,
47023,
741,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInsecureAlgorithmErrorString(t *testing.T) {
tests := []struct {
sa SignatureAlgorithm
want string
}{
{MD2WithRSA, "x509: cannot verify signature: insecure algorithm MD2-RSA"},
{-1, "x509: cannot verify signature: insecure algorithm -1"},
{0, "x509: cannot verify signature: insecure algorithm 0"},
{9999, "x509: cannot verify signature: insecure algorithm 9999"},
}
for i, tt := range tests {
if got := fmt.Sprint(InsecureAlgorithmError(tt.sa)); got != tt.want {
t.Errorf("%d. mismatch.\n got: %s\nwant: %s\n", i, got, tt.want)
}
}
} | explode_data.jsonl/68009 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
641,
25132,
27847,
1454,
703,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
1903,
64,
256,
32232,
27847,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
90,
6076,
17,
2354,
73564,
11,
330,
87,
20,
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 TestGETPlayers(t *testing.T) {
store := StubPlayerStore{
map[string]int{
"Pepper": 20,
"Floyd": 10,
},
nil,
nil,
}
server := NewPlayerServer(&store)
t.Run("returns Pepper's score", func(t *testing.T) {
request := newGetScoreRequest("Pepper")
response := httptest.NewRecorder()
server.ServeHTTP(response, request)
assertStatus(t, response.Code, http.StatusOK)
assertResponseBody(t, response.Body.String(), "20")
})
t.Run("returns Floyd's score", func(t *testing.T) {
request := newGetScoreRequest("Floyd")
response := httptest.NewRecorder()
server.ServeHTTP(response, request)
assertStatus(t, response.Code, http.StatusOK)
assertResponseBody(t, response.Body.String(), "10")
})
t.Run("returns 404 on missing players", func(t *testing.T) {
request := newGetScoreRequest("Apollo")
response := httptest.NewRecorder()
server.ServeHTTP(response, request)
assertStatus(t, response.Code, http.StatusNotFound)
})
} | explode_data.jsonl/29293 | {
"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,
3806,
24257,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
66611,
4476,
6093,
515,
197,
19567,
14032,
63025,
515,
298,
197,
1,
10197,
6922,
788,
220,
17,
15,
345,
298,
197,
86555,
25796,
788,
220,
220,
16,
15,
345,
197,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewMapwatcherToEventMap(t *testing.T) {
k0, k1, k2 := []byte("foo0"), []byte("foo1"), []byte("foo2")
v0, v1, v2 := []byte("bar0"), []byte("bar1"), []byte("bar2")
ws := []*watcher{{key: k0}, {key: k1}, {key: k2}}
evs := []mvccpb.Event{
{
Type: mvccpb.PUT,
Kv: &mvccpb.KeyValue{Key: k0, Value: v0},
},
{
Type: mvccpb.PUT,
Kv: &mvccpb.KeyValue{Key: k1, Value: v1},
},
{
Type: mvccpb.PUT,
Kv: &mvccpb.KeyValue{Key: k2, Value: v2},
},
}
tests := []struct {
sync []*watcher
evs []mvccpb.Event
wwe map[*watcher][]mvccpb.Event
}{
// no watcher in sync, some events should return empty wwe
{
nil,
evs,
map[*watcher][]mvccpb.Event{},
},
// one watcher in sync, one event that does not match the key of that
// watcher should return empty wwe
{
[]*watcher{ws[2]},
evs[:1],
map[*watcher][]mvccpb.Event{},
},
// one watcher in sync, one event that matches the key of that
// watcher should return wwe with that matching watcher
{
[]*watcher{ws[1]},
evs[1:2],
map[*watcher][]mvccpb.Event{
ws[1]: evs[1:2],
},
},
// two watchers in sync that watches two different keys, one event
// that matches the key of only one of the watcher should return wwe
// with the matching watcher
{
[]*watcher{ws[0], ws[2]},
evs[2:],
map[*watcher][]mvccpb.Event{
ws[2]: evs[2:],
},
},
// two watchers in sync that watches the same key, two events that
// match the keys should return wwe with those two watchers
{
[]*watcher{ws[0], ws[1]},
evs[:2],
map[*watcher][]mvccpb.Event{
ws[0]: evs[:1],
ws[1]: evs[1:2],
},
},
}
for i, tt := range tests {
wg := newWatcherGroup()
for _, w := range tt.sync {
wg.add(w)
}
gwe := newWatcherBatch(&wg, tt.evs)
if len(gwe) != len(tt.wwe) {
t.Errorf("#%d: len(gwe) got = %d, want = %d", i, len(gwe), len(tt.wwe))
}
// compare gwe and tt.wwe
for w, eb := range gwe {
if len(eb.evs) != len(tt.wwe[w]) {
t.Errorf("#%d: len(eb.evs) got = %d, want = %d", i, len(eb.evs), len(tt.wwe[w]))
}
if !reflect.DeepEqual(eb.evs, tt.wwe[w]) {
t.Errorf("#%d: reflect.DeepEqual events got = %v, want = true", i, false)
}
}
}
} | explode_data.jsonl/67210 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1117
} | [
2830,
3393,
3564,
2227,
14321,
261,
1249,
1556,
2227,
1155,
353,
8840,
836,
8,
341,
16463,
15,
11,
595,
16,
11,
595,
17,
1669,
3056,
3782,
445,
7975,
15,
3975,
3056,
3782,
445,
7975,
16,
3975,
3056,
3782,
445,
7975,
17,
1138,
5195,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestWalletSignTransaction(t *testing.T) {
wallet, err := initializeWallet()
assert.Nil(t, err)
// Build a mock transaction
gas := uint64(1000000)
gasPrice := int64(1000000000)
tx := types.NewTransaction(
0,
common.HexToAddress("0x6f6704e5a10332af6672e50b3d9754dc460dfa4d"),
big.NewInt(0),
gas,
big.NewInt(gasPrice),
[]byte("data"),
)
tx, err = wallet.SignTransaction(tx)
assert.Nil(t, err)
V, R, S := tx.RawSignatureValues()
assert.NotEqual(t, new(big.Int), V)
assert.NotEqual(t, new(big.Int), R)
assert.NotEqual(t, new(big.Int), S)
} | explode_data.jsonl/25346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
38259,
7264,
8070,
1155,
353,
8840,
836,
8,
341,
6692,
7464,
11,
1848,
1669,
9468,
38259,
741,
6948,
59678,
1155,
11,
1848,
692,
197,
322,
7854,
264,
7860,
7745,
198,
3174,
300,
1669,
2622,
21,
19,
7,
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,
1... | 1 |
func TestHasPrefix(t *testing.T) {
cases := []struct {
s interface{}
prefix interface{}
want interface{}
isErr bool
}{
{"abcd", "ab", true, false},
{"abcd", "cd", false, false},
{template.HTML("abcd"), "ab", true, false},
{template.HTML("abcd"), "cd", false, false},
{template.HTML("1234"), 12, true, false},
{template.HTML("1234"), 34, false, false},
{[]byte("abcd"), "ab", true, false},
}
for i, c := range cases {
res, err := hasPrefix(c.s, c.prefix)
if (err != nil) != c.isErr {
t.Fatalf("[%d] unexpected isErr state: want %v, got %v, err = %v", i, c.isErr, err != nil, err)
}
if res != c.want {
t.Errorf("[%d] want %v, got %v", i, c.want, res)
}
}
} | explode_data.jsonl/9220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
10281,
14335,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
1903,
414,
3749,
16094,
197,
3223,
5060,
3749,
16094,
197,
50780,
256,
3749,
16094,
197,
19907,
7747,
220,
1807,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestValidateComponentConfig(t *testing.T) {
testCases := []struct {
name string
config *Config
errExpected bool
}{
{
name: "Valid default URL, no err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{"*": "https://my-prow"}}}},
errExpected: false,
},
{
name: "Invalid default URL, err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{"*": "https:// my-prow"}}}},
errExpected: true,
},
{
name: "Org config, valid URLs, no err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{
"*": "https://my-prow",
"my-org": "https://my-alternate-prow",
},
}}},
errExpected: false,
},
{
name: "Org override, invalid default jobURLPrefix URL, err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{
"*": "https:// my-prow",
"my-org": "https://my-alternate-prow",
},
}}},
errExpected: true,
},
{
name: "Org override, invalid org URL, err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{
"*": "https://my-prow",
"my-org": "https:// my-alternate-prow",
},
}}},
errExpected: true,
},
{
name: "Org override, invalid URLs, err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{
"*": "https:// my-prow",
"my-org": "https:// my-alternate-prow",
},
}}},
errExpected: true,
},
{
name: "Repo override, valid URLs, no err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{
"*": "https://my-prow",
"my-org": "https://my-alternate-prow",
"my-org/my-repo": "https://my-third-prow",
}}}},
errExpected: false,
},
{
name: "Repo override, invalid repo URL, err",
config: &Config{ProwConfig: ProwConfig{Plank: Plank{
JobURLPrefixConfig: map[string]string{
"*": "https://my-prow",
"my-org": "https://my-alternate-prow",
"my-org/my-repo": "https:// my-third-prow",
}}}},
errExpected: true,
},
{
name: "Both RerunAuthConfig and RerunAuthConfigs are invalid, err",
config: &Config{ProwConfig: ProwConfig{Deck: Deck{
RerunAuthConfig: &prowapi.RerunAuthConfig{AllowAnyone: true},
RerunAuthConfigs: RerunAuthConfigs{"*": prowapi.RerunAuthConfig{AllowAnyone: true}},
}}},
errExpected: true,
},
{
name: "RerunAuthConfig and not RerunAuthConfigs is valid, no err",
config: &Config{ProwConfig: ProwConfig{Deck: Deck{
RerunAuthConfig: &prowapi.RerunAuthConfig{AllowAnyone: false, GitHubUsers: []string{"grantsmith"}},
}}},
errExpected: false,
},
{
name: "RerunAuthConfig only and validation fails, err",
config: &Config{ProwConfig: ProwConfig{Deck: Deck{
RerunAuthConfig: &prowapi.RerunAuthConfig{AllowAnyone: true, GitHubUsers: []string{"grantsmith"}},
}}},
errExpected: true,
},
{
name: "RerunAuthConfigs and not RerunAuthConfig is valid, no err",
config: &Config{ProwConfig: ProwConfig{Deck: Deck{
RerunAuthConfigs: RerunAuthConfigs{
"*": prowapi.RerunAuthConfig{AllowAnyone: true},
"kubernetes": prowapi.RerunAuthConfig{GitHubUsers: []string{"easterbunny"}},
"kubernetes/kubernetes": prowapi.RerunAuthConfig{GitHubOrgs: []string{"kubernetes", "kubernetes-sigs"}},
},
}}},
errExpected: false,
},
{
name: "RerunAuthConfigs only and validation fails, err",
config: &Config{ProwConfig: ProwConfig{Deck: Deck{
RerunAuthConfigs: RerunAuthConfigs{
"*": prowapi.RerunAuthConfig{AllowAnyone: true},
"kubernetes": prowapi.RerunAuthConfig{GitHubUsers: []string{"easterbunny"}},
"kubernetes/kubernetes": prowapi.RerunAuthConfig{AllowAnyone: true, GitHubOrgs: []string{"kubernetes", "kubernetes-sigs"}},
},
}}},
errExpected: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if hasErr := tc.config.validateComponentConfig() != nil; hasErr != tc.errExpected {
t.Errorf("expected err: %t but was %t", tc.errExpected, hasErr)
}
})
}
} | explode_data.jsonl/8087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2018
} | [
2830,
3393,
17926,
2189,
2648,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
25873,
414,
353,
2648,
198,
197,
9859,
18896,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReleaseAsset_String(t *testing.T) {
v := ReleaseAsset{
ID: Int64(0),
URL: String(""),
Name: String(""),
Label: String(""),
State: String(""),
ContentType: String(""),
Size: Int(0),
DownloadCount: Int(0),
CreatedAt: &Timestamp{},
UpdatedAt: &Timestamp{},
BrowserDownloadURL: String(""),
Uploader: &User{},
NodeID: String(""),
}
want := `github.ReleaseAsset{ID:0, URL:"", Name:"", Label:"", State:"", ContentType:"", Size:0, DownloadCount:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, BrowserDownloadURL:"", Uploader:github.User{}, NodeID:""}`
if got := v.String(); got != want {
t.Errorf("ReleaseAsset.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33280 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 425
} | [
2830,
3393,
16077,
16604,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
17381,
16604,
515,
197,
29580,
25,
338,
1333,
21,
19,
7,
15,
1326,
197,
79055,
25,
394,
923,
445,
4461,
197,
21297,
25,
2290,
923,
445,
4461,
197,
82126,
25,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestHealthWithBogusCheck(t *testing.T) {
h := New()
err := h.RegisterCheck(&Config{
ExecutionPeriod: 1,
InitialDelay: 1,
})
defer h.DeregisterAll()
assert.Error(t, err, "register bogus check should fail")
assert.Contains(t, err.Error(), "misconfigured check", "fail message")
assert.True(t, h.IsHealthy(), "health after bogus register")
results, healthy := h.Results()
assert.True(t, healthy, "results after bogus register")
assert.Empty(t, results, "results after bogus register")
} | explode_data.jsonl/28828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
14542,
2354,
33,
538,
355,
3973,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
1532,
2822,
9859,
1669,
305,
19983,
3973,
2099,
2648,
515,
197,
197,
20294,
23750,
25,
220,
16,
345,
197,
197,
6341,
20039,
25,
262,
220,
16,
345... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBadConn(t *testing.T) {
var err error
cn := conn{}
func() {
defer cn.errRecover(&err)
panic(io.EOF)
}()
if err != driver.ErrBadConn {
t.Fatalf("expected driver.ErrBadConn, got: %#v", err)
}
if !cn.bad {
t.Fatalf("expected cn.bad")
}
cn = conn{}
func() {
defer cn.errRecover(&err)
e := &Error{Severity: Efatal}
panic(e)
}()
if err != driver.ErrBadConn {
t.Fatalf("expected driver.ErrBadConn, got: %#v", err)
}
if !cn.bad {
t.Fatalf("expected cn.bad")
}
} | explode_data.jsonl/73482 | {
"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,
17082,
9701,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
271,
1444,
77,
1669,
4534,
16094,
29244,
368,
341,
197,
16867,
13665,
18441,
693,
3688,
2099,
615,
340,
197,
30764,
37258,
86492,
340,
197,
69826,
743,
1848,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAllocateTokensTruncation(t *testing.T) {
communityTax := sdk.NewDec(0)
ctx, _, _, k, sk, fck, _ := CreateTestInputAdvanced(t, false, 1000000, communityTax)
fmt.Println("====", k.GetCommunityTax(ctx))
sh := staking.NewHandler(sk)
// create validator with 10% commission
commission := staking.NewCommissionMsg(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
msg := staking.NewMsgCreateValidator(valOpAddr1, valConsPk1,
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(110)), staking.Description{}, commission, sdk.OneInt(), sdk.OneInt(), sdk.OneInt())
require.True(t, sh(ctx, msg).IsOK())
// create second validator with 10% commission
commission = staking.NewCommissionMsg(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
msg = staking.NewMsgCreateValidator(valOpAddr2, valConsPk2,
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), staking.Description{}, commission, sdk.OneInt(), sdk.OneInt(), sdk.OneInt())
require.True(t, sh(ctx, msg).IsOK())
// create third validator with 10% commission
commission = staking.NewCommissionMsg(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), sdk.NewDec(0))
msg = staking.NewMsgCreateValidator(valOpAddr3, valConsPk3,
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), staking.Description{}, commission, sdk.OneInt(), sdk.OneInt(), sdk.OneInt())
require.True(t, sh(ctx, msg).IsOK())
abciValA := abci.Validator{
Address: valConsPk1.Address(),
Power: 11,
}
abciValB := abci.Validator{
Address: valConsPk2.Address(),
Power: 10,
}
abciValС := abci.Validator{
Address: valConsPk3.Address(),
Power: 10,
}
// assert initial state: zero outstanding rewards, zero community pool, zero commission, zero current rewards
require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).IsZero())
require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).IsZero())
require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr3).IsZero())
require.True(t, k.GetFeePool(ctx).CommunityPool.IsZero())
require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero())
require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).IsZero())
require.True(t, k.GetValidatorCurrentRewards(ctx, valOpAddr1).Rewards.IsZero())
require.True(t, k.GetValidatorCurrentRewards(ctx, valOpAddr2).Rewards.IsZero())
// allocate tokens as if both had voted and second was proposer
fees := sdk.Coins{
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(634195840)),
}
fck.SetCollectedFees(fees)
votes := []abci.VoteInfo{
{
Validator: abciValA,
SignedLastBlock: true,
},
{
Validator: abciValB,
SignedLastBlock: true,
},
{
Validator: abciValС,
SignedLastBlock: true,
},
}
k.AllocateTokens(ctx, 31, 31, valConsAddr2, votes)
require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).IsValid())
require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).IsValid())
require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr3).IsValid())
} | explode_data.jsonl/45678 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1219
} | [
2830,
3393,
75380,
29300,
1282,
1347,
367,
1155,
353,
8840,
836,
8,
341,
197,
28402,
31349,
1669,
45402,
7121,
4900,
7,
15,
340,
20985,
11,
8358,
8358,
595,
11,
1901,
11,
282,
377,
11,
716,
1669,
4230,
2271,
2505,
35457,
1155,
11,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUGlobalLongShortRatio(t *testing.T) {
t.Parallel()
_, err := b.UGlobalLongShortRatio(context.Background(), currency.NewPair(currency.BTC, currency.USDT), "5m", 3, time.Time{}, time.Time{})
if err != nil {
t.Error(err)
}
_, err = b.UGlobalLongShortRatio(context.Background(), currency.NewPair(currency.BTC, currency.USDT), "4h", 0, time.Unix(1577836800, 0), time.Unix(1580515200, 0))
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76567 | {
"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,
2941,
2042,
6583,
12472,
22777,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
13,
2941,
2042,
6583,
12472,
22777,
5378,
19047,
1507,
11413,
7121,
12443,
90475,
1785,
7749,
11,
11413,
67672,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIAVLDefaultPruning(t *testing.T) {
//Expected stored / deleted version numbers for:
//numRecent = 5, storeEvery = 3
var states = []pruneState{
{[]int64{}, []int64{}},
{[]int64{1}, []int64{}},
{[]int64{1, 2}, []int64{}},
{[]int64{1, 2, 3}, []int64{}},
{[]int64{1, 2, 3, 4}, []int64{}},
{[]int64{1, 2, 3, 4, 5}, []int64{}},
{[]int64{1, 2, 3, 4, 5, 6}, []int64{}},
{[]int64{2, 3, 4, 5, 6, 7}, []int64{1}},
{[]int64{3, 4, 5, 6, 7, 8}, []int64{1, 2}},
{[]int64{3, 4, 5, 6, 7, 8, 9}, []int64{1, 2}},
{[]int64{3, 5, 6, 7, 8, 9, 10}, []int64{1, 2, 4}},
{[]int64{3, 6, 7, 8, 9, 10, 11}, []int64{1, 2, 4, 5}},
{[]int64{3, 6, 7, 8, 9, 10, 11, 12}, []int64{1, 2, 4, 5}},
{[]int64{3, 6, 8, 9, 10, 11, 12, 13}, []int64{1, 2, 4, 5, 7}},
{[]int64{3, 6, 9, 10, 11, 12, 13, 14}, []int64{1, 2, 4, 5, 7, 8}},
{[]int64{3, 6, 9, 10, 11, 12, 13, 14, 15}, []int64{1, 2, 4, 5, 7, 8}},
}
testPruning(t, int64(5), int64(3), states)
} | explode_data.jsonl/44275 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 532
} | [
2830,
3393,
5863,
30698,
3675,
3533,
37202,
1155,
353,
8840,
836,
8,
341,
197,
322,
18896,
9768,
608,
11062,
2319,
5109,
369,
510,
197,
322,
2413,
25140,
284,
220,
20,
11,
3553,
11510,
284,
220,
18,
198,
2405,
5302,
284,
3056,
649,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerRejectHeadWithBody(t *testing.T) {
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
// No response body.
})
defer st.Close()
st.greet()
st.writeHeaders(HeadersFrameParam{
StreamID: 1, // clients send odd numbers
BlockFragment: st.encodeHeader(":method", "HEAD"),
EndStream: false, // what we're testing, a bogus HEAD request with body
EndHeaders: true,
})
st.wantRSTStream(1, ErrCodeProtocol)
} | explode_data.jsonl/71694 | {
"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,
5475,
78413,
12346,
2354,
5444,
1155,
353,
8840,
836,
8,
341,
18388,
1669,
501,
5475,
58699,
1155,
11,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
197,
322,
2308,
2033,
2487,
624,
197,
3518,
16867,
357,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrderCountMetafields(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/orders/1/metafields/count.json", client.pathPrefix),
httpmock.NewStringResponder(200, `{"count": 3}`))
params := map[string]string{"created_at_min": "2016-01-01T00:00:00Z"}
httpmock.RegisterResponderWithQuery(
"GET",
fmt.Sprintf("https://fooshop.myshopify.com/%s/orders/1/metafields/count.json", client.pathPrefix),
params,
httpmock.NewStringResponder(200, `{"count": 2}`))
cnt, err := client.Order.CountMetafields(1, nil)
if err != nil {
t.Errorf("Order.CountMetafields() returned error: %v", err)
}
expected := 3
if cnt != expected {
t.Errorf("Order.CountMetafields() returned %d, expected %d", cnt, expected)
}
date := time.Date(2016, time.January, 1, 0, 0, 0, 0, time.UTC)
cnt, err = client.Order.CountMetafields(1, CountOptions{CreatedAtMin: date})
if err != nil {
t.Errorf("Order.CountMetafields() returned error: %v", err)
}
expected = 2
if cnt != expected {
t.Errorf("Order.CountMetafields() returned %d, expected %d", cnt, expected)
}
} | explode_data.jsonl/17993 | {
"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,
4431,
2507,
12175,
9007,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
28080,
16712,
19983,
30884,
445,
3806,
497,
8879,
17305,
445,
2428,
1110,
824,
9267,
453,
12618,
8675,
1437,
905,
12627,
82,
82818,
14,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_DeleteVote(t *testing.T) {
if testUser == nil || testUser.Id < 1 ||
testMovie == nil || testMovie.Id < 1 ||
testCycle == nil || testCycle.Id < 1 {
t.Skip("Skipping due to previous failure")
}
err := conn.DeleteVote(testUser.Id, testMovie.Id)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/22023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
57418,
41412,
1155,
353,
8840,
836,
8,
341,
743,
1273,
1474,
621,
2092,
1369,
1273,
1474,
6444,
366,
220,
16,
8244,
197,
18185,
19668,
621,
2092,
1369,
1273,
19668,
6444,
366,
220,
16,
8244,
197,
18185,
44820,
621,
2092,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestStrArray_FilterEmpty(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.NewStrArrayFrom(g.SliceStr{"", "1", "2", "0"})
t.Assert(array.FilterEmpty(), g.SliceStr{"1", "2", "0"})
})
gtest.C(t, func(t *gtest.T) {
array := garray.NewStrArrayFrom(g.SliceStr{"1", "2"})
t.Assert(array.FilterEmpty(), g.SliceStr{"1", "2"})
})
} | explode_data.jsonl/53117 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
2580,
1857,
68935,
3522,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11923,
1669,
342,
1653,
7121,
2580,
1857,
3830,
3268,
95495,
2580,
4913,
497,
330,
16,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrint(t *testing.T) {
data := []byte(`{
"Name": "some-name",
"Project": "some-project",
"Zone": "some-zone",
"GCSPath": "gs://some-bucket/images",
"Vars": {
"instance_name": "i1",
"machine_type": {"Value": "n1-standard-1", "Required": true}
},
"Steps": {
"${instance_name}Delete": {
"DeleteResources": {
"Instances": ["${instance_name}"]
}
}
}
}`)
want := `{
"Name": "some-name",
"Project": "some-project",
"Zone": "some-zone",
"GCSPath": "gs://some-bucket/images",
"Vars": {
"instance_name": {
"Value": "i1"
},
"machine_type": {
"Value": "n1-standard-1",
"Required": true
}
},
"Steps": {
"i1Delete": {
"Timeout": "10m",
"DeleteResources": {
"Instances": [
"i1"
]
}
}
},
"DefaultTimeout": "10m",
"ForceCleanupOnError": false
}
`
td, err := ioutil.TempDir(os.TempDir(), "")
if err != nil {
t.Fatalf("error creating temp dir: %v", err)
}
defer os.RemoveAll(td)
tf := filepath.Join(td, "test.wf.json")
ioutil.WriteFile(tf, data, 0600)
got, err := NewFromFile(tf)
if err != nil {
t.Fatal(err)
}
got.ComputeClient, _ = newTestGCEClient()
got.StorageClient, _ = newTestGCSClient()
old := os.Stdout
r, w, err := os.Pipe()
if err != nil {
t.Fatal(err)
}
os.Stdout = w
got.Print(context.Background())
w.Close()
os.Stdout = old
var buf bytes.Buffer
if _, err := io.Copy(&buf, r); err != nil {
t.Fatal(err)
}
if diffRes := diff(buf.String(), want, 0); diffRes != "" {
t.Errorf("printed workflow does not match expectation: (-got +want)\n%s", diffRes)
}
} | explode_data.jsonl/3882 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 736
} | [
2830,
3393,
8994,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
5809,
515,
1,
675,
788,
330,
14689,
11494,
756,
1,
7849,
788,
330,
14689,
33696,
756,
1,
15363,
788,
330,
14689,
77763,
756,
89199,
6412,
1820,
788,
330,
5857,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestOVSBridgeExternalIDs(t *testing.T) {
data := &testData{}
data.setup(t)
defer data.teardown(t)
returnedIDs, err := data.br.GetExternalIDs()
require.Nil(t, err, "Failed to get external IDs of the bridge")
assert.Empty(t, returnedIDs)
providedIDs := map[string]interface{}{"k1": "v1", "k2": "v2"}
err = data.br.SetExternalIDs(providedIDs)
require.Nil(t, err, "Failed to set external IDs to the bridge")
returnedIDs, err = data.br.GetExternalIDs()
require.Nil(t, err, "Failed to get external IDs of the bridge")
for k, v := range providedIDs {
rv, ok := returnedIDs[k]
if !assert.Truef(t, ok, "Returned external IDs do not include the expected ID: %s:%s", k, v) {
continue
}
assert.Equalf(t, v.(string), rv, "Returned external IDs include an ID with an unexpected value: %s:%s", k, v)
}
} | explode_data.jsonl/74750 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
38957,
16680,
11183,
25913,
30466,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
609,
1944,
1043,
16094,
8924,
25338,
1155,
340,
16867,
821,
31853,
37496,
1155,
692,
853,
291,
30466,
11,
1848,
1669,
821,
20937,
2234,
25913,
30466,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiRangeBoundedBatchScanUnsortedOrder(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)
db := s.DB()
if err := setupMultipleRanges(ctx, db, "a", "b", "c", "d", "e", "f"); err != nil {
t.Fatal(err)
}
for _, key := range []string{"a1", "a2", "a3", "b1", "b2", "b3", "b4", "b5", "c1", "c2", "d1", "f1", "f2", "f3"} {
if err := db.Put(ctx, key, "value"); err != nil {
t.Fatal(err)
}
}
bound := 6
b := &client.Batch{}
b.Header.MaxSpanRequestKeys = int64(bound)
// Two non-overlapping requests out of order.
spans := [][]string{{"b3", "c2"}, {"a", "b3"}}
for _, span := range spans {
b.Scan(span[0], span[1])
}
if err := db.Run(ctx, b); err != nil {
t.Fatal(err)
}
// See incomplete results for the two requests.
expResults := [][]string{
{"b3", "b4", "b5"},
{"a1", "a2", "a3"},
}
checkScanResults(t, spans, b.Results, expResults, nil /* satisfied */, checkOptions{mode: Strict})
} | explode_data.jsonl/36452 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 453
} | [
2830,
3393,
20358,
6046,
33,
13082,
21074,
26570,
1806,
28298,
4431,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1903,
11,
716,
1669,
1191,
2753,
20193,
52096,
5475,
1155,
340,
20985,
1669,
2266,
90988,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestImportDirectPostWithAttachments(t *testing.T) {
th := Setup(t)
defer th.TearDown()
testsDir, _ := fileutils.FindDir("tests")
testImage := filepath.Join(testsDir, "test.png")
testImage2 := filepath.Join(testsDir, "test.svg")
// create a temp file with same name as original but with a different first byte
tmpFolder, _ := ioutil.TempDir("", "imgFake")
testImageFake := filepath.Join(tmpFolder, "test.png")
fakeFileData, _ := ioutil.ReadFile(testImage)
fakeFileData[0] = 0
_ = ioutil.WriteFile(testImageFake, fakeFileData, 0644)
defer os.RemoveAll(tmpFolder)
// Create a user.
username := model.NewId()
th.App.importUser(&UserImportData{
Username: &username,
Email: ptrStr(model.NewId() + "@example.com"),
}, false)
user1, err := th.App.GetUserByUsername(username)
require.Nil(t, err, "Failed to get user1 from database.")
username2 := model.NewId()
th.App.importUser(&UserImportData{
Username: &username2,
Email: ptrStr(model.NewId() + "@example.com"),
}, false)
user2, err := th.App.GetUserByUsername(username2)
require.Nil(t, err, "Failed to get user2 from database.")
directImportData := &DirectPostImportData{
ChannelMembers: &[]string{
user1.Username,
user2.Username,
},
User: &user1.Username,
Message: ptrStr("Direct message"),
CreateAt: ptrInt64(model.GetMillis()),
Attachments: &[]AttachmentImportData{{Path: &testImage}},
}
t.Run("Regular import of attachment", func(t *testing.T) {
err := th.App.importDirectPost(directImportData, false)
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Len(t, attachments, 1)
assert.Contains(t, attachments[0].Path, "noteam")
AssertFileIdsInPost(attachments, th, t)
})
t.Run("Attempt to import again with same file entirely, should NOT add an attachment", func(t *testing.T) {
err := th.App.importDirectPost(directImportData, false)
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Len(t, attachments, 1)
})
t.Run("Attempt to import again with same name and size but different content, SHOULD add an attachment", func(t *testing.T) {
directImportDataFake := &DirectPostImportData{
ChannelMembers: &[]string{
user1.Username,
user2.Username,
},
User: &user1.Username,
Message: ptrStr("Direct message"),
CreateAt: ptrInt64(model.GetMillis()),
Attachments: &[]AttachmentImportData{{Path: &testImageFake}},
}
err := th.App.importDirectPost(directImportDataFake, false)
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Len(t, attachments, 2)
})
t.Run("Attempt to import again with same data, SHOULD add an attachment, since it's different name", func(t *testing.T) {
directImportData2 := &DirectPostImportData{
ChannelMembers: &[]string{
user1.Username,
user2.Username,
},
User: &user1.Username,
Message: ptrStr("Direct message"),
CreateAt: ptrInt64(model.GetMillis()),
Attachments: &[]AttachmentImportData{{Path: &testImage2}},
}
err := th.App.importDirectPost(directImportData2, false)
require.Nil(t, err, "Expected success.")
attachments := GetAttachments(user1.Id, th, t)
assert.Len(t, attachments, 3)
})
} | explode_data.jsonl/67146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1247
} | [
2830,
3393,
11511,
16027,
4133,
2354,
75740,
1155,
353,
8840,
836,
8,
1476,
70479,
1669,
18626,
1155,
340,
16867,
270,
836,
682,
4454,
2822,
78216,
6184,
11,
716,
1669,
1034,
6031,
9998,
6184,
445,
23841,
1138,
18185,
1906,
1669,
26054,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConnectorServiceQuerySuccess(t *testing.T) {
// given
var (
fixAppName = "app-name"
fixURL = "http://some-url-with-token"
fixGQLObj = &gqlschema.ConnectorService{
URL: "http://some-url-with-token",
}
)
serviceMock := automock.NewApplicationSvc()
defer serviceMock.AssertExpectations(t)
serviceMock.On("GetConnectionURL", fixAppName).Return(fixURL, nil)
resolver := application.NewApplicationResolver(serviceMock, nil)
// when
gotURLObj, err := resolver.ConnectorServiceQuery(context.Background(), fixAppName)
// then
require.NoError(t, err)
assert.Equal(t, fixGQLObj, gotURLObj)
} | explode_data.jsonl/28765 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
35954,
1860,
2859,
7188,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
2405,
2399,
197,
1166,
941,
87994,
284,
330,
676,
11494,
698,
197,
1166,
941,
3144,
257,
284,
330,
1254,
1110,
14689,
25443,
26189,
34841,
698,
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 TestUserDefinedBool(t *testing.T) {
var flags FlagSet
flags.Init("test", ContinueOnError)
var b boolFlagVar
var err error
flags.Var(&b, "b", "usage")
if err = flags.Parse([]string{"-b", "-b", "-b", "-b=true", "-b=false", "-b", "barg", "-b"}); err != nil {
if b.count < 4 {
t.Error(err)
}
}
if b.count != 4 {
t.Errorf("want: %d; got: %d", 4, b.count)
}
if err == nil {
t.Error("expected error; got none")
}
} | explode_data.jsonl/53995 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
1474,
29361,
11233,
1155,
353,
8840,
836,
8,
341,
2405,
8042,
22666,
1649,
198,
59516,
26849,
445,
1944,
497,
15003,
74945,
340,
2405,
293,
1807,
12135,
3962,
198,
2405,
1848,
1465,
198,
59516,
87968,
2099,
65,
11,
330,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTenantPrefix(t *testing.T) {
tIDs := []roachpb.TenantID{
roachpb.SystemTenantID,
roachpb.MakeTenantID(2),
roachpb.MakeTenantID(999),
roachpb.MakeTenantID(math.MaxUint64),
}
for _, tID := range tIDs {
t.Run(fmt.Sprintf("%v", tID), func(t *testing.T) {
// Encode tenant ID.
k := MakeTenantPrefix(tID)
// The system tenant has no tenant prefix.
if tID == roachpb.SystemTenantID {
require.Len(t, k, 0)
}
// Encode table prefix.
const tableID = 5
k = encoding.EncodeUvarintAscending(k, tableID)
// Decode tenant ID.
rem, retTID, err := DecodeTenantPrefix(k)
require.Equal(t, tID, retTID)
require.NoError(t, err)
// Decode table prefix.
rem, retTableID, err := encoding.DecodeUvarintAscending(rem)
require.Len(t, rem, 0)
require.Equal(t, uint64(tableID), retTableID)
require.NoError(t, err)
})
}
} | explode_data.jsonl/56601 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 395
} | [
2830,
3393,
71252,
14335,
1155,
353,
8840,
836,
8,
341,
3244,
30466,
1669,
3056,
64500,
16650,
836,
25121,
915,
515,
197,
197,
64500,
16650,
16620,
71252,
915,
345,
197,
197,
64500,
16650,
50133,
71252,
915,
7,
17,
1326,
197,
197,
64500... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReminderExecutionZeroDuration(t *testing.T) {
testActorsRuntime := newTestActorsRuntime()
actorType, actorID := getTestActorTypeAndID()
actorKey := testActorsRuntime.constructCompositeKey(actorType, actorID)
fakeCallAndActivateActor(testActorsRuntime, actorKey)
err := testActorsRuntime.executeReminder(actorType, actorID, "0ms", "0ms", "reminder0", "data")
assert.Nil(t, err)
} | explode_data.jsonl/60013 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
95359,
20294,
17999,
12945,
1155,
353,
8840,
836,
8,
341,
18185,
2414,
1087,
15123,
1669,
501,
2271,
2414,
1087,
15123,
741,
93410,
929,
11,
12089,
915,
1669,
633,
2271,
18870,
929,
3036,
915,
741,
93410,
1592,
1669,
1273,
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 TestReadPlainBYTE_ARRAY(t *testing.T) {
testData := [][]interface{}{
{("hello"), ("world")},
{("good"), (""), ("a"), ("b")},
}
for _, data := range testData {
res, _ := ReadPlainBYTE_ARRAY(bytes.NewReader(WritePlainBYTE_ARRAY(data)), uint64(len(data)))
if fmt.Sprintf("%v", data) != fmt.Sprintf("%v", res) {
t.Errorf("ReadPlainBYTE_ARRAY err, %v", data)
}
}
} | explode_data.jsonl/23895 | {
"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,
26982,
33908,
17724,
1155,
353,
8840,
836,
8,
341,
18185,
1043,
1669,
52931,
4970,
67066,
197,
197,
90,
445,
14990,
3975,
3489,
14615,
79583,
197,
197,
90,
445,
18536,
3975,
320,
3014,
701,
3489,
64,
3975,
3489,
65,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPackObjectReturnsObjectWithDeltaBaseOffset(t *testing.T) {
const original = "Hello"
compressed, _ := compress(original)
delta, err := compress(string([]byte{
0x05, // Source size: 5.
0x0e, // Destination size: 14.
0x91, // (1000 0001) (instruction=copy, bitmask=0001)
0x00, // (0000 0000) (offset=0)
0x05, // (0000 0101) (size=5)
0x09, // (0000 0111) (instruction=add, size=7)
// Contents: ...
',', ' ', 'w', 'o', 'r', 'l', 'd', '!', '\n',
}))
p := &Packfile{
idx: IndexWith(map[string]uint32{
"cccccccccccccccccccccccccccccccccccccccc": uint32(32 + 1 + len(compressed)),
}),
r: bytes.NewReader(append(append([]byte{
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x35, // (0011 0101) (msb=0, type=blob, size=5)
}, compressed...), append([]byte{
0x6e, // (0110 1010) (msb=0, type=obj_ofs_delta, size=10)
0x12, // (0001 0001) (ofs_delta=-17, len(compressed))
}, delta...)...)),
}
o, err := p.Object(DecodeHex(t, "cccccccccccccccccccccccccccccccccccccccc"))
assert.NoError(t, err)
assert.Equal(t, TypeBlob, o.Type())
unpacked, err := o.Unpack()
assert.Equal(t, []byte(original+", world!\n"), unpacked)
assert.NoError(t, err)
} | explode_data.jsonl/30628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 660
} | [
2830,
3393,
30684,
1190,
16446,
1190,
2354,
20277,
3978,
6446,
1155,
353,
8840,
836,
8,
341,
4777,
4024,
284,
330,
9707,
698,
32810,
14318,
11,
716,
1669,
24611,
39809,
692,
85435,
11,
1848,
1669,
24611,
3609,
10556,
3782,
515,
197,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetServiceKeyByName(t *testing.T) {
Convey("Get service key by name", t, func() {
setup(MockRoute{"GET", "/v2/service_keys", getServiceKeyPayload, "", 200, "q=name:test01_key", nil}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
serviceKey, err := client.GetServiceKeyByName("test01_key")
So(err, ShouldBeNil)
So(serviceKey, ShouldNotBeNil)
So(serviceKey.Name, ShouldEqual, "test01_key")
So(serviceKey.ServiceInstanceGuid, ShouldEqual, "ecf26687-e176-4784-b181-b3c942fecb62")
So(serviceKey.Credentials, ShouldNotEqual, nil)
So(serviceKey.ServiceInstanceUrl, ShouldEqual, "/v2/service_instances/fcf26687-e176-4784-b181-b3c942fecb62")
})
} | explode_data.jsonl/66019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
1949,
1860,
1592,
16898,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
1949,
2473,
1376,
553,
829,
497,
259,
11,
2915,
368,
341,
197,
84571,
66436,
4899,
4913,
3806,
497,
3521,
85,
17,
34186,
12631,
497,
85869,
1592,
296... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAPINewMultipartHandlerParallel(t *testing.T) {
defer DetectTestLeak(t)()
ExecObjectLayerAPITest(t, testAPINewMultipartHandlerParallel, []string{"NewMultipart"})
} | explode_data.jsonl/10704 | {
"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,
2537,
687,
365,
44,
18204,
3050,
16547,
1155,
353,
8840,
836,
8,
341,
16867,
33287,
2271,
2304,
585,
1155,
8,
741,
197,
10216,
1190,
9188,
2537,
952,
477,
1155,
11,
1273,
2537,
687,
365,
44,
18204,
3050,
16547,
11,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestNSERetryClient_Unregister(t *testing.T) {
t.Cleanup(func() { goleak.VerifyNone(t) })
var callCounter = &count.CallCounter{}
var counter = count.NewNetworkServiceEndpointRegistryClient(callCounter)
var client = chain.NewNetworkServiceEndpointRegistryClient(
retry.NewNetworkServiceEndpointRegistryClient(
context.Background(),
retry.WithInterval(time.Millisecond*10),
retry.WithTryTimeout(time.Second/30)),
counter,
injecterror.NewNetworkServiceEndpointRegistryClient(injecterror.WithUnregisterErrorTimes(0, 1, 2, 3, 4)),
)
var _, err = client.Unregister(context.Background(), nil)
require.NoError(t, err)
require.Equal(t, 6, callCounter.Unregisters())
} | explode_data.jsonl/68614 | {
"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,
2448,
640,
15149,
2959,
40687,
6343,
1155,
353,
8840,
836,
8,
341,
3244,
727,
60639,
18552,
368,
314,
728,
273,
585,
54853,
4064,
1155,
8,
9568,
2405,
1618,
14099,
284,
609,
1830,
27017,
14099,
16094,
2405,
5546,
284,
1760,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadCRSpecFromEnvYaml(t *testing.T) {
os.Setenv("YAML_CONF", "")
_, err := ReadCRSpecFromEnvYaml()
if err == nil {
t.Fail()
}
setup(t)
cfg, err := ReadCRSpecFromEnvYaml()
if err != nil {
t.Fatalf("error reading config from env")
}
if cfg.Spec.Configs["qliksense"][0].Name != "acceptEULA" {
t.Fail()
}
if cfg.Spec.Configs["qliksense"][0].Value != "yes" {
t.Fail()
}
} | explode_data.jsonl/60728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
4418,
8973,
8327,
3830,
14359,
56,
9467,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
445,
56,
31102,
29212,
497,
14676,
197,
6878,
1848,
1669,
4457,
8973,
8327,
3830,
14359,
56,
9467,
741,
743,
1848,
621,
2092,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTradeActions_SyntheticOfferIds(t *testing.T) {
ht := StartHTTPTest(t, "offer_ids")
defer ht.Finish()
var records []horizon.Trade
w := ht.Get("/trades")
if ht.Assert.Equal(200, w.Code) {
if ht.Assert.PageOf(4, w.Body) {
ht.UnmarshalPage(w.Body, &records)
assertOfferType(ht, records[0].BaseOfferID, TOIDType)
assertOfferType(ht, records[1].BaseOfferID, TOIDType)
assertOfferType(ht, records[2].BaseOfferID, CoreOfferIDType)
assertOfferType(ht, records[3].BaseOfferID, CoreOfferIDType)
}
}
} | explode_data.jsonl/6927 | {
"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,
39173,
12948,
1098,
1872,
17556,
39462,
12701,
1155,
353,
8840,
836,
8,
341,
197,
426,
1669,
5145,
9230,
2271,
1155,
11,
330,
25077,
8077,
1138,
16867,
34323,
991,
18176,
741,
2405,
7424,
3056,
19530,
16973,
8240,
1021,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFooterRoundTrip(t *testing.T) {
buf := make([]byte, 100+maxFooterLen)
for _, format := range []TableFormat{
TableFormatRocksDBv2,
TableFormatLevelDB,
} {
t.Run(fmt.Sprintf("format=%d", format), func(t *testing.T) {
checksums := []ChecksumType{ChecksumTypeCRC32c}
if format != TableFormatLevelDB {
checksums = []ChecksumType{ChecksumTypeCRC32c, ChecksumTypeXXHash64}
}
for _, checksum := range checksums {
t.Run(fmt.Sprintf("checksum=%d", checksum), func(t *testing.T) {
footer := footer{
format: format,
checksum: checksum,
metaindexBH: BlockHandle{Offset: 1, Length: 2},
indexBH: BlockHandle{Offset: 3, Length: 4},
}
for _, offset := range []int64{0, 1, 100} {
t.Run(fmt.Sprintf("offset=%d", offset), func(t *testing.T) {
mem := vfs.NewMem()
f, err := mem.Create("test")
require.NoError(t, err)
_, err = f.Write(buf[:offset])
require.NoError(t, err)
encoded := footer.encode(buf[100:])
_, err = f.Write(encoded)
require.NoError(t, err)
require.NoError(t, f.Close())
footer.footerBH.Offset = uint64(offset)
footer.footerBH.Length = uint64(len(encoded))
f, err = mem.Open("test")
require.NoError(t, err)
result, err := readFooter(f)
require.NoError(t, err)
require.NoError(t, f.Close())
if diff := pretty.Diff(footer, result); diff != nil {
t.Fatalf("expected %+v, but found %+v\n%s",
footer, result, strings.Join(diff, "\n"))
}
})
}
})
}
})
}
} | explode_data.jsonl/40344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 794
} | [
2830,
3393,
19445,
27497,
56352,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
1281,
10556,
3782,
11,
220,
16,
15,
15,
10,
2810,
19445,
11271,
340,
2023,
8358,
3561,
1669,
2088,
3056,
2556,
4061,
515,
197,
197,
2556,
4061,
49,
25183,
350... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkdir(t *testing.T) {
b := &Builder{flags: &BFlags{}, runConfig: &container.Config{}, disableCommit: true}
workingDir := "/app"
if runtime.GOOS == "windows" {
workingDir = "C:\app"
}
err := workdir(b, []string{workingDir}, nil, "")
if err != nil {
t.Fatalf("Error should be empty, got: %s", err.Error())
}
if b.runConfig.WorkingDir != workingDir {
t.Fatalf("WorkingDir should be set to %s, got %s", workingDir, b.runConfig.WorkingDir)
}
} | explode_data.jsonl/28279 | {
"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,
6776,
3741,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
609,
3297,
90,
11161,
25,
609,
33,
9195,
22655,
1598,
2648,
25,
609,
3586,
10753,
22655,
11156,
33441,
25,
830,
630,
197,
21152,
6184,
1669,
3521,
676,
1837,
743,
15592... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCrossShardPoolv2RemoveBlockByHeight(t *testing.T) {
ResetCrossShardPoolTest()
removeSinceBlockHeight := make(map[byte]uint64)
fromShardID := byte(0)
toShardID := byte(1)
removeSinceBlockHeight[fromShardID] = 4
crossShardPoolMapTest[toShardID].validPool[fromShardID] = append(crossShardPoolMapTest[toShardID].validPool[fromShardID], crossShardBlock2)
crossShardPoolMapTest[toShardID].validPool[fromShardID] = append(crossShardPoolMapTest[toShardID].validPool[fromShardID], crossShardBlock5)
crossShardPoolMapTest[toShardID].pendingPool[fromShardID] = append(crossShardPoolMapTest[toShardID].pendingPool[fromShardID], crossShardBlock3)
crossShardPoolMapTest[toShardID].pendingPool[fromShardID] = append(crossShardPoolMapTest[toShardID].pendingPool[fromShardID], crossShardBlock6)
if len(crossShardPoolMapTest[toShardID].pendingPool[fromShardID]) != 2 {
t.Fatalf("expect pending pool has two block but get %+v", len(crossShardPoolMapTest[toShardID].pendingPool[fromShardID]))
}
if len(crossShardPoolMapTest[toShardID].validPool[fromShardID]) != 2 {
t.Fatalf("expect valid pool has two block but get %+v", len(crossShardPoolMapTest[toShardID].validPool[fromShardID]))
}
crossShardPoolMapTest[toShardID].removeBlockByHeight(removeSinceBlockHeight)
if len(crossShardPoolMapTest[toShardID].pendingPool[fromShardID]) != 1 {
t.Fatalf("expect pending pool has two block but get %+v", len(crossShardPoolMapTest[toShardID].pendingPool[fromShardID]))
}
if len(crossShardPoolMapTest[toShardID].validPool[fromShardID]) != 1 {
t.Fatalf("expect valid pool has two block but get %+v", len(crossShardPoolMapTest[toShardID].validPool[fromShardID]))
}
if crossShardPoolMapTest[toShardID].pendingPool[fromShardID][0].Header.Height != 6 {
t.Fatalf("expect pending pool has block 6 but get %+v", crossShardPoolMapTest[toShardID].pendingPool[fromShardID][0].Header.Height)
}
if crossShardPoolMapTest[toShardID].validPool[fromShardID][0].Header.Height != 5 {
t.Fatalf("expect valid pool has block 5 but get %+v", crossShardPoolMapTest[toShardID].validPool[fromShardID][0].Header.Height)
}
} | explode_data.jsonl/74592 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 784
} | [
2830,
3393,
28501,
2016,
567,
10551,
85,
17,
13021,
4713,
1359,
3640,
1155,
353,
8840,
836,
8,
341,
197,
14828,
28501,
2016,
567,
10551,
2271,
741,
47233,
12549,
4713,
3640,
1669,
1281,
9147,
58,
3782,
60,
2496,
21,
19,
340,
42727,
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... | 7 |
func TestShouldHashSHA512Password(t *testing.T) {
hash, err := HashPassword("password", "aFr56HjK3DrB8t3S", HashingAlgorithmSHA512, 50000, 0, 0, 0, 16)
assert.NoError(t, err)
code, parameters, salt, hash, _ := crypt.DecodeSettings(hash)
assert.Equal(t, "6", code)
assert.Equal(t, "aFr56HjK3DrB8t3S", salt)
assert.Equal(t, "zhPQiS85cgBlNhUKKE6n/AHMlpqrvYSnSL3fEVkK0yHFQ.oFFAd8D4OhPAy18K5U61Z2eBhxQXExGU/eknXlY1", hash)
assert.Equal(t, schema.DefaultPasswordSHA512Configuration.Iterations, parameters.GetInt("rounds", HashingDefaultSHA512Iterations))
} | explode_data.jsonl/40164 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
14996,
6370,
33145,
20,
16,
17,
4876,
1155,
353,
8840,
836,
8,
341,
50333,
11,
1848,
1669,
6531,
4876,
445,
3833,
497,
330,
64,
22560,
20,
21,
39,
73,
42,
18,
8847,
33,
23,
83,
18,
50,
497,
6531,
287,
27847,
33145,
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 TestAdditionalCIDR(t *testing.T) {
runTestAWS(t, "additionalcidr.example.com", "additional_cidr", "v1alpha3", false, 3, true, false, nil)
runTestCloudformation(t, "additionalcidr.example.com", "additional_cidr", "v1alpha2", false, nil)
} | explode_data.jsonl/17506 | {
"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,
29019,
54146,
49,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
36136,
1155,
11,
330,
35499,
20558,
81,
7724,
905,
497,
330,
35499,
68699,
81,
497,
330,
85,
16,
7141,
18,
497,
895,
11,
220,
18,
11,
830,
11,
895,
11,
2092,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_StrStrMap_Batch(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
m := gmap.NewStrStrMap()
m.Sets(map[string]string{"a": "a", "b": "b", "c": "c"})
t.Assert(m.Map(), map[string]string{"a": "a", "b": "b", "c": "c"})
m.Removes([]string{"a", "b"})
t.Assert(m.Map(), map[string]string{"c": "c"})
})
} | explode_data.jsonl/36007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
46171,
2580,
2227,
1668,
754,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
2109,
1669,
342,
2186,
7121,
2580,
2580,
2227,
2822,
197,
2109,
808,
1415,
9147,
14032,
30953... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue20575(t *testing.T) {
db := newTestDB(t, "people")
defer closeDB(t, db)
tx, err := db.Begin()
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
_, err = tx.QueryContext(ctx, "SELECT|people|age,name|")
if err != nil {
t.Fatal(err)
}
// Do not close Rows from QueryContext.
err = tx.Rollback()
if err != nil {
t.Fatal(err)
}
select {
default:
case <-ctx.Done():
t.Fatal("timeout: failed to rollback query without closing rows:", ctx.Err())
}
} | explode_data.jsonl/16018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 225
} | [
2830,
3393,
42006,
17,
15,
20,
22,
20,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
501,
2271,
3506,
1155,
11,
330,
16069,
1138,
16867,
3265,
3506,
1155,
11,
2927,
692,
46237,
11,
1848,
1669,
2927,
28467,
741,
743,
1848,
961,
2092,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleOrderByMultiDirection(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
{
`SELECT col FROM tbl order by col desc, col2 asc`,
},
{
`SELECT col FROM tbl order by col, col2`,
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleOrderByMultiDirection()
if rule.Item != "KEY.008" {
t.Error("Rule not match:", rule.Item, "Expect : KEY.008")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleOrderByMultiDirection()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
11337,
34605,
20358,
9268,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
515,
298,
197,
63,
4858,
1375,
4295,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStepper_Before(t *testing.T) {
st := Stepper{
N: 1,
U: Unum,
}
val, err := st.Before(2)
assert.NoError(t, err)
assert.Equal(t, 1, val)
} | explode_data.jsonl/78068 | {
"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,
20903,
6922,
1668,
4642,
1155,
353,
8840,
836,
8,
341,
18388,
1669,
3360,
6922,
515,
197,
18317,
25,
220,
16,
345,
197,
15980,
25,
1230,
372,
345,
197,
532,
19302,
11,
1848,
1669,
357,
31153,
7,
17,
340,
6948,
35699,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDelimiterRegexRegex(t *testing.T) {
delim := delimiterRegexp("--\\*")
tokens := Tokenize("-*--*---**---", delim)
if delim.str != nil ||
tokens[0].text.ToString() != "-*--*" ||
tokens[1].text.ToString() != "---*" ||
tokens[2].text.ToString() != "*---" {
t.Errorf("%s %d", tokens, len(tokens))
}
} | explode_data.jsonl/40863 | {
"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,
91098,
32464,
32464,
1155,
353,
8840,
836,
8,
341,
2698,
39795,
1669,
29020,
3477,
4580,
21549,
3422,
9,
1138,
3244,
9713,
1669,
9660,
551,
13645,
9,
313,
9,
4421,
334,
4421,
497,
63209,
340,
743,
63209,
9528,
961,
2092,
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... | 5 |
func TestGocloak_LoginAdmin(t *testing.T) {
t.Parallel()
cfg := GetConfig(t)
client := NewClientWithDebug(t)
_, err := client.LoginAdmin(
cfg.Admin.UserName,
cfg.Admin.Password,
cfg.Admin.Realm)
FailIfErr(t, err, "LoginAdmin failed")
} | explode_data.jsonl/79520 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
38,
509,
385,
585,
79232,
7210,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
1669,
2126,
2648,
1155,
340,
25291,
1669,
1532,
2959,
2354,
7939,
1155,
340,
197,
6878,
1848,
1669,
2943,
32499,
7210,
1006,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Service_Echo(t *testing.T) {
bkoff := backoff.NewExponentialBackOff()
bkoff.MaxElapsedTime = time.Second * 15
err := backoff.Retry(func() error {
logger, _ := test.NewNullLogger()
logger.SetLevel(logrus.DebugLevel)
c := service.NewContainer(logger)
c.Register(ID, &Service{})
err := c.Init(&testCfg{httpCfg: `{
"enable": true,
"address": ":6536",
"maxRequestSize": 1024,
"uploads": {
"dir": ` + tmpDir() + `,
"forbid": []
},
"workers":{
"command": "php ../../tests/http/client.php echo pipes",
"relay": "pipes",
"pool": {
"numWorkers": 1,
"allocateTimeout": 10000000,
"destroyTimeout": 10000000
}
}
}`})
if err != nil {
return err
}
s, st := c.Get(ID)
assert.NotNil(t, s)
assert.Equal(t, service.StatusOK, st)
// should do nothing
s.(*Service).Stop()
go func() {
err := c.Serve()
if err != nil {
t.Errorf("serve error: %v", err)
}
}()
time.Sleep(time.Millisecond * 100)
req, err := http.NewRequest("GET", "http://localhost:6536?hello=world", nil)
if err != nil {
c.Stop()
return err
}
r, err := http.DefaultClient.Do(req)
if err != nil {
c.Stop()
return err
}
b, err := ioutil.ReadAll(r.Body)
if err != nil {
c.Stop()
return err
}
assert.Equal(t, 201, r.StatusCode)
assert.Equal(t, "WORLD", string(b))
err = r.Body.Close()
if err != nil {
c.Stop()
return err
}
c.Stop()
return nil
}, bkoff)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/34498 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 718
} | [
2830,
3393,
52548,
2089,
958,
1155,
353,
8840,
836,
8,
341,
2233,
74,
1847,
1669,
1182,
1847,
7121,
840,
59825,
3707,
4596,
741,
2233,
74,
1847,
14535,
98483,
284,
882,
32435,
353,
220,
16,
20,
271,
9859,
1669,
1182,
1847,
2013,
15149... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSyncConfig(t *testing.T) {
var testcases = []struct {
name string
oldRes []common.Resource
newRes []common.Resource
expect []common.Resource
}{
{
name: "empty",
oldRes: []common.Resource{},
newRes: []common.Resource{},
expect: []common.Resource{},
},
{
name: "append",
oldRes: []common.Resource{},
newRes: []common.Resource{
{
Name: "res",
Type: "t",
},
},
expect: []common.Resource{
{
Name: "res",
Type: "t",
State: "free",
},
},
},
{
name: "should not have a type change",
oldRes: []common.Resource{
{
Name: "res",
Type: "t",
},
},
newRes: []common.Resource{
{
Name: "res",
Type: "d",
},
},
expect: []common.Resource{
{
Name: "res",
Type: "t",
},
},
},
{
name: "delete",
oldRes: []common.Resource{
{
Name: "res",
Type: "t",
},
},
newRes: []common.Resource{},
expect: []common.Resource{},
},
{
name: "delete busy",
oldRes: []common.Resource{
{
Name: "res",
Type: "t",
State: "busy",
Owner: "o",
},
},
newRes: []common.Resource{},
expect: []common.Resource{
{
Name: "res",
Type: "t",
State: "busy",
Owner: "o",
},
},
},
{
name: "append and delete",
oldRes: []common.Resource{
{
Name: "res-1",
Type: "t",
},
},
newRes: []common.Resource{
{
Name: "res-2",
Type: "t",
},
},
expect: []common.Resource{
{
Name: "res-2",
Type: "t",
State: "free",
},
},
},
{
name: "append and delete busy",
oldRes: []common.Resource{
{
Name: "res-1",
Type: "t",
State: "busy",
Owner: "o",
},
},
newRes: []common.Resource{
{
Name: "res-2",
Type: "t",
},
},
expect: []common.Resource{
{
Name: "res-1",
Type: "t",
State: "busy",
Owner: "o",
},
{
Name: "res-2",
Type: "t",
State: "free",
},
},
},
{
name: "append/delete mixed type",
oldRes: []common.Resource{
{
Name: "res-1",
Type: "t",
},
},
newRes: []common.Resource{
{
Name: "res-2",
Type: "t",
},
{
Name: "res-3",
Type: "t2",
},
},
expect: []common.Resource{
{
Name: "res-2",
Type: "t",
State: "free",
},
{
Name: "res-3",
Type: "t2",
State: "free",
},
},
},
}
for _, tc := range testcases {
c := MakeTestRanch(tc.oldRes)
c.syncConfigHelper(tc.newRes)
if !reflect.DeepEqual(c.Resources, tc.expect) {
t.Errorf("Test %v: got %v, expect %v", tc.name, c.Resources, tc.expect)
}
}
} | explode_data.jsonl/12951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1571
} | [
2830,
3393,
12154,
2648,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
23910,
284,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
61828,
1061,
3056,
5464,
20766,
198,
197,
8638,
1061,
3056,
5464,
20766,
198,
197,
24952,
3056,
5464,
20766,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecode(t *testing.T) {
t.Run("int", func(t *testing.T) {
var x int
err := conf.DecodeValues([]string{"10"}, conf.IntType, &x)
assert.NoError(t, err)
assert.Equal(t, 10, x)
err = conf.DecodeValues([]string{"10m"}, conf.DurationType, &x)
assert.NoError(t, err)
assert.Equal(t, int(time.Minute*10), x)
})
t.Run("float", func(t *testing.T) {
var x float64
err := conf.DecodeValues([]string{"10.2"}, conf.FloatType, &x)
assert.NoError(t, err)
assert.Equal(t, 10.2, x)
})
t.Run("bool", func(t *testing.T) {
var x bool
err := conf.DecodeValues([]string{"yes"}, conf.BoolType, &x)
assert.NoError(t, err)
assert.Equal(t, true, x)
})
t.Run("interface", func(t *testing.T) {
var x interface{}
err := conf.DecodeValues([]string{"yes"}, conf.BoolType, &x)
assert.NoError(t, err)
assert.Equal(t, true, x)
x = nil
err = conf.DecodeValues([]string{"100"}, conf.IntType, &x)
assert.NoError(t, err)
assert.Equal(t, 100, x)
x = nil
err = conf.DecodeValues([]string{"1.0", "2.1", "3.2"}, conf.FloatSliceType, &x)
assert.NoError(t, err)
assert.Equal(t, []float64{1.0, 2.1, 3.2}, x)
x = nil
err = conf.DecodeValues([]string{"10m5s"}, conf.DurationType, &x)
assert.NoError(t, err)
assert.Equal(t, time.Minute*10+time.Second*5, x)
})
} | explode_data.jsonl/20303 | {
"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,
32564,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
396,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2405,
856,
526,
271,
197,
9859,
1669,
2335,
56372,
6227,
10556,
917,
4913,
16,
15,
14345,
2335,
7371,
929,
11,
609... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUpdateUserHashedPassword(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
password := "SuperSecurePass23!"
passwordHash := "$2a$10$CiS1iWVPUj7rQNdY6XW53.DmaPLsETIvmW2p0asp4Dqpofs10UL5W"
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
_, err := client.UpdateUserHashedPassword(th.BasicUser.Id, passwordHash)
require.NoError(t, err)
})
_, _, err := client.Login(th.BasicUser.Email, password)
require.NoError(t, err)
// Standard users should never be updating their passwords with already-
// hashed passwords.
resp, err := client.UpdateUserHashedPassword(th.BasicUser.Id, passwordHash)
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
} | explode_data.jsonl/47528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
4289,
1474,
6370,
291,
4876,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
25291,
1669,
270,
11716,
271,
58199,
1669,
330,
19284,
49813,
12187,
17,
18,
24734,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractCustomQueryParams(t *testing.T) {
testcases := []struct {
name string
config *mysql.Config
expectedParams map[string]string
expectedCustomParams map[string]string
expectedErr error
}{
{name: "nil config", expectedErr: ErrNilConfig},
{
name: "no params",
config: mysql.NewConfig(),
expectedCustomParams: map[string]string{},
},
{
name: "no custom params",
config: &mysql.Config{Params: map[string]string{"hello": "world"}},
expectedParams: map[string]string{"hello": "world"},
expectedCustomParams: map[string]string{},
},
{
name: "one param, one custom param",
config: &mysql.Config{
Params: map[string]string{"hello": "world", "x-foo": "bar"},
},
expectedParams: map[string]string{"hello": "world"},
expectedCustomParams: map[string]string{"x-foo": "bar"},
},
{
name: "multiple params, multiple custom params",
config: &mysql.Config{
Params: map[string]string{
"hello": "world",
"x-foo": "bar",
"dead": "beef",
"x-cat": "hat",
},
},
expectedParams: map[string]string{"hello": "world", "dead": "beef"},
expectedCustomParams: map[string]string{"x-foo": "bar", "x-cat": "hat"},
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
customParams, err := extractCustomQueryParams(tc.config)
if tc.config != nil {
assert.Equal(t, tc.expectedParams, tc.config.Params,
"Expected config params have custom params properly removed")
}
assert.Equal(t, tc.expectedErr, err, "Expected errors to match")
assert.Equal(t, tc.expectedCustomParams, customParams,
"Expected custom params to be properly extracted")
})
}
} | explode_data.jsonl/47866 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 799
} | [
2830,
3393,
28959,
10268,
2859,
4870,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
25873,
2290,
353,
12272,
10753,
198,
197,
42400,
4870,
981,
2415,
14032,
30953,
198,
197,
42400,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLdFlagsFullTemplate(t *testing.T) {
run := time.Now().UTC()
commit := time.Now().AddDate(-1, 0, 0)
ctx := &context.Context{
Git: context.GitInfo{
CurrentTag: "v1.2.3",
Commit: "123",
CommitDate: commit,
},
Date: run,
Version: "1.2.3",
Env: map[string]string{"FOO": "123"},
}
artifact := &artifact.Artifact{Goarch: "amd64"}
flags, err := tmpl.New(ctx).WithArtifact(artifact, map[string]string{}).
Apply(`-s -w -X main.version={{.Version}} -X main.tag={{.Tag}} -X main.date={{.Date}} -X main.commit={{.Commit}} -X "main.foo={{.Env.FOO}}" -X main.time={{ time "20060102" }} -X main.arch={{.Arch}} -X main.commitDate={{.CommitDate}}`)
require.NoError(t, err)
require.Contains(t, flags, "-s -w")
require.Contains(t, flags, "-X main.version=1.2.3")
require.Contains(t, flags, "-X main.tag=v1.2.3")
require.Contains(t, flags, "-X main.commit=123")
require.Contains(t, flags, fmt.Sprintf("-X main.date=%d", run.Year()))
require.Contains(t, flags, fmt.Sprintf("-X main.time=%d", run.Year()))
require.Contains(t, flags, `-X "main.foo=123"`)
require.Contains(t, flags, `-X main.arch=amd64`)
require.Contains(t, flags, fmt.Sprintf("-X main.commitDate=%d", commit.Year()))
} | explode_data.jsonl/54153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 538
} | [
2830,
3393,
43,
67,
9195,
9432,
7275,
1155,
353,
8840,
836,
8,
341,
56742,
1669,
882,
13244,
1005,
21183,
741,
197,
17413,
1669,
882,
13244,
1005,
2212,
1916,
4080,
16,
11,
220,
15,
11,
220,
15,
692,
20985,
1669,
609,
2147,
9328,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInputService10ProtocolTestBlobAndTimestampShapesCase1(t *testing.T) {
sess := session.New()
svc := NewInputService10ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService10TestShapeInputService10TestCaseOperation1Input{
StructureParam: &InputService10TestShapeStructureShape{
B: []byte("foo"),
T: aws.Time(time.Unix(1422172800, 0)),
},
}
req, _ := svc.InputService10TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
restxml.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body := util.SortXML(r.Body)
awstesting.AssertXML(t, `<OperationRequest xmlns="https://foo/"><StructureParam xmlns="https://foo/"><b xmlns="https://foo/">Zm9v</b><t xmlns="https://foo/">2015-01-25T08:00:00Z</t></StructureParam></OperationRequest>`, util.Trim(string(body)), InputService10TestShapeInputService10TestCaseOperation1Input{})
// assert URL
awstesting.AssertURL(t, "https://test/2014-01-01/hostedzone", r.URL.String())
// assert headers
} | explode_data.jsonl/46480 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
2505,
1860,
16,
15,
20689,
2271,
37985,
3036,
20812,
92193,
4207,
16,
1155,
353,
8840,
836,
8,
341,
1903,
433,
1669,
3797,
7121,
741,
1903,
7362,
1669,
1532,
2505,
1860,
16,
15,
20689,
2271,
57223,
11,
609,
8635,
10753,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeltaDecode(t *testing.T) {
t.Skipf("TODO: investigate this test failure")
for _, test := range []struct {
name string
input []byte
want []uint32
}{
{
name: "small",
input: []byte{0x03, 0x43, 0x01, 0x00, 0x04, 0x06, 0x42, 0x27, 0x08},
want: []uint32{3, 4, 5, 6, 9, 10, 15, 17, 18, 333},
},
} {
t.Run(test.name, func(t *testing.T) {
buffer := make([]uint32, len(test.want), len(test.want)+32)
num := turbopfor.P4nd1dec32(test.input, buffer)
if got, want := num, len(test.input); got != want {
t.Fatalf("got %d, want %d", got, want)
}
if !reflect.DeepEqual(buffer, test.want) {
t.Fatalf("got %v, want %v", buffer, test.want)
}
})
}
} | explode_data.jsonl/42860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 335
} | [
2830,
3393,
20277,
32564,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
69,
445,
14732,
25,
19314,
419,
1273,
7901,
1138,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
3056,
3782,
198,
197,
50780,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccAWSS3BucketObject_defaultBucketSSE(t *testing.T) {
var obj1 s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
rInt := acctest.RandInt()
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSS3BucketObjectConfig_defaultBucketSSE(rInt, "stuff"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj1),
testAccCheckAWSS3BucketObjectBody(&obj1, "stuff"),
),
},
},
})
} | explode_data.jsonl/64975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
14603,
14419,
1220,
18,
36018,
1190,
9993,
36018,
50,
925,
1155,
353,
8840,
836,
8,
341,
2405,
2839,
16,
274,
18,
25618,
5097,
198,
50346,
675,
1669,
330,
8635,
643,
18,
38749,
5314,
6035,
698,
7000,
1072,
1669,
1613,
6788... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSpecificIndexer(t *testing.T) {
p := mock.TVIndexer{}
indexersCollection = []Indexer{p}
if _, err := GetIndexer("Unknown"); err == nil {
t.Error("Expected to have error when getting unknown indexer, got none")
}
if _, err := GetIndexer("TVIndexer"); err != nil {
t.Errorf("Got error while retrieving known indexer: %s", err.Error())
}
} | explode_data.jsonl/81820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
1949,
47514,
1552,
261,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
7860,
836,
53,
1552,
261,
16094,
26327,
388,
6482,
284,
3056,
1552,
261,
90,
79,
630,
743,
8358,
1848,
1669,
2126,
1552,
261,
445,
13790,
5038,
1848,
621,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPopulateCluster_IsolateMasters(t *testing.T) {
c := buildMinimalCluster()
c.Spec.IsolateMasters = fi.Bool(true)
cloud, err := BuildCloud(c)
if err != nil {
t.Fatalf("error from BuildCloud: %v", err)
}
err = PerformAssignments(c, cloud)
if err != nil {
t.Fatalf("error from PerformAssignments: %v", err)
}
full, err := mockedPopulateClusterSpec(c)
if err != nil {
t.Fatalf("Unexpected error from PopulateCluster: %v", err)
}
if fi.BoolValue(full.Spec.MasterKubelet.EnableDebuggingHandlers) != false {
t.Fatalf("Unexpected EnableDebuggingHandlers: %v", fi.BoolValue(full.Spec.MasterKubelet.EnableDebuggingHandlers))
}
if fi.BoolValue(full.Spec.MasterKubelet.ReconcileCIDR) != false {
t.Fatalf("Unexpected ReconcileCIDR: %v", fi.BoolValue(full.Spec.MasterKubelet.ReconcileCIDR))
}
} | explode_data.jsonl/75036 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 323
} | [
2830,
3393,
11598,
6334,
28678,
31879,
33066,
44,
14199,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1936,
88328,
28678,
741,
1444,
36473,
4506,
33066,
44,
14199,
284,
9136,
52497,
3715,
340,
197,
12361,
11,
1848,
1669,
7854,
16055,
1337,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestPutReflect(t *testing.T) {
var a1 int16 = 42
var a2 float32 = 9.2
expected := make([]byte, 6)
lex.PutInt16(expected, a1)
lex.PutFloat32(expected[2:], a2)
actual := make([]byte, 6)
lex.PutReflect(actual, a1)
lex.PutReflect(actual[2:], a2)
assert.True(t, bytes.Equal(expected, actual))
} | explode_data.jsonl/50145 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
19103,
72789,
1155,
353,
8840,
836,
8,
341,
2405,
264,
16,
526,
16,
21,
284,
220,
19,
17,
198,
2405,
264,
17,
2224,
18,
17,
284,
220,
24,
13,
17,
271,
42400,
1669,
1281,
10556,
3782,
11,
220,
21,
340,
197,
2571,
3982... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPipeWriteMultiThread(t *testing.T) {
pReader, pWriter := New(WithSizeLimit(0))
var errg errgroup.Group
for i := 0; i < 10; i++ {
errg.Go(func() error {
b := buf.New()
b.WriteString("abcd")
return pWriter.WriteMultiBuffer(buf.MultiBuffer{b})
})
}
time.Sleep(time.Millisecond * 100)
pWriter.Close()
errg.Wait()
b, err := pReader.ReadMultiBuffer()
common.Must(err)
if r := cmp.Diff(b[0].Bytes(), []byte{'a', 'b', 'c', 'd'}); r != "" {
t.Error(r)
}
} | explode_data.jsonl/987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
34077,
7985,
20358,
6855,
1155,
353,
8840,
836,
8,
341,
3223,
5062,
11,
281,
6492,
1669,
1532,
7,
2354,
1695,
16527,
7,
15,
4390,
2405,
1848,
70,
1848,
4074,
5407,
198,
2023,
600,
1669,
220,
15,
26,
600,
366,
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 |
func TestGetActionStr(t *testing.T) {
tt := []struct {
statement string
actionStr string
isError bool
}{
{
statement: "create table t (id int primary key)",
actionStr: sqlparser.CreateStr,
},
{
statement: "alter table t drop column c",
actionStr: sqlparser.AlterStr,
},
{
statement: "drop table t",
actionStr: sqlparser.DropStr,
},
{
statement: "rename table t to t2",
isError: true,
},
}
for _, ts := range tt {
t.Run(ts.statement, func(t *testing.T) {
onlineDDL := &OnlineDDL{SQL: ts.statement}
_, actionStr, err := onlineDDL.GetActionStr()
if ts.isError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
assert.Equal(t, actionStr, ts.actionStr)
}
})
}
} | explode_data.jsonl/42826 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
1949,
2512,
2580,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
89566,
914,
198,
197,
38933,
2580,
914,
198,
197,
19907,
1454,
256,
1807,
198,
197,
59403,
197,
197,
515,
298,
89566,
25,
330,
3182,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAmount(t *testing.T) {
tt := test.Start(t)
defer tt.Finish()
action := makeTestAction()
result := action.GetAmount("minus_one")
tt.Assert.NoError(action.Err)
tt.Assert.Equal(xdr.Int64(-10000000), result)
result = action.GetAmount("zero")
tt.Assert.NoError(action.Err)
tt.Assert.Equal(xdr.Int64(0), result)
result = action.GetAmount("two")
tt.Assert.NoError(action.Err)
tt.Assert.Equal(xdr.Int64(20000000), result)
result = action.GetAmount("twenty")
tt.Assert.NoError(action.Err)
tt.Assert.Equal(xdr.Int64(200000000), result)
} | explode_data.jsonl/554 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
10093,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
1273,
12101,
1155,
340,
16867,
17853,
991,
18176,
741,
38933,
1669,
1281,
2271,
2512,
2822,
9559,
1669,
1917,
2234,
10093,
445,
38365,
11667,
1138,
3244,
83,
11711,
35699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCommandNoEnvFileNoError(t *testing.T) {
tmp := os.TempDir()
cmd := cli.NewCommand("unit test")
cmd.SetArgs([]string{"-c", path.Join(tmp, ".rr.yaml"), "--dotenv", path.Join(tmp, ".env")})
var executed bool
f, err := os.Create(path.Join(tmp, ".env"))
require.NoError(t, err)
f2, err := os.Create(path.Join(tmp, ".rr.yaml"))
require.NoError(t, err)
defer func() {
_ = f.Close()
_ = f2.Close()
}()
if cmd.Run == nil { // override "Run" property for test (if it was not set)
cmd.Run = func(cmd *cobra.Command, args []string) {
executed = true
}
}
assert.NoError(t, cmd.Execute())
assert.True(t, executed)
t.Cleanup(func() {
_ = os.RemoveAll(path.Join(tmp, ".env"))
_ = os.RemoveAll(path.Join(tmp, ".rr.yaml"))
})
} | explode_data.jsonl/17539 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 319
} | [
2830,
3393,
4062,
2753,
14359,
1703,
2753,
1454,
1155,
353,
8840,
836,
8,
341,
20082,
1669,
2643,
65009,
6184,
2822,
25920,
1669,
21348,
7121,
4062,
445,
3843,
1273,
1138,
25920,
4202,
4117,
10556,
917,
4913,
12,
66,
497,
1815,
22363,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAPIServiceResourceErrorActionable(t *testing.T) {
tests := []struct {
name string
errs []error
actionable bool
}{
{
name: "Nil/Actionable",
errs: nil,
actionable: true,
},
{
name: "Empty/Actionable",
errs: nil,
actionable: true,
},
{
name: "Error/Actionable",
errs: []error{fmt.Errorf("err-a")},
actionable: true,
},
{
name: "Errors/Actionable",
errs: []error{fmt.Errorf("err-a"), fmt.Errorf("err-b")},
actionable: true,
},
{
name: "ContainsUnadoptable/NotActionable",
errs: []error{fmt.Errorf("err-a"), olmerrors.UnadoptableError{}},
actionable: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
op := &Operator{}
aggregate := utilerrors.NewAggregate(tt.errs)
require.Equal(t, tt.actionable, op.apiServiceResourceErrorActionable(aggregate))
})
}
} | explode_data.jsonl/31216 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 476
} | [
2830,
3393,
2537,
95125,
4783,
1454,
2512,
480,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
9859,
82,
981,
3056,
841,
198,
197,
38933,
480,
1807,
198,
197,
59403,
197,
197,
515,
298,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMapProxy_GetAllWithNilKeys(t *testing.T) {
_, err := mp.GetAll(nil)
AssertErrorNotNil(t, err, "GetAll did not return an error for nil keys")
mp.Clear()
} | explode_data.jsonl/57023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
2227,
16219,
13614,
2403,
2354,
19064,
8850,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
10490,
45732,
27907,
340,
18017,
1454,
96144,
1155,
11,
1848,
11,
330,
1949,
2403,
1521,
537,
470,
458,
1465,
369,
2092,
6894,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEffectiveProxyConfig(t *testing.T) {
cases := []struct {
name string
configs []config.Config
defaultConfig *meshconfig.ProxyConfig
proxy *NodeMetadata
expected *meshconfig.ProxyConfig
}{
{
name: "CR applies to matching namespace",
configs: []config.Config{
newProxyConfig("ns", "test-ns",
&v1beta1.ProxyConfig{
Concurrency: v(3),
}),
},
proxy: newMeta("test-ns", nil, nil),
expected: &meshconfig.ProxyConfig{Concurrency: v(3)},
},
{
name: "CR takes precedence over meshConfig.defaultConfig",
configs: []config.Config{
newProxyConfig("ns", istioRootNamespace,
&v1beta1.ProxyConfig{
Concurrency: v(3),
}),
},
defaultConfig: &meshconfig.ProxyConfig{Concurrency: v(2)},
proxy: newMeta("bar", nil, nil),
expected: &meshconfig.ProxyConfig{Concurrency: v(3)},
},
{
name: "workload matching CR takes precedence over namespace matching CR",
configs: []config.Config{
newProxyConfig("workload", "test-ns",
&v1beta1.ProxyConfig{
Selector: selector(map[string]string{
"test": "selector",
}),
Concurrency: v(3),
}),
newProxyConfig("ns", "test-ns",
&v1beta1.ProxyConfig{
Concurrency: v(2),
}),
},
proxy: newMeta("test-ns", map[string]string{"test": "selector"}, nil),
expected: &meshconfig.ProxyConfig{Concurrency: v(3)},
},
{
name: "matching workload CR takes precedence over annotation",
configs: []config.Config{
newProxyConfig("workload", "test-ns",
&v1beta1.ProxyConfig{
Selector: selector(map[string]string{
"test": "selector",
}),
Concurrency: v(3),
}),
},
proxy: newMeta(
"test-ns",
map[string]string{
"test": "selector",
}, map[string]string{
annotation.ProxyConfig.Name: "{ \"concurrency\": 5 }",
}),
expected: &meshconfig.ProxyConfig{Concurrency: v(3)},
},
{
name: "CR in other namespaces get ignored",
configs: []config.Config{
newProxyConfig("ns", "wrong-ns",
&v1beta1.ProxyConfig{
Concurrency: v(1),
}),
newProxyConfig("workload", "wrong-ns",
&v1beta1.ProxyConfig{
Selector: selector(map[string]string{
"test": "selector",
}),
Concurrency: v(2),
}),
newProxyConfig("global", istioRootNamespace,
&v1beta1.ProxyConfig{
Concurrency: v(3),
}),
},
proxy: newMeta("test-ns", map[string]string{"test": "selector"}, nil),
expected: &meshconfig.ProxyConfig{Concurrency: v(3)},
},
{
name: "multiple matching workload CRs, oldest applies",
configs: []config.Config{
setCreationTimestamp(newProxyConfig("workload-a", "test-ns",
&v1beta1.ProxyConfig{
Selector: selector(map[string]string{
"test": "selector",
}),
EnvironmentVariables: map[string]string{
"A": "1",
},
}), now),
setCreationTimestamp(newProxyConfig("workload-b", "test-ns",
&v1beta1.ProxyConfig{
Selector: selector(map[string]string{
"test": "selector",
}),
EnvironmentVariables: map[string]string{
"B": "2",
},
}), now.Add(time.Hour)),
setCreationTimestamp(newProxyConfig("workload-c", "test-ns",
&v1beta1.ProxyConfig{
Selector: selector(map[string]string{
"test": "selector",
}),
EnvironmentVariables: map[string]string{
"C": "3",
},
}), now.Add(time.Hour)),
},
proxy: newMeta(
"test-ns",
map[string]string{
"test": "selector",
}, map[string]string{}),
expected: &meshconfig.ProxyConfig{ProxyMetadata: map[string]string{
"A": "1",
}},
},
{
name: "multiple matching namespace CRs, oldest applies",
configs: []config.Config{
setCreationTimestamp(newProxyConfig("workload-a", "test-ns",
&v1beta1.ProxyConfig{
EnvironmentVariables: map[string]string{
"A": "1",
},
}), now),
setCreationTimestamp(newProxyConfig("workload-b", "test-ns",
&v1beta1.ProxyConfig{
EnvironmentVariables: map[string]string{
"B": "2",
},
}), now.Add(time.Hour)),
setCreationTimestamp(newProxyConfig("workload-c", "test-ns",
&v1beta1.ProxyConfig{
EnvironmentVariables: map[string]string{
"C": "3",
},
}), now.Add(time.Hour)),
},
proxy: newMeta(
"test-ns",
map[string]string{}, map[string]string{}),
expected: &meshconfig.ProxyConfig{ProxyMetadata: map[string]string{
"A": "1",
}},
},
{
name: "no configured CR or default config",
proxy: newMeta("ns", nil, nil),
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
store := newProxyConfigStore(t, tc.configs)
m := &meshconfig.MeshConfig{
RootNamespace: istioRootNamespace,
DefaultConfig: tc.defaultConfig,
}
pcs, err := GetProxyConfigs(store, m)
if err != nil {
t.Fatalf("failed to list proxyconfigs: %v", err)
}
merged := pcs.EffectiveProxyConfig(
tc.proxy,
&meshconfig.MeshConfig{
RootNamespace: istioRootNamespace,
DefaultConfig: tc.defaultConfig,
})
pc := mesh.DefaultProxyConfig()
proto.Merge(&pc, tc.expected)
if diff := cmp.Diff(merged, &pc); diff != "" {
t.Fatalf("merged did not equal expected: %s", diff)
}
})
}
} | explode_data.jsonl/52375 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2476
} | [
2830,
3393,
67539,
16219,
2648,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
25873,
82,
981,
3056,
1676,
10753,
198,
197,
11940,
2648,
353,
23506,
1676,
75200,
2648,
198,
197,
197,
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 TestStructInfo(t *testing.T) {
expect := StructInfo{
Type: reflect.TypeOf(testStruct{}),
RawSchema: []byte("Field1\x00Field2\x00Foo\x00Bar\x00Astolfo"),
Fields: []StructField{
{
Type: reflect.TypeOf(""),
Kind: reflect.String,
Name: []byte("Field1"),
Size: 2 * unsafe.Sizeof(0),
Offset: 0,
},
{
Type: reflect.TypeOf(""),
Kind: reflect.String,
Name: []byte("Field2"),
Size: 2 * unsafe.Sizeof(0),
Offset: 2 * unsafe.Sizeof(0),
},
{
Type: reflect.TypeOf(int(0)),
Kind: reflect.Int,
Name: []byte("Foo"),
Size: unsafe.Sizeof(0),
Offset: 4 * unsafe.Sizeof(0),
},
{
Type: reflect.TypeOf(int(0)),
Kind: reflect.Int,
Name: []byte("Bar"),
Size: unsafe.Sizeof(0),
Offset: 5 * unsafe.Sizeof(0),
},
{
Type: reflect.TypeOf(anotherStruct{}),
Kind: reflect.Struct,
Name: []byte("Astolfo"),
Size: 2 * unsafe.Sizeof(0),
Offset: 6 * unsafe.Sizeof(0),
},
},
}
got := GetStructInfo(reflect.TypeOf(testStruct{}))
for _, ineq := range deep.Equal(&expect, got) {
t.Errorf("expect/got: %q", ineq)
}
} | explode_data.jsonl/9688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 586
} | [
2830,
3393,
9422,
1731,
1155,
353,
8840,
836,
8,
341,
24952,
1669,
16139,
1731,
515,
197,
27725,
25,
414,
8708,
73921,
8623,
9422,
6257,
1326,
197,
11143,
672,
8632,
25,
3056,
3782,
445,
1877,
16,
3462,
15,
15,
1877,
17,
3462,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetParametersFromSsmParameterStoreWithAllResolvedNoPaging(t *testing.T) {
parametersList := []string{}
expectedValues := map[string]SsmParameterInfo{}
for i := 0; i < maxParametersRetrievedFromSsm/2; i++ {
name := "name_" + strconv.Itoa(i)
key := ssmNonSecurePrefix + name
parametersList = append(parametersList, key)
expectedValues[key] = SsmParameterInfo{
Name: name,
Value: "value_" + name,
Type: "String",
}
}
serviceObject := newServiceMockedObjectWithExtraRecords(expectedValues)
log := log.DefaultLogger()
t.Log("Testing getParametersFromSsmParameterStore API for all parameters present without paging...")
retrievedValues, err := getParametersFromSsmParameterStore(&serviceObject, log, parametersList)
assert.Nil(t, err)
assert.True(t, reflect.DeepEqual(expectedValues, retrievedValues))
} | explode_data.jsonl/56723 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
1949,
9706,
3830,
50,
3563,
4971,
6093,
2354,
2403,
65394,
2753,
47,
4118,
1155,
353,
8840,
836,
8,
341,
67543,
852,
1669,
3056,
917,
16094,
42400,
6227,
1669,
2415,
14032,
60,
50,
3563,
4971,
1731,
31483,
2023,
600,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.