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 TestHead_Truncate(t *testing.T) {
h, err := NewHead(nil, nil, nil, 1000)
testutil.Ok(t, err)
defer h.Close()
h.initTime(0)
s1, _ := h.getOrCreate(1, labels.FromStrings("a", "1", "b", "1"))
s2, _ := h.getOrCreate(2, labels.FromStrings("a", "2", "b", "1"))
s3, _ := h.getOrCreate(3, labels.FromStrings("a", "1", "b", "2"))
s4, _ := h.getOrCreate(4, labels.FromStrings("a", "2", "b", "2", "c", "1"))
s1.chunks = []*memChunk{
{minTime: 0, maxTime: 999},
{minTime: 1000, maxTime: 1999},
{minTime: 2000, maxTime: 2999},
}
s2.chunks = []*memChunk{
{minTime: 1000, maxTime: 1999},
{minTime: 2000, maxTime: 2999},
{minTime: 3000, maxTime: 3999},
}
s3.chunks = []*memChunk{
{minTime: 0, maxTime: 999},
{minTime: 1000, maxTime: 1999},
}
s4.chunks = []*memChunk{}
// Truncation need not be aligned.
testutil.Ok(t, h.Truncate(1))
testutil.Ok(t, h.Truncate(2000))
testutil.Equals(t, []*memChunk{
{minTime: 2000, maxTime: 2999},
}, h.series.getByID(s1.ref).chunks)
testutil.Equals(t, []*memChunk{
{minTime: 2000, maxTime: 2999},
{minTime: 3000, maxTime: 3999},
}, h.series.getByID(s2.ref).chunks)
testutil.Assert(t, h.series.getByID(s3.ref) == nil, "")
testutil.Assert(t, h.series.getByID(s4.ref) == nil, "")
postingsA1, _ := index.ExpandPostings(h.postings.Get("a", "1"))
postingsA2, _ := index.ExpandPostings(h.postings.Get("a", "2"))
postingsB1, _ := index.ExpandPostings(h.postings.Get("b", "1"))
postingsB2, _ := index.ExpandPostings(h.postings.Get("b", "2"))
postingsC1, _ := index.ExpandPostings(h.postings.Get("c", "1"))
postingsAll, _ := index.ExpandPostings(h.postings.Get("", ""))
testutil.Equals(t, []uint64{s1.ref}, postingsA1)
testutil.Equals(t, []uint64{s2.ref}, postingsA2)
testutil.Equals(t, []uint64{s1.ref, s2.ref}, postingsB1)
testutil.Equals(t, []uint64{s1.ref, s2.ref}, postingsAll)
testutil.Assert(t, postingsB2 == nil, "")
testutil.Assert(t, postingsC1 == nil, "")
testutil.Equals(t, map[string]struct{}{
"": {}, // from 'all' postings list
"a": {},
"b": {},
"1": {},
"2": {},
}, h.symbols)
testutil.Equals(t, map[string]stringset{
"a": {"1": struct{}{}, "2": struct{}{}},
"b": {"1": struct{}{}},
"": {"": struct{}{}},
}, h.values)
} | explode_data.jsonl/38159 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1040
} | [
2830,
3393,
12346,
21038,
26900,
1155,
353,
8840,
836,
8,
341,
9598,
11,
1848,
1669,
1532,
12346,
27907,
11,
2092,
11,
2092,
11,
220,
16,
15,
15,
15,
340,
18185,
1314,
54282,
1155,
11,
1848,
340,
16867,
305,
10421,
2822,
9598,
8271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeciding_CanTransitionTo(t *testing.T) {
st := &deciding{}
require.Equal(t, stateNameDeciding, st.Name())
require.True(t, st.CanTransitionTo(&waiting{}))
require.True(t, st.CanTransitionTo(&done{}))
require.True(t, st.CanTransitionTo(&abandoning{}))
require.False(t, st.CanTransitionTo(&noOp{}))
require.False(t, st.CanTransitionTo(&start{}))
require.False(t, st.CanTransitionTo(&delivering{}))
require.False(t, st.CanTransitionTo(&arranging{}))
require.False(t, st.CanTransitionTo(&confirming{}))
require.False(t, st.CanTransitionTo(&deciding{}))
require.False(t, st.CanTransitionTo(&requesting{}))
} | explode_data.jsonl/66251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
4900,
6577,
920,
276,
21768,
1249,
1155,
353,
8840,
836,
8,
341,
18388,
1669,
609,
8169,
6577,
16094,
17957,
12808,
1155,
11,
1584,
675,
4900,
6577,
11,
357,
2967,
12367,
17957,
32443,
1155,
11,
357,
53280,
21768,
1249,
2099... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDecode(t *testing.T) {
for _, p := range pairs {
dbuf := make([]byte, StdEncoding.DecodedLen(len(p.encoded)))
count, end, err := StdEncoding.decode(dbuf, []byte(p.encoded))
testEqual(t, "Decode(%q) = error %v, want %v", p.encoded, err, os.Error(nil))
testEqual(t, "Decode(%q) = length %v, want %v", p.encoded, count, len(p.decoded))
if len(p.encoded) > 0 {
testEqual(t, "Decode(%q) = end %v, want %v", p.encoded, end, (p.encoded[len(p.encoded)-1] == '='))
}
testEqual(t, "Decode(%q) = %q, want %q", p.encoded,
string(dbuf[0:count]),
p.decoded)
}
} | explode_data.jsonl/43941 | {
"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,
32564,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
281,
1669,
2088,
13530,
341,
197,
20939,
1704,
1669,
1281,
10556,
3782,
11,
42517,
14690,
22442,
6737,
11271,
6901,
1295,
13,
19329,
5929,
197,
18032,
11,
835,
11,
1848,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMsiTrue(t *testing.T) {
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
SkipIfUnsupportedArch(t, c)
ip, port, err := c.Port(defaultPort)
if err != nil {
t.Fatal(err)
}
addr := msConnectionStringMsi(ip, port, true)
p := &SQLServer{}
_, err = p.Open(addr)
if err == nil {
t.Fatal("MSI should fail when not running in an Azure context.")
}
})
} | explode_data.jsonl/74117 | {
"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,
44,
6321,
2514,
1155,
353,
8840,
836,
8,
341,
2698,
74,
8840,
41288,
7957,
2271,
1155,
11,
32247,
11,
2915,
1155,
353,
8840,
836,
11,
272,
40204,
1944,
33672,
1731,
8,
341,
197,
7568,
13389,
2679,
41884,
18727,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAsPathAs4Trans4(t *testing.T) {
as := []uint16{65000, 4000, bgp.AS_TRANS, bgp.AS_TRANS, 40001}
params := []bgp.AsPathParamInterface{bgp.NewAsPathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, as)}
aspath := bgp.NewPathAttributeAsPath(params)
as4 := []uint32{400000, 300000, 40001}
as4param1 := bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, as4)
as5 := []uint32{10, 20, 30}
as4param2 := bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SET, as5)
param4s := []*bgp.As4PathParam{as4param1, as4param2}
as4path := bgp.NewPathAttributeAs4Path(param4s)
msg := bgp.NewBGPUpdateMessage(nil, []bgp.PathAttributeInterface{aspath, as4path}, nil).Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(msg)
assert.Equal(t, len(msg.PathAttributes), 1)
assert.Equal(t, len(msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value), 2)
assert.Equal(t, len(msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS), 4)
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[0], uint32(65000))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[1], uint32(400000))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[2], uint32(300000))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[0].(*bgp.As4PathParam).AS[3], uint32(40001))
assert.Equal(t, len(msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[1].(*bgp.As4PathParam).AS), 3)
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[1].(*bgp.As4PathParam).AS[0], uint32(10))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[1].(*bgp.As4PathParam).AS[1], uint32(20))
assert.Equal(t, msg.PathAttributes[0].(*bgp.PathAttributeAsPath).Value[1].(*bgp.As4PathParam).AS[2], uint32(30))
} | explode_data.jsonl/29052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 780
} | [
2830,
3393,
2121,
1820,
2121,
19,
3167,
19,
1155,
353,
8840,
836,
8,
341,
60451,
1669,
3056,
2496,
16,
21,
90,
21,
20,
15,
15,
15,
11,
220,
19,
15,
15,
15,
11,
8951,
79,
875,
50,
28953,
11,
8951,
79,
875,
50,
28953,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWorkspace_write(t *testing.T) {
testCases := map[string]struct {
elems []string
wantedPath string
wantedErr error
}{
"create file under nested directories": {
elems: []string{"webhook", "addons", "policy.yml"},
wantedPath: "/copilot/webhook/addons/policy.yml",
},
"create file under copilot directory": {
elems: []string{pipelineFileName},
wantedPath: "/copilot/pipeline.yml",
},
"return ErrFileExists if file already exists": {
elems: []string{"manifest.yml"},
wantedErr: &ErrFileExists{FileName: "/copilot/manifest.yml"},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
// GIVEN
fs := afero.NewMemMapFs()
utils := &afero.Afero{
Fs: fs,
}
utils.MkdirAll("/copilot", 0755)
utils.WriteFile("/copilot/manifest.yml", []byte{}, 0644)
ws := &Workspace{
workingDir: "/",
copilotDir: "/copilot",
fsUtils: utils,
}
// WHEN
actualPath, actualErr := ws.write(nil, tc.elems...)
// THEN
if tc.wantedErr != nil {
require.EqualError(t, actualErr, tc.wantedErr.Error(), "expected the same error")
} else {
require.Equal(t, tc.wantedPath, actualPath, "expected the same path")
}
})
}
} | explode_data.jsonl/30118 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 550
} | [
2830,
3393,
45981,
9165,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
7727,
39616,
3056,
917,
271,
197,
6692,
7566,
1820,
914,
198,
197,
6692,
7566,
7747,
220,
1465,
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,
1... | 2 |
func TestAssign(t *testing.T) {
is := assert.New(t)
result1 := Assign[string, int](map[string]int{"a": 1, "b": 2}, map[string]int{"b": 3, "c": 4})
is.Len(result1, 3)
is.Equal(result1, map[string]int{"a": 1, "b": 3, "c": 4})
} | explode_data.jsonl/52774 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
28933,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
2060,
7121,
1155,
692,
9559,
16,
1669,
31639,
14032,
11,
526,
9533,
2186,
14032,
63025,
4913,
64,
788,
220,
16,
11,
330,
65,
788,
220,
17,
2137,
2415,
14032,
63025,
4913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseBase(t *testing.T) {
tests := []struct {
in string
out string
ok bool
}{
{"en", "en", true},
{"EN", "en", true},
{"nld", "nl", true},
{"dut", "dut", true}, // bibliographic
{"aaj", "und", false}, // unknown
{"qaa", "qaa", true},
{"a", "und", false},
{"", "und", false},
{"aaaa", "und", false},
}
for i, tt := range tests {
x, err := ParseBase(tt.in)
if x.String() != tt.out || err == nil != tt.ok {
t.Errorf("%d:%s: was %s, %v; want %s, %v", i, tt.in, x, err == nil, tt.out, tt.ok)
}
if y, _, _ := Raw.Make(tt.out).Raw(); x != y {
t.Errorf("%d:%s: tag was %s; want %s", i, tt.in, x, y)
}
}
} | explode_data.jsonl/15833 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
14463,
3978,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
220,
914,
198,
197,
13967,
914,
198,
197,
59268,
220,
1807,
198,
197,
59403,
197,
197,
4913,
268,
497,
330,
268,
497,
830,
1583,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestBadSignature(t *testing.T) {
publicKey, err := LoadPublicKeyFromFile(publicKeyPEMFile)
require.NoError(t, err)
testData, err := ioutil.ReadFile(testDataFile)
require.NoError(t, err)
signatureBad, err := ioutil.ReadFile(signatureBadFile)
require.NoError(t, err)
verified := ed25519.Verify(publicKey, testData, signatureBad)
require.Equal(t, false, verified)
} | explode_data.jsonl/58516 | {
"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,
17082,
25088,
1155,
353,
8840,
836,
8,
341,
1219,
1592,
11,
1848,
1669,
8893,
61822,
43633,
31688,
1592,
1740,
44,
1703,
340,
17957,
35699,
1155,
11,
1848,
692,
18185,
1043,
11,
1848,
1669,
43144,
78976,
8623,
1043,
1703,
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... | 1 |
func TestWaitingTimeoutOnNilPolka(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
config := configSetup(t)
cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
height, round := cs1.Height, cs1.Round
timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
// start round
startTestRound(ctx, cs1, height, round)
ensureNewRound(t, newRoundCh, height, round)
signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.voteTimeout(round).Nanoseconds())
ensureNewRound(t, newRoundCh, height, round+1)
} | explode_data.jsonl/54284 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
42104,
7636,
1925,
19064,
14658,
4554,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
741,
25873,
1669,
2193,
21821,
1155,
692,
71899,
16,
11,
348,
778,
1669,
1281,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateJsonString(t *testing.T) {
type testCases struct {
Value string
ErrCount int
}
invalidCases := []testCases{
{
Value: `{0:"1"}`,
ErrCount: 1,
},
{
Value: `{'abc':1}`,
ErrCount: 1,
},
{
Value: `{"def":}`,
ErrCount: 1,
},
{
Value: `{"xyz":[}}`,
ErrCount: 1,
},
}
for _, tc := range invalidCases {
_, errors := validateJsonString(tc.Value, "json")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected %q to trigger a validation error.", tc.Value)
}
}
validCases := []testCases{
{
Value: ``,
ErrCount: 0,
},
{
Value: `{}`,
ErrCount: 0,
},
{
Value: `{"abc":["1","2"]}`,
ErrCount: 0,
},
}
for _, tc := range validCases {
_, errors := validateJsonString(tc.Value, "json")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected %q not to trigger a validation error.", tc.Value)
}
}
} | explode_data.jsonl/78584 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 458
} | [
2830,
3393,
17926,
5014,
703,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
37302,
2036,
341,
197,
47399,
262,
914,
198,
197,
197,
7747,
2507,
526,
198,
197,
630,
197,
11808,
37302,
1669,
3056,
1944,
37302,
515,
197,
197,
515,
298,
47399... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCombinedShortFlagArg(t *testing.T) {
a := New("test", "")
n := a.Flag("short", "").Short('s').Int()
_, err := a.Parse([]string{"-s10"})
assert.NoError(t, err)
assert.Equal(t, 10, *n)
} | explode_data.jsonl/74864 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
94268,
12472,
12135,
2735,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
445,
1944,
497,
14676,
9038,
1669,
264,
80911,
445,
8676,
497,
35229,
12472,
492,
82,
1823,
1072,
741,
197,
6878,
1848,
1669,
264,
8937,
10556,
917,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestManagerError(t *testing.T) {
tests := []struct {
in waddrmgr.ManagerError
want string
}{
// Manager level error.
{
waddrmgr.ManagerError{Description: "human-readable error"},
"human-readable error",
},
// Encapsulated database error.
{
waddrmgr.ManagerError{
Description: "failed to store master private " +
"key parameters",
ErrorCode: waddrmgr.ErrDatabase,
Err: fmt.Errorf("underlying db error"),
},
"failed to store master private key parameters: " +
"underlying db error",
},
// Encapsulated key chain error.
{
waddrmgr.ManagerError{
Description: "failed to derive extended key " +
"branch 0",
ErrorCode: waddrmgr.ErrKeyChain,
Err: fmt.Errorf("underlying error"),
},
"failed to derive extended key branch 0: underlying " +
"error",
},
// Encapsulated crypto error.
{
waddrmgr.ManagerError{
Description: "failed to decrypt account 0 " +
"private key",
ErrorCode: waddrmgr.ErrCrypto,
Err: fmt.Errorf("underlying error"),
},
"failed to decrypt account 0 private key: underlying " +
"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\ngot: %s\nwant: %s", i, result,
test.want)
continue
}
}
} | explode_data.jsonl/67913 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 568
} | [
2830,
3393,
2043,
1454,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
289,
6214,
48292,
58298,
1454,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
322,
10567,
2188,
1465,
624,
197,
197,
515,
298,
6692... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkload(t *testing.T) {
defer leaktest.AfterTest(t)()
c := newCLITest(cliTestParams{noServer: true})
defer c.cleanup()
out, err := c.RunWithCapture("workload init --help")
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out, `startrek`) {
t.Fatalf(`startrek workload failed to register got: %s`, out)
}
} | explode_data.jsonl/33203 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
6776,
1078,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
1444,
1669,
501,
3140,
952,
477,
70249,
2271,
4870,
90,
2152,
5475,
25,
830,
3518,
16867,
272,
87689,
2822,
13967,
11,
1848,
1669,
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 TestDecodeDataMessageAtsetDataFrame(t *testing.T) {
bin := []byte("payload")
r := bytes.NewReader(bin)
d := amf0.NewDecoder(r)
var v AMFConvertible
err := DataBodyDecoderFor("@setDataFrame")(r, d, &v)
assert.Nil(t, err)
assert.Equal(t, &NetStreamSetDataFrame{
Payload: bin,
}, v)
} | explode_data.jsonl/7720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
32564,
1043,
2052,
1655,
43891,
4369,
1155,
353,
8840,
836,
8,
341,
2233,
258,
1669,
3056,
3782,
445,
19427,
1138,
7000,
1669,
5820,
68587,
49669,
340,
2698,
1669,
1079,
69,
15,
7121,
20732,
2601,
692,
2405,
348,
6769,
37,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBatch(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db := setup(t)
defer s.Stopper().Stop()
b := &client.Batch{}
b.Get("aa")
b.Put("bb", "2")
if err := db.Run(context.TODO(), b); err != nil {
t.Fatal(err)
}
expected := map[string][]byte{
"aa": []byte(""),
"bb": []byte("2"),
}
checkResults(t, expected, b.Results)
} | explode_data.jsonl/20020 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
21074,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1903,
11,
2927,
1669,
6505,
1155,
340,
16867,
274,
7758,
18487,
1005,
10674,
2822,
2233,
1669,
609,
2972,
45791,
16094,
2233,
2234,
445,
530... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWeight_Hex(t *testing.T) {
assertEncodeToHex(t, []encodeToHexAssert{
{NewWeight(29), "0x1d00000000000000"},
})
} | explode_data.jsonl/5201 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 56
} | [
2830,
3393,
8295,
2039,
327,
1155,
353,
8840,
836,
8,
341,
6948,
32535,
1249,
20335,
1155,
11,
3056,
6180,
1249,
20335,
8534,
515,
197,
197,
90,
3564,
8295,
7,
17,
24,
701,
330,
15,
87,
16,
67,
15,
15,
15,
15,
15,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestIsGt(t *testing.T) {
validate := New()
myMap := map[string]string{}
errs := validate.Var(myMap, "gt=0")
NotEqual(t, errs, nil)
f := 1.23
errs = validate.Var(f, "gt=5")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gt")
var ui uint = 5
errs = validate.Var(ui, "gt=10")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gt")
i := true
PanicMatches(t, func() { _ = validate.Var(i, "gt") }, "Bad field type bool")
tm := time.Now().UTC()
tm = tm.Add(time.Hour * 24)
errs = validate.Var(tm, "gt")
Equal(t, errs, nil)
t2 := time.Now().UTC().Add(-time.Hour)
errs = validate.Var(t2, "gt")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gt")
type Test struct {
Now *time.Time `validate:"gt"`
}
s := &Test{
Now: &tm,
}
errs = validate.Struct(s)
Equal(t, errs, nil)
s = &Test{
Now: &t2,
}
errs = validate.Struct(s)
NotEqual(t, errs, nil)
AssertError(t, errs, "Test.Now", "Test.Now", "Now", "Now", "gt")
} | explode_data.jsonl/77310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 472
} | [
2830,
3393,
3872,
38,
83,
1155,
353,
8840,
836,
8,
341,
197,
7067,
1669,
1532,
741,
13624,
2227,
1669,
2415,
14032,
30953,
16094,
9859,
82,
1669,
9593,
87968,
13941,
2227,
11,
330,
5178,
28,
15,
1138,
197,
2623,
2993,
1155,
11,
70817,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSplitLines(t *testing.T) {
type scenario struct {
multilineString string
expected []string
}
scenarios := []scenario{
{
"",
[]string{},
},
{
"\n",
[]string{},
},
{
"hello world !\nhello universe !\n",
[]string{
"hello world !",
"hello universe !",
},
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, SplitLines(s.multilineString))
}
} | explode_data.jsonl/11569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
20193,
16794,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
2109,
494,
26560,
703,
914,
198,
197,
42400,
286,
3056,
917,
198,
197,
630,
29928,
60494,
1669,
3056,
61422,
515,
197,
197,
515,
298,
197,
39680,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRenameReservedUsername(t *testing.T) {
defer prepareTestEnv(t)()
reservedUsernames := []string{
".",
"..",
".well-known",
"admin",
"api",
"assets",
"attachments",
"avatar",
"avatars",
"captcha",
"commits",
"debug",
"error",
"explore",
"favicon.ico",
"ghost",
"issues",
"login",
"manifest.json",
"metrics",
"milestones",
"new",
"notifications",
"org",
"pulls",
"raw",
"repo",
"repo-avatars",
"robots.txt",
"search",
"serviceworker.js",
"ssh_info",
"swagger.v1.json",
"user",
"v2",
}
session := loginUser(t, "user2")
for _, reservedUsername := range reservedUsernames {
t.Logf("Testing username %s", reservedUsername)
req := NewRequestWithValues(t, "POST", "/user/settings", map[string]string{
"_csrf": GetCSRF(t, session, "/user/settings"),
"name": reservedUsername,
"email": "user2@example.com",
"language": "en-US",
})
resp := session.MakeRequest(t, req, http.StatusSeeOther)
req = NewRequest(t, "GET", test.RedirectURL(resp))
resp = session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t,
htmlDoc.doc.Find(".ui.negative.message").Text(),
i18n.Tr("en", "user.form.name_reserved", reservedUsername),
)
unittest.AssertNotExistsBean(t, &user_model.User{Name: reservedUsername})
}
} | explode_data.jsonl/28858 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 608
} | [
2830,
3393,
88757,
53003,
11115,
1155,
353,
8840,
836,
8,
341,
16867,
10549,
2271,
14359,
1155,
8,
2822,
10202,
2771,
1474,
11400,
1669,
3056,
917,
515,
197,
197,
3263,
756,
197,
197,
62923,
756,
197,
197,
3263,
9157,
21309,
756,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAWSCluster_DefaultAllowedCIDRBlocks(t *testing.T) {
g := NewWithT(t)
tests := []struct {
name string
beforeCluster *AWSCluster
afterCluster *AWSCluster
}{
{
name: "empty AllowedCIDRBlocks is defaulted to allow open ingress to bastion host",
beforeCluster: &AWSCluster{
Spec: AWSClusterSpec{},
},
afterCluster: &AWSCluster{
Spec: AWSClusterSpec{
Bastion: Bastion{
AllowedCIDRBlocks: []string{
"0.0.0.0/0",
},
},
},
},
},
{
name: "empty AllowedCIDRBlocks is kept if DisableIngressRules is true",
beforeCluster: &AWSCluster{
Spec: AWSClusterSpec{
Bastion: Bastion{
AllowedCIDRBlocks: []string{},
DisableIngressRules: true,
Enabled: true,
},
},
},
afterCluster: &AWSCluster{
Spec: AWSClusterSpec{
Bastion: Bastion{
AllowedCIDRBlocks: []string{},
DisableIngressRules: true,
Enabled: true,
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := context.TODO()
cluster := tt.beforeCluster.DeepCopy()
cluster.ObjectMeta = metav1.ObjectMeta{
GenerateName: "cluster-",
Namespace: "default",
}
g.Expect(testEnv.Create(ctx, cluster)).To(Succeed())
g.Expect(cluster.Spec.Bastion).To(Equal(tt.afterCluster.Spec.Bastion))
})
}
} | explode_data.jsonl/70927 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 689
} | [
2830,
3393,
14419,
3540,
75,
4993,
60336,
35382,
54146,
49,
29804,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
340,
78216,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
63234,
28678,
353,
14419,
3540,
75,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConvertToTektonParamSpecs(t *testing.T) {
tc := map[string]struct {
params []ParameterDefine
expectedParamSpec []tektonv1beta1.ParamSpec
}{
"params": {
params: []ParameterDefine{
{
Name: "array-param-spec",
DefaultArray: []string{"array-string1", "array-string2"},
Description: "ParamSpec with default array",
},
{
Name: "string-param-spec",
DefaultStr: "string",
Description: "ParamSpec with default string",
},
},
expectedParamSpec: []tektonv1beta1.ParamSpec{
{
Name: "array-param-spec",
Type: "array",
Description: "ParamSpec with default array",
Default: tektonv1beta1.NewArrayOrString("array-string1", "array-string2"),
},
{
Name: "string-param-spec",
Type: "string",
Description: "ParamSpec with default string",
Default: tektonv1beta1.NewArrayOrString("string"),
},
},
},
"nil": {
params: nil,
expectedParamSpec: nil,
},
}
for name, c := range tc {
t.Run(name, func(t *testing.T) {
paramSpec := ConvertToTektonParamSpecs(c.params)
require.Equal(t, c.expectedParamSpec, paramSpec)
})
}
} | explode_data.jsonl/46142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 571
} | [
2830,
3393,
12012,
1249,
55715,
777,
2001,
8327,
82,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
2415,
14032,
60,
1235,
341,
197,
25856,
310,
3056,
4971,
35338,
198,
197,
42400,
2001,
8327,
3056,
42713,
777,
85,
16,
19127,
16,
9580,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
s := v1.PodSpec{}
s.Containers = []v1.Container{
{
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("100m"),
},
},
},
}
rs := &extensionsv1beta1.ReplicaSet{
Spec: extensionsv1beta1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
},
},
Spec: s,
},
},
}
output := roundTrip(t, runtime.Object(rs))
rs2 := output.(*extensionsv1beta1.ReplicaSet)
defaultRequest := rs2.Spec.Template.Spec.Containers[0].Resources.Requests
requestValue := defaultRequest[v1.ResourceCPU]
if requestValue.String() != "0" {
t.Errorf("Expected 0 request value, got: %s", requestValue.String())
}
} | explode_data.jsonl/53702 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
3675,
1900,
3872,
2623,
1649,
2461,
18327,
15317,
1649,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
348,
16,
88823,
8327,
16094,
1903,
2451,
20568,
284,
3056,
85,
16,
33672,
515,
197,
197,
515,
298,
197,
11277,
25,
348,
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... | 2 |
func TestCancelMultipleMarginOrders(t *testing.T) {
TestSetRealOrderDefaults(t)
request := okgroup.CancelMultipleSpotOrdersRequest{
InstrumentID: spotCurrency,
OrderIDs: []int64{1, 2, 3, 4},
}
_, errs := o.CancelMultipleMarginOrders(request)
if len(errs) > 0 {
testStandardErrorHandling(t, errs[0])
}
} | explode_data.jsonl/30185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
9269,
32089,
21681,
24898,
1155,
353,
8840,
836,
8,
341,
73866,
1649,
12768,
4431,
16273,
1155,
340,
23555,
1669,
5394,
4074,
36491,
32089,
47049,
24898,
1900,
515,
197,
197,
56324,
915,
25,
7702,
26321,
345,
197,
197,
4431,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMessagerCacheOrder(t *testing.T) {
mc := newCache(10)
if !mc.Add(&MessageRow{
TimeNext: 1,
Epoch: 0,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row01")},
}) {
t.Fatal("Add returned false")
}
if !mc.Add(&MessageRow{
TimeNext: 2,
Epoch: 0,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row02")},
}) {
t.Fatal("Add returned false")
}
if !mc.Add(&MessageRow{
TimeNext: 2,
Epoch: 1,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row12")},
}) {
t.Fatal("Add returned false")
}
if !mc.Add(&MessageRow{
TimeNext: 1,
Epoch: 1,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row11")},
}) {
t.Fatal("Add returned false")
}
if !mc.Add(&MessageRow{
TimeNext: 3,
Epoch: 0,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row03")},
}) {
t.Fatal("Add returned false")
}
var rows []string
for i := 0; i < 5; i++ {
rows = append(rows, mc.Pop().Row[0].ToString())
}
want := []string{
"row03",
"row02",
"row01",
"row12",
"row11",
}
if !reflect.DeepEqual(rows, want) {
t.Errorf("Pop order: %+v, want %+v", rows, want)
}
} | explode_data.jsonl/24948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 540
} | [
2830,
3393,
84423,
1409,
8233,
4431,
1155,
353,
8840,
836,
8,
341,
97662,
1669,
501,
8233,
7,
16,
15,
340,
743,
753,
12887,
1904,
2099,
2052,
3102,
515,
197,
67567,
5847,
25,
220,
16,
345,
197,
197,
44338,
25,
262,
220,
15,
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... | 8 |
func TestGetListenerStatsTree(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleListenerGetStatsTree(t)
client := fake.ServiceClient()
actual, err := listeners.GetStats(client, "4ec89087-d057-4e2c-911f-60a3b47ee304").Extract()
if err != nil {
t.Fatalf("Unexpected Get error: %v", err)
}
th.CheckDeepEquals(t, ListenerStatsTree, *actual)
} | explode_data.jsonl/27555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
1949,
2743,
16635,
6533,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
197,
6999,
2743,
1949,
16635,
6533,
1155,
692,
25291,
1669,
12418,
13860,
2959,
741,
88814,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCreateVPC(t *testing.T) {
type args struct {
ctx context.Context
req service.CreateVPCRequest
}
tests := []struct {
name string
args args
wantVpcId string
wantErr bool
}{
{
name: "测试创建vpc",
args: args{
ctx: nil,
req: service.CreateVPCRequest{
Provider: "AlibabaCloud",
RegionId: "cn-qingdao",
VpcName: "vpc测试自动更新",
CidrBlock: "",
AK: "LTAI5t7qCv6L8ZFh3hzSYpSv",
},
},
wantVpcId: "",
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotVpcId, err := service.CreateVPC(tt.args.ctx, tt.args.req)
if (err != nil) != tt.wantErr {
t.Errorf("CreateVPC() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotVpcId == "" {
t.Errorf("CreateVPC() gotVpcId = %v, want %v", gotVpcId, tt.wantVpcId)
}
})
}
} | explode_data.jsonl/72639 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 483
} | [
2830,
3393,
4021,
53,
4872,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
20985,
2266,
9328,
198,
197,
24395,
2473,
7251,
53,
4872,
1900,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
31215,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSplitImageName(t *testing.T) {
tt := []struct {
in string
outImage string
outTag string
outError error
}{
{in: "", outImage: "", outTag: "", outError: fmt.Errorf("Failed to split image name ''")},
{in: "path/to/image", outImage: "path/to/image", outTag: "", outError: nil},
{in: "path/to/image:tag", outImage: "path/to/image", outTag: "tag", outError: nil},
{in: "https://my.registry.com/path/to/image:tag", outImage: "", outTag: "", outError: fmt.Errorf("Failed to split image name 'https://my.registry.com/path/to/image:tag'")},
}
for _, test := range tt {
i, tag, err := splitFullImageName(test.in)
assert.Equal(t, test.outImage, i, "Image value unexpected")
assert.Equal(t, test.outTag, tag, "Tag value unexpected")
assert.Equal(t, test.outError, err, "Error value not as expected")
}
} | explode_data.jsonl/37085 | {
"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,
20193,
1906,
675,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
17430,
981,
914,
198,
197,
13967,
1906,
914,
198,
197,
13967,
5668,
256,
914,
198,
197,
13967,
1454,
1465,
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... | 2 |
func TestIsSignatureContractBadNoCheckSig(t *testing.T) {
prog := make([]byte, 34)
prog[0] = byte(PUSHBYTES33)
assert.Equal(t, false, IsSignatureContract(prog))
assert.Equal(t, false, IsStandardContract(prog))
} | explode_data.jsonl/40582 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
3872,
25088,
14067,
17082,
2753,
3973,
47246,
1155,
353,
8840,
836,
8,
341,
197,
32992,
1669,
1281,
10556,
3782,
11,
220,
18,
19,
340,
197,
32992,
58,
15,
60,
284,
4922,
5304,
19518,
97849,
18,
18,
340,
6948,
12808,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestClusterMember(t *testing.T) {
membs := []*Member{
newTestMember(1, nil, "node1", nil),
newTestMember(2, nil, "node2", nil),
}
tests := []struct {
id types.ID
match bool
}{
{1, true},
{2, true},
{3, false},
}
for i, tt := range tests {
c := newTestCluster(membs)
m := c.Member(tt.id)
if g := m != nil; g != tt.match {
t.Errorf("#%d: find member = %v, want %v", i, g, tt.match)
}
if m != nil && m.ID != tt.id {
t.Errorf("#%d: id = %x, want %x", i, m.ID, tt.id)
}
}
} | explode_data.jsonl/52329 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
28678,
9366,
1155,
353,
8840,
836,
8,
341,
14145,
1279,
1669,
29838,
9366,
515,
197,
8638,
2271,
9366,
7,
16,
11,
2092,
11,
330,
3509,
16,
497,
2092,
1326,
197,
8638,
2271,
9366,
7,
17,
11,
2092,
11,
330,
3509,
17,
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... | 5 |
func TestEntryAddUntimedDifferentCutoverDifferentMetadata(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
var (
withPrepopulation = true
prePopulateData = testAggregationKeys
nowNanos = time.Now().UnixNano()
inputMetadatas = metadata.StagedMetadatas{
metadata.StagedMetadata{
CutoverNanos: nowNanos - 1000,
Tombstoned: false,
Metadata: metadata.Metadata{Pipelines: testDefaultPipelines},
},
metadata.StagedMetadata{
CutoverNanos: nowNanos - 10,
Tombstoned: false,
Metadata: metadata.Metadata{Pipelines: testNewPipelines},
},
metadata.StagedMetadata{
CutoverNanos: nowNanos + 100,
Tombstoned: false,
Metadata: metadata.Metadata{Pipelines: testPipelines},
},
}
expectedShouldAdd = true
expectedCutoverNanos = nowNanos - 10
expectedAggregationKeys = testNewAggregationKeys
lists *metricLists
)
deletedStoragePolicies := make(map[policy.StoragePolicy]struct{})
deletedStoragePolicies[testAggregationKeys[1].storagePolicy] = struct{}{}
deletedStoragePolicies[testAggregationKeys[2].storagePolicy] = struct{}{}
preAddFn := func(e *Entry, now *time.Time) {
*now = time.Unix(0, nowNanos)
e.hasDefaultMetadatas = false
e.cutoverNanos = nowNanos - 100
lists = e.lists
}
postAddFn := func(t *testing.T) {
require.Equal(t, 4, len(lists.lists))
expectedLengths := [][]int{{1, 1, 2}, {1, 2, 1}}
for i, keys := range [][]aggregationKey{testAggregationKeys, testNewAggregationKeys} {
for j := range keys {
listID := standardMetricListID{
resolution: keys[j].storagePolicy.Resolution().Window,
}.toMetricListID()
res, exists := lists.lists[listID]
require.True(t, exists)
list := res.(*standardMetricList)
require.Equal(t, expectedLengths[i][j], list.aggregations.Len())
for elem := list.aggregations.Front(); elem != nil; elem = elem.Next() {
checkElemTombstoned(t, elem.Value.(metricElem), deletedStoragePolicies)
}
}
}
}
testEntryAddUntimed(
t, ctrl, withPrepopulation, prePopulateData,
preAddFn, inputMetadatas, postAddFn, expectedShouldAdd,
expectedCutoverNanos, expectedAggregationKeys,
)
} | explode_data.jsonl/24221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 918
} | [
2830,
3393,
5874,
2212,
20250,
75485,
69123,
34,
1535,
423,
69123,
14610,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
2405,
2399,
197,
46948,
4703,
44441,
284,
830,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMemberRollOutsideWatchedNamespaceIsAlwaysAllowed(t *testing.T) {
roll := newMemberRoll("not-default", "not-watched")
validator, _, _ := createMemberRollValidatorTestFixture(smcp)
validator.namespaceFilter = "watched-namespace"
response := validator.Handle(ctx, createCreateRequest(roll))
assert.True(response.Allowed, "Expected validator to allow ServiceMeshMemberRoll whose namespace isn't watched", t)
} | explode_data.jsonl/70261 | {
"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,
9366,
32355,
41365,
14247,
291,
22699,
3872,
37095,
35382,
1155,
353,
8840,
836,
8,
341,
197,
1100,
1669,
501,
9366,
32355,
445,
1921,
13672,
497,
330,
1921,
2630,
34244,
1138,
197,
16112,
11,
8358,
716,
1669,
1855,
9366,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSettings(t *testing.T) {
RegisterFailHandler(Fail)
junitReporter := reporters.NewJUnitReporter("junit.xml")
RunSpecsWithDefaultAndCustomReporters(t, "Config Suite", []Reporter{junitReporter})
} | explode_data.jsonl/28609 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
6086,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
340,
12428,
3843,
52766,
1669,
19040,
7121,
56248,
52766,
445,
73,
3843,
9028,
1138,
85952,
8327,
16056,
3675,
3036,
10268,
10361,
388,
1155,
11,
330,
2648,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func Test_endpointHost(t *testing.T) {
type args struct {
h *zipkincore.Endpoint
}
tests := []struct {
name string
args args
want string
}{
{
name: "Host Found",
args: args{
h: &zipkincore.Endpoint{
Ipv4: 1234,
Port: 8888,
},
},
want: "0.0.4.210:8888",
},
{
name: "No Host",
args: args{
h: nil,
},
want: "0.0.0.0",
},
{
name: "int overflow zipkin uses an int16 type as an unsigned int 16.",
args: args{
h: &zipkincore.Endpoint{
Ipv4: 1234,
Port: -1,
},
},
want: "0.0.4.210:65535",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
e := endpoint{tt.args.h}
if got := e.Host(); got != tt.want {
t.Errorf("host() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/57264 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 426
} | [
2830,
3393,
36699,
9296,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
9598,
353,
9964,
7989,
2153,
90409,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
914,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCreateValidAutoCreateMasterPolicyBindings(t *testing.T) {
storage := makeTestStorage()
roleBinding := &authorizationapi.RoleBinding{
ObjectMeta: kapi.ObjectMeta{Name: "my-roleBinding"},
RoleRef: kapi.ObjectReference{Name: "admin", Namespace: bootstrappolicy.DefaultMasterAuthorizationNamespace},
}
ctx := kapi.WithUser(kapi.WithNamespace(kapi.NewContext(), "unittest"), &user.DefaultInfo{Name: "system:admin"})
obj, err := storage.Create(ctx, roleBinding)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
switch r := obj.(type) {
case *kapi.Status:
t.Errorf("Got back unexpected status: %#v", r)
case *authorizationapi.RoleBinding:
// expected case
default:
t.Errorf("Got unexpected type: %#v", r)
}
} | explode_data.jsonl/9641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 268
} | [
2830,
3393,
4021,
4088,
13253,
4021,
18041,
13825,
52843,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
1281,
2271,
5793,
741,
197,
5778,
15059,
1669,
609,
39554,
2068,
35955,
15059,
515,
197,
23816,
12175,
25,
595,
2068,
80222,
63121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUserGroupsPageArgs(t *testing.T) {
requests := []*http.Request{}
ts := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, getEmptyPageArgsResponse)
requests = append(requests, r)
}),
)
defer ts.Close()
duo := buildAdminClient(ts.URL, nil)
_, err := duo.GetUserGroups("DU3RP9I2WOC59VZX672N", func(values *url.Values) {
values.Set("limit", "200")
values.Set("offset", "1")
return
})
if err != nil {
t.Errorf("Encountered unexpected error: %s", err)
}
if len(requests) != 1 {
t.Errorf("Expected there to be one request, found %d", len(requests))
}
request := requests[0]
request_query := request.URL.Query()
if request_query["limit"][0] != "200" {
t.Errorf("Expected to see a limit of 100 in request, bug got %s", request_query["limit"])
}
if request_query["offset"][0] != "1" {
t.Errorf("Expected to see an offset of 0 in request, bug got %s", request_query["offset"])
}
} | explode_data.jsonl/61407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
1949,
1474,
22173,
2665,
4117,
1155,
353,
8840,
836,
8,
341,
23555,
82,
1669,
29838,
1254,
9659,
16094,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
1006,
197,
28080,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEndToEnd(t *testing.T) {
RegisterFailHandler(Fail)
SetDefaultEventuallyTimeout(1 * time.Minute)
SetDefaultEventuallyPollingInterval(1 * time.Second)
SetDefaultConsistentlyDuration(30 * time.Second)
SetDefaultConsistentlyPollingInterval(1 * time.Second)
// always configure a junit report when ARTIFACTS_DIR has been set
if artifactsDir := os.Getenv("ARTIFACTS_DIR"); artifactsDir != "" {
junitReporter := reporters.NewJUnitReporter(path.Join(artifactsDir, junitDir, fmt.Sprintf("junit_e2e_%02d.xml", config.GinkgoConfig.ParallelNode)))
RunSpecsWithDefaultAndCustomReporters(t, "End-to-end", []Reporter{junitReporter})
} else if junitDir := os.Getenv("JUNIT_DIRECTORY"); junitDir != "" { // Downstream-only legacy requirement
junitReporter := reporters.NewJUnitReporter(path.Join(junitDir, fmt.Sprintf("junit_e2e_%02d.xml", config.GinkgoConfig.ParallelNode)))
RunSpecsWithDefaultAndCustomReporters(t, "End-to-end", []Reporter{junitReporter})
} else {
RunSpecs(t, "End-to-end")
}
} | explode_data.jsonl/16396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
3727,
66573,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
340,
22212,
3675,
67982,
7636,
7,
16,
353,
882,
75770,
340,
22212,
3675,
67982,
49207,
287,
10256,
7,
16,
353,
882,
32435,
340,
22212,
3675,
15220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewReadLogsCommandFileSeekToInvalidLocation(t *testing.T) {
testFile, cleanup := setupTestFile(t)
defer cleanup()
cmd := newReadLogsCommand()
cmd.Path = testFile.Name()
cmd.WaitFileTimeout = time.Minute
cmd.Offset = -1
err := cmd.execute()
var expectedErr *os.PathError
assert.ErrorAs(t, err, &expectedErr)
} | explode_data.jsonl/3425 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
3564,
4418,
51053,
4062,
1703,
39350,
1249,
7928,
4707,
1155,
353,
8840,
836,
8,
341,
18185,
1703,
11,
21290,
1669,
6505,
2271,
1703,
1155,
340,
16867,
21290,
2822,
25920,
1669,
501,
4418,
51053,
4062,
741,
25920,
17474,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidatePorts(t *testing.T) {
successCase := []api.ContainerPort{
{Name: "abc", ContainerPort: 80, HostPort: 80, Protocol: "TCP"},
{Name: "easy", ContainerPort: 82, Protocol: "TCP"},
{Name: "as", ContainerPort: 83, Protocol: "UDP"},
{Name: "do-re-me", ContainerPort: 84, Protocol: "UDP"},
{ContainerPort: 85, Protocol: "TCP"},
}
if errs := validatePorts(successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
nonCanonicalCase := []api.ContainerPort{
{ContainerPort: 80, Protocol: "TCP"},
}
if errs := validatePorts(nonCanonicalCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
errorCases := map[string]struct {
P []api.ContainerPort
T errors.ValidationErrorType
F string
D string
}{
"name > 15 characters": {[]api.ContainerPort{{Name: strings.Repeat("a", 16), ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", portNameErrorMsg},
"name not a IANA svc name ": {[]api.ContainerPort{{Name: "a.b.c", ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", portNameErrorMsg},
"name not a IANA svc name (i.e. a number)": {[]api.ContainerPort{{Name: "80", ContainerPort: 80, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].name", portNameErrorMsg},
"name not unique": {[]api.ContainerPort{
{Name: "abc", ContainerPort: 80, Protocol: "TCP"},
{Name: "abc", ContainerPort: 81, Protocol: "TCP"},
}, errors.ValidationErrorTypeDuplicate, "[1].name", ""},
"zero container port": {[]api.ContainerPort{{ContainerPort: 0, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg},
"invalid container port": {[]api.ContainerPort{{ContainerPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].containerPort", portRangeErrorMsg},
"invalid host port": {[]api.ContainerPort{{ContainerPort: 80, HostPort: 65536, Protocol: "TCP"}}, errors.ValidationErrorTypeInvalid, "[0].hostPort", portRangeErrorMsg},
"invalid protocol case": {[]api.ContainerPort{{ContainerPort: 80, Protocol: "tcp"}}, errors.ValidationErrorTypeNotSupported, "[0].protocol", "supported values: TCP, UDP"},
"invalid protocol": {[]api.ContainerPort{{ContainerPort: 80, Protocol: "ICMP"}}, errors.ValidationErrorTypeNotSupported, "[0].protocol", "supported values: TCP, UDP"},
"protocol required": {[]api.ContainerPort{{Name: "abc", ContainerPort: 80}}, errors.ValidationErrorTypeRequired, "[0].protocol", ""},
}
for k, v := range errorCases {
errs := validatePorts(v.P)
if len(errs) == 0 {
t.Errorf("expected failure for %s", k)
}
for i := range errs {
if errs[i].(*errors.ValidationError).Type != v.T {
t.Errorf("%s: expected errors to have type %s: %v", k, v.T, errs[i])
}
if errs[i].(*errors.ValidationError).Field != v.F {
t.Errorf("%s: expected errors to have field %s: %v", k, v.F, errs[i])
}
detail := errs[i].(*errors.ValidationError).Detail
if detail != v.D {
t.Errorf("%s: expected error detail either empty or %s, got %s", k, v.D, detail)
}
}
}
} | explode_data.jsonl/62787 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1172
} | [
2830,
3393,
17926,
68273,
1155,
353,
8840,
836,
8,
341,
30553,
4207,
1669,
3056,
2068,
33672,
7084,
515,
197,
197,
63121,
25,
330,
13683,
497,
9678,
7084,
25,
220,
23,
15,
11,
16102,
7084,
25,
220,
23,
15,
11,
24572,
25,
330,
49896,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestMessageForExecuteEmpty(t *testing.T) {
// Test a truly empty template.
tmpl := New("empty")
var b bytes.Buffer
err := tmpl.Execute(&b, 0)
if err == nil {
t.Fatal("expected initial error")
}
got := err.Error()
want := `template: empty: "empty" is an incomplete or empty template`
if got != want {
t.Errorf("expected error %s got %s", want, got)
}
// Add a non-empty template to check that the error is helpful.
tests, err := New("").Parse(testTemplates)
if err != nil {
t.Fatal(err)
}
tmpl.AddParseTree("secondary", tests.Tree)
err = tmpl.Execute(&b, 0)
if err == nil {
t.Fatal("expected second error")
}
got = err.Error()
want = `template: empty: "empty" is an incomplete or empty template`
if got != want {
t.Errorf("expected error %s got %s", want, got)
}
// Make sure we can execute the secondary.
err = tmpl.ExecuteTemplate(&b, "secondary", 0)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/41523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
2052,
2461,
17174,
3522,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
264,
9428,
4287,
3811,
624,
3244,
54010,
1669,
1532,
445,
3194,
1138,
2405,
293,
5820,
22622,
198,
9859,
1669,
79839,
13827,
2099,
65,
11,
220,
15,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestMember(t *testing.T) {
gopClTest(t, `
import "flag"
a := &struct {
A int
B string
}{1, "Hello"}
x := a.A
a.B = "Hi"
flag.Usage = nil
`, `package main
import flag "flag"
func main() {
a := &struct {
A int
B string
}{1, "Hello"}
x := a.A
a.B = "Hi"
flag.Usage = nil
}
`)
} | explode_data.jsonl/73661 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
9366,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
1565,
271,
474,
330,
9903,
1837,
64,
1669,
609,
1235,
341,
22985,
526,
198,
12791,
914,
198,
15170,
16,
11,
330,
9707,
63159,
87,
1669,
264,
875,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLastAccessTimeSerialization(t *testing.T) {
require := require.New(t)
lat := NewLastAccessTime(time.Now().Add(-time.Hour))
b, err := lat.Serialize()
require.NoError(err)
var newLat LastAccessTime
require.NoError(newLat.Deserialize(b))
require.Equal(lat.Time.Unix(), newLat.Time.Unix())
} | explode_data.jsonl/21496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
5842,
6054,
1462,
35865,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
197,
5524,
1669,
1532,
5842,
6054,
1462,
9730,
13244,
1005,
2212,
4080,
1678,
73550,
1171,
2233,
11,
1848,
1669,
6844,
32859,
741,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPreserveCommentsWithAdjust(t *testing.T) {
kustomizationContentWithComments := []byte(`
# Some comments
# This is some comment we should preserve
# don't delete it
RESOURCES:
- ../namespaces
- pod.yaml
# See which field this comment goes into
- service.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: kustomization
# something you may want to keep
vars:
- fieldref:
fieldPath: metadata.name
name: MY_SERVICE_NAME
objref:
apiVersion: v1
kind: Service
name: my-service
# some descriptions for the patches
patchesStrategicMerge:
- service.yaml
- pod.yaml
# generator options
generatorOptions:
disableNameSuffixHash: true
`)
expected := []byte(`
# Some comments
# This is some comment we should preserve
# don't delete it
# See which field this comment goes into
resources:
- ../namespaces
- pod.yaml
- service.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: kustomization
# something you may want to keep
vars:
- fieldref:
fieldPath: metadata.name
name: MY_SERVICE_NAME
objref:
apiVersion: v1
kind: Service
name: my-service
# some descriptions for the patches
patchesStrategicMerge:
- service.yaml
- pod.yaml
# generator options
generatorOptions:
disableNameSuffixHash: true
`)
fSys := filesys.MakeFsInMemory()
testutils_test.WriteTestKustomizationWith(
fSys, kustomizationContentWithComments)
mf, err := NewKustomizationFile(fSys)
if err != nil {
t.Fatalf("Unexpected Error: %v", err)
}
kustomization, err := mf.Read()
if err != nil {
t.Fatalf("Unexpected Error: %v", err)
}
if err = mf.Write(kustomization); err != nil {
t.Fatalf("Unexpected Error: %v", err)
}
bytes, _ := fSys.ReadFile(mf.path)
if diff := cmp.Diff(expected, bytes); diff != "" {
t.Errorf("Mismatch (-expected, +actual):\n%s", diff)
}
} | explode_data.jsonl/77187 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 668
} | [
2830,
3393,
14367,
5852,
17373,
2354,
38616,
1155,
353,
8840,
836,
8,
341,
16463,
1450,
2022,
2762,
2354,
17373,
1669,
3056,
3782,
5809,
271,
14808,
2,
4329,
6042,
198,
2,
1096,
374,
1045,
3980,
582,
1265,
21129,
198,
2,
1513,
944,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReverseInt32(t *testing.T) {
type args struct {
s []int32
}
tests := []struct {
name string
args args
want []int32
}{
{name: "testcase1", args: args{s: []int32{1, 2, 3, 4, 5}}, want: []int32{5, 4, 3, 2, 1}},
{name: "testcase2", args: args{s: []int32{}}, want: []int32{}},
{name: "testcase3", args: args{s: []int32{1, 2, 3, 4, 5, 6}}, want: []int32{6, 5, 4, 3, 2, 1}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ReverseInt32(tt.args.s)
if reflect.DeepEqual(tt.args.s, tt.want) != true {
t.Errorf("ReverseInt32() got = %v, want %v", tt.args.s, tt.want)
}
})
}
} | explode_data.jsonl/73903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
45695,
1072,
18,
17,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1903,
3056,
396,
18,
17,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
3056,
396,
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 TestAccJunosSecurityAddressBook_basic(t *testing.T) {
if os.Getenv("TESTACC_SWITCH") == "" && os.Getenv("TESTACC_ROUTER") == "" {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccJunosSecurityAddressBookConfigCreate(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"name", "global"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"description", "testacc global description"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.#", "2"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.0.name", "testacc_network"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.0.description", "testacc_network description"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.0.value", "10.0.0.0/24"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.1.name", "testacc_network2"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.1.description", "testacc_network description2"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.1.value", "10.1.0.0/24"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"wildcard_address.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"wildcard_address.0.value", "10.0.0.0/255.255.0.255"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"wildcard_address.0.name", "testacc_wildcard"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"range_address.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"range_address.0.name", "testacc_range"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"range_address.0.from", "10.1.1.1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"range_address.0.to", "10.1.1.5"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"dns_name.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"dns_name.0.name", "testacc_dns"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"dns_name.0.value", "google.com"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"address_set.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"address_set.0.address.#", "3"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"name", "testacc_secAddrBook"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"attach_zone.#", "2"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"attach_zone.0", "testacc_secZoneAddr1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"attach_zone.1", "testacc_secZoneAddr2"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"network_address.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"network_address.0.name", "testacc_network"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"network_address.0.value", "10.1.2.3/32"),
),
},
{
Config: testAccJunosSecurityAddressBookConfigUpdate(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityGlobalAddressBook",
"network_address.0.value", "10.1.0.0/24"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"network_address.#", "1"),
resource.TestCheckResourceAttr("junos_security_address_book.testacc_securityNamedAddressBook",
"network_address.0.value", "10.1.2.4/32"),
),
},
{
ResourceName: "junos_security_address_book.testacc_securityGlobalAddressBook",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
} | explode_data.jsonl/1643 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2058
} | [
2830,
3393,
14603,
35590,
436,
15352,
4286,
7134,
34729,
1155,
353,
8840,
836,
8,
341,
743,
2643,
64883,
445,
10033,
29442,
51183,
899,
621,
1591,
1009,
2643,
64883,
445,
10033,
29442,
69588,
640,
899,
621,
1591,
341,
197,
50346,
8787,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLiveUpdateDockerBuildLocalContainer(t *testing.T) {
f := newBDFixture(t, k8s.EnvDockerDesktop, container.RuntimeDocker)
defer f.TearDown()
tCase := testCase{
manifest: NewSanchoLiveUpdateManifest(f),
changedFiles: []string{"a.txt"},
expectDockerBuildCount: 0,
expectDockerPushCount: 0,
expectDockerCopyCount: 1,
expectDockerExecCount: 1,
expectDockerRestartCount: 1,
}
runTestCase(t, f, tCase)
} | explode_data.jsonl/35152 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
20324,
4289,
35,
13659,
11066,
7319,
4502,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
33,
5262,
12735,
1155,
11,
595,
23,
82,
81214,
35,
13659,
23597,
11,
5476,
16706,
35,
13659,
340,
16867,
282,
836,
682,
4454,
2822,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRebindQueryInfo(t *testing.T) {
session := createSession(t)
defer session.Close()
if err := createTable(session, "CREATE TABLE gocql_test.rebind_query (id int, value text, PRIMARY KEY (id))"); err != nil {
t.Fatalf("failed to create table with error '%v'", err)
}
if err := session.Query("INSERT INTO rebind_query (id, value) VALUES (?, ?)", 23, "quux").Exec(); err != nil {
t.Fatalf("insert into rebind_query failed, err '%v'", err)
}
if err := session.Query("INSERT INTO rebind_query (id, value) VALUES (?, ?)", 24, "w00t").Exec(); err != nil {
t.Fatalf("insert into rebind_query failed, err '%v'", err)
}
q := session.Query("SELECT value FROM rebind_query WHERE ID = ?")
q.Bind(23)
iter := q.Iter()
var value string
for iter.Scan(&value) {
}
if value != "quux" {
t.Fatalf("expected %v but got %v", "quux", value)
}
q.Bind(24)
iter = q.Iter()
for iter.Scan(&value) {
}
if value != "w00t" {
t.Fatalf("expected %v but got %v", "w00t", value)
}
} | explode_data.jsonl/11153 | {
"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,
693,
7666,
2859,
1731,
1155,
353,
8840,
836,
8,
341,
25054,
1669,
1855,
5283,
1155,
340,
16867,
3797,
10421,
2822,
743,
1848,
1669,
1855,
2556,
16264,
11,
330,
22599,
14363,
342,
509,
1470,
4452,
1327,
7666,
5738,
320,
307,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObjectsAll(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionWithObjectHeaders(t)
defer rollback()
objects, err := c.ObjectsAll(ctx, CONTAINER, nil)
if err != nil {
t.Fatal(err)
}
if len(objects) != 1 || objects[0].Name != OBJECT {
t.Error("Incorrect listing", objects)
}
} | explode_data.jsonl/12701 | {
"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,
11543,
2403,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
2354,
1190,
10574,
1155,
340,
16867,
60414,
741,
197,
19210,
11,
1848,
1669,
272,
40314,
2403,
7502,
11,
16120,
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... | 4 |
func TestBenchmarkGetWorkflowsWithAPI(t *testing.T) {
t.SkipNow()
api, db, router := newTestAPI(t)
// Init project
key := sdk.RandomString(10)
proj := assets.InsertTestProject(t, db, api.Cache, key, key)
// Init user
u, pass := assets.InsertLambdaUser(t, db, &proj.ProjectGroups[0].Group)
// Init pipeline
pip := sdk.Pipeline{
Name: "pipeline1",
ProjectID: proj.ID,
}
assert.NoError(t, pipeline.InsertPipeline(db, &pip))
app := sdk.Application{
Name: sdk.RandomString(10),
}
assert.NoError(t, application.Insert(db, *proj, &app))
prj, err := project.Load(db, proj.Key,
project.LoadOptions.WithPipelines,
project.LoadOptions.WithApplications,
project.LoadOptions.WithWorkflows,
)
assert.NoError(t, err)
for i := 0; i < 300; i++ {
wf := sdk.Workflow{
ProjectID: proj.ID,
ProjectKey: proj.Key,
Name: sdk.RandomString(10),
Groups: proj.ProjectGroups,
WorkflowData: sdk.WorkflowData{
Node: sdk.Node{
Name: "root",
Context: &sdk.NodeContext{
PipelineID: pip.ID,
ApplicationID: app.ID,
},
},
},
}
assert.NoError(t, workflow.Insert(context.TODO(), db, api.Cache, *prj, &wf))
}
//Prepare request
vars := map[string]string{
"permProjectKey": proj.Key,
}
uri := router.GetRoute("GET", api.getWorkflowsHandler, vars)
test.NotEmpty(t, uri)
res := testing.Benchmark(func(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
b.StopTimer()
req := assets.NewAuthentifiedRequest(t, u, pass, "GET", uri, vars)
b.StartTimer()
//Do the request
w := httptest.NewRecorder()
router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
b.StopTimer()
workflows := []sdk.Workflow{}
json.Unmarshal(w.Body.Bytes(), &workflows)
test.Equal(t, 300, len(workflows))
}
b.StopTimer()
})
t.Logf("N : %d", res.N)
t.Logf("ns/op : %d", res.NsPerOp())
assert.False(t, res.NsPerOp() >= 500000000, "Workflows load is too long: GOT %d and EXPECTED lower than 500000000 (500ms)", res.NsPerOp())
} | explode_data.jsonl/31082 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 907
} | [
2830,
3393,
84971,
1949,
6776,
38140,
2354,
7082,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
7039,
741,
54299,
11,
2927,
11,
9273,
1669,
501,
2271,
7082,
1155,
692,
197,
322,
15690,
2390,
198,
23634,
1669,
45402,
26709,
703,
7,
16,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_JsonInputSchemaMappingProperties_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip from JsonInputSchemaMappingProperties to JsonInputSchemaMappingProperties via AssignPropertiesToJsonInputSchemaMappingProperties & AssignPropertiesFromJsonInputSchemaMappingProperties returns original",
prop.ForAll(RunPropertyAssignmentTestForJsonInputSchemaMappingProperties, JsonInputSchemaMappingPropertiesGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
} | explode_data.jsonl/39624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
62,
5014,
2505,
8632,
6807,
7903,
62,
4498,
7903,
61941,
2568,
795,
21884,
1690,
26040,
39838,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
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 TestValidatorDippingInAndOut(t *testing.T) {
// initial setup
// keeperTestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500
ctx, _, sk, _, keeper := createTestInput(t, keeperTestParams())
params := sk.GetParams(ctx)
params.MaxValidators = 1
sk.SetParams(ctx, params)
power := int64(100)
amt := sdk.TokensFromTendermintPower(power)
addr, val := addrs[0], pks[0]
consAddr := sdk.ConsAddress(addr)
sh := staking.NewHandler(sk)
got := sh(ctx, NewTestMsgCreateValidator(addr, val, amt))
require.True(t, got.IsOK())
staking.EndBlocker(ctx, sk)
// 100 first blocks OK
height := int64(0)
for ; height < int64(100); height++ {
ctx = ctx.WithBlockHeight(height)
keeper.handleValidatorSignature(ctx, val.Address(), power, true)
}
// validator kicked out of validator set
newAmt := sdk.TokensFromTendermintPower(101)
got = sh(ctx, NewTestMsgCreateValidator(addrs[1], pks[1], newAmt))
require.True(t, got.IsOK())
validatorUpdates, _ := staking.EndBlocker(ctx, sk)
require.Equal(t, 2, len(validatorUpdates))
validator, _ := sk.GetValidator(ctx, addr)
require.Equal(t, sdk.Unbonding, validator.Status)
// 600 more blocks happened
height = int64(700)
ctx = ctx.WithBlockHeight(height)
// validator added back in
delTokens := sdk.TokensFromTendermintPower(3)
got = sh(ctx, newTestMsgDelegate(sdk.AccAddress(addrs[2]), addrs[0], delTokens))
require.True(t, got.IsOK())
validatorUpdates, _ = staking.EndBlocker(ctx, sk)
require.Equal(t, 2, len(validatorUpdates))
validator, _ = sk.GetValidator(ctx, addr)
require.Equal(t, sdk.Bonded, validator.Status)
newPower := int64(103)
// validator misses a block
keeper.handleValidatorSignature(ctx, val.Address(), newPower, false)
height++
// shouldn't be jailed/kicked yet
validator, _ = sk.GetValidator(ctx, addr)
require.Equal(t, sdk.Bonded, validator.Status)
// validator misses 500 more blocks, 501 total
latest := height
for ; height < latest+500; height++ {
ctx = ctx.WithBlockHeight(height)
keeper.handleValidatorSignature(ctx, val.Address(), newPower, false)
}
// should now be jailed & kicked
staking.EndBlocker(ctx, sk)
validator, _ = sk.GetValidator(ctx, addr)
require.Equal(t, sdk.Unbonding, validator.Status)
// check all the signing information
signInfo, found := keeper.getValidatorSigningInfo(ctx, consAddr)
require.True(t, found)
require.Equal(t, int64(0), signInfo.MissedBlocksCounter)
require.Equal(t, int64(0), signInfo.IndexOffset)
// array should be cleared
for offset := int64(0); offset < keeper.SignedBlocksWindow(ctx); offset++ {
missed := keeper.getValidatorMissedBlockBitArray(ctx, consAddr, offset)
require.False(t, missed)
}
// some blocks pass
height = int64(5000)
ctx = ctx.WithBlockHeight(height)
// validator rejoins and starts signing again
sk.Unjail(ctx, consAddr)
keeper.handleValidatorSignature(ctx, val.Address(), newPower, true)
height++
// validator should not be kicked since we reset counter/array when it was jailed
staking.EndBlocker(ctx, sk)
validator, _ = sk.GetValidator(ctx, addr)
require.Equal(t, sdk.Bonded, validator.Status)
// validator misses 501 blocks
latest = height
for ; height < latest+501; height++ {
ctx = ctx.WithBlockHeight(height)
keeper.handleValidatorSignature(ctx, val.Address(), newPower, false)
}
// validator should now be jailed & kicked
staking.EndBlocker(ctx, sk)
validator, _ = sk.GetValidator(ctx, addr)
require.Equal(t, sdk.Unbonding, validator.Status)
} | explode_data.jsonl/44700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1255
} | [
2830,
3393,
14256,
35,
5654,
641,
3036,
2662,
1155,
353,
8840,
836,
8,
1476,
197,
322,
2856,
6505,
198,
197,
322,
53416,
2271,
4870,
738,
279,
52453,
29804,
4267,
311,
220,
16,
15,
15,
15,
323,
7487,
35312,
291,
29804,
3889,
4267,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestSpear(t *testing.T) {
c, err := newTestContext()
require.NoError(t, err)
src := &Entity{
Name: "Single_1",
}
require.NoError(t, s.Put(c, src))
require.EqualError(t, s.Save(c, src), ErrConflictEntity.Error())
dst := &Entity{
ID: src.ID,
}
require.NoError(t, s.Get(c, dst))
assert.EqualValues(t, src, dst)
ido := &SlimEntity{
ID: src.ID,
}
require.NoError(t, s.Get(c, ido))
assert.Equal(t, src.Name, ido.Name)
require.NoError(t, s.Delete(c, dst))
require.NoError(t, s.Save(c, src))
require.NoError(t, s.Delete(c, dst))
} | explode_data.jsonl/13757 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
50,
8015,
1155,
353,
8840,
836,
8,
1476,
1444,
11,
1848,
1669,
501,
2271,
1972,
741,
17957,
35699,
1155,
11,
1848,
692,
41144,
1669,
609,
3030,
515,
197,
21297,
25,
330,
10888,
62,
16,
756,
197,
532,
17957,
35699,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEventCreate(t *testing.T) {
defaultCtx := context.Background()
badEvent := types.FixtureEvent("entity1", "check1")
badEvent.Check.Name = "!@#!#$@#^$%&$%&$&$%&%^*%&(%@###"
incompleteEvent := &types.Event{
Entity: types.FixtureEntity("entity1"),
}
metricEvent := &types.Event{
Entity: types.FixtureEntity("entity1"),
Metrics: types.FixtureMetrics(),
}
testCases := []struct {
name string
ctx context.Context
argument *types.Event
fetchResult *types.Event
fetchErr error
busErr error
expectedErr bool
expectedErrCode ErrCode
}{
{
name: "Created",
ctx: defaultCtx,
argument: types.FixtureEvent("entity1", "check1"),
expectedErr: false,
},
{
name: "Already Exists",
ctx: defaultCtx,
argument: types.FixtureEvent("entity1", "check1"),
fetchResult: types.FixtureEvent("entity1", "check1"),
expectedErr: true,
expectedErrCode: AlreadyExistsErr,
},
{
name: "store Err on Fetch",
ctx: defaultCtx,
argument: types.FixtureEvent("entity1", "check1"),
fetchErr: errors.New("dunno"),
expectedErr: true,
expectedErrCode: InternalErr,
},
{
name: "Validation Error",
ctx: defaultCtx,
argument: badEvent,
expectedErr: true,
expectedErrCode: InvalidArgument,
},
{
name: "Message Bus Error",
ctx: defaultCtx,
argument: types.FixtureEvent("entity1", "check1"),
busErr: errors.New("where's the wizard"),
expectedErr: true,
expectedErrCode: InternalErr,
},
{
name: "No check or metric event",
ctx: defaultCtx,
argument: incompleteEvent,
expectedErr: true,
expectedErrCode: InvalidArgument,
},
{
name: "Metric Event",
ctx: defaultCtx,
argument: metricEvent,
expectedErr: false,
},
}
for _, tc := range testCases {
store := &mockstore.MockStore{}
bus := &mockbus.MockBus{}
actions := NewEventController(store, bus)
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
// Mock store methods
store.
On("GetEventByEntityCheck", mock.Anything, mock.Anything, mock.Anything).
Return(tc.fetchResult, tc.fetchErr)
bus.On("Publish", mock.Anything, mock.Anything).Return(tc.busErr)
// Exec Query
err := actions.Create(tc.ctx, *tc.argument)
if tc.expectedErr {
inferErr, ok := err.(Error)
if ok {
assert.Equal(tc.expectedErrCode, inferErr.Code)
} else {
assert.Error(err)
assert.FailNow("Given was not of type 'Error'")
}
} else {
assert.NoError(err)
}
})
}
} | explode_data.jsonl/34059 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1340
} | [
2830,
3393,
1556,
4021,
1155,
353,
8840,
836,
8,
341,
11940,
23684,
1669,
2266,
19047,
741,
2233,
329,
1556,
1669,
4494,
991,
12735,
1556,
445,
2996,
16,
497,
330,
2028,
16,
1138,
2233,
329,
1556,
10600,
2967,
284,
53074,
31,
8010,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestK8sInfraProwBuildJobsMustHavePodQOSGuaranteed(t *testing.T) {
jobs := allStaticJobs()
for _, job := range jobs {
// Only consider Pods destined for the k8s-infra-prow-builds cluster
if job.Spec == nil || job.Cluster != "k8s-infra-prow-build" {
continue
}
errs := verifyPodQOSGuaranteed(job.Spec)
for _, err := range errs {
t.Errorf("%v: %v", job.Name, err)
}
}
} | explode_data.jsonl/55587 | {
"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,
42,
23,
82,
19433,
956,
47,
651,
11066,
40667,
31776,
12116,
23527,
48,
3126,
16780,
277,
58250,
1155,
353,
8840,
836,
8,
341,
12428,
5481,
1669,
678,
11690,
40667,
741,
2023,
8358,
2618,
1669,
2088,
6887,
341,
197,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTranscodingMKV(t *testing.T) {
var inputPath = "/tmp/ffmpeg/mkv"
var outputPath = "/tmp/ffmpeg/out/mkv.mp4"
trans := new(transcoder.Transcoder)
err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
done := trans.Run(false)
err = <-done
assert.Nil(t, err)
} | explode_data.jsonl/57660 | {
"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,
3167,
48367,
44140,
53,
1155,
353,
8840,
836,
8,
1476,
2405,
1946,
1820,
284,
3521,
5173,
14,
72422,
3183,
43408,
698,
2405,
95017,
284,
3521,
5173,
14,
72422,
48316,
3183,
43408,
16870,
19,
1837,
72453,
1669,
501,
33089,
40... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApplicationContext_NestValueField(t *testing.T) {
t.Run("private", func(t *testing.T) {
c, ch := container()
c.Property("sdk.wx.auto-create", true)
c.Property("sdk.wx.enable", true)
bd := c.Provide(func() int { return 3 })
assert.Equal(t, bd.BeanName(), "int")
c.Object(new(wxChannel))
err := c.Refresh()
assert.Nil(t, err)
p := <-ch
var channel *wxChannel
err = p.BeanRegistry().Get(&channel)
assert.Nil(t, err)
assert.Equal(t, *channel.baseChannel.Int, 3)
assert.Equal(t, *channel.int, 3)
assert.Equal(t, channel.baseChannel.Int, channel.int)
assert.Equal(t, channel.enable, true)
assert.Equal(t, channel.AutoCreate, true)
})
t.Run("public", func(t *testing.T) {
c, ch := container()
c.Property("sdk.wx.auto-create", true)
c.Property("sdk.wx.enable", true)
c.Provide(func() int { return 3 })
c.Object(new(WXChannel))
err := c.Refresh()
assert.Nil(t, err)
p := <-ch
var channel *WXChannel
err = p.BeanRegistry().Get(&channel)
assert.Nil(t, err)
assert.Equal(t, *channel.BaseChannel.Int, 3)
assert.Equal(t, *channel.Int, 3)
assert.Equal(t, channel.BaseChannel.Int, channel.Int)
assert.True(t, channel.Enable)
assert.True(t, channel.AutoCreate)
})
} | explode_data.jsonl/17423 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 529
} | [
2830,
3393,
19736,
1604,
477,
1130,
1877,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
1996,
497,
2915,
1155,
353,
8840,
836,
8,
1476,
197,
1444,
11,
521,
1669,
5476,
741,
197,
1444,
15727,
445,
51295,
94668,
23614,
39679,
497,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandlerCallsHandleFunc(t *testing.T) {
req := events.APIGatewayProxyRequest{
Path: "/test",
HTTPMethod: http.MethodPost,
}
handlerCalled := false
route := &Route{
func(_ events.APIGatewayProxyRequest) bool {
return true
},
func(_ events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
handlerCalled = true
return events.APIGatewayProxyResponse{}, nil
},
}
r := NewRouter()
r.AddRoute("test", route)
_, err := r.Handle(req)
assert.Nil(t, err)
assert.True(t, handlerCalled)
} | explode_data.jsonl/4494 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 215
} | [
2830,
3393,
3050,
55292,
6999,
9626,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
4357,
24922,
40709,
16219,
1900,
515,
197,
69640,
25,
981,
3521,
1944,
756,
197,
197,
9230,
3523,
25,
1758,
20798,
4133,
345,
197,
630,
53326,
20960,
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 TestDeploymentAnnotationExplicitlyDisabled(t *testing.T) {
t.Parallel()
deploymentSpec := apps_v1.Deployment{
TypeMeta: meta_v1.TypeMeta{
Kind: "Deployment",
APIVersion: apps_v1.SchemeGroupVersion.String(),
},
ObjectMeta: meta_v1.ObjectMeta{
Namespace: testNs,
},
Spec: apps_v1.DeploymentSpec{
Template: core_v1.PodTemplateSpec{
ObjectMeta: meta_v1.ObjectMeta{
Annotations: map[string]string{
EnvRefHashAnnotation: "disabled",
},
},
Spec: core_v1.PodSpec{
Containers: []core_v1.Container{
core_v1.Container{
EnvFrom: []core_v1.EnvFromSource{
core_v1.EnvFromSource{
SecretRef: &core_v1.SecretEnvSource{
LocalObjectReference: core_v1.LocalObjectReference{
Name: "secret1",
},
},
},
},
},
},
},
},
},
}
spec := runtimeToUnstructured(t, &deploymentSpec)
logger := zaptest.NewLogger(t)
defer logger.Sync() // nolint: errcheck
store := speccheckertesting.FakeStore{Namespace: testNs}
updatedSpec, err := deployment{}.BeforeCreate(&specchecker.Context{Logger: logger, Store: store}, spec)
require.NoError(t, err)
deploymentCheck := updatedSpec.(*apps_v1.Deployment)
assert.Contains(t, deploymentCheck.Spec.Template.Annotations, EnvRefHashAnnotation)
assert.Equal(t, "disabled", deploymentCheck.Spec.Template.Annotations[EnvRefHashAnnotation])
} | explode_data.jsonl/78686 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 628
} | [
2830,
3393,
75286,
19711,
98923,
398,
25907,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
82213,
8327,
1669,
10500,
2273,
16,
34848,
39130,
515,
197,
27725,
12175,
25,
8823,
2273,
16,
10184,
12175,
515,
298,
197,
10629,
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 TestVariables_ListsAndNullability_DoesNotAllowNonNullListsToBeNull(t *testing.T) {
doc := `
query q($input: [String]!) {
nnList(input: $input)
}
`
expected := &graphql.Result{
Data: nil,
Errors: []gqlerrors.FormattedError{
{
Message: `Variable "$input" of required type "[String]!" was not provided.`,
Locations: []location.SourceLocation{
{
Line: 2, Column: 17,
},
},
},
},
}
ast := testutil.TestParse(t, doc)
// execute
ep := graphql.ExecuteParams{
Schema: variablesTestSchema,
AST: ast,
}
result := testutil.TestExecute(t, ep)
if len(result.Errors) != len(expected.Errors) {
t.Fatalf("Unexpected errors, Diff: %v", testutil.Diff(expected.Errors, result.Errors))
}
if !reflect.DeepEqual(expected, result) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, result))
}
} | explode_data.jsonl/6455 | {
"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,
22678,
27104,
82,
3036,
3280,
2897,
1557,
7072,
2623,
18605,
16834,
37848,
1249,
60360,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
22074,
286,
3239,
2804,
699,
1355,
25,
508,
703,
60,
16315,
341,
688,
10883,
852,
5384,
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... | 3 |
func TestAESCore(t *testing.T) {
/* AES Test vectors: https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program
key := 53382df51d7d4d17964e178d9ccb2dea7ae8e2238c3a91a392d53fba523f48c4
iv := ede60d67a345d2be699d3b24
pt := 7e14b6a5b616ce97e02f9377002786a5
ct: = 5c4ba32d35959c7e9e94a1f9c0a5c2e0
*/
//adata := nil
var (
aesKey []byte
aesIV []byte
plaintext string
password string
verbose bool
)
verbose = false
// Test Plaintext
plaintext = "Attack at dawn! I have special characters: !@#(%*U@#)$(_+!@#_|||&&DROPFILLSELECT. This is the end of text"
// Test Password
password = "LegitPassword2"
// Expand test password and build insecure IV
aesKey = KeyFromPassword(&password, nil, 64, verbose)
aesIV = aesKey[:12]
// Test AES encryption and decryption
operationEnc := "encrypt"
encAESResult, encError := AESCore(aesIV, aesKey, nil, []byte(plaintext), &operationEnc, verbose)
if encError != nil {
fmt.Println("Error in TEST ENCRYPTION:", encError)
}
operationDec := "decrypt"
decAESResult, decError := AESCore(aesIV, aesKey, nil, encAESResult, &operationDec, verbose)
if decError != nil {
fmt.Println("Error in TEST DECRYPTION:", decError)
}
// Test AES construction primitives
aesBlock, _ := aes.NewCipher(aesKey)
aesGCM, _ := cipher.NewGCM(aesBlock)
// Manual AES GCM operation
ciphertext := aesGCM.Seal(nil, aesIV, []byte(plaintext), nil)
// Compare ciphertexts -- removing first 12 bytes of encAESResult (IV)
cipherString := string(ciphertext)
encAESRString := string(encAESResult[12:])
if cipherString != encAESRString {
t.Errorf("FAIL - Test expected AESCore enc/dec plaintext to be equivalent. They were not:")
fmt.Printf("TestFramework - Manual Ciphertext Output: %x\n", cipherString)
fmt.Printf("TestFramework - AESCore Ciphertext Output: \"%s\"\n", encAESResult)
}
plaintext2 := string(decAESResult)
if plaintext != plaintext2 {
t.Errorf("FAIL - plaintext before and after enc/dec are not equivalent.")
fmt.Println("Plaintext:", plaintext)
fmt.Println("Plaintext after decryption:", plaintext2)
}
} | explode_data.jsonl/72450 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 813
} | [
2830,
3393,
69168,
5386,
1155,
353,
8840,
836,
8,
1476,
197,
1057,
38841,
3393,
22879,
25,
3703,
1110,
66,
3548,
1253,
380,
14156,
39606,
2899,
3571,
12679,
18779,
7095,
58346,
66020,
198,
23634,
1669,
220,
20,
18,
18,
23,
17,
2940,
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... | 5 |
func TestLeaveChannel(t *testing.T) {
// Scenario: Have our peer receive a stateInfo message
// from a peer that has left the channel, and ensure that it skips it
// when returning membership.
// Next, have our own peer leave the channel and ensure:
// 1) It doesn't return any members of the channel when queried
// 2) It doesn't send anymore pull for blocks
// 3) When asked for pull for blocks, it ignores the request
t.Parallel()
jcm := &joinChanMsg{
members2AnchorPeers: map[string][]api.AnchorPeer{
"ORG1": {},
"ORG2": {},
},
}
cs := &cryptoService{}
cs.On("VerifyBlock", mock.Anything).Return(nil)
adapter := new(gossipAdapterMock)
adapter.On("Gossip", mock.Anything)
adapter.On("Forward", mock.Anything)
adapter.On("DeMultiplex", mock.Anything)
members := []discovery.NetworkMember{
{PKIid: pkiIDInOrg1},
{PKIid: pkiIDinOrg2},
}
var helloPullWG sync.WaitGroup
helloPullWG.Add(1)
configureAdapter(adapter, members...)
gc := NewGossipChannel(common.PKIidType("p0"), orgInChannelA, cs, channelA, adapter, jcm, disabledMetrics)
adapter.On("Send", mock.Anything, mock.Anything).Run(func(arguments mock.Arguments) {
msg := arguments.Get(0).(*proto.SignedGossipMessage)
if msg.IsPullMsg() {
helloPullWG.Done()
assert.False(t, gc.(*gossipChannel).hasLeftChannel())
}
})
gc.HandleMessage(&receivedMsg{PKIID: pkiIDInOrg1, msg: createStateInfoMsg(1, pkiIDInOrg1, channelA)})
gc.HandleMessage(&receivedMsg{PKIID: pkiIDinOrg2, msg: createStateInfoMsg(1, pkiIDinOrg2, channelA)})
// Have some peer send a block to us, so we can send some peer a digest when hello is sent to us
gc.HandleMessage(&receivedMsg{msg: createDataMsg(2, channelA), PKIID: pkiIDInOrg1})
assert.Len(t, gc.GetPeers(), 2)
// Now, have peer in org2 "leave the channel" by publishing is an update
stateInfoMsg := &receivedMsg{PKIID: pkiIDinOrg2, msg: createStateInfoMsg(0, pkiIDinOrg2, channelA)}
stateInfoMsg.GetGossipMessage().GetStateInfo().Properties.LeftChannel = true
gc.HandleMessage(stateInfoMsg)
assert.Len(t, gc.GetPeers(), 1)
// Ensure peer in org1 remained and peer in org2 is skipped
assert.Equal(t, pkiIDInOrg1, gc.GetPeers()[0].PKIid)
var digestSendTime int32
var DigestSentWg sync.WaitGroup
DigestSentWg.Add(1)
hello := createHelloMsg(pkiIDInOrg1)
hello.On("Respond", mock.Anything).Run(func(arguments mock.Arguments) {
atomic.AddInt32(&digestSendTime, 1)
// Ensure we only respond with digest before we leave the channel
assert.Equal(t, int32(1), atomic.LoadInt32(&digestSendTime))
DigestSentWg.Done()
})
// Wait until we send a hello pull message
helloPullWG.Wait()
go gc.HandleMessage(hello)
DigestSentWg.Wait()
// Make the peer leave the channel
gc.LeaveChannel()
// Send another hello. Shouldn't respond
go gc.HandleMessage(hello)
// Ensure it doesn't know now any other peer
assert.Len(t, gc.GetPeers(), 0)
// Sleep 3 times the pull interval.
// we're not supposed to send a pull during this time.
time.Sleep(conf.PullInterval * 3)
} | explode_data.jsonl/66313 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1087
} | [
2830,
3393,
21833,
9629,
1155,
353,
8840,
836,
8,
341,
197,
322,
58663,
25,
12243,
1039,
14397,
5258,
264,
1584,
1731,
1943,
198,
197,
322,
504,
264,
14397,
429,
702,
2115,
279,
5496,
11,
323,
5978,
429,
432,
91520,
432,
198,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDeleteAllUsersByDomain(t *testing.T) {
testDeleteAllUsersByDomain(t, "domain1", [][]string{
{"admin", "domain2", "data2", "read"},
{"admin", "domain2", "data2", "write"},
}, [][]string{
{"bob", "admin", "domain2"},
})
testDeleteAllUsersByDomain(t, "domain2", [][]string{
{"admin", "domain1", "data1", "read"},
{"admin", "domain1", "data1", "write"},
}, [][]string{
{"alice", "admin", "domain1"},
})
} | explode_data.jsonl/65637 | {
"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,
6435,
2403,
7137,
1359,
13636,
1155,
353,
8840,
836,
8,
341,
18185,
6435,
2403,
7137,
1359,
13636,
1155,
11,
330,
12204,
16,
497,
52931,
917,
515,
197,
197,
4913,
2882,
497,
330,
12204,
17,
497,
330,
691,
17,
497,
330,
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 TestOperator_Name(t *testing.T) {
t.Run("without generics", func(t *testing.T) {
op := NewOperator[float32](&dummyFunctionFloat32{})
assert.Equal(t, "dummyFunctionFloat32", op.Name())
})
t.Run("with generics - float32", testOperatorName[float32])
t.Run("with generics - float64", testOperatorName[float64])
} | explode_data.jsonl/49574 | {
"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,
18461,
19015,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
28996,
95545,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
39703,
1669,
1532,
18461,
95381,
18,
17,
60,
2099,
31390,
5152,
5442,
18,
17,
37790,
197,
6948,
1280... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_AddEntryListenerRemoved(t *testing.T) {
var wg *sync.WaitGroup = new(sync.WaitGroup)
entryAdded := &AddEntry{wg: wg}
registrationId, err := mp.AddEntryListener(entryAdded, true)
AssertEqual(t, err, nil, nil)
wg.Add(2)
mp.Put("test", "key")
mp.Remove("test")
timeout := WaitTimeout(wg, Timeout)
AssertEqualf(t, nil, false, timeout, "AddEntryListener entryRemoved failed")
mp.RemoveEntryListener(registrationId)
mp.Clear()
} | explode_data.jsonl/57030 | {
"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,
2227,
16219,
21346,
5874,
2743,
42642,
1155,
353,
8840,
836,
8,
341,
2405,
63581,
353,
12996,
28384,
2808,
284,
501,
97233,
28384,
2808,
340,
48344,
19337,
1669,
609,
2212,
5874,
90,
45540,
25,
63581,
532,
197,
25862,
764,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSocketWritev(t *testing.T) {
// Using socketpair here because it's already connected.
pair, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_STREAM, 0)
if err != nil {
t.Fatalf("host socket creation failed: %v", err)
}
ctx := contexttest.Context(t)
socket, err := newSocket(ctx, pair[0], false)
if err != nil {
t.Fatalf("newSocket(%v) => %v", pair[0], err)
}
defer socket.DecRef(ctx)
buf := []byte("hello world\n")
n, err := socket.Writev(contexttest.Context(t), usermem.BytesIOSequence(buf))
if err != nil {
t.Fatalf("socket writev failed: %v", err)
}
if n != int64(len(buf)) {
t.Fatalf("socket writev wrote incorrect bytes: %d", n)
}
} | explode_data.jsonl/252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 265
} | [
2830,
3393,
10286,
7985,
85,
1155,
353,
8840,
836,
8,
341,
197,
322,
12091,
7575,
12670,
1588,
1576,
432,
594,
2669,
8433,
624,
3223,
1310,
11,
1848,
1669,
51866,
52089,
12670,
18364,
941,
70860,
82754,
11,
51866,
78922,
23584,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestUserServiceUpdate(t *testing.T) {
// prepare mock and service
mock := NewMockUserService(t)
service := NewUserService(mock)
// EXPECT SUCCESS will simulated normal operation with no error return
// this simulation expect all process goes as expected
t.Run("EXPECT SUCCESS", func(t *testing.T){
// actual method call (method to test)
got, err := service.Update(u[0].ID.String(), *convertToRequest(*u[0]))
assert.NoError(t, err)
assert.Equal(t, u[0].ID, got.ID)
assert.Equal(t, u[0].Username, got.Username)
assert.Equal(t, u[0].Firstname, got.Firstname)
assert.Equal(t, u[0].Email, got.Email)
})
// EXPECT SUCCESS with new hashed pass generated.
// Simulated by override helper.HashPassword and helper.CheckPasswordHash
t.Run("EXPECT SUCCESS new hashed password", func(t *testing.T){
// mock checkPassHashFunc (instance func of helper.CheckPasswordHash)
checkPassHash := checkPassHashFunc
checkPassHashFunc = func(password string, hash string) bool {
return true
}
// mock generateHashPassFunc (instance func of helper.HashPassword)
hashPass := generateHashPassFunc
generateHashPassFunc = func(password string) (string,error) {
return u[0].PassKey, nil
}
defer func() {
generateHashPassFunc = hashPass
checkPassHashFunc = checkPassHash
}()
// actual method call (method to test)
got, err := service.Update(u[0].ID.String(), *convertToRequest(*u[0]))
assert.NoError(t, err)
assert.NotNil(t, got)
})
// EXPECT SUCCESS with old hashed pass.
// Simulated by override helper.HashPassword and helper.CheckPasswordHash
t.Run("EXPECT SUCCESS old hashed password", func(t *testing.T){
// mock checkPassHashFunc (instance func of helper.CheckPasswordHash)
checkPassHash := checkPassHashFunc
checkPassHashFunc = func(password string, hash string) bool {
return false
}
// mock generateHashPassFunc (instance func of helper.HashPassword)
hashPass := generateHashPassFunc
generateHashPassFunc = func(password string) (string,error) {
return u[0].PassKey, nil
}
defer func() {
generateHashPassFunc = hashPass
checkPassHashFunc = checkPassHash
}()
// actual method call (method to test)
got, err := service.Update(u[0].ID.String(), *convertToRequest(*u[0]))
assert.NoError(t, err)
assert.NotNil(t, got)
})
// EXPECT FAIL with hash pass generated fail.
// Simulated by override helper.HashPassword and helper.CheckPasswordHash
t.Run("EXPECT FAIL hashed password generate error", func(t *testing.T){
// mock checkPassHashFunc (instance func of helper.CheckPasswordHash)
checkPassHash := checkPassHashFunc
checkPassHashFunc = func(password string, hash string) bool {
return false
}
// mock generateHashPassFunc (instance func of helper.HashPassword)
hashPass := generateHashPassFunc
generateHashPassFunc = func(password string) (string,error) {
return "", E.New(E.ErrPasswordTooShort)
}
defer func() {
generateHashPassFunc = hashPass
checkPassHashFunc = checkPassHash
}()
// actual method call (method to test)
got, err := service.Update(u[0].ID.String(), *convertToRequest(*u[0]))
assert.Error(t, err)
assert.Nil(t, got)
})
// EXPECT FAIL invalid data error. Simulated by giving invalid input data
t.Run("EXPECT FAIL invalid data error", func(t *testing.T){
// prepare invalid user data
invalidUser := convertToRequest(*u[0])
invalidUser.Firstname = ""
// actual method call (method to test)
got, err := service.Update(u[0].ID.String(), *invalidUser)
assert.Error(t, err)
assert.Nil(t, got)
})
// EXPECT FAIL invalid email error. Simulated by giving invalid email data
t.Run("EXPECT FAIL invalid email error", func(t *testing.T){
// prepare invalid user data
invalidUser := convertToRequest(*u[0])
invalidUser.Email = "john.doe.com"
// actual method call (method to test)
got, err := service.Update(u[0].ID.String(), *invalidUser)
assert.Error(t, err)
assert.Nil(t, got)
})
// EXPECT FAIL get user record for comparison. Simulated by forcing to return error
// by setting wantErr=true
t.Run("EXPECT FAIL get user record error", func(t *testing.T){
// prepare invalid user data
invalidUser := convertToRequest(*u[0])
invalidUser.RoleID = 5
// actual method call (method to test)
wantErr = true
got, err := service.Update(u[0].ID.String(), *convertToRequest(*u[0]))
wantErr = false
assert.Error(t, err)
assert.Nil(t, got)
})
// EXPECT FAIL update record error. Simulated by forcing to return error
// by setting wantErr=true
t.Run("EXPECT FAIL update record error", func(t *testing.T){
// prepare invalid user data
invalidUser := convertToRequest(*u[0])
// actual method call (method to test)
wantErr = true
got, err := service.Update(uuid.NewString(), *invalidUser)
wantErr = false
assert.Error(t, err)
assert.Nil(t, got)
})
} | explode_data.jsonl/30944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2262
} | [
2830,
3393,
60004,
4289,
1155,
353,
8840,
836,
8,
341,
262,
442,
10549,
7860,
323,
2473,
198,
262,
7860,
1669,
1532,
11571,
60004,
1155,
340,
262,
2473,
1669,
1532,
60004,
30389,
692,
262,
442,
8921,
33941,
686,
45736,
4622,
5666,
448,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateWorkflow(t *testing.T) {
type (
args struct {
db mock.DB
wfTemplate, wfHardware string
}
want struct {
expectedError bool
}
)
testCases := map[string]struct {
args args
want want
}{
"FailedToGetTemplate": {
args: args{
db: mock.DB{
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (string, string, string, error) {
return "", "", "", errors.New("failed to get template")
},
},
wfTemplate: templateID,
wfHardware: hw,
},
want: want{
expectedError: true,
},
},
"FailedCreatingWorkflow": {
args: args{
db: mock.DB{
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (string, string, string, error) {
return "", "", templateData, nil
},
CreateWorkflowFunc: func(ctx context.Context, wf db.Workflow, data string, id uuid.UUID) error {
return errors.New("failed to create a workfow")
},
},
wfTemplate: templateID,
wfHardware: hw,
},
want: want{
expectedError: true,
},
},
"SuccessCreatingWorkflow": {
args: args{
db: mock.DB{
GetTemplateFunc: func(ctx context.Context, fields map[string]string, deleted bool) (string, string, string, error) {
return "", "", templateData, nil
},
CreateWorkflowFunc: func(ctx context.Context, wf db.Workflow, data string, id uuid.UUID) error {
return nil
},
},
wfTemplate: templateID,
wfHardware: hw,
},
want: want{
expectedError: false,
},
},
}
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
s := testServer(t, tc.args.db)
res, err := s.CreateWorkflow(ctx, &workflow.CreateRequest{
Hardware: tc.args.wfHardware,
Template: tc.args.wfTemplate,
})
if err != nil {
assert.Error(t, err)
assert.Empty(t, res)
assert.True(t, tc.want.expectedError)
return
}
assert.NoError(t, err)
assert.NotEmpty(t, res)
assert.False(t, tc.want.expectedError)
})
}
} | explode_data.jsonl/51753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 945
} | [
2830,
3393,
4021,
62768,
1155,
353,
8840,
836,
8,
341,
13158,
2399,
197,
31215,
2036,
341,
298,
20939,
3824,
7860,
22537,
198,
298,
6692,
69,
7275,
11,
41248,
66862,
914,
198,
197,
197,
532,
197,
50780,
2036,
341,
298,
42400,
1454,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStripNanoAddr(t *testing.T) {
cv.Convey("StripNanomsgAddressPrefix should omit the 'tcp://' stuff", t, func() {
strip, err := StripNanomsgAddressPrefix("tcp://a.b.c.d:9090")
cv.So(strip, cv.ShouldEqual, "a.b.c.d:9090")
cv.So(err, cv.ShouldEqual, nil)
})
} | explode_data.jsonl/666 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
5901,
83819,
13986,
1155,
353,
8840,
836,
8,
1476,
41170,
4801,
5617,
445,
5901,
45,
276,
316,
1991,
4286,
14335,
1265,
51044,
279,
364,
27161,
66739,
6259,
497,
259,
11,
2915,
368,
341,
197,
197,
13105,
11,
1848,
1669,
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... | 1 |
func TestAdmit(t *testing.T) {
containerName := "container"
pod := &api.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "mypod",
Namespace: "namespace",
Labels: map[string]string{
"security": "S2",
},
},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: containerName,
Env: []api.EnvVar{{Name: "abc", Value: "value2"}, {Name: "ABCD", Value: "value3"}},
},
},
},
}
pip := &settings.PodPreset{
ObjectMeta: v1.ObjectMeta{
Name: "hello",
Namespace: "namespace",
},
Spec: settings.PodPresetSpec{
Selector: v1.LabelSelector{
MatchExpressions: []v1.LabelSelectorRequirement{
{
Key: "security",
Operator: v1.LabelSelectorOpIn,
Values: []string{"S2"},
},
},
},
Volumes: []api.Volume{{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
Env: []api.EnvVar{{Name: "abcd", Value: "value"}, {Name: "ABC", Value: "value"}},
EnvFrom: []api.EnvFromSource{
{
ConfigMapRef: &api.ConfigMapEnvSource{
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
},
},
{
Prefix: "pre_",
ConfigMapRef: &api.ConfigMapEnvSource{
LocalObjectReference: api.LocalObjectReference{Name: "abc"},
},
},
},
},
}
err := admitPod(pod, pip)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/20885 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 650
} | [
2830,
3393,
2589,
1763,
1155,
353,
8840,
836,
8,
341,
53290,
675,
1669,
330,
3586,
1837,
3223,
347,
1669,
609,
2068,
88823,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
86134,
347,
756,
298,
90823,
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 TestValidateRevisionNameFn(t *testing.T) {
tests := []struct {
caseName string
validatingAppConfig ValidatingAppConfig
want []error
}{
{
caseName: "componentName and revisionName are both assigned",
validatingAppConfig: ValidatingAppConfig{
validatingComps: []ValidatingComponent{
{
appConfigComponent: v1alpha2.ApplicationConfigurationComponent{
ComponentName: "example-comp",
RevisionName: "example-comp-v1",
},
},
},
},
want: []error{
fmt.Errorf(errFmtRevisionName, "example-comp", "example-comp-v1"),
},
},
{
caseName: "componentName is assigned",
validatingAppConfig: ValidatingAppConfig{
validatingComps: []ValidatingComponent{
{
appConfigComponent: v1alpha2.ApplicationConfigurationComponent{
ComponentName: "example-comp",
},
},
},
},
want: nil,
},
{
caseName: "revisionName is assigned",
validatingAppConfig: ValidatingAppConfig{
validatingComps: []ValidatingComponent{
{
appConfigComponent: v1alpha2.ApplicationConfigurationComponent{
RevisionName: "example-comp-v1",
},
},
},
},
want: nil,
},
}
for _, tc := range tests {
result := ValidateRevisionNameFn(ctx, tc.validatingAppConfig)
assert.Equal(t, tc.want, result, fmt.Sprintf("Test case: %q", tc.caseName))
}
} | explode_data.jsonl/1601 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 596
} | [
2830,
3393,
17926,
33602,
675,
24911,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
2722,
675,
310,
914,
198,
197,
56322,
1095,
2164,
2648,
7818,
1095,
2164,
2648,
198,
197,
50780,
394,
3056,
841,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocalSubchartFileDependencies(t *testing.T) {
input := []byte(fileRequirementsYAML)
expected := "./foobar"
actual, err := localSubchartDependencies(input)
if err != nil {
t.Fatal(err)
}
assert.Contains(t, actual, expected)
} | explode_data.jsonl/15143 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
7319,
3136,
15941,
1703,
48303,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
3056,
3782,
4866,
59202,
56,
31102,
340,
42400,
1669,
5924,
50267,
698,
88814,
11,
1848,
1669,
2205,
3136,
15941,
48303,
5384,
340,
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
] | 2 |
func TestGetZone(t *testing.T) {
cloud := &Cloud{
Config: Config{
Location: "eastus",
UseInstanceMetadata: true,
},
}
testcases := []struct {
name string
zone string
faultDomain string
expected string
}{
{
name: "GetZone should get real zone if only node's zone is set",
zone: "1",
expected: "eastus-1",
},
{
name: "GetZone should get real zone if both node's zone and FD are set",
zone: "1",
faultDomain: "99",
expected: "eastus-1",
},
{
name: "GetZone should get faultDomain if node's zone isn't set",
faultDomain: "99",
expected: "99",
},
}
for _, test := range testcases {
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Errorf("Test [%s] unexpected error: %v", test.name, err)
}
mux := http.NewServeMux()
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, fmt.Sprintf(`{"compute":{"zone":"%s", "platformFaultDomain":"%s"}}`, test.zone, test.faultDomain))
}))
go func() {
http.Serve(listener, mux)
}()
defer listener.Close()
cloud.metadata, err = NewInstanceMetadataService("http://" + listener.Addr().String() + "/")
if err != nil {
t.Errorf("Test [%s] unexpected error: %v", test.name, err)
}
zone, err := cloud.GetZone(context.Background())
if err != nil {
t.Errorf("Test [%s] unexpected error: %v", test.name, err)
}
if zone.FailureDomain != test.expected {
t.Errorf("Test [%s] unexpected zone: %s, expected %q", test.name, zone.FailureDomain, test.expected)
}
if zone.Region != cloud.Location {
t.Errorf("Test [%s] unexpected region: %s, expected: %s", test.name, zone.Region, cloud.Location)
}
}
} | explode_data.jsonl/80282 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 757
} | [
2830,
3393,
1949,
15363,
1155,
353,
8840,
836,
8,
341,
197,
12361,
1669,
609,
16055,
515,
197,
66156,
25,
5532,
515,
298,
197,
4707,
25,
310,
330,
60501,
355,
756,
298,
95023,
2523,
14610,
25,
830,
345,
197,
197,
1583,
197,
532,
181... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerragruntStdOut(t *testing.T) {
t.Parallel()
var (
stdout bytes.Buffer
stderr bytes.Buffer
)
runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_STDOUT))
runTerragruntRedirectOutput(t, fmt.Sprintf("terragrunt output foo --terragrunt-non-interactive --terragrunt-working-dir %s", TEST_FIXTURE_STDOUT), &stdout, &stderr)
output := stdout.String()
assert.Equal(t, "\"foo\"\n", output)
} | explode_data.jsonl/10085 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
51402,
68305,
3850,
22748,
2662,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2405,
2399,
197,
6736,
411,
5820,
22622,
198,
197,
6736,
615,
5820,
22622,
198,
197,
692,
56742,
51402,
68305,
3850,
1155,
11,
8879,
173... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetaReverseScanBounds(t *testing.T) {
testCases := []struct {
key []byte
expStart, expEnd []byte
expError string
}{
{
key: roachpb.RKey{},
expStart: nil,
expEnd: nil,
expError: "KeyMin and Meta1Prefix can't be used as the key of reverse scan",
},
{
key: Meta1Prefix,
expStart: nil,
expEnd: nil,
expError: "KeyMin and Meta1Prefix can't be used as the key of reverse scan",
},
{
key: Meta2KeyMax.Next(),
expStart: nil,
expEnd: nil,
expError: "body of meta key range lookup is",
},
{
key: Meta1KeyMax.Next(),
expStart: nil,
expEnd: nil,
expError: "body of meta key range lookup is",
},
{
key: makeKey(Meta2Prefix, roachpb.Key("foo")),
expStart: Meta2Prefix,
expEnd: makeKey(Meta2Prefix, roachpb.Key("foo\x00")),
expError: "",
},
{
key: makeKey(Meta1Prefix, roachpb.Key("foo")),
expStart: Meta1Prefix,
expEnd: makeKey(Meta1Prefix, roachpb.Key("foo\x00")),
expError: "",
},
{
key: MustAddr(Meta2Prefix),
expStart: Meta1Prefix,
expEnd: Meta2Prefix.Next(),
expError: "",
},
{
key: Meta2KeyMax,
expStart: Meta2Prefix,
expEnd: Meta2KeyMax.Next(),
expError: "",
},
}
for i, test := range testCases {
res, err := MetaReverseScanBounds(roachpb.RKey(test.key))
if !testutils.IsError(err, test.expError) {
t.Errorf("expected error %q ; got %v", test.expError, err)
}
expected := roachpb.RSpan{Key: test.expStart, EndKey: test.expEnd}
if !res.Equal(expected) {
t.Errorf("%d: range bounds %s don't match expected bounds %s for key %s",
i, res, expected, roachpb.Key(test.key))
}
}
} | explode_data.jsonl/56595 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 824
} | [
2830,
3393,
12175,
45695,
26570,
11394,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
23634,
1060,
3056,
3782,
198,
197,
48558,
3479,
11,
1343,
3727,
3056,
3782,
198,
197,
48558,
1454,
260,
914,
198,
197,
59403... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCurrentContextClusterType(t *testing.T) {
conf, cleanup := testutil.InitConfig(t)
defer cleanup(t)
expectedClusterType := "ephemeral"
clusterTypeEmpty, err := conf.CurrentContextClusterType()
require.Error(t, err)
assert.Equal(t, "", clusterTypeEmpty)
conf.CurrentContext = currentContextName
conf.Contexts[currentContextName].Manifest = defaultString
actualClusterType, err := conf.CurrentContextClusterType()
require.NoError(t, err)
assert.Equal(t, expectedClusterType, actualClusterType)
} | explode_data.jsonl/57909 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
5405,
1972,
28678,
929,
1155,
353,
8840,
836,
8,
341,
67850,
11,
21290,
1669,
1273,
1314,
26849,
2648,
1155,
340,
16867,
21290,
1155,
692,
42400,
28678,
929,
1669,
330,
23544,
336,
3253,
1837,
197,
18855,
929,
3522,
11,
1848... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCORSResponseHeaders(t *testing.T) {
tests := []struct {
desc string
requestOrigin string
setHeaders map[string]string
expectedLog string
}{
{
desc: "not cors",
requestOrigin: "",
setHeaders: map[string]string{},
expectedLog: "",
},
{
desc: "origin",
requestOrigin: "origin",
setHeaders: map[string]string{
config.CORSAllowOrigin: "origin",
config.CORSAllowHeaders: "AllowHeaders",
config.CORSExposeHeaders: "ExposeHeaders",
config.CORSAllowMethods: "AllowMethods",
config.CORSMaxAge: "42",
config.CORSAllowCredentials: "true",
config.CORSVary: config.CORSVaryOrigin,
},
expectedLog: "Response header mods:\n = \"access-control-allow-credentials\": \"true\"\n = \"access-control-allow-headers\": \"Allow...\"\n = \"access-control-allow-methods\": \"Allow...\"\n = \"access-control-allow-origin\": \"origi...\"\n = \"access-control-expose-headers\": \"Expos...\"\n = \"access-control-max-age\": \"42\"\n = \"vary\": \"Origi...\"\n",
},
{
desc: "wildcard",
requestOrigin: "foo",
setHeaders: map[string]string{
config.CORSAllowOrigin: "*",
config.CORSAllowHeaders: "AllowHeaders",
config.CORSExposeHeaders: "ExposeHeaders",
config.CORSAllowMethods: "AllowMethods",
config.CORSMaxAge: "42",
config.CORSVary: config.CORSVaryOrigin,
},
expectedLog: "Response header mods:\n = \"access-control-allow-headers\": \"Allow...\"\n = \"access-control-allow-methods\": \"Allow...\"\n = \"access-control-allow-origin\": \"*\"\n = \"access-control-expose-headers\": \"Expos...\"\n = \"access-control-max-age\": \"42\"\n = \"vary\": \"Origi...\"\n",
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
envSpec := createAuthEnvSpec()
specExt, err := config.NewEnvironmentSpecExt(&envSpec)
if err != nil {
t.Fatal(err)
}
headers := map[string]string{config.CORSOriginHeader: test.requestOrigin}
envoyReq := testutil.NewEnvoyRequest(http.MethodOptions, "/v1/petstore", headers, nil)
req := config.NewEnvironmentSpecRequest(&testAuthMan{}, specExt, envoyReq)
headerOptions := corsResponseHeaders(req)
if len(test.setHeaders) != len(headerOptions) {
t.Errorf("expected %d headers, got: %d: %v", len(test.setHeaders), len(headerOptions), headerOptions)
}
for k, v := range test.setHeaders {
if !hasHeaderAdd(headerOptions, k, v, false) {
t.Errorf("expected header set: %q: %q", k, v)
}
}
okResponse := &authv3.OkHttpResponse{ResponseHeadersToAdd: headerOptions}
logged := printHeaderMods(okResponse)
if test.expectedLog != logged {
t.Errorf("want: %q\n, got: %q\n", test.expectedLog, logged)
}
})
}
} | explode_data.jsonl/73195 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1194
} | [
2830,
3393,
34,
9821,
2582,
10574,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
688,
914,
198,
197,
23555,
13298,
914,
198,
197,
8196,
10574,
262,
2415,
14032,
30953,
198,
197,
42400,
2201,
256,
914,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestAllValsetConfirmsBynonce(t *testing.T) {
input := CreateTestEnv(t)
ctx := input.Context
addrs := []string{
"cosmos1u508cfnsk2nhakv80vdtq3nf558ngyvldkfjj9",
"cosmos1krtcsrxhadj54px0vy6j33pjuzcd3jj8kmsazv",
"cosmos1u94xef3cp9thkcpxecuvhtpwnmg8mhlja8hzkd",
}
// seed confirmations
for i := 0; i < 3; i++ {
addr, _ := sdk.AccAddressFromBech32(addrs[i])
msg := types.MsgValsetConfirm{}
msg.EthAddress = gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(i + 1)}, 20)).String()
msg.Nonce = uint64(1)
msg.Orchestrator = addr.String()
msg.Signature = fmt.Sprintf("signature %d", i+1)
input.GravityKeeper.SetValsetConfirm(ctx, msg)
}
specs := map[string]struct {
srcNonce string
expErr bool
expResp []byte
}{
"all good": {
srcNonce: "1",
expResp: []byte(`[
{"eth_address":"0x0202020202020202020202020202020202020202", "nonce": "1", "orchestrator": "cosmos1krtcsrxhadj54px0vy6j33pjuzcd3jj8kmsazv", "signature": "signature 2"},
{"eth_address":"0x0303030303030303030303030303030303030303", "nonce": "1", "orchestrator": "cosmos1u94xef3cp9thkcpxecuvhtpwnmg8mhlja8hzkd", "signature": "signature 3"},
{"eth_address":"0x0101010101010101010101010101010101010101", "nonce": "1", "orchestrator": "cosmos1u508cfnsk2nhakv80vdtq3nf558ngyvldkfjj9", "signature": "signature 1"}
]`),
},
"unknown nonce": {
srcNonce: "999999",
expResp: nil,
},
"invalid nonce": {
srcNonce: "not a valid nonce",
expErr: true,
},
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
got, err := queryAllValsetConfirms(ctx, spec.srcNonce, input.GravityKeeper)
if spec.expErr {
require.Error(t, err)
return
}
require.NoError(t, err)
if spec.expResp == nil {
assert.Nil(t, got)
return
}
assert.JSONEq(t, string(spec.expResp), string(got))
})
}
} | explode_data.jsonl/8794 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 883
} | [
2830,
3393,
2403,
2208,
746,
15578,
14404,
1359,
39593,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
14359,
1155,
340,
20985,
1669,
1946,
9328,
271,
12718,
5428,
1669,
3056,
917,
515,
197,
197,
1,
9407,
8631,
16,
84,
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 TestMutableForEachStopIterator(t *testing.T) {
t.Parallel()
// Insert a few keys.
numItems := 10
testTreap := NewMutable()
for i := 0; i < numItems; i++ {
key := serializeUint32(uint32(i))
testTreap.Put(key, key)
}
// Ensure ForEach exits early on false return by caller.
var numIterated int
testTreap.ForEach(func(k, v []byte) bool {
numIterated++
return numIterated != numItems/2
})
if numIterated != numItems/2 {
t.Fatalf("ForEach: unexpected iterate count - got %d, want %d",
numIterated, numItems/2)
}
} | explode_data.jsonl/70549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
11217,
91392,
10674,
11951,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
17101,
264,
2421,
6894,
624,
22431,
4353,
1669,
220,
16,
15,
198,
18185,
65775,
391,
1669,
1532,
11217,
741,
2023,
600,
1669,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEmbeddedSimple(t *testing.T) {
type UUID [16]byte
type MyID struct {
UUID
}
type Item struct {
ID MyID
}
z := Item{}
m := NewMapper("db")
m.TypeMap(reflect.TypeOf(z))
} | explode_data.jsonl/59095 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
83466,
16374,
1155,
353,
8840,
836,
8,
341,
13158,
23698,
508,
16,
21,
90184,
198,
13158,
3017,
915,
2036,
341,
197,
15980,
6463,
198,
197,
532,
13158,
5739,
2036,
341,
197,
29580,
3017,
915,
198,
197,
532,
20832,
1669,
57... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfirmTask(t *testing.T) {
taskIdArgs := &TaskIdArgs{
TaskId: BBC_TestTaskId,
}
err := BBC_CLIENT.ConfirmRepairTask(taskIdArgs)
ExpectEqual(t.Errorf, err, nil)
} | explode_data.jsonl/4081 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
16728,
6262,
1155,
353,
8840,
836,
8,
341,
49115,
764,
4117,
1669,
609,
6262,
764,
4117,
515,
197,
81153,
764,
25,
18096,
32541,
6262,
764,
345,
197,
532,
9859,
1669,
18096,
22521,
4801,
8802,
98386,
6262,
17483,
764,
4117,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoMatch(t *testing.T) {
config, err := NewConfig(bytes.NewBuffer(testConfig))
require.NoError(t, err, "There should be no error while unmarshaling config")
testEvent = v1.Event{
Message: "Other message",
Source: v1.EventSource{
Host: "Testnode",
},
Type: "Normal",
}
matches := LogEvent(&testEvent, &EventRouter{Config: config})
require.Empty(t, matches)
} | explode_data.jsonl/36667 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
2753,
8331,
1155,
353,
8840,
836,
8,
341,
25873,
11,
1848,
1669,
1532,
2648,
23158,
7121,
4095,
8623,
2648,
1171,
17957,
35699,
1155,
11,
1848,
11,
330,
3862,
1265,
387,
902,
1465,
1393,
650,
36239,
6132,
2193,
5130,
18185,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCloneNode(t *testing.T) {
tests := []struct {
name string
v *Node
}{
{"nil_fields", &Node{}},
{"zero_fields", &Node{
Addresses: make([]netaddr.IPPrefix, 0),
AllowedIPs: make([]netaddr.IPPrefix, 0),
Endpoints: make([]string, 0),
}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v2 := tt.v.Clone()
if !reflect.DeepEqual(tt.v, v2) {
t.Errorf("not equal")
}
})
}
} | explode_data.jsonl/48392 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
37677,
1955,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
5195,
262,
353,
1955,
198,
197,
59403,
197,
197,
4913,
8385,
12132,
497,
609,
1955,
6257,
1583,
197,
197,
4913,
14154,
121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue10156(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("CREATE TABLE `t1` (`period_name` varchar(24) DEFAULT NULL ,`period_id` bigint(20) DEFAULT NULL ,`starttime` bigint(20) DEFAULT NULL)")
tk.MustExec("CREATE TABLE `t2` (`bussid` bigint(20) DEFAULT NULL,`ct` bigint(20) DEFAULT NULL)")
q := `
select
a.period_name,
b.date8
from
(select * from t1) a
left join
(select bussid,date(from_unixtime(ct)) date8 from t2) b
on
a.period_id = b.bussid
where
datediff(b.date8, date(from_unixtime(a.starttime))) >= 0`
tk.MustQuery(q)
} | explode_data.jsonl/65483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
42006,
16,
15,
16,
20,
21,
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,
692,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExponentialBackoff(t *testing.T) {
backoff, _ := NewExponentialBackoff(100, 2000, 1.3)
for i := 1; i < 100; i++ {
backoff.NextDelayMillis(i)
}
if _, err := NewExponentialBackoff(-1, 12, 3); err == nil {
t.FailNow()
}
if _, err := NewExponentialBackoff(3, 2, 3); err == nil {
t.FailNow()
}
if _, err := NewExponentialBackoff(3, 12, 0.3); err == nil {
t.FailNow()
}
// fake
if saturatedMultiply(3, float64(math.MaxInt64)) != math.MaxInt64 {
t.FailNow()
}
} | explode_data.jsonl/64689 | {
"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,
840,
59825,
3707,
1847,
1155,
353,
8840,
836,
8,
341,
77446,
1847,
11,
716,
1669,
1532,
840,
59825,
3707,
1847,
7,
16,
15,
15,
11,
220,
17,
15,
15,
15,
11,
220,
16,
13,
18,
340,
2023,
600,
1669,
220,
16,
26,
600,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestAddItemRootIAuthorSetsAuthorIAuthor(t *testing.T) {
t.Parallel()
// arrange
p := podcast.New("title", "link", "description", nil, nil)
p.IAuthor = "me@janedoe.com"
i := podcast.Item{Title: "title", Description: "desc", Link: "http://a.co/"}
// act
added, err := p.AddItem(i)
// assert
assert.EqualValues(t, 1, added)
assert.NoError(t, err)
assert.Len(t, p.Items, 1)
assert.EqualValues(t, "me@janedoe.com", p.Items[0].Author.Email)
assert.EqualValues(t, "me@janedoe.com", p.Items[0].IAuthor)
} | explode_data.jsonl/73084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
2212,
1234,
8439,
5863,
1553,
30175,
7133,
5863,
1553,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
30893,
198,
3223,
1669,
17711,
7121,
445,
2102,
497,
330,
2080,
497,
330,
4684,
497,
2092,
11,
2092,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetProtoSeldonMessage(t *testing.T) {
g := NewGomegaWithT(t)
var sm seldon.SeldonMessage
var data = `{"data":{"ndarray":[1.1,2]}}`
err := jsonpb.UnmarshalString(data, &sm)
g.Expect(err).To(BeNil())
b, err := proto.Marshal(&sm)
g.Expect(err).To(BeNil())
sm2, err := getProto("seldon.protos.SeldonMessage", b)
g.Expect(err).To(BeNil())
g.Expect(proto.Equal(sm2, &sm)).Should(Equal(true))
} | explode_data.jsonl/80300 | {
"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,
1949,
31549,
50,
55043,
2052,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
692,
2405,
1525,
274,
55043,
808,
55043,
2052,
198,
2405,
821,
284,
1565,
4913,
691,
22317,
303,
1653,
8899,
16,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRequestReauthsAtMostOnce(t *testing.T) {
// There was an issue where Gophercloud would go into an infinite
// reauthentication loop with buggy services that send 401 even for fresh
// tokens. This test simulates such a service and checks that a call to
// ProviderClient.Request() will not try to reauthenticate more than once.
reauthCounter := 0
var reauthCounterMutex sync.Mutex
p := new(gophercloud.ProviderClient)
p.UseTokenLock()
p.SetToken(client.TokenID)
p.ReauthFunc = func() error {
reauthCounterMutex.Lock()
reauthCounter++
reauthCounterMutex.Unlock()
//The actual token value does not matter, the endpoint does not check it.
return nil
}
th.SetupHTTP()
defer th.TeardownHTTP()
requestCounter := 0
var requestCounterMutex sync.Mutex
th.Mux.HandleFunc("/route", func(w http.ResponseWriter, r *http.Request) {
requestCounterMutex.Lock()
requestCounter++
//avoid infinite loop
if requestCounter == 10 {
http.Error(w, "too many requests", http.StatusTooManyRequests)
return
}
requestCounterMutex.Unlock()
//always reply 401, even immediately after reauthenticate
http.Error(w, "unauthorized", http.StatusUnauthorized)
})
// The expected error message indicates that we reauthenticated once (that's
// the part before the colon), but when encountering another 401 response, we
// did not attempt reauthentication again and just passed that 401 response to
// the caller as ErrDefault401.
_, err := p.Request("GET", th.Endpoint()+"/route", &gophercloud.RequestOpts{})
expectedErrorMessage := "Successfully re-authenticated, but got error executing request: Authentication failed"
th.AssertEquals(t, expectedErrorMessage, err.Error())
} | explode_data.jsonl/5892 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 523
} | [
2830,
3393,
1900,
693,
3242,
82,
1655,
13319,
12522,
1155,
353,
8840,
836,
8,
341,
197,
322,
2619,
572,
458,
4265,
1380,
479,
16940,
12361,
1035,
728,
1119,
458,
23809,
198,
197,
322,
312,
45890,
6337,
448,
79311,
3516,
429,
3624,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContextResetInHandler(t *testing.T) {
w := CreateTestResponseRecorder()
c, _ := CreateTestContext(w)
c.handlers = []HandlerFunc{
func(c *Context) { c.reset() },
}
assert.NotPanics(t, func() {
c.Next()
})
} | explode_data.jsonl/26840 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
1972,
14828,
641,
3050,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
4230,
2271,
2582,
47023,
741,
1444,
11,
716,
1669,
4230,
2271,
1972,
3622,
692,
1444,
55001,
284,
3056,
3050,
9626,
515,
197,
29244,
1337,
353,
1972,
8,
314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBuffering(t *testing.T) {
c, s := net.Pipe()
done := make(chan bool)
clientWCC := &writeCountingConn{Conn: c}
serverWCC := &writeCountingConn{Conn: s}
go func() {
Server(serverWCC, testConfig).Handshake()
serverWCC.Close()
done <- true
}()
err := Client(clientWCC, testConfig).Handshake()
if err != nil {
t.Fatal(err)
}
clientWCC.Close()
<-done
if n := clientWCC.numWrites; n != 2 {
t.Errorf("expected client handshake to complete with only two writes, but saw %d", n)
}
if n := serverWCC.numWrites; n != 2 {
t.Errorf("expected server handshake to complete with only two writes, but saw %d", n)
}
} | explode_data.jsonl/32307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
4095,
287,
1155,
353,
8840,
836,
8,
341,
1444,
11,
274,
1669,
4179,
1069,
3444,
741,
40495,
1669,
1281,
35190,
1807,
692,
25291,
54,
3706,
1669,
609,
4934,
2507,
287,
9701,
90,
9701,
25,
272,
532,
41057,
54,
3706,
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 TestIngessToPrometheus_ServiceMetric(t *testing.T) {
framework.
NewTest(t).
// TODO(https://github.com/istio/istio/issues/14819)
Label(label.Flaky).
Run(func(ctx framework.TestContext) {
label := "source_workload"
labelValue := "istio-ingressgateway"
testMetric(t, ctx, label, labelValue)
})
} | explode_data.jsonl/49345 | {
"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,
25416,
433,
1249,
35186,
39705,
52548,
54310,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
624,
197,
197,
3564,
2271,
1155,
4292,
197,
197,
322,
5343,
7,
2428,
1110,
5204,
905,
14,
380,
815,
14,
380,
815,
38745,
14,
16,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSensitiveFindallSingleword(t *testing.T) {
filter := New()
filter.AddWord("东")
testcases := []struct {
Text string
Expect []string
}{
{"两个东西", []string{"东"}},
}
for _, tc := range testcases {
if got := filter.FindAll(tc.Text); !reflect.DeepEqual(tc.Expect, got) {
t.Errorf("findall %s, got %s, expect %s", tc.Text, got, tc.Expect)
}
}
} | explode_data.jsonl/80996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
63316,
9885,
541,
10888,
1158,
1155,
353,
8840,
836,
8,
341,
50108,
1669,
1532,
741,
50108,
1904,
10879,
445,
67364,
5130,
18185,
23910,
1669,
3056,
1235,
341,
197,
49635,
256,
914,
198,
197,
35911,
3056,
917,
198,
197,
5940... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyMerger(t *testing.T) {
assert(t, EmptyMerger.Length() == 0, "Not empty")
assert(t, EmptyMerger.count == 0, "Invalid count")
assert(t, len(EmptyMerger.lists) == 0, "Invalid lists")
assert(t, len(EmptyMerger.merged) == 0, "Invalid merged list")
} | explode_data.jsonl/22593 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
3522,
26716,
1389,
1155,
353,
8840,
836,
8,
341,
6948,
1155,
11,
22228,
26716,
1389,
6833,
368,
621,
220,
15,
11,
330,
2623,
4287,
1138,
6948,
1155,
11,
22228,
26716,
1389,
6501,
621,
220,
15,
11,
330,
7928,
1760,
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... | 1 |
func TestInvalidPing(t *testing.T) {
runTests(t, "http://invalid-server:8765", func(dbt *DBTest) {
err := dbt.db.Ping()
if err == nil {
t.Error("Expected ping to fail, but did not get any error")
}
})
} | explode_data.jsonl/20924 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
7928,
69883,
1155,
353,
8840,
836,
8,
341,
56742,
18200,
1155,
11,
330,
1254,
1110,
11808,
26300,
25,
23,
22,
21,
20,
497,
2915,
9791,
83,
353,
3506,
2271,
8,
341,
197,
9859,
1669,
2927,
83,
7076,
1069,
287,
2822,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDefaultLabeller(t *testing.T) {
tests := []struct {
description string
version string
expected string
}{
{
description: "version mentioned",
version: "1.0",
expected: "skaffold-1.0",
},
{
description: "empty version should add postfix unknown",
expected: "skaffold-unknown",
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.Override(&version.Get, func() *version.Info {
return &version.Info{
Version: test.version,
}
})
l := NewLabeller(config.SkaffoldOptions{})
labels := l.Labels()
expected := map[string]string{
"app.kubernetes.io/managed-by": test.expected,
"skaffold.dev/run-id": l.runID,
}
t.CheckDeepEqual(expected, labels)
})
}
} | explode_data.jsonl/31969 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
3675,
29046,
7073,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
74954,
257,
914,
198,
197,
42400,
262,
914,
198,
197,
59403,
197,
197,
515,
298,
42407,
25,
330,
4366,
9733,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckEnvVars(t *testing.T) {
result, err := checkEnvVars([]string{"ABC=def", "GHI=jkl"})
if err != nil {
t.Errorf("Expected there to be no error but got: %s", err)
}
if result["ABC"] != "def" {
t.Errorf("Expected ABC to be set to def but got: %s", result)
}
if result["GHI"] != "jkl" {
t.Errorf("Expected ABC to be set to def but got: %s", result)
}
} | explode_data.jsonl/53756 | {
"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,
3973,
14359,
28305,
1155,
353,
8840,
836,
8,
341,
9559,
11,
1848,
1669,
1779,
14359,
28305,
10556,
917,
4913,
25411,
28,
750,
497,
330,
38,
23913,
45612,
10561,
1,
8824,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
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... | 4 |
func TestDisconnectGitAlternatesNoAlternates(t *testing.T) {
locator := config.NewLocator(config.Config)
server, serverSocketPath := runObjectPoolServer(t, config.Config, locator)
defer server.Stop()
client, conn := newObjectPoolClient(t, serverSocketPath)
defer conn.Close()
ctx, cancel := testhelper.Context()
defer cancel()
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
altPath, err := locator.InfoAlternatesPath(testRepo)
require.NoError(t, err, "find info/alternates")
testhelper.AssertPathNotExists(t, altPath)
_, err = client.DisconnectGitAlternates(ctx, &gitalypb.DisconnectGitAlternatesRequest{Repository: testRepo})
require.NoError(t, err, "call DisconnectGitAlternates on repository without alternates")
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "fsck")
} | explode_data.jsonl/9 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
60651,
46562,
34543,
973,
2753,
34543,
973,
1155,
353,
8840,
836,
8,
341,
197,
68033,
1669,
2193,
7121,
33831,
8754,
10753,
340,
41057,
11,
3538,
10286,
1820,
1669,
1598,
1190,
10551,
5475,
1155,
11,
2193,
10753,
11,
47117,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetRevertUUID(t *testing.T) {
tt := []struct {
statement string
uuid string
isError bool
}{
{
statement: "revert 4e5dcf80_354b_11eb_82cd_f875a4d24e90",
uuid: "4e5dcf80_354b_11eb_82cd_f875a4d24e90",
},
{
statement: "REVERT 4e5dcf80_354b_11eb_82cd_f875a4d24e90",
uuid: "4e5dcf80_354b_11eb_82cd_f875a4d24e90",
},
{
statement: "alter table t drop column c",
isError: true,
},
}
for _, ts := range tt {
t.Run(ts.statement, func(t *testing.T) {
onlineDDL := &OnlineDDL{SQL: ts.statement}
uuid, err := onlineDDL.GetRevertUUID()
if ts.isError {
assert.Error(t, err)
return
}
assert.NoError(t, err)
assert.Equal(t, ts.uuid, uuid)
})
}
migrationContext := "354b-11eb-82cd-f875a4d24e90"
for _, ts := range tt {
t.Run(ts.statement, func(t *testing.T) {
onlineDDL, err := NewOnlineDDL("test_ks", "t", ts.statement, NewDDLStrategySetting(DDLStrategyOnline, ""), migrationContext)
assert.NoError(t, err)
require.NotNil(t, onlineDDL)
uuid, err := onlineDDL.GetRevertUUID()
if ts.isError {
assert.Error(t, err)
return
}
assert.NoError(t, err)
assert.Equal(t, ts.uuid, uuid)
})
}
} | explode_data.jsonl/42828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 615
} | [
2830,
3393,
1949,
693,
1621,
24754,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
89566,
914,
198,
197,
10676,
2423,
414,
914,
198,
197,
19907,
1454,
256,
1807,
198,
197,
59403,
197,
197,
515,
298,
89566,
25,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetTarget(t *testing.T) {
config.SetUpMockConfig(t)
target := &Target{
ManagerAddress: "10.10.0.14",
Password: []byte("Password"),
UserName: "admin",
DeviceUUID: "1e61aeb6-0f03-4a35-b266-9c98e08da111",
PluginID: "GRF",
}
create(target)
resp, err := GetTarget(target.DeviceUUID)
if err != nil {
t.Fatalf("Failed to get the device details")
}
assert.Equal(t, resp.ManagerAddress, target.ManagerAddress, "should be same")
assert.Equal(t, resp.UserName, target.UserName, "should be same")
assert.Equal(t, resp.PluginID, target.PluginID, "should be same")
// Negative Test case
// Invalid device uuid
resp, err = GetTarget("uuid")
assert.NotNil(t, err, "Error Should not be nil")
assert.Nil(t, resp, "resp Should not nil")
} | explode_data.jsonl/49400 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
1949,
6397,
1155,
353,
8840,
836,
8,
341,
25873,
4202,
2324,
11571,
2648,
1155,
340,
28861,
1669,
609,
6397,
515,
197,
197,
2043,
4286,
25,
330,
16,
15,
13,
16,
15,
13,
15,
13,
16,
19,
756,
197,
197,
4876,
25,
981,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_extractParams(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "/users/1/status", nil)
assert.NoError(t, err)
req.Header.Set(encoding.ContentTypeHeader, json.Type)
req.Header.Set(encoding.AcceptHeader, json.Type)
var fields map[string]string
proc := func(_ context.Context, req *Request) (*Response, error) {
fields = req.Fields
return nil, nil
}
router := httprouter.New()
route, err := NewRouteBuilder("/users/:id/status", proc).MethodGet().Build()
assert.NoError(t, err)
router.HandlerFunc(route.method, route.path, route.handler)
router.ServeHTTP(httptest.NewRecorder(), req)
assert.Equal(t, "1", fields["id"])
} | explode_data.jsonl/54960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
39123,
4870,
1155,
353,
8840,
836,
8,
341,
24395,
11,
1848,
1669,
1758,
75274,
19886,
20798,
1949,
11,
3521,
4218,
14,
16,
32518,
497,
2092,
340,
6948,
35699,
1155,
11,
1848,
340,
24395,
15753,
4202,
85863,
62710,
4047,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_readmodel_name_with_spaces_is_ok(t *testing.T) {
const emlYAML = `Solution: Identity & Access
Contexts:
- Name: Identity & Access
Streams:
- Stream: User
Commands:
- Command:
Name: Register User
Parameters:
- Name: userId
Type: string
IsRequired: true
- Name: email
Type: string
IsRequired: false
- Name: password
Type: string
IsRequired: false
Postconditions:
- UserRegistered
Events:
- Event:
Name: UserRegistered
Properties:
- Name: userId
Type: string
IsHashed: false
- Name: email
Type: string
IsHashed: false
- Name: password
Type: string
IsHashed: true
Readmodels:
- Readmodel:
Name: Users List
Key: userId
SubscribesTo:
- UserRegistered
Errors: []
`
sut := eml.Solution{}
sut.LoadYAML([]byte(emlYAML))
sut.Validate()
if len(sut.Errors) != 0 {
t.Error("expected no errors")
}
} | explode_data.jsonl/46929 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 519
} | [
2830,
3393,
6443,
2528,
1269,
6615,
67883,
6892,
19817,
1155,
353,
8840,
836,
8,
341,
4777,
976,
75,
56,
31102,
284,
1565,
36842,
25,
26540,
609,
9549,
198,
1972,
82,
510,
12,
3988,
25,
26540,
609,
9549,
198,
220,
94522,
510,
220,
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... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.