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 TestClientWithDefaultHeaders(t *testing.T) {
testCases := []struct {
name string
requestHeaders http.Header
defaultHeaders http.Header
expectedHeaders http.Header
}{
{
name: "no headers added when none set",
defaultHeaders: http.Header{},
expectedHeaders: http.Header{},
},
{
name: "existing headers in the request remain present",
requestHeaders: http.Header{"Some-Other": []string{"value"}},
defaultHeaders: http.Header{},
expectedHeaders: http.Header{"Some-Other": []string{"value"}},
},
{
name: "headers are set when present",
defaultHeaders: http.Header{
"User-Agent": []string{"foo/devel"},
"Authorization": []string{"some-token"},
},
expectedHeaders: http.Header{
"User-Agent": []string{"foo/devel"},
"Authorization": []string{"some-token"},
},
},
{
name: "headers can have multiple values",
defaultHeaders: http.Header{
"Authorization": []string{"some-token", "some-other-token"},
},
expectedHeaders: http.Header{
"Authorization": []string{"some-token", "some-other-token"},
},
},
{
name: "default headers do not overwrite request headers",
requestHeaders: http.Header{
"Authorization": []string{"request-auth-token"},
"Other-Request-Header": []string{"other-request-header"},
},
defaultHeaders: http.Header{
"Authorization": []string{"default-auth-token"},
"Other-Default-Header": []string{"other-default-header"},
},
expectedHeaders: http.Header{
"Authorization": []string{"request-auth-token"},
"Other-Request-Header": []string{"other-request-header"},
"Other-Default-Header": []string{"other-default-header"},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
client := &fakeHTTPClient{
defaultHeaders: tc.defaultHeaders,
}
request, err := http.NewRequest("GET", "http://example.com/foo", nil)
if err != nil {
t.Fatalf("%+v", err)
}
for k, v := range tc.requestHeaders {
request.Header[k] = v
}
client.Do(request)
requestsWithHeaders := getFakeClientRequests(t, client)
if got, want := len(requestsWithHeaders), 1; got != want {
t.Fatalf("got: %d, want: %d", got, want)
}
requestWithHeader := requestsWithHeaders[0]
if got, want := requestWithHeader.Header, tc.expectedHeaders; !cmp.Equal(got, want) {
t.Errorf(cmp.Diff(want, got))
}
})
}
} | explode_data.jsonl/12752 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1005
} | [
2830,
3393,
2959,
2354,
3675,
10574,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
23555,
10574,
220,
1758,
15753,
198,
197,
11940,
10574,
220,
1758,
15753,
198,
197,
42400,
10574,
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... | 5 |
func TestParseCommentsBeforeDot(t *testing.T) {
accessor := SourceAccessorFromMap(map[string]string{
"test.proto": `
syntax = "proto3";
message Foo {
// leading comments
.Foo foo = 1;
}
`,
})
compiler := Compiler{
Resolver: &SourceResolver{Accessor: accessor},
IncludeSourceInfo: true,
}
ctx := context.Background()
fds, err := compiler.Compile(ctx, "test.proto")
assert.Nil(t, err)
field := fds[0].Messages().Get(0).Fields().Get(0)
comment := fds[0].SourceLocations().ByDescriptor(field).LeadingComments
assert.Equal(t, " leading comments\n", comment)
} | explode_data.jsonl/18032 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
14463,
17373,
10227,
34207,
1155,
353,
8840,
836,
8,
341,
197,
5211,
269,
1669,
8748,
29889,
3830,
2227,
9147,
14032,
30953,
515,
197,
197,
1,
1944,
57322,
788,
22074,
56193,
284,
330,
15110,
18,
876,
1994,
33428,
341,
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 TestUnencodedMessage(t *testing.T) {
m := NewMessage(SetEncoding(Unencoded))
m.SetHeaders(map[string][]string{
"From": {"from@example.com"},
"To": {"to@example.com"},
"Subject": {"Café"},
})
m.SetBody("text/html", "¡Hola, señor!")
want := &message{
from: "from@example.com",
to: []string{"to@example.com"},
content: "From: from@example.com\r\n" +
"To: to@example.com\r\n" +
"Subject: =?UTF-8?q?Caf=C3=A9?=\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
"\r\n" +
"¡Hola, señor!",
}
testMessage(t, m, 0, want)
} | explode_data.jsonl/31571 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
1806,
19329,
2052,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
2052,
52474,
14690,
49289,
19329,
1171,
2109,
4202,
10574,
9147,
14032,
45725,
917,
515,
197,
197,
1,
3830,
788,
262,
5212,
1499,
35487,
905,
7115,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMonitoringHandler(t *testing.T) {
checkMonitoring := func(t *testing.T,
h func(*request.Context),
expected map[request.ResultID]int,
m map[request.ResultID]*monitoring.Int,
) {
c, _ := beatertest.DefaultContextWithResponseRecorder()
equal, result := beatertest.CompareMonitoringInt(Apply(MonitoringMiddleware(m), h), c, expected, m)
assert.True(t, equal, result)
}
t.Run("Error", func(t *testing.T) {
checkMonitoring(t,
beatertest.Handler403,
map[request.ResultID]int{
request.IDRequestCount: 1,
request.IDResponseCount: 1,
request.IDResponseErrorsCount: 1,
request.IDResponseErrorsForbidden: 1},
mockMonitoring)
})
t.Run("Accepted", func(t *testing.T) {
checkMonitoring(t,
beatertest.Handler202,
map[request.ResultID]int{
request.IDRequestCount: 1,
request.IDResponseCount: 1,
request.IDResponseValidCount: 1,
request.IDResponseValidAccepted: 1},
mockMonitoring)
})
t.Run("Idle", func(t *testing.T) {
checkMonitoring(t,
beatertest.HandlerIdle,
map[request.ResultID]int{
request.IDRequestCount: 1,
request.IDResponseCount: 1,
request.IDResponseValidCount: 1,
request.IDUnset: 1},
mockMonitoring)
})
t.Run("Panic", func(t *testing.T) {
checkMonitoring(t,
Apply(RecoverPanicMiddleware(), beatertest.HandlerPanic),
map[request.ResultID]int{
request.IDRequestCount: 1,
request.IDResponseCount: 1,
request.IDResponseErrorsCount: 1,
request.IDResponseErrorsInternal: 1,
},
mockMonitoring)
})
t.Run("Nil", func(t *testing.T) {
checkMonitoring(t,
beatertest.HandlerIdle,
map[request.ResultID]int{},
mockMonitoringNil)
})
} | explode_data.jsonl/17719 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 786
} | [
2830,
3393,
98062,
3050,
1155,
353,
8840,
836,
8,
341,
25157,
98062,
1669,
2915,
1155,
353,
8840,
836,
345,
197,
9598,
2915,
4071,
2035,
9328,
1326,
197,
42400,
2415,
58,
2035,
18456,
915,
63025,
345,
197,
2109,
2415,
58,
2035,
18456,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenesisAccountValidate(t *testing.T) {
pubkey := secp256k1.GenPrivKey().PubKey()
addr := sdk.AccAddress(pubkey.Address())
baseAcc := types.NewBaseAccount(addr, pubkey, 0, 0)
tests := []struct {
name string
acc types.GenesisAccount
expErr bool
}{
{
"valid base account",
baseAcc,
false,
},
{
"invalid base valid account",
types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0),
true,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expErr, tt.acc.Validate() != nil)
})
}
} | explode_data.jsonl/80931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
84652,
7365,
17926,
1155,
353,
8840,
836,
8,
341,
62529,
792,
1669,
511,
4672,
17,
20,
21,
74,
16,
65384,
32124,
1592,
1005,
29162,
1592,
741,
53183,
1669,
45402,
77538,
4286,
74186,
792,
26979,
2398,
24195,
14603,
1669,
449... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImmudbStoreReaderAsBefore(t *testing.T) {
opts := DefaultOptions().WithSynced(false).WithMaxConcurrency(4)
immuStore, err := Open("data_store_reader_as_before", opts)
require.NoError(t, err)
defer os.RemoveAll("data_store_reader_as_before")
txCount := 100
eCount := 100
for i := 0; i < txCount; i++ {
kvs := make([]*KV, eCount)
for j := 0; j < eCount; j++ {
var k [8]byte
binary.BigEndian.PutUint64(k[:], uint64(j))
var v [8]byte
binary.BigEndian.PutUint64(v[:], uint64(i))
kvs[j] = &KV{Key: k[:], Value: v[:]}
}
_, err := immuStore.Commit(kvs, true)
require.NoError(t, err)
}
snap, err := immuStore.Snapshot()
require.NoError(t, err)
reader, err := snap.NewKeyReader(&KeyReaderSpec{})
require.NoError(t, err)
defer reader.Close()
for i := 0; i < txCount; i++ {
for j := 0; j < eCount; j++ {
var k [8]byte
binary.BigEndian.PutUint64(k[:], uint64(j))
var v [8]byte
binary.BigEndian.PutUint64(v[:], uint64(i))
rk, vref, _, err := reader.ReadAsBefore(uint64(i + 2))
require.NoError(t, err)
require.Equal(t, k[:], rk)
rv, err := vref.Resolve()
require.NoError(t, err)
require.Equal(t, v[:], rv)
}
_, _, _, _, err = reader.Read()
require.Equal(t, ErrNoMoreEntries, err)
err = reader.Reset()
require.NoError(t, err)
}
} | explode_data.jsonl/68526 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 611
} | [
2830,
3393,
50739,
661,
65,
6093,
5062,
2121,
10227,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
7899,
3798,
1005,
2354,
12154,
291,
3576,
568,
2354,
5974,
79611,
7,
19,
340,
197,
12543,
84,
6093,
11,
1848,
1669,
5264,
445,
691,
14809,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDryRunCreateDoesntCreate(t *testing.T) {
s, destroy := NewDryRunnableTestStorage(t)
defer destroy()
obj := UnstructuredOrDie(`{"kind": "Pod"}`)
out := UnstructuredOrDie(`{}`)
err := s.Create(context.Background(), "key", obj, out, 0, true)
if err != nil {
t.Fatalf("Failed to create new dry-run object: %v", err)
}
err = s.Get(context.Background(), "key", storage.GetOptions{}, out)
if e, ok := err.(*storage.StorageError); !ok || e.Code != storage.ErrCodeKeyNotFound {
t.Errorf("Expected key to be not found, error: %v", err)
}
} | explode_data.jsonl/5458 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
85215,
6727,
4021,
21468,
406,
4021,
1155,
353,
8840,
836,
8,
341,
1903,
11,
6921,
1669,
1532,
85215,
68836,
2271,
5793,
1155,
340,
16867,
6921,
2822,
22671,
1669,
1230,
51143,
2195,
18175,
5809,
4913,
15314,
788,
330,
23527,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLintInvalid(t *testing.T) {
ctx := context.TODO()
errs := eclint.Lint(ctx, "testdata/invalid/.editorconfig")
if len(errs) == 0 {
t.Error("an error was expected, got none")
}
for _, err := range errs {
if err == nil {
t.Error("an error was expected")
}
}
} | explode_data.jsonl/82389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
47556,
7928,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
90988,
2822,
9859,
82,
1669,
59958,
396,
1214,
396,
7502,
11,
330,
92425,
14,
11808,
11930,
8868,
1676,
1138,
743,
2422,
3964,
82,
8,
621,
220,
15,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestParseDurationString_ShouldParseDurationStringWithMultiValueUnits(t *testing.T) {
duration, err := ParseDurationString("10ms")
assert.NoError(t, err)
assert.Equal(t, time.Duration(10)*time.Millisecond, duration)
} | explode_data.jsonl/12150 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
14463,
12945,
703,
36578,
616,
14463,
12945,
703,
2354,
20358,
1130,
26314,
1155,
353,
8840,
836,
8,
341,
89300,
11,
1848,
1669,
14775,
12945,
703,
445,
16,
15,
1011,
5130,
6948,
35699,
1155,
11,
1848,
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 |
func TestCopy(t *testing.T) {
ctx := log.Testing(t)
type StructB struct {
F float32
P *StructB
}
type StructA struct {
I int
B bool
T string
P *StructB
M map[int]StructB
S []bool
G interface{}
A assignable
N nonAssignable
}
cyclic := &StructB{F: 10}
cyclic.P = cyclic
for _, test := range []struct {
dst, src, expect interface{}
}{
{&StructA{}, StructA{}, StructA{}},
{&StructA{}, StructA{I: 10}, StructA{I: 10}},
{&StructA{I: 20}, StructA{I: 10}, StructA{I: 10}},
{&StructA{}, StructA{I: 10, B: true, T: "meow"}, StructA{I: 10, B: true, T: "meow"}},
{&StructA{}, StructA{A: assignable{5}}, StructA{A: assignable{5}}},
{&StructA{}, StructA{N: nonAssignable{5}}, StructA{N: nonAssignable{0}}},
{
&StructA{},
StructA{
I: 10, B: true, T: "meow", P: &StructB{F: 123.456},
},
StructA{
I: 10, B: true, T: "meow", P: &StructB{F: 123.456},
},
}, {
&StructA{},
StructA{
I: 10, B: true, T: "meow", P: cyclic,
},
StructA{
I: 10, B: true, T: "meow", P: cyclic,
},
}, {
&StructA{},
struct{ G string }{"purr"},
StructA{G: "purr"},
}, {
&StructA{},
struct{ P interface{} }{cyclic},
StructA{P: cyclic},
},
} {
ctx := log.V{"src": test.src}.Bind(ctx)
err := deep.Copy(test.dst, test.src)
if assert.For(ctx, "err").ThatError(err).Succeeded() {
got := reflect.ValueOf(test.dst).Elem().Interface()
assert.For(ctx, "res").That(got).DeepEquals(test.expect)
}
}
} | explode_data.jsonl/65699 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 731
} | [
2830,
3393,
12106,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1487,
8787,
287,
1155,
340,
13158,
16139,
33,
2036,
341,
197,
12727,
2224,
18,
17,
198,
197,
10025,
353,
9422,
33,
198,
197,
532,
13158,
16139,
32,
2036,
341,
197,
24486,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAdapterResponse_UnmarshalJSON_Happy(t *testing.T) {
tests := []struct {
name, content string
expect decimal.Decimal
}{
{"basic", `{"data":{"result":123.4567890},"jobRunID":"1","statusCode":200}`, decimal.NewFromFloat(123.456789)},
{"bravenewcoin", mustReadFile(t, "../testdata/bravenewcoin.json"), decimal.NewFromFloat(306.52036004)},
{"coinmarketcap", mustReadFile(t, "../testdata/coinmarketcap.json"), decimal.NewFromFloat(305.5574615)},
{"cryptocompare", mustReadFile(t, "../testdata/cryptocompare.json"), decimal.NewFromFloat(305.76)},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var response adapterResponse
err := json.Unmarshal([]byte(test.content), &response)
assert.NoError(t, err)
result := response.Result()
assert.Equal(t, test.expect.String(), result.String())
})
}
} | explode_data.jsonl/26500 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
5940,
2582,
40687,
27121,
5370,
2039,
11144,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
11,
2213,
914,
198,
197,
24952,
286,
12122,
40675,
198,
197,
59403,
197,
197,
4913,
22342,
497,
1565,
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 TestServer_Response_Data_Sniff_DoesntOverride(t *testing.T) {
const msg = "<html>this is HTML."
testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Content-Type", "foo/bar")
io.WriteString(w, msg)
return nil
}, func(st *serverTester) {
getSlash(st)
hf := st.wantHeaders()
if hf.StreamEnded() {
t.Fatal("don't want END_STREAM, expecting data")
}
if !hf.HeadersEnded() {
t.Fatal("want END_HEADERS flag")
}
goth := st.decodeHeader(hf.HeaderBlockFragment())
wanth := [][2]string{
{":status", "200"},
{"content-type", "foo/bar"},
{"content-length", strconv.Itoa(len(msg))},
}
if !reflect.DeepEqual(goth, wanth) {
t.Errorf("Got headers %v; want %v", goth, wanth)
}
df := st.wantData()
if !df.StreamEnded() {
t.Error("expected DATA to have END_STREAM flag")
}
if got := string(df.Data()); got != msg {
t.Errorf("got DATA %q; want %q", got, msg)
}
})
} | explode_data.jsonl/71663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 414
} | [
2830,
3393,
5475,
65873,
17817,
1098,
77,
3092,
1557,
7072,
406,
2177,
1155,
353,
8840,
836,
8,
341,
4777,
3750,
284,
4055,
1551,
89810,
374,
9308,
10040,
18185,
5475,
2582,
1155,
11,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteJob(t *testing.T) {
db := getTestDB()
defer db.Close()
tx, _ := db.Beginx()
defer tx.Rollback()
var insertedJobID int64
insertedJob := &Job{
QueueName: "foo",
Data: []byte("update bar"),
RunAfter: time.Now(),
}
err := tx.QueryRow(`
INSERT into pgq_jobs (
queue_name, data, run_after, retry_waits
) VALUES (
$1, $2, $3, $4
) RETURNING id;
`, insertedJob.QueueName, insertedJob.Data, insertedJob.RunAfter, insertedJob.RetryWaits).Scan(&insertedJobID)
assert.Nil(t, err)
insertedJob.ID = insertedJobID
err = deleteJob(tx, insertedJob)
assert.Nil(t, err)
// should be no jobs in DB
var count int
err = tx.QueryRow("SELECT count(*) from pgq_jobs;").Scan(&count)
assert.Nil(t, err)
assert.Equal(t, 0, count)
} | explode_data.jsonl/48961 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 319
} | [
2830,
3393,
6435,
12245,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
633,
2271,
3506,
741,
16867,
2927,
10421,
741,
46237,
11,
716,
1669,
2927,
28467,
87,
741,
16867,
9854,
88918,
2822,
2405,
21578,
12245,
915,
526,
21,
19,
198,
59847,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeAssuredCallStatusFailure(t *testing.T) {
decoded := false
expected := &Call{
Path: "test/assured",
StatusCode: http.StatusOK,
Method: http.MethodGet,
Headers: map[string]string{"Assured-Status": "four oh three"},
Query: map[string]string{},
}
testDecode := func(resp http.ResponseWriter, req *http.Request) {
c, err := decodeAssuredCall(ctx, req)
require.NoError(t, err)
require.Equal(t, expected, c)
decoded = true
}
req, err := http.NewRequest(http.MethodGet, "/given/test/assured", nil)
require.NoError(t, err)
req.Header.Set("Assured-Status", "four oh three")
router := mux.NewRouter()
router.HandleFunc("/given/{path:.*}", testDecode).Methods(http.MethodGet)
resp := httptest.NewRecorder()
router.ServeHTTP(resp, req)
require.True(t, decoded, "decode method was not hit")
} | explode_data.jsonl/20256 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
32564,
5615,
3073,
7220,
2522,
17507,
1155,
353,
8840,
836,
8,
341,
197,
62913,
1669,
895,
198,
42400,
1669,
609,
7220,
515,
197,
69640,
25,
981,
330,
1944,
14,
395,
3073,
756,
197,
197,
15872,
25,
1758,
52989,
345,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCloser_Ctx(t *testing.T) {
t.Parallel()
var c sync.Closer
ctx := c.Ctx()
assert.NoError(t, ctx.Err())
assert.Nil(t, ctx.Value(nil))
_, ok := ctx.Deadline()
assert.False(t, ok)
select {
case <-ctx.Done():
t.Error("context should not be closed")
default: // expected
}
done := make(chan struct{})
go func() {
defer close(done)
<-ctx.Done()
assert.Same(t, ctx.Err(), context.Canceled)
}()
assert.NoError(t, c.Close())
<-done
} | explode_data.jsonl/47720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
51236,
799,
920,
3998,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2405,
272,
12811,
727,
69215,
198,
20985,
1669,
272,
727,
3998,
741,
6948,
35699,
1155,
11,
5635,
27862,
2398,
6948,
59678,
1155,
11,
5635,
6167,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJobSpecsController_Show_Unauthenticated(t *testing.T) {
t.Parallel()
rpcClient, gethClient, _, assertMocksCalled := cltest.NewEthMocksWithStartupAssertions(t)
defer assertMocksCalled()
app, cleanup := cltest.NewApplication(t,
eth.NewClientWith(rpcClient, gethClient),
)
defer cleanup()
require.NoError(t, app.Start())
resp, err := http.Get(app.Server.URL + "/v2/specs/garbage")
assert.NoError(t, err)
assert.Equal(t, http.StatusUnauthorized, resp.StatusCode, "Response should be forbidden")
} | explode_data.jsonl/31823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
12245,
8327,
82,
2051,
79665,
40687,
57707,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
7000,
3992,
2959,
11,
633,
71,
2959,
11,
8358,
2060,
72577,
20960,
1669,
1185,
1944,
7121,
65390,
11571,
16056,
39076,
90206,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewInvoice(t *testing.T) {
t.Parallel()
tests := []struct {
newInvoice func() (*Invoice, error)
encodedInvoice string
valid bool
}{
{
// Both Description and DescriptionHash set.
newInvoice: func() (*Invoice, error) {
return NewInvoice(chaincfg.MainNetParams(),
testPaymentHash, time.Unix(1496314658, 0),
DescriptionHash(testDescriptionHash),
Description(testPleaseConsider))
},
valid: false, // Both Description and DescriptionHash set.
},
{
// Invoice with no amount.
newInvoice: func() (*Invoice, error) {
return NewInvoice(
chaincfg.MainNetParams(),
testPaymentHash,
time.Unix(1496314658, 0),
Description(testCupOfCoffee),
)
},
valid: true,
encodedInvoice: "lndcr1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsmvp0ygkvzd3zh9wkfj59cuze0se5fzuh4f7rysdukv68n6fafa45sudrzg8d33paaw50zczd5mzmppqaalvzneu0yd3zfrvzhnfzpkgppyrza2",
},
{
// 'n' field set.
newInvoice: func() (*Invoice, error) {
return NewInvoice(chaincfg.MainNetParams(),
testPaymentHash, time.Unix(1503429093, 0),
Amount(testMilliAt24DCR),
Description(testEmptyString),
Destination(testPubKey))
},
valid: true,
encodedInvoice: "lndcr241pveeq09pp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqqnp4q0n326hr8v9zprg8gsvezcch06gfaqqhde2aj730yg0durunfhv66husxpmqj9fh878hrkccqzvazqk2mhj0fdtjyngvhz5vje86eh39zu8cmp7k0kml38p3d3ujyuuhqe32kfgdt98t5e8r74xmwk53u5mqqm45579",
},
{
// On mainnet, with fallback address DsQxuVRvS4eaJ42dhQEsCXauMWjvopWgrVg with extra routing info to go via nodes 029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255 then 039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255
newInvoice: func() (*Invoice, error) {
return NewInvoice(chaincfg.MainNetParams(),
testPaymentHash, time.Unix(1496314658, 0),
Amount(testMilliAt20mDCR),
DescriptionHash(testDescriptionHash),
FallbackAddr(testRustyAddr),
RouteHint(testDoubleHop),
)
},
valid: true,
encodedInvoice: "lndcr20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp5p0y6smqsu95wrj2v9dzntwn88pmz4ck92063nkhxju832w0tr5hsfpp3qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr9yq20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzqykl3fr9qy3yxam6xh55lxtfcp7uxsdl4krv6206de6j4lvfdu0l4hjwsy9aad8ap527ygzpc0gcrx8t98gxn3kr2xaq2nympn0jv9rqpqjas5d",
},
{
// On simnet
newInvoice: func() (*Invoice, error) {
return NewInvoice(chaincfg.SimNetParams(),
testPaymentHash, time.Unix(1496314658, 0),
Amount(testMilliAt24DCR),
Description(testEmptyString),
Destination(testPubKey))
},
valid: true,
encodedInvoice: "lnsdcr241pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqqnp4q0n326hr8v9zprg8gsvezcch06gfaqqhde2aj730yg0durunfhv66zh5xhvtchse36pt88lj4djy8g58lx26xfz3np7humcd9594rmgv92nws6vllf9mhq670x9nrwhjzw0shsklr6gq235whh9x9089ue7gpjur6cc",
},
{
// On regtest
newInvoice: func() (*Invoice, error) {
return NewInvoice(chaincfg.RegNetParams(),
testPaymentHash, time.Unix(1496314658, 0),
Amount(testMilliAt24DCR),
Description(testEmptyString),
Destination(testPubKey))
},
valid: true,
encodedInvoice: "lnrdcr241pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdqqnp4q0n326hr8v9zprg8gsvezcch06gfaqqhde2aj730yg0durunfhv668eyx3hxz79l45wdm93chts7yvd7n5dd4peq0dwdkrdamnrylws34pynkyyw7dndfy047tcelp4l8w26j8jjht8urq204g3ca6tgm7ycpq5qkd2",
},
}
for i, test := range tests {
invoice, err := test.newInvoice()
if err != nil && !test.valid {
continue
}
encoded, err := invoice.Encode(testMessageSigner)
if (err == nil) != test.valid {
t.Errorf("NewInvoice test %d failed: %v", i, err)
return
}
if test.valid && test.encodedInvoice != encoded {
t.Errorf("Encoding %d failed, expected %v, got %v",
i, test.encodedInvoice, encoded)
return
}
}
} | explode_data.jsonl/40481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2202
} | [
2830,
3393,
3564,
34674,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
8638,
34674,
257,
2915,
368,
4609,
34674,
11,
1465,
340,
197,
197,
19329,
34674,
914,
198,
197,
56322,
688,
1807,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJobsController_Show_NonExistentID(t *testing.T) {
client, cleanup, _, _, _, _ := setupJobSpecsControllerTestsWithJobs(t)
defer cleanup()
response, cleanup := client.Get("/v2/jobs/999999999")
defer cleanup()
cltest.AssertServerResponse(t, response, http.StatusNotFound)
} | explode_data.jsonl/1628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
40667,
2051,
79665,
1604,
263,
840,
18128,
915,
1155,
353,
8840,
836,
8,
341,
25291,
11,
21290,
11,
8358,
8358,
8358,
716,
1669,
6505,
12245,
8327,
82,
2051,
2271,
16056,
40667,
1155,
340,
16867,
21290,
2822,
21735,
11,
2129... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindByNumber(t *testing.T) {
table := Load(data)
if len(Find(table, "949")) != 1 {
t.Fatal("Find Failed to find 1 match by Number")
}
} | explode_data.jsonl/5874 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
47131,
2833,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
8893,
2592,
340,
743,
2422,
7832,
484,
15761,
11,
330,
24,
19,
24,
2761,
961,
220,
16,
341,
197,
3244,
26133,
445,
9885,
21379,
311,
1477,
220,
16,
2432,
553,
5624,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestErrWrap1(t *testing.T) {
errorf, ok := I.FindFuncv("Errorf")
if !ok {
t.Fatal("FindFuncv failed: Errorf")
}
frame := &errors.Frame{
Pkg: "main",
Func: "TestErrWrap",
Code: `errorf("not found")?`,
File: `./flow_test.go`,
Line: 45,
}
retErr := NewVar(TyError, "err")
code := newBuilder().
DefineVar(retErr).
Push("arg1").
Push("arg2").
Push("arg3").
Push(123).
Push("not found").
CallGoFuncv(errorf, 1, 1).
ErrWrap(2, retErr, frame, 3).
Resolve()
ctx := NewContext(code)
ctx.base = 3
ctx.Exec(0, code.Len())
if e := ctx.GetVar(retErr); e != nil {
frame, ok := e.(*errors.Frame)
if !ok {
t.Fatal("TestErrWrap1 failed:", e)
}
fmt.Println(frame.Args...)
} else {
t.Fatal("TestErrWrap1 failed: retErr not set")
}
} | explode_data.jsonl/74954 | {
"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,
7747,
26787,
16,
1155,
353,
8840,
836,
8,
341,
18290,
69,
11,
5394,
1669,
358,
9998,
9626,
85,
445,
1454,
69,
1138,
743,
753,
562,
341,
197,
3244,
26133,
445,
9885,
9626,
85,
4641,
25,
4600,
69,
1138,
197,
630,
34465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnknownFieldFails(t *testing.T) {
_, ac := newNonRunningTestResourceAdmissionController(t)
req := &admissionv1beta1.AdmissionRequest{
Operation: admissionv1beta1.Create,
Kind: metav1.GroupVersionKind{
Group: "pkg.knative.dev",
Version: "v1alpha1",
Kind: "Resource",
},
}
marshaled, err := json.Marshal(map[string]interface{}{
"spec": map[string]interface{}{
"foo": "bar",
},
})
if err != nil {
t.Fatalf("Failed to marshal resource: %v", err)
}
req.Object.Raw = marshaled
ExpectFailsWith(t, ac.Admit(TestContextWithLogger(t), req),
`validation failed: cannot decode incoming new object: json: unknown field "foo"`)
} | explode_data.jsonl/18333 | {
"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,
13790,
1877,
37,
6209,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1613,
1669,
501,
8121,
18990,
2271,
4783,
2589,
2728,
2051,
1155,
340,
24395,
1669,
609,
329,
2728,
85,
16,
19127,
16,
17865,
2728,
1900,
515,
197,
197,
8432,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUtilUUID(t *testing.T) {
for id := 1; id < 11; id++ {
recordUUID, err := uuid.GenerateUUID()
t.Logf("Checking[%d]: %s\n", id, recordUUID)
if err != nil {
t.Fatalf("Failed to generate UUID %s: %s ", recordUUID, err)
} else if isValidUUID(recordUUID) == false {
t.Fatalf("Failed to validate UUID: %s ", recordUUID)
}
}
} | explode_data.jsonl/9658 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
2742,
24754,
1155,
353,
8840,
836,
8,
341,
2023,
877,
1669,
220,
16,
26,
877,
366,
220,
16,
16,
26,
877,
1027,
341,
197,
71952,
24754,
11,
1848,
1669,
16040,
57582,
24754,
741,
197,
3244,
98954,
445,
40129,
25113,
67,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddGlobalArtifactToScope(t *testing.T) {
woc := newWoc()
art := wfv1.Artifact{
Name: "test-art",
ArtifactLocation: wfv1.ArtifactLocation{
S3: &wfv1.S3Artifact{
S3Bucket: wfv1.S3Bucket{
Bucket: "my-bucket",
},
Key: "some/key",
},
},
}
// Make sure if the artifact is not global, don't add to scope
woc.addArtifactToGlobalScope(art, nil)
assert.Nil(t, woc.wf.Status.Outputs)
// Now mark it as global. Verify it is added to workflow outputs
art.GlobalName = "global-art"
woc.addArtifactToGlobalScope(art, nil)
assert.Equal(t, 1, len(woc.wf.Status.Outputs.Artifacts))
assert.Equal(t, art.GlobalName, woc.wf.Status.Outputs.Artifacts[0].Name)
assert.Equal(t, "some/key", woc.wf.Status.Outputs.Artifacts[0].S3.Key)
// Change the value and verify update is reflected
art.S3.Key = "new/key"
woc.addArtifactToGlobalScope(art, nil)
assert.Equal(t, 1, len(woc.wf.Status.Outputs.Artifacts))
assert.Equal(t, art.GlobalName, woc.wf.Status.Outputs.Artifacts[0].Name)
assert.Equal(t, "new/key", woc.wf.Status.Outputs.Artifacts[0].S3.Key)
// Add a new global artifact
art.GlobalName = "global-art2"
art.S3.Key = "new/new/key"
woc.addArtifactToGlobalScope(art, nil)
assert.Equal(t, 2, len(woc.wf.Status.Outputs.Artifacts))
assert.Equal(t, art.GlobalName, woc.wf.Status.Outputs.Artifacts[1].Name)
assert.Equal(t, "new/new/key", woc.wf.Status.Outputs.Artifacts[1].S3.Key)
} | explode_data.jsonl/54375 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 623
} | [
2830,
3393,
2212,
11646,
85578,
1249,
10803,
1155,
353,
8840,
836,
8,
341,
6692,
509,
1669,
501,
54,
509,
741,
197,
471,
1669,
289,
27890,
16,
50064,
20754,
515,
197,
21297,
25,
330,
1944,
37821,
756,
197,
197,
85578,
4707,
25,
289,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientHook(t *testing.T) {
var g generator
g.clientHook("Foo")
got := g.pt.String()
want := "var newFooClientHook clientHook\n\n"
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("clientHook() (-got,+want): %s", diff)
}
} | explode_data.jsonl/40031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
2959,
31679,
1155,
353,
8840,
836,
8,
341,
2405,
342,
13823,
271,
3174,
6581,
31679,
445,
40923,
1138,
3174,
354,
1669,
342,
39326,
6431,
741,
50780,
1669,
330,
947,
501,
40923,
2959,
31679,
2943,
31679,
1699,
1699,
1837,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNestedSeq(t *testing.T) {
input := "(concat (0 1 2) (3 4 5))"
lex := lexer.NewLexer(input)
tokens, _ := lex.GetTokens()
parser := NewParser(tokens)
expressions, _ := parser.GetExpressions()
sym, ok := expressions[0].(expr.Seq).Exprs[0].(expr.Symbol)
if !ok {
t.Fatalf("Expected symbol to be symbol")
}
assertString(t, "concat", sym.Name)
firstNested := expressions[0].(expr.Seq).Exprs[1].(expr.Seq)
for i := 0; i < 3; i++ {
val := firstNested.Exprs[i].(expr.Atom).Value.(float64)
assertNumber(t, float64(i), val)
}
secondNested := expressions[0].(expr.Seq).Exprs[2].(expr.Seq)
for i := 0; i < 3; i++ {
val := secondNested.Exprs[i].(expr.Atom).Value.(float64)
assertNumber(t, float64(i)+3, val)
}
} | explode_data.jsonl/43721 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
71986,
20183,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
11993,
20164,
320,
15,
220,
16,
220,
17,
8,
320,
18,
220,
19,
220,
20,
53740,
197,
2571,
1669,
53259,
7121,
92847,
5384,
340,
3244,
9713,
11,
716,
1669,
22429,
223... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGenericHTTPFeatures(t *testing.T) {
ht := StartHTTPTest(t, "base")
defer ht.Finish()
// CORS
w := ht.Get("/")
if ht.Assert.Equal(200, w.Code) {
ht.Assert.Empty(w.HeaderMap.Get("Access-Control-Allow-Origin"))
}
w = ht.Get("/", func(r *http.Request) {
r.Header.Set("Origin", "somewhere.com")
})
if ht.Assert.Equal(200, w.Code) {
ht.Assert.Equal(
"somewhere.com",
w.HeaderMap.Get("Access-Control-Allow-Origin"),
)
}
// Trailing slash is stripped
w = ht.Get("/ledgers")
ht.Assert.Equal(200, w.Code)
w = ht.Get("/ledgers/")
ht.Assert.Equal(200, w.Code)
} | explode_data.jsonl/46408 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
19964,
9230,
21336,
1155,
353,
8840,
836,
8,
341,
197,
426,
1669,
5145,
9230,
2271,
1155,
11,
330,
3152,
1138,
16867,
34323,
991,
18176,
2822,
197,
322,
90666,
198,
6692,
1669,
34323,
2234,
61710,
743,
34323,
11711,
12808,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGraph_BuildOrder(t *testing.T) {
testSuite := []struct {
title string
variables []string
dependencies map[string][]string
result []Group
}{
{
title: "single variable",
variables: []string{"myVariable"},
result: []Group{{Variables: []string{"myVariable"}}},
},
{
title: "independent variable",
variables: []string{"a", "d", "e"},
result: []Group{{Variables: []string{"a", "d", "e"}}},
},
{
title: "a depend on d depend on e",
variables: []string{"a", "d", "e"},
dependencies: map[string][]string{
"a": {"d"},
"d": {"e"},
},
result: []Group{
{Variables: []string{"e"}},
{Variables: []string{"d"}},
{Variables: []string{"a"}},
},
},
{
title: "complete dep graph",
variables: []string{"f", "d", "c", "b", "g", "a", "h", "e"},
dependencies: map[string][]string{
"e": {"a", "b"},
"a": {"c", "f", "b"},
"h": {"b"},
"g": {"d"},
"c": {"f"},
"b": {"f"},
},
result: []Group{
{Variables: []string{"f", "d"}},
{Variables: []string{"c", "b", "g"}},
{Variables: []string{"a", "h"}},
{Variables: []string{"e"}},
},
},
}
for _, test := range testSuite {
t.Run(test.title, func(t *testing.T) {
g := newGraph(test.variables, test.dependencies, nil, nil)
result, err := g.buildOrder()
assert.NoError(t, err)
assert.Equal(t, len(test.result), len(result))
for i := 0; i < len(result); i++ {
assert.ElementsMatch(t, test.result[i].Variables, result[i].Variables)
}
})
}
} | explode_data.jsonl/34532 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 744
} | [
2830,
3393,
11212,
96686,
4431,
1155,
353,
8840,
836,
8,
341,
18185,
28000,
1669,
3056,
1235,
341,
197,
24751,
286,
914,
198,
197,
2405,
2156,
82,
262,
3056,
917,
198,
197,
197,
54274,
2415,
14032,
45725,
917,
198,
197,
9559,
981,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadMultipleTopLevelDocuments(t *testing.T) {
testCases := []struct {
name string
input string
expected [][]byte
}{
{
"single top-level document",
"{\"foo\":1}",
[][]byte{
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
},
},
{
"single top-level document with leading and trailing whitespace",
"\n\n {\"foo\":1} \n",
[][]byte{
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
},
},
{
"two top-level documents",
"{\"foo\":1}{\"foo\":2}",
[][]byte{
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x02, 0x00, 0x00, 0x00, 0x00},
},
},
{
"two top-level documents with leading and trailing whitespace and whitespace separation ",
"\n\n {\"foo\":1}\n{\"foo\":2}\n ",
[][]byte{
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x02, 0x00, 0x00, 0x00, 0x00},
},
},
{
"top-level array with single document",
"[{\"foo\":1}]",
[][]byte{
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
},
},
{
"top-level array with 2 documents",
"[{\"foo\":1},{\"foo\":2}]",
[][]byte{
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x01, 0x00, 0x00, 0x00, 0x00},
{0x0E, 0x00, 0x00, 0x00, 0x10, 'f', 'o', 'o', 0x00, 0x02, 0x00, 0x00, 0x00, 0x00},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
r := strings.NewReader(tc.input)
vr, err := NewExtJSONValueReader(r, false)
if err != nil {
t.Fatalf("expected no error, but got %v", err)
}
actual, err := readAllDocuments(vr)
if err != nil {
t.Fatalf("expected no error, but got %v", err)
}
if diff := cmp.Diff(tc.expected, actual); diff != "" {
t.Fatalf("expected does not match actual: %v", diff)
}
})
}
} | explode_data.jsonl/44883 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1128
} | [
2830,
3393,
4418,
32089,
5366,
4449,
27143,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
914,
198,
197,
42400,
52931,
3782,
198,
197,
59403,
197,
197,
515,
298,
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... | 4 |
func TestReversiAnz36(t *testing.T) {
r := NewReversiAnz()
if r.GetOwnEdgeSideOtherCnt() != 0 {
t.Errorf("NG")
}
} | explode_data.jsonl/23059 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
693,
3004,
72,
2082,
89,
18,
21,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
693,
3004,
72,
2082,
89,
741,
743,
435,
2234,
14182,
11656,
16384,
11409,
33747,
368,
961,
220,
15,
341,
197,
3244,
13080,
445,
6140,
1138,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestRunDASH(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess := newSessionForTesting(t)
defer sess.Close()
builder, err := sess.NewExperimentBuilder("dash")
if err != nil {
t.Fatal(err)
}
if !builder.Interruptible() {
t.Fatal("dash not marked as interruptible")
}
runexperimentflow(t, builder.NewExperiment(), "")
} | explode_data.jsonl/26307 | {
"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,
6727,
35,
9537,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
20599,
1273,
304,
2805,
3856,
1138,
197,
532,
1903,
433,
1669,
501,
5283,
2461,
16451,
1155,
340,
16867,
21875,
10421,
741,
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... | 4 |
func TestWorkerErrNoneFuncs(t *testing.T) {
if !runIntegrationTests {
t.Skip("To run this test, use: go test -integration")
}
err := worker.Ready()
if err != ErrNoneFuncs {
t.Error("ErrNoneFuncs expected.")
}
} | explode_data.jsonl/43512 | {
"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,
21936,
7747,
4064,
9626,
82,
1155,
353,
8840,
836,
8,
341,
743,
753,
6108,
52464,
18200,
341,
197,
3244,
57776,
445,
1249,
1598,
419,
1273,
11,
990,
25,
728,
1273,
481,
60168,
1138,
197,
532,
9859,
1669,
11864,
6503,
88,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParticiaTrie_DeleteNonExistent(t *testing.T) {
trie := NewTrie()
insertData := []testData{
{"Pepan", "Pepan Zdepan", success},
{"Honza", "Honza Novak", success},
{"Jenik", "Jenik Poustevnicek", success},
}
deleteData := []testData{
{"Pepan", "Pepan Zdepan", success},
{"Honza", "Honza Novak", success},
{"Pepan", "Pepan Zdepan", failure},
{"Jenik", "Jenik Poustevnicek", success},
{"Honza", "Honza Novak", failure},
}
for _, v := range insertData {
t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
}
}
for _, v := range deleteData {
t.Logf("DELETE word=%v, success=%v", v.key, v.retVal)
if ok := trie.Delete([]byte(v.key)); ok != v.retVal {
t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
}
}
} | explode_data.jsonl/2370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
5800,
24024,
51,
7231,
57418,
8121,
840,
18128,
1155,
353,
8840,
836,
8,
341,
197,
8927,
1669,
1532,
51,
7231,
2822,
59847,
1043,
1669,
3056,
1944,
1043,
515,
197,
197,
4913,
47,
747,
276,
497,
330,
47,
747,
276,
1863,
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... | 5 |
func TestRCManagerNotReady(t *testing.T) {
c := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
fakePodControl := controller.FakePodControl{}
manager := NewReplicationManager(c, controller.NoResyncPeriodFunc, 2, 0)
manager.podControl = &fakePodControl
manager.podStoreSynced = func() bool { return false }
// Simulates the rc reflector running before the pod reflector. We don't
// want to end up creating replicas in this case until the pod reflector
// has synced, so the rc manager should just requeue the rc.
controllerSpec := newReplicationController(1)
manager.rcStore.Store.Add(controllerSpec)
rcKey := getKey(controllerSpec, t)
manager.syncReplicationController(rcKey)
validateSyncReplication(t, &fakePodControl, 0, 0)
queueRC, _ := manager.queue.Get()
if queueRC != rcKey {
t.Fatalf("Expected to find key %v in queue, found %v", rcKey, queueRC)
}
manager.podStoreSynced = alwaysReady
manager.syncReplicationController(rcKey)
validateSyncReplication(t, &fakePodControl, 1, 0)
} | explode_data.jsonl/37496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 346
} | [
2830,
3393,
7380,
2043,
2623,
19202,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2943,
746,
7121,
2461,
2648,
2195,
18175,
2099,
3927,
2972,
10753,
90,
9296,
25,
7342,
8883,
2648,
25,
2732,
2972,
12614,
2648,
90,
2808,
5637,
25,
1273,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLogRecorder(t *testing.T) {
r := NewLogRecorder()
assert := assert.New(t)
assert.Empty(r.String())
r.Log(logx.LevelDebug, "")
r.Log(logx.LevelError, "msg")
r.Log(logx.LevelInfo, "", "k1", "v1", "k2", 2, 3)
r.Log(logx.LevelInfo, "msg", "k1", "v1")
res := r.String()
want := `level=DEBUG message=
level=ERROR message=msg
level=INFO message= k1=v1 k2=2 UNKNOWN=3
level=INFO message=msg k1=v1
`
assert.Equal(want, res)
checkMap := func(idx int, key, wantValue string) {
m := r.m[idx]
v := m[key]
assert.Equal(wantValue, v)
}
checkMap(0, "level", "DEBUG")
checkMap(0, "message", "")
checkMap(1, "level", "ERROR")
checkMap(1, "message", "msg")
checkMap(2, "level", "INFO")
checkMap(2, "message", "")
checkMap(2, "k1", "v1")
checkMap(2, "k2", "2")
checkMap(2, "UNKNOWN", "3")
checkMap(3, "level", "INFO")
checkMap(3, "message", "msg")
checkMap(3, "k1", "v1")
} | explode_data.jsonl/59264 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 410
} | [
2830,
3393,
2201,
47023,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
2201,
47023,
741,
6948,
1669,
2060,
7121,
1155,
340,
6948,
11180,
2601,
6431,
12367,
7000,
5247,
12531,
87,
25259,
7939,
11,
14676,
7000,
5247,
12531,
87,
25259,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLimitWorkspaceScope(t *testing.T) {
const mod = `
-- go.mod --
module mod.com
-- a/main.go --
package main
func main() {}
-- main.go --
package main
func main() {
var x int
}
`
withOptions(WithRootPath("a")).run(t, mod, func(t *testing.T, env *Env) {
env.OpenFile("a/main.go")
env.Await(
env.DiagnosticAtRegexp("main.go", "x"),
)
})
withOptions(WithRootPath("a"), WithLimitWorkspaceScope()).run(t, mod, func(t *testing.T, env *Env) {
env.OpenFile("a/main.go")
env.Await(
NoDiagnostics("main.go"),
)
})
} | explode_data.jsonl/38936 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
16527,
45981,
10803,
1155,
353,
8840,
836,
8,
341,
4777,
1463,
284,
22074,
313,
728,
10929,
39514,
4352,
1463,
905,
198,
313,
264,
15351,
18002,
39514,
1722,
1887,
271,
2830,
1887,
368,
5613,
313,
1887,
18002,
39514,
1722,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCaptureVariables(t *testing.T) {
tests := []struct {
s string
expected []string
}{
{
"${scheme}://${host}",
[]string{"scheme", "host"},
},
{
"http://www.nginx.org",
nil,
},
{
"${}",
[]string{""},
},
}
for _, test := range tests {
result := captureVariables(test.s)
if !reflect.DeepEqual(result, test.expected) {
t.Errorf("captureVariables(%s) returned %v but expected %v", test.s, result, test.expected)
}
}
} | explode_data.jsonl/65834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
27429,
22678,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
1903,
286,
914,
198,
197,
42400,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
197,
74013,
46141,
92,
72271,
3790,
24375,
298,
197,
1294,
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... | 3 |
func TestGenerateModel_WithRef(t *testing.T) {
tt := templateTest{t, templates.MustGet("model").Lookup("schema")}
specDoc, err := loads.Spec("../fixtures/codegen/todolist.models.yml")
require.NoError(t, err)
definitions := specDoc.Spec().Definitions
schema := definitions["WithRef"]
opts := opts()
genModel, err := makeGenDefinition("WithRef", "models", schema, specDoc, opts)
require.NoError(t, err)
assert.True(t, genModel.IsComplexObject)
assert.Equal(t, "WithRef", genModel.Name)
assert.Equal(t, "WithRef", genModel.GoType)
buf := bytes.NewBuffer(nil)
require.NoError(t, tt.template.Execute(buf, genModel))
res := buf.String()
assertInCode(t, "type WithRef struct {", res)
assertInCode(t, "Notes *Notable `json:\"notes,omitempty\"`", res)
} | explode_data.jsonl/2515 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 283
} | [
2830,
3393,
31115,
1712,
62,
2354,
3945,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3811,
2271,
90,
83,
11,
19911,
50463,
1949,
445,
2528,
1827,
34247,
445,
17349,
42132,
98100,
9550,
11,
1848,
1669,
20907,
36473,
17409,
45247,
46928... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDialHost(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
md := newMockDialer()
md.setDial(md.unreachableDial)
_, err := dialHost(ctx, md)
if _, ok := err.(*ErrMaxConnectAttempts); !ok {
t.Fatalf("Didn't receive expected ErrMaxConnectAttempts. Got: %s", err)
}
e := err.(*ErrMaxConnectAttempts)
if e.underlyingError != errHostUnreachable {
t.Fatalf("Got invalid underlying error. Expected %s Got %s\n", e.underlyingError, errHostUnreachable)
}
if md.dialCount != MaxReconnectAttempts {
t.Fatalf("Unexpected number of reconnect attempts. Expected %d, Got %d", MaxReconnectAttempts, md.dialCount)
}
md.setDial(md.defaultDial)
_, err = dialHost(ctx, md)
if err != nil {
t.Fatalf("Unexpected error when dialing the mock host: %s", err)
}
} | explode_data.jsonl/55819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
35,
530,
9296,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
741,
84374,
1669,
501,
11571,
35,
530,
261,
741,
84374,
980,
35,
530,
48645,
6307,
46550,
35,
530,
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... | 5 |
func TestCheck_Valid(t *testing.T) {
type args struct {
custom *check.Custom
}
type wants struct {
err error
script string
}
validQuery := `package main
import "influxdata/influxdb/monitor"
import "influxdata/influxdb/v1"
data = from(bucket: "_tasks")
|> range(start: -1m)
|> filter(fn: (r) =>
(r._measurement == "runs"))
|> filter(fn: (r) =>
(r._field == "finishedAt"))
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
option task = {name: "moo", every: 1m, offset: 0s}
check = {
_check_id: "%s",
_check_name: "moo",
_type: "custom",
tags: {a: "b", c: "d"},
}
warn = (r) =>
(r.finishedAt > 20)
crit = (r) =>
(r.finishedAt > 20)
info = (r) =>
(r.finishedAt > 20)
messageFn = (r) =>
("Check: ${r._check_name} is: ${r._level}")
data
|> v1.fieldsAsCols()
|> monitor.check(
data: check,
messageFn: messageFn,
warn: warn,
crit: crit,
info: info,
)`
invalidTaskQuery := `package main
import "influxdata/influxdb/monitor"
import "influxdata/influxdb/v1"
data = from(bucket: "_tasks")
|> range(start: -1m)
|> filter(fn: (r) =>
(r._measurement == "runs"))
|> filter(fn: (r) =>
(r._field == "finishedAt"))
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
check = {
_check_id: "%s",
_check_name: "moo",
_type: "custom",
tags: {a: "b", c: "d"},
}
warn = (r) =>
(r.finishedAt > 20)
crit = (r) =>
(r.finishedAt > 20)
info = (r) =>
(r.finishedAt > 20)
messageFn = (r) =>
("Check: ${r._check_name} is: ${r._level}")
data
|> v1.fieldsAsCols()
|> monitor.check(
data: check,
messageFn: messageFn,
warn: warn,
crit: crit,
info: info,
)`
tests := []struct {
name string
args args
wants wants
}{
{
name: "valid flux script is valid and unchanged",
args: args{
custom: &check.Custom{
ID: 10,
Name: "moo",
Query: influxdb.DashboardQuery{
Text: ast.Format(parser.ParseSource(fmt.Sprintf(validQuery, "000000000000000a"))),
},
},
},
wants: wants{
err: nil,
script: ast.Format(parser.ParseSource(fmt.Sprintf(validQuery, "000000000000000a"))),
},
},
{
name: "valid flux script is valid but check ID is replaced if wrong",
args: args{
custom: &check.Custom{
ID: 10,
Name: "moo",
Query: influxdb.DashboardQuery{
Text: ast.Format(parser.ParseSource(fmt.Sprintf(validQuery, "000000000000000b"))),
},
},
},
wants: wants{
err: nil,
script: ast.Format(parser.ParseSource(fmt.Sprintf(validQuery, "000000000000000a"))),
},
},
{
name: "empty check query returns helpful error",
args: args{
custom: &check.Custom{
ID: 10,
Name: "moo",
Query: influxdb.DashboardQuery{
Text: "",
},
},
},
wants: wants{
err: errors.New("Custom flux must have an object called 'check'"),
},
},
{
name: "Script missing task option receives error that says so",
args: args{
custom: &check.Custom{
ID: 10,
Name: "moo",
Query: influxdb.DashboardQuery{
Text: ast.Format(parser.ParseSource(fmt.Sprintf(invalidTaskQuery, "000000000000000b"))),
},
},
},
wants: wants{
err: errors.New("Custom flux missing task option statement"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.args.custom.Valid(fluxlang.DefaultService)
if exp, got := tt.wants.err, err; exp != nil && got != nil {
// expected error, got error check that they match
if exp.Error() != got.Error() {
t.Errorf("expected:\n%v\n\ngot:\n%v\n", exp, got)
}
} else if (exp == nil || got == nil) && got != exp {
//either exp or got are nil
t.Errorf("expected:\n%v\n\ngot:\n%v\n", exp, got)
} else {
// neither errs are nil check that scripts match
if exp, got := tt.wants.script, tt.args.custom.Query.Text; exp != got {
t.Errorf("\n\nStrings do not match:\n\n%s", diff.LineDiff(exp, got))
}
}
})
}
} | explode_data.jsonl/7556 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1882
} | [
2830,
3393,
3973,
97279,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1444,
1450,
353,
2028,
27649,
198,
197,
532,
13158,
6801,
2036,
341,
197,
9859,
262,
1465,
198,
197,
86956,
914,
198,
197,
630,
56322,
2859,
1669,
156... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPretty(t *testing.T) {
exp := "\u274c int value:\nexp 42\ngot -1"
got := fmtexpl.Pretty("int value", 42, -1)
if got != exp {
t.Errorf("\nexp %s\ngot %s", exp, got)
}
} | explode_data.jsonl/56816 | {
"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,
51940,
1155,
353,
8840,
836,
8,
341,
48558,
1669,
2917,
84,
17,
22,
19,
66,
526,
897,
7190,
77,
4580,
220,
19,
17,
59,
968,
354,
481,
16,
698,
3174,
354,
1669,
8879,
29892,
1069,
21322,
445,
396,
897,
497,
220,
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... | 2 |
func TestGitGetter_setupGitEnvWithExisting_sshKey(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skipf("skipping on windows since the test requires sh")
return
}
// start with an existing ssh command configuration
os.Setenv("GIT_SSH_COMMAND", "ssh -o StrictHostKeyChecking=no")
defer os.Setenv("GIT_SSH_COMMAND", "")
cmd := exec.Command("/bin/sh", "-c", "echo $GIT_SSH_COMMAND")
setupGitEnv(cmd, "/tmp/foo.pem")
out, err := cmd.Output()
if err != nil {
t.Fatal(err)
}
actual := strings.TrimSpace(string(out))
if actual != "ssh -o StrictHostKeyChecking=no -i /tmp/foo.pem" {
t.Fatalf("unexpected GIT_SSH_COMMAND: %q", actual)
}
} | explode_data.jsonl/39702 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
46562,
31485,
21363,
46562,
14359,
2354,
53067,
82805,
1592,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
69,
445,
4886,
5654,
389,
11030,
2474,
279,
1273,
7460,
557,
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... | 4 |
func TestHTMLAllowed(t *testing.T) {
for _, test := range htmlTestsAllowing {
output, err := HTMLAllowing(test.input)
if err != nil {
t.Fatalf(Format, test.input, test.expected, output, err)
}
if output != test.expected {
t.Fatalf(Format, test.input, test.expected, output)
}
}
} | explode_data.jsonl/7071 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
5835,
35382,
1155,
353,
8840,
836,
8,
1476,
2023,
8358,
1273,
1669,
2088,
5272,
18200,
18605,
287,
341,
197,
21170,
11,
1848,
1669,
9308,
18605,
287,
8623,
10046,
340,
197,
743,
1848,
961,
2092,
341,
298,
3244,
30762,
7,
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... | 4 |
func TestNewCommand(t *testing.T) {
// Arrange
ctx := context.Background()
wg := &sync.WaitGroup{}
lc := logger.MockLogger{}
testDefaultTimeout := "10s"
testDefaultRetryInterval := "1s"
tests := []struct {
name string
cmdArgs []string
timeout string
retryInterval string
expectedErr bool
}{
{"Good: waitFor required at least one --uri option", []string{"--uri=http://localhost:11120"},
testDefaultTimeout, testDefaultRetryInterval, false},
{"Good: waitFor multiple --uri options", []string{"--uri=http://localhost:11120", "--uri=file:///testfile"},
testDefaultTimeout, testDefaultRetryInterval, false},
{"Good: waitFor --uri with --timeout options", []string{"--uri=http://:11120", "--timeout=1s"},
testDefaultTimeout, testDefaultRetryInterval, false},
{"Good: waitFor multiple --uri with --timeout options",
[]string{"--uri=http://:11120", "--uri=file:///testfile", "--timeout=1s"}, testDefaultTimeout,
testDefaultRetryInterval, false},
{"Good: waitFor --uri with --retryInterval options", []string{"--uri=http://:11120", "--retryInterval=5s"},
testDefaultTimeout, testDefaultRetryInterval, false},
{"Good: waitFor multiple --uri with --retryInterval options",
[]string{"--uri=http://:11120", "--uri=file:///testfile", "--retryInterval=5s"}, testDefaultTimeout,
testDefaultRetryInterval, false},
{"Good: waitFor --uri --timeout --retryInterval options",
[]string{"--uri=http://:11120", "--timeout=1s", "--retryInterval=5s"}, testDefaultTimeout,
testDefaultRetryInterval, false},
{"Bad: waitFor invalid option", []string{"--invalid=http://localhost:123"}, testDefaultTimeout,
testDefaultRetryInterval, true},
{"Bad: waitFor empty option", []string{""}, testDefaultTimeout, testDefaultRetryInterval, true},
{"Bad: waitFor interval option parse error", []string{"--uri=http://:11120", "--timeout=100"},
testDefaultTimeout, testDefaultRetryInterval, true},
{"Bad: waitFor bad syntax timeout config", []string{"--uri=http://localhost:11120"}, "10",
testDefaultRetryInterval, true},
{"Bad: waitFor bad syntax retryInterval config", []string{"--uri=http://localhost:11120"}, testDefaultTimeout,
"1", true},
{"Bad: waitFor negative value timeout config", []string{"--uri=http://localhost:11120"}, "-10s",
testDefaultRetryInterval, true},
{"Bad: waitFor negative value retryInterval config", []string{"--uri=http://localhost:11120"},
testDefaultTimeout, "-1m", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
config := getTestConfig(tt.timeout, tt.retryInterval)
command, err := NewCommand(ctx, wg, lc, config, tt.cmdArgs)
if tt.expectedErr {
require.Error(t, err)
} else {
require.NoError(t, err)
require.NotNil(t, command)
}
})
}
} | explode_data.jsonl/30991 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 996
} | [
2830,
3393,
3564,
4062,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
20985,
1669,
2266,
19047,
741,
72079,
1669,
609,
12996,
28384,
2808,
16094,
8810,
66,
1669,
5925,
24664,
7395,
16094,
18185,
3675,
7636,
1669,
330,
16,
15,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConnAsyncCBDeadlock(t *testing.T) {
s := RunServerOnPort(TEST_PORT)
defer s.Shutdown()
ch := make(chan bool)
o := GetDefaultOptions()
o.Url = fmt.Sprintf("nats://127.0.0.1:%d", TEST_PORT)
o.ClosedCB = func(_ *Conn) {
ch <- true
}
o.AsyncErrorCB = func(nc *Conn, sub *Subscription, err error) {
// do something with nc that requires locking behind the scenes
_ = nc.LastError()
}
nc, err := o.Connect()
if err != nil {
t.Fatalf("Should have connected ok: %v", err)
}
total := 300
wg := &sync.WaitGroup{}
wg.Add(total)
for i := 0; i < total; i++ {
go func() {
// overwhelm asyncCB with errors
nc.processErr(AUTHORIZATION_ERR)
wg.Done()
}()
}
wg.Wait()
nc.Close()
if e := Wait(ch); e != nil {
t.Fatal("Deadlock")
}
} | explode_data.jsonl/44920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
9701,
6525,
12979,
28320,
1023,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
6452,
5475,
1925,
7084,
50320,
12377,
340,
16867,
274,
10849,
18452,
2822,
23049,
1669,
1281,
35190,
1807,
340,
22229,
1669,
2126,
3675,
3798,
741,
2222... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPS(t *testing.T) {
//
// Test Plan:
//
// - Spin up a named conatainer using appsody run (any one will do)
// - Use docker ps to wait until it is ready
// - execute 'appsody ps', and check it we get at least a header line and the
// right container in the output
// - use 'appsody stop' to stop the container
//
// create a temporary dir to create the project and run the test
sandbox, cleanup := cmdtest.TestSetupWithSandbox(t, true)
defer cleanup()
// appsody init nodejs-express
args := []string{"init", "nodejs-express"}
_, err := cmdtest.RunAppsody(sandbox, args...)
if err != nil {
t.Fatal(err)
}
// appsody run
runChannel := make(chan error)
containerName := "testPSContainer"
go func() {
args = []string{"run", "--name", containerName}
_, err = cmdtest.RunAppsody(sandbox, args...)
runChannel <- err
close(runChannel)
}()
defer func() {
// run appsody stop to close the docker container
args = []string{"stop", "--name", containerName}
_, err = cmdtest.RunAppsody(sandbox, args...)
if err != nil {
t.Logf("Ignoring error running appsody stop: %s", err)
}
// wait for the appsody command/goroutine to finish
runErr := <-runChannel
if runErr != nil {
t.Logf("Ignoring error from the appsody command: %s", runErr)
}
}()
// It will take a while for the container to spin up, so let's use docker ps to wait for it
t.Log("calling docker ps to wait for container")
containerRunning := false
count := 15 // wait 30 seconds
for {
dockerOutput, dockerErr := cmdtest.RunDockerCmdExec([]string{"ps", "-q", "-f", "name=" + containerName}, t)
if dockerErr != nil {
t.Log("Ignoring error running docker ps -q -f name="+containerName, dockerErr)
}
if dockerOutput != "" {
t.Log("docker container " + containerName + " was found")
containerRunning = true
} else {
time.Sleep(2 * time.Second)
count = count - 1
}
if count == 0 || containerRunning {
break
}
}
if !containerRunning {
t.Fatal("container never appeared to start")
}
// now run appsody ps and see if we can spot the container
t.Log("about to run appsody ps")
stopOutput, errStop := cmdtest.RunAppsody(sandbox, "ps")
if !strings.Contains(stopOutput, "CONTAINER") {
t.Fatal("output doesn't contain header line")
}
if !strings.Contains(stopOutput, containerName) {
t.Fatal("output doesn't contain correct container name")
}
if errStop != nil {
t.Logf("Ignoring error running appsody ps: %s", errStop)
}
} | explode_data.jsonl/42530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 866
} | [
2830,
3393,
5012,
1155,
353,
8840,
836,
8,
341,
197,
2289,
197,
322,
3393,
9680,
510,
197,
2289,
197,
322,
481,
40685,
705,
264,
6941,
390,
459,
10453,
1667,
10500,
1076,
1598,
320,
3767,
825,
686,
653,
340,
197,
322,
481,
5443,
265... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldCreateMethodHandlers(t *testing.T) {
r := NewRouter()
items := map[string]func(string, HandlerProviderFunc){
http.MethodGet: r.Get,
http.MethodDelete: r.Delete,
http.MethodHead: r.Head,
http.MethodOptions: r.Options,
http.MethodPatch: r.Patch,
http.MethodPost: r.Post,
http.MethodPut: r.Put,
http.MethodTrace: r.Trace,
}
for method, handle := range items {
// create a fake handler and assert that Handle was called when executing
// a request with the provided method
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mh := NewMockHandler(ctrl)
mh.EXPECT().Handle(gomock.Any()).Do(func(c Context, args ...interface{}) {
assert.Equal(t, method, c.Request().Method)
}).Return(nil)
// call the router method Get,Delete,etc providing our mock handler
handle("/", func(Context) (Handler, error) {
return mh, nil
})
req := httptest.NewRequest(method, "/", nil)
r.ServeHTTP(httptest.NewRecorder(), req)
}
} | explode_data.jsonl/18955 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
14996,
4021,
3523,
39949,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
9523,
2822,
46413,
1669,
2415,
14032,
60,
2830,
3609,
11,
19954,
5179,
9626,
1264,
197,
28080,
20798,
1949,
25,
257,
435,
2234,
345,
197,
28080,
20798... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoStructLevelValidation(t *testing.T) {
type Inner struct {
Test string `validate:"len=5"`
}
type Outer struct {
InnerStruct *Inner `validate:"required,nostructlevel"`
}
outer := &Outer{
InnerStruct: nil,
}
validate := New()
errs := validate.Struct(outer)
NotEqual(t, errs, nil)
AssertError(t, errs, "Outer.InnerStruct", "Outer.InnerStruct", "InnerStruct", "InnerStruct", "required")
inner := &Inner{
Test: "1234",
}
outer = &Outer{
InnerStruct: inner,
}
errs = validate.Struct(outer)
Equal(t, errs, nil)
} | explode_data.jsonl/77295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
2753,
9422,
4449,
13799,
1155,
353,
8840,
836,
8,
1476,
13158,
36356,
2036,
341,
197,
73866,
914,
1565,
7067,
2974,
2892,
28,
20,
8805,
197,
630,
13158,
55197,
2036,
341,
197,
197,
31597,
9422,
353,
31597,
1565,
7067,
2974,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecompressStreamGzip(t *testing.T) {
cmd := exec.Command("sh", "-c", "touch /tmp/archive && gzip -f /tmp/archive")
output, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Fail to create an archive file for test : %s.", output)
}
archive, err := os.Open(tmp + "archive.gz")
_, err = DecompressStream(archive)
if err != nil {
t.Fatalf("Failed to decompress a gzip file.")
}
} | explode_data.jsonl/81967 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
4900,
316,
1873,
3027,
38,
9964,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
3883,
12714,
445,
927,
497,
6523,
66,
497,
330,
22020,
608,
5173,
71627,
1009,
57795,
481,
69,
608,
5173,
71627,
1138,
21170,
11,
1848,
1669,
5439... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalLocalTime(t *testing.T) {
type timeStruct struct {
Time LocalTime
}
examples := []struct {
name string
in LocalTime
out string
}{
{
name: "normal",
out: "Time = 07:32:00\n",
in: LocalTime{
Hour: 7,
Minute: 32,
Second: 0,
Nanosecond: 0,
}},
{
name: "with nanoseconds",
out: "Time = 00:32:00.999999000\n",
in: LocalTime{
Hour: 0,
Minute: 32,
Second: 0,
Nanosecond: 999999000,
},
},
}
for i, example := range examples {
t.Run(fmt.Sprintf("%d_%s", i, example.name), func(t *testing.T) {
obj := timeStruct{
Time: example.in,
}
b, err := Marshal(obj)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
got := string(b)
if got != example.out {
t.Errorf("expected '%s', got '%s'", example.out, got)
}
})
}
} | explode_data.jsonl/46364 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 452
} | [
2830,
3393,
55438,
7319,
1462,
1155,
353,
8840,
836,
8,
341,
13158,
882,
9422,
2036,
341,
197,
67567,
8774,
1462,
198,
197,
630,
8122,
4023,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
17430,
256,
8774,
1462,
198,
197,
13967,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPrintRoleBinding(t *testing.T) {
tests := []struct {
binding rbac.RoleBinding
options printers.GenerateOptions
expected []metav1.TableRow
}{
// Basic role binding
{
binding: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: "binding1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Subjects: []rbac.Subject{
{
Kind: "User",
Name: "system:kube-controller-manager",
},
},
RoleRef: rbac.RoleRef{
Kind: "Role",
Name: "extension-apiserver-authentication-reader",
},
},
options: printers.GenerateOptions{},
// Columns: Name, Age
expected: []metav1.TableRow{{Cells: []interface{}{"binding1", "Role/extension-apiserver-authentication-reader", "0s"}}},
},
// Generate options=Wide; print subject and roles.
{
binding: rbac.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: "binding2",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Subjects: []rbac.Subject{
{
Kind: "User",
Name: "user-name",
},
{
Kind: "Group",
Name: "group-name",
},
{
Kind: "ServiceAccount",
Name: "service-account-name",
Namespace: "service-account-namespace",
},
},
RoleRef: rbac.RoleRef{
Kind: "Role",
Name: "role-name",
},
},
options: printers.GenerateOptions{Wide: true},
// Columns: Name, Age, Role, Users, Groups, ServiceAccounts
expected: []metav1.TableRow{{Cells: []interface{}{"binding2", "Role/role-name", "0s", "user-name", "group-name", "service-account-namespace/service-account-name"}}},
},
}
for i, test := range tests {
rows, err := printRoleBinding(&test.binding, test.options)
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 932
} | [
2830,
3393,
8994,
9030,
15059,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
2233,
3961,
220,
18717,
580,
35955,
15059,
198,
197,
35500,
220,
55953,
57582,
3798,
198,
197,
42400,
3056,
4059,
402,
16,
18257,
3102,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDictValidatorEncode(t *testing.T) {
testCases := []encoderTestCase{
{
name: `KeysValidator=nil,Values.Validator=nil}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{},
},
},
},
customValidate: fieldValidator("d", `{"type": "object", "additionalProperties": true}`),
},
{
name: `KeysValidator=Integer{}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.Integer{},
},
},
},
},
expectError: "KeysValidator type not supported",
},
{
name: `KeysValidator=String{}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{},
},
},
},
},
customValidate: fieldValidator("d", `{"type": "object", "additionalProperties": true}`),
},
{
name: `Values.Validator=Integer{}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
Values: schema.Field{
Validator: &schema.Integer{},
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": {
"type": "integer"
}
}`),
},
{
name: `KeysValidator=String{Regexp:"re"}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{Regexp: "re"},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"re": {}
}
}`),
},
{
name: `KeysValidator=String{Regexp:"re"},ValuesValidator=Integer{}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{Regexp: "re"},
Values: schema.Field{
Validator: &schema.Integer{},
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"re": {
"type": "integer"
}
}
}`),
},
{
name: `KeysValidator=String{Allowed:["match1"]}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
Allowed: []string{"match1"},
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^(match1)$": {}
}
}`),
},
{
name: `KeysValidator=String{Allowed:["match1","match2"]}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
Allowed: []string{"match1", "match2"},
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^(match1|match2)$": {}
}
}`),
},
{
name: `KeysValidator=String{Regexp:"tch",Allowed:["match1","match2"]}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
Regexp: "tch",
Allowed: []string{"match1", "match2"},
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"allOf": [
{"patternProperties": {"^(match1|match2)$": {}}},
{"patternProperties": {"tch": {}}}
]
}`),
},
{
name: `KeysValidator=String{Regexp:"tch",Allowed:["match1","match2"]},ValuesValidator=Integer{}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
Regexp: "tch",
Allowed: []string{"match1", "match2"},
},
Values: schema.Field{
Validator: &schema.Integer{},
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"allOf": [
{"patternProperties": {"^(match1|match2)$": {"type": "integer"}}},
{"patternProperties": {"tch": {"type": "integer"}}}
]
}`),
},
{
name: `KeysValidator=String{MinLen:3},ValuesValidator=nil}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
MinLen: 3,
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.{3,}$": {}
}
}`),
},
{
name: `KeysValidator=String{MaxLen:4}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
MaxLen: 4,
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.{0,4}$": {}
}
}`),
},
{
name: `KeysValidator=String{MinLen:3,MaxLen:4}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
MinLen: 3,
MaxLen: 4,
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.{3,4}$": {}
}
}`),
},
{
name: `KeysValidator=String{MinLen:3,MaxLen:3}"`,
schema: schema.Schema{
Fields: schema.Fields{
"d": {
Validator: &schema.Dict{
KeysValidator: &schema.String{
MinLen: 3,
MaxLen: 3,
},
},
},
},
},
customValidate: fieldValidator("d", `{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^.{3}$": {}
}
}`),
},
}
for i := range testCases {
testCases[i].Run(t)
}
} | explode_data.jsonl/13166 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3221
} | [
2830,
3393,
13448,
14256,
32535,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
27008,
16458,
515,
197,
197,
515,
298,
11609,
25,
1565,
8850,
14256,
63358,
11,
6227,
13,
14256,
63358,
9863,
12892,
298,
1903,
3416,
25,
10802,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMongo_BlockUserWithTTL(t *testing.T) {
m, skip := prepMongo(t, true) // adds two comments
if skip {
return
}
assert.False(t, m.IsBlocked("radio-t", "user1"), "nothing blocked")
assert.NoError(t, m.SetBlock("radio-t", "user1", true, 500*time.Millisecond))
assert.True(t, m.IsBlocked("radio-t", "user1"), "user1 blocked")
time.Sleep(500 * time.Millisecond)
assert.False(t, m.IsBlocked("radio-t", "user1"), "user1 un-blocked automatically")
} | explode_data.jsonl/54206 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
54998,
51779,
1474,
2354,
51,
13470,
1155,
353,
8840,
836,
8,
341,
2109,
11,
10706,
1669,
21327,
54998,
1155,
11,
830,
8,
442,
11367,
1378,
6042,
198,
743,
10706,
341,
197,
853,
198,
197,
532,
6948,
50757,
1155,
11,
296,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGrpc_LoadParaTxByTitle(t *testing.T) {
qapi.On("LoadParaTxByTitle", mock.Anything, mock.Anything, mock.Anything).Return(nil, nil)
_, err := g.LoadParaTxByTitle(getOkCtx(), &pb.ReqHeightByTitle{})
assert.NoError(t, err)
} | explode_data.jsonl/339 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
6464,
3992,
19553,
30205,
31584,
1359,
3851,
1155,
353,
8840,
836,
8,
341,
18534,
2068,
8071,
445,
5879,
30205,
31584,
1359,
3851,
497,
7860,
13311,
1596,
11,
7860,
13311,
1596,
11,
7860,
13311,
1596,
568,
5598,
27907,
11,
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 TestParse(t *testing.T) {
testParse(t, clearsignInput, "Hello world\r\nline 2", "Hello world\nline 2\n")
testParse(t, clearsignInput2, "\r\n\r\n(This message has a couple of blank lines at the start and end.)\r\n\r\n", "\n\n(This message has a couple of blank lines at the start and end.)\n\n\n")
} | explode_data.jsonl/47769 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
14463,
1155,
353,
8840,
836,
8,
341,
18185,
14463,
1155,
11,
2797,
7752,
2505,
11,
330,
9707,
1879,
12016,
1699,
1056,
220,
17,
497,
330,
9707,
1879,
1699,
1056,
220,
17,
1699,
1138,
18185,
14463,
1155,
11,
2797,
7752,
250... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVerify(t *testing.T) {
testRules := []struct {
Role string
Resource *auth.Resource
}{
{
Role: "*",
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.PublicList"},
},
{
Role: "user.*",
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.List"},
},
{
Role: "user.developer",
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Update"},
},
{
Role: "admin",
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Delete"},
},
{
Role: "admin",
Resource: &auth.Resource{Type: "service", Name: "*", Endpoint: "*"},
},
}
a := NewAuth()
for _, r := range testRules {
if err := a.Grant(r.Role, r.Resource); err != nil {
t.Fatalf("Grant returned an error: %v, expected nil", err)
}
}
testTable := []struct {
Name string
Roles []string
Resource *auth.Resource
Error error
}{
{
Name: "An account with no roles accessing a public endpoint",
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.PublicList"},
},
{
Name: "An account with no roles accessing a private endpoint",
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Update"},
Error: auth.ErrForbidden,
},
{
Name: "An account with the user role accessing a user* endpoint",
Roles: []string{"user"},
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.List"},
},
{
Name: "An account with the user role accessing a user.admin endpoint",
Roles: []string{"user"},
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Delete"},
Error: auth.ErrForbidden,
},
{
Name: "An account with the developer role accessing a user.developer endpoint",
Roles: []string{"user.developer"},
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Update"},
},
{
Name: "An account with the developer role accessing an admin endpoint",
Roles: []string{"user.developer"},
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Delete"},
Error: auth.ErrForbidden,
},
{
Name: "An admin account accessing an admin endpoint",
Roles: []string{"admin"},
Resource: &auth.Resource{Type: "service", Name: "go.micro.apps", Endpoint: "Apps.Delete"},
},
{
Name: "An admin account accessing a generic service endpoint",
Roles: []string{"admin"},
Resource: &auth.Resource{Type: "service", Name: "go.micro.foo", Endpoint: "Foo.Bar"},
},
{
Name: "An admin account accessing an unauthorised endpoint",
Roles: []string{"admin"},
Resource: &auth.Resource{Type: "infra", Name: "go.micro.foo", Endpoint: "Foo.Bar"},
Error: auth.ErrForbidden,
},
{
Name: "A account with no roles accessing an unauthorised endpoint",
Resource: &auth.Resource{Type: "infra", Name: "go.micro.foo", Endpoint: "Foo.Bar"},
Error: auth.ErrForbidden,
},
}
for _, tc := range testTable {
t.Run(tc.Name, func(t *testing.T) {
acc := &auth.Account{Roles: tc.Roles}
if err := a.Verify(acc, tc.Resource); err != tc.Error {
t.Errorf("Verify returned %v error, expected %v", err, tc.Error)
}
})
}
} | explode_data.jsonl/80454 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1371
} | [
2830,
3393,
32627,
1155,
353,
8840,
836,
8,
341,
18185,
26008,
1669,
3056,
1235,
341,
197,
197,
9030,
257,
914,
198,
197,
79487,
353,
3242,
20766,
198,
197,
59403,
197,
197,
515,
298,
197,
9030,
25,
257,
15630,
756,
298,
79487,
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 TestParseEventDeclaration(t *testing.T) {
t.Parallel()
result, errs := ParseProgram(`
event Transfer(to: Address, from: Address)
`)
require.Empty(t, errs)
utils.AssertEqualWithDiff(t,
[]ast.Declaration{
&ast.CompositeDeclaration{
CompositeKind: common.CompositeKindEvent,
Identifier: ast.Identifier{
Identifier: "Transfer",
Pos: ast.Position{Offset: 15, Line: 2, Column: 14},
},
Members: ast.NewMembers(
[]ast.Declaration{
&ast.SpecialFunctionDeclaration{
Kind: common.DeclarationKindInitializer,
FunctionDeclaration: &ast.FunctionDeclaration{
ParameterList: &ast.ParameterList{
Parameters: []*ast.Parameter{
{
Label: "",
Identifier: ast.Identifier{
Identifier: "to",
Pos: ast.Position{Offset: 24, Line: 2, Column: 23},
},
TypeAnnotation: &ast.TypeAnnotation{
IsResource: false,
Type: &ast.NominalType{
Identifier: ast.Identifier{
Identifier: "Address",
Pos: ast.Position{Offset: 28, Line: 2, Column: 27},
},
},
StartPos: ast.Position{Offset: 28, Line: 2, Column: 27},
},
Range: ast.Range{
StartPos: ast.Position{Offset: 24, Line: 2, Column: 23},
EndPos: ast.Position{Offset: 34, Line: 2, Column: 33},
},
},
{
Label: "",
Identifier: ast.Identifier{
Identifier: "from",
Pos: ast.Position{Offset: 37, Line: 2, Column: 36},
},
TypeAnnotation: &ast.TypeAnnotation{
IsResource: false,
Type: &ast.NominalType{
Identifier: ast.Identifier{
Identifier: "Address",
Pos: ast.Position{Offset: 43, Line: 2, Column: 42},
},
},
StartPos: ast.Position{Offset: 43, Line: 2, Column: 42},
},
Range: ast.Range{
StartPos: ast.Position{Offset: 37, Line: 2, Column: 36},
EndPos: ast.Position{Offset: 49, Line: 2, Column: 48},
},
},
},
Range: ast.Range{
StartPos: ast.Position{Offset: 23, Line: 2, Column: 22},
EndPos: ast.Position{Offset: 50, Line: 2, Column: 49},
},
},
StartPos: ast.Position{Offset: 23, Line: 2, Column: 22},
},
},
},
),
Range: ast.Range{
StartPos: ast.Position{Offset: 9, Line: 2, Column: 8},
EndPos: ast.Position{Offset: 50, Line: 2, Column: 49},
},
},
},
result.Declarations(),
)
} | explode_data.jsonl/35989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1450
} | [
2830,
3393,
14463,
1556,
24489,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
9559,
11,
70817,
1669,
14775,
10690,
61528,
286,
1538,
23200,
12186,
25,
9177,
11,
504,
25,
9177,
340,
197,
24183,
17957,
11180,
1155,
11,
70817,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGossipAfterAbortOfSystemConfigTransactionAfterFailureDueToIntents(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
ctx := context.Background()
tc := testcluster.StartTestCluster(t, 1, base.TestClusterArgs{})
defer tc.Stopper().Stop(ctx)
require.NoError(t, tc.WaitForFullReplication())
db := tc.Server(0).DB()
txA := db.NewTxn(ctx, "a")
txB := db.NewTxn(ctx, "b")
require.NoError(t, txA.SetSystemConfigTrigger(true /* forSystemTenant */))
db1000 := dbdesc.NewInitial(1000, "1000", security.AdminRoleName())
require.NoError(t, txA.Put(ctx,
keys.SystemSQLCodec.DescMetadataKey(1000),
db1000.DescriptorProto()))
require.NoError(t, txB.SetSystemConfigTrigger(true /* forSystemTenant */))
db2000 := dbdesc.NewInitial(2000, "2000", security.AdminRoleName())
require.NoError(t, txB.Put(ctx,
keys.SystemSQLCodec.DescMetadataKey(2000),
db2000.DescriptorProto()))
const someTime = 10 * time.Millisecond
clearNotifictions := func(ch <-chan struct{}) {
for {
select {
case <-ch:
case <-time.After(someTime):
return
}
}
}
systemConfChangeCh := tc.Server(0).GossipI().(*gossip.Gossip).RegisterSystemConfigChannel()
clearNotifictions(systemConfChangeCh)
require.NoError(t, txB.Commit(ctx))
select {
case <-systemConfChangeCh:
// This case is rare but happens sometimes. We gossip the node liveness
// in a bunch of cases so we just let the test finish here. The important
// thing is that sometimes we get to the next phase.
t.Log("got unexpected update. This can happen for a variety of " +
"reasons like lease transfers. The test is exiting without testing anything")
return
case <-time.After(someTime):
// Did not expect an update so this is the happy case
}
// Roll back the transaction which had laid down the intent which blocked the
// earlier gossip update, make sure we get a gossip notification now.
const aLongTime = 20 * someTime
require.NoError(t, txA.Rollback(ctx))
select {
case <-systemConfChangeCh:
// Got an update.
case <-time.After(aLongTime):
t.Fatal("expected update")
}
} | explode_data.jsonl/1141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 736
} | [
2830,
3393,
38,
41473,
6025,
85891,
2124,
2320,
2648,
8070,
6025,
17507,
33060,
38544,
805,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
692,
20985,
1669,
2266,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestInitMap(t *testing.T) {
m1 := map[int]int{1: 1, 2: 4, 3: 9}
t.Log(m1[2])
t.Logf("len m1=%d", len(m1))
m2 := map[int]int{}
m2[4] = 16
t.Logf("len m2=%d", len(m2))
m3 := make(map[int]int, 10)
t.Logf("len m3=%d", len(m3))
} | explode_data.jsonl/74655 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 141
} | [
2830,
3393,
3803,
2227,
1155,
353,
8840,
836,
8,
341,
2109,
16,
1669,
2415,
18640,
63025,
90,
16,
25,
220,
16,
11,
220,
17,
25,
220,
19,
11,
220,
18,
25,
220,
24,
532,
3244,
5247,
1255,
16,
58,
17,
2546,
3244,
98954,
445,
2892,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCombine(t *testing.T) {
type args struct {
n int
k int
}
tests := []struct {
name string
args args
want [][]int
}{
{
name: "01",
args: args{
n: 4,
k: 2,
},
want: [][]int{
{1, 2},
{1, 3},
{1, 4},
{2, 3},
{2, 4},
{3, 4},
},
},
{
name: "02",
args: args{
n: 1,
k: 1,
},
want: [][]int{
{1},
},
},
}
for _, tt := range tests {
t.Run(
tt.name, func(t *testing.T) {
if got := combine(tt.args.n, tt.args.k); !reflect.DeepEqual(got, tt.want) {
t.Errorf("combine() = %v, want %v", got, tt.want)
}
},
)
}
} | explode_data.jsonl/7369 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
81114,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
9038,
526,
198,
197,
16463,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
52931,
396,
198,
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 TestUnmarshal(t *testing.T) {
cgroupRoot := "/ecs/taskid"
cgroupMountPath := "/sys/fs/cgroup"
bytes := []byte("{\"CgroupRoot\":\"/ecs/taskid\",\"CgroupMountPath\":\"/sys/fs/cgroup\"," +
"\"CreatedAt\":\"0001-01-01T00:00:00Z\",\"DesiredStatus\":\"CREATED\",\"KnownStatus\":\"NONE\"}")
unmarshalledCgroup := &CgroupResource{}
err := unmarshalledCgroup.UnmarshalJSON(bytes)
assert.NoError(t, err)
assert.Equal(t, cgroupRoot, unmarshalledCgroup.GetCgroupRoot())
assert.Equal(t, cgroupMountPath, unmarshalledCgroup.GetCgroupMountPath())
assert.Equal(t, time.Time{}, unmarshalledCgroup.GetCreatedAt())
assert.Equal(t, resourcestatus.ResourceStatus(CgroupCreated), unmarshalledCgroup.GetDesiredStatus())
assert.Equal(t, resourcestatus.ResourceStatus(CgroupStatusNone), unmarshalledCgroup.GetKnownStatus())
} | explode_data.jsonl/68164 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
1444,
4074,
8439,
1669,
3521,
53717,
58186,
307,
698,
1444,
4074,
16284,
1820,
1669,
3521,
7791,
73036,
2899,
4074,
698,
70326,
1669,
3056,
3782,
99141,
34,
4074,
8439,
23488,
14,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMySQLServerRepoAll(t *testing.T) {
TestMySQLServerRepo_Execute(t)
TestMySQLServerRepo_Transaction(t)
TestMySQLServerRepo_Create(t)
TestMySQLServerRepo_GetAll(t)
TestMySQLServerRepo_GetByClusterID(t)
TestMySQLServerRepo_GetByID(t)
TestMySQLServerRepo_GetByHostInfo(t)
TestMySQLServerRepo_GetID(t)
TestMySQLServerRepo_Update(t)
TestMySQLServerRepo_Delete(t)
} | explode_data.jsonl/80034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
59224,
5475,
25243,
2403,
1155,
353,
8840,
836,
8,
341,
73866,
59224,
5475,
25243,
83453,
1155,
340,
73866,
59224,
5475,
25243,
34932,
1311,
1155,
340,
73866,
59224,
5475,
25243,
34325,
1155,
340,
73866,
59224,
5475,
25243,
1361... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVbdec32(t *testing.T) {
for _, test := range []struct {
name string
input []byte
want []uint32
}{
{
name: "first1", // first value fitting in 1 byte
input: []byte{0x00},
want: []uint32{0},
},
{
name: "last1", // last value fitting in 1 byte
input: []byte{0xb0},
want: []uint32{176},
},
{
name: "first2", // first value fitting in 2 bytes
input: []byte{0xb1, 0x00},
want: []uint32{177},
},
{
name: "last2", // last value fitting in 2 bytes
input: []byte{0xf0, 0xff},
want: []uint32{16560},
},
{
name: "first3", // first value fitting in 3 bytes
input: []byte{0xf1, 0x00, 0x00},
want: []uint32{16561},
},
{
name: "last3", // last value fitting in 3 bytes
input: []byte{0xf8, 0xff, 0xff},
want: []uint32{540848},
},
{
name: "first4", // first value fitting in 4 bytes
input: []byte{0xf9, 0xb1, 0x40, 0x08},
want: []uint32{540849},
},
{
name: "last4", // last value fitting in 4 bytes
input: []byte{0xf9, 0xff, 0xff, 0xff},
want: []uint32{16777215},
},
{
name: "first5", // first value fitting in 5 bytes (overflow)
input: []byte{0xff, 0x00, 0x00, 0x00, 0x01},
want: []uint32{16777216},
},
{
name: "last5", // last value fitting in 5 bytes (overflow)
input: []byte{0xff, 0xff, 0xff, 0xff, 0xff},
want: []uint32{4294967295},
},
{
name: "multi5", // multiple values, exercising the 5 bytes
input: []byte{0x00, 0x00, 0x00, 0xfa, 0xff, 0xff, 0xff, 0xff},
want: []uint32{0, 0, 0, 4294967295},
},
} {
t.Run(test.name, func(t *testing.T) {
padded := make([]byte, len(test.input)*4)
copy(padded, test.input)
output := make([]uint32, len(test.want))
read := vbdec32(padded, output)
if got, want := read, len(test.input); got != want {
t.Fatalf("vbdec32 read %d, want %d", got, want)
}
if got, want := output, test.want; !reflect.DeepEqual(got, want) {
t.Fatalf("vbdec32: got %d, want %d", got, want)
}
})
}
} | explode_data.jsonl/48360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 956
} | [
2830,
3393,
53,
65,
8169,
18,
17,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
3056,
3782,
198,
197,
50780,
220,
3056,
2496,
18,
17,
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... | 3 |
func TestProvider_Format(t *testing.T) {
mockSingle := storage.MockNvmeController()
for name, tc := range map[string]struct {
req storage.BdevFormatRequest
mbc *MockBackendConfig
expRes *storage.BdevFormatResponse
expErr error
}{
"empty input": {
req: storage.BdevFormatRequest{},
expErr: errors.New("empty DeviceList"),
},
"NVMe failure": {
req: storage.BdevFormatRequest{
Properties: storage.BdevTierProperties{
Class: storage.ClassNvme,
DeviceList: []string{mockSingle.PciAddr},
},
},
mbc: &MockBackendConfig{
FormatRes: &storage.BdevFormatResponse{
DeviceResponses: storage.BdevDeviceFormatResponses{
mockSingle.PciAddr: &storage.BdevDeviceFormatResponse{
Error: FaultFormatError(mockSingle.PciAddr,
errors.New("foobared")),
},
},
},
},
expRes: &storage.BdevFormatResponse{
DeviceResponses: storage.BdevDeviceFormatResponses{
mockSingle.PciAddr: &storage.BdevDeviceFormatResponse{
Error: FaultFormatError(mockSingle.PciAddr,
errors.New("foobared")),
},
},
},
},
"NVMe success": {
req: storage.BdevFormatRequest{
Properties: storage.BdevTierProperties{
Class: storage.ClassNvme,
DeviceList: []string{mockSingle.PciAddr},
},
},
mbc: &MockBackendConfig{
FormatRes: &storage.BdevFormatResponse{
DeviceResponses: storage.BdevDeviceFormatResponses{
mockSingle.PciAddr: &storage.BdevDeviceFormatResponse{
Formatted: true,
},
},
},
},
expRes: &storage.BdevFormatResponse{
DeviceResponses: storage.BdevDeviceFormatResponses{
mockSingle.PciAddr: &storage.BdevDeviceFormatResponse{
Formatted: true,
},
},
},
},
} {
t.Run(name, func(t *testing.T) {
log, buf := logging.NewTestLogger(name)
defer common.ShowBufferOnFailure(t, buf)
p := NewMockProvider(log, tc.mbc)
gotRes, gotErr := p.Format(tc.req)
common.CmpErr(t, tc.expErr, gotErr)
if gotErr != nil {
return
}
common.AssertEqual(t, len(tc.expRes.DeviceResponses),
len(gotRes.DeviceResponses), "number of device responses")
for addr, resp := range tc.expRes.DeviceResponses {
common.AssertEqual(t, resp, gotRes.DeviceResponses[addr],
"device response")
}
})
}
} | explode_data.jsonl/67555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1041
} | [
2830,
3393,
5179,
72999,
1155,
353,
8840,
836,
8,
341,
77333,
10888,
1669,
5819,
24664,
45,
85,
2660,
2051,
2822,
2023,
829,
11,
17130,
1669,
2088,
2415,
14032,
60,
1235,
341,
197,
24395,
262,
5819,
1785,
3583,
4061,
1900,
198,
197,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMachoFiles(t *testing.T) {
skipUnlessDarwinAmd64(t)
t.Skip("Disabled because of issues with addr2line (see https://github.com/google/pprof/pull/313#issuecomment-364073010)")
// Load `file`, pretending it was mapped at `start`. Then get the symbol
// table. Check that it contains the symbol `sym` and that the address
// `addr` gives the `expected` stack trace.
for _, tc := range []struct {
desc string
file string
start, limit, offset uint64
addr uint64
sym string
expected []plugin.Frame
}{
{"normal mapping", "exe_mac_64", 0x100000000, math.MaxUint64, 0,
0x100000f50, "_main",
[]plugin.Frame{
{Func: "main", File: "/tmp/hello.c", Line: 3},
}},
{"other mapping", "exe_mac_64", 0x200000000, math.MaxUint64, 0,
0x200000f50, "_main",
[]plugin.Frame{
{Func: "main", File: "/tmp/hello.c", Line: 3},
}},
{"lib normal mapping", "lib_mac_64", 0, math.MaxUint64, 0,
0xfa0, "_bar",
[]plugin.Frame{
{Func: "bar", File: "/tmp/lib.c", Line: 6},
}},
} {
t.Run(tc.desc, func(t *testing.T) {
bu := &Binutils{}
f, err := bu.Open(filepath.Join("testdata", tc.file), tc.start, tc.limit, tc.offset)
if err != nil {
t.Fatalf("Open: unexpected error %v", err)
}
defer f.Close()
syms, err := f.Symbols(nil, 0)
if err != nil {
t.Fatalf("Symbols: unexpected error %v", err)
}
m := findSymbol(syms, tc.sym)
if m == nil {
t.Fatalf("Symbols: could not find symbol %v", tc.sym)
}
gotFrames, err := f.SourceLine(tc.addr)
if err != nil {
t.Fatalf("SourceLine: unexpected error %v", err)
}
if !reflect.DeepEqual(gotFrames, tc.expected) {
t.Fatalf("SourceLine for main: got %v; want %v\n", gotFrames, tc.expected)
}
})
}
} | explode_data.jsonl/74916 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 832
} | [
2830,
3393,
44,
63429,
10809,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
35587,
52673,
7526,
32,
2277,
21,
19,
1155,
692,
3244,
57776,
445,
25907,
1576,
315,
4714,
448,
10789,
17,
1056,
320,
4060,
3703,
1110,
5204,
905,
40689,
87146,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProviderRateLimiterDisable(t *testing.T) {
t.Log("testing providerratelimiter handler with qps enabled as false")
initEnv()
c := handler.Chain{}
c.AddHandler(&handler.ProviderRateLimiterHandler{})
config.GlobalDefinition = &model.GlobalCfg{}
config.GlobalDefinition.Cse.FlowControl.Provider.QPS.Enabled = false
i := &invocation.Invocation{
SourceMicroService: "service1",
SchemaID: "schema1",
OperationID: "SayHello",
Args: &helloworld.HelloRequest{Name: "peter"},
}
c.Next(i, func(r *invocation.Response) error {
assert.NoError(t, r.Err)
log.Println(r.Result)
return r.Err
})
} | explode_data.jsonl/62819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
5179,
11564,
43,
17700,
25479,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
445,
8840,
2059,
59609,
301,
17700,
7013,
448,
2804,
1690,
8970,
438,
895,
1138,
28248,
14359,
2822,
1444,
1669,
7013,
98269,
16094,
1444,
1904,
3050,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetRetryTimes(t *testing.T) {
assert := internal.NewAssert(t, "TestSetRetryTimes")
var number int
increaseNumber := func() error {
number++
return errors.New("error occurs")
}
err := Retry(increaseNumber, RetryDuration(time.Microsecond*50), RetryTimes(3))
assert.IsNotNil(err)
assert.Equal(3, number)
} | explode_data.jsonl/30740 | {
"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,
1649,
51560,
18889,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
5306,
7121,
8534,
1155,
11,
330,
2271,
1649,
51560,
18889,
5130,
2405,
1372,
526,
198,
17430,
19947,
2833,
1669,
2915,
368,
1465,
341,
197,
57135,
22940,
197,
853... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnknownAuthorityError(t *testing.T) {
for i, tt := range unknownAuthorityErrorTests {
der, _ := pem.Decode([]byte(tt.cert))
if der == nil {
t.Errorf("#%d: Unable to decode PEM block", i)
}
c, err := ParseCertificate(der.Bytes)
if err != nil {
t.Errorf("#%d: Unable to parse certificate -> %v", i, err)
}
uae := &UnknownAuthorityError{
Cert: c,
hintErr: fmt.Errorf("empty"),
hintCert: c,
}
actual := uae.Error()
if actual != tt.expected {
t.Errorf("#%d: UnknownAuthorityError.Error() response invalid actual: %s expected: %s", i, actual, tt.expected)
}
}
} | explode_data.jsonl/29002 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 262
} | [
2830,
3393,
13790,
45532,
1454,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
17853,
1669,
2088,
9788,
45532,
1454,
18200,
341,
197,
197,
1107,
11,
716,
1669,
54184,
56372,
10556,
3782,
47152,
67016,
1171,
197,
743,
2694,
621,
2092,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestEncryptionHeaderExistsTrue(t *testing.T) {
encImagePath := "../test/cirros-x86.qcow2_enc"
isImageEncrypted, err := EncryptionHeaderExists(encImagePath)
assert.NoError(t, err)
assert.True(t, isImageEncrypted)
} | explode_data.jsonl/24981 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
79239,
4047,
15575,
2514,
1155,
353,
8840,
836,
8,
341,
197,
954,
66356,
1669,
7005,
1944,
2899,
404,
3630,
6558,
23,
21,
11354,
18921,
17,
13781,
698,
19907,
1906,
7408,
14026,
11,
1848,
1669,
62055,
4047,
15575,
66941,
663... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomerUsecaseImpl_CheckAccoutExist(t *testing.T) {
t.Run("Test Normal Case", func(t *testing.T) {
mockAccountRepo := new(mocks.CustomerRepoMock)
mockAccountRepo.On("CheckAccoutExist", mockAccount.AccountNumber).Return(nil)
customerUsecase := usecase.CreateCustomerUsecase(mockAccountRepo)
isExist := customerUsecase.CheckAccoutExist(mockAccount.AccountNumber)
assert.Equal(t, true, isExist)
})
} | explode_data.jsonl/70252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
12792,
52,
5024,
519,
9673,
28188,
14603,
411,
25613,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2271,
18437,
11538,
497,
2915,
1155,
353,
8840,
836,
8,
1476,
197,
77333,
7365,
25243,
1669,
501,
1255,
25183,
37293,
2524... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_AZUQueueStorageAnalyticsTurnedOn(t *testing.T) {
expectedCode := "azure-storage-queue-services-logging-enabled"
var tests = []struct {
name string
source string
mustIncludeResultCode string
mustExcludeResultCode string
}{
{
name: "check queue services storage account without analytics logging causes failure",
source: `
resource "azurerm_storage_account" "good_example" {
name = "example"
resource_group_name = data.azurerm_resource_group.example.name
location = data.azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "GRS"
queue_properties {
}
}
`,
mustIncludeResultCode: expectedCode,
},
{
name: "check queue services storage account with analytics logging enabled passes",
source: `
resource "azurerm_storage_account" "good_example" {
name = "example"
resource_group_name = data.azurerm_resource_group.example.name
location = data.azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "GRS"
queue_properties {
logging {
delete = true
read = true
write = true
version = "1.0"
retention_policy_days = 10
}
}
}
`,
mustExcludeResultCode: expectedCode,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
results := testutil.ScanHCL(test.source, t)
testutil.AssertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results)
})
}
} | explode_data.jsonl/43004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 759
} | [
2830,
3393,
1566,
57,
52,
7554,
5793,
60539,
19389,
291,
1925,
1155,
353,
8840,
836,
8,
341,
42400,
2078,
1669,
330,
39495,
62795,
12,
4584,
58292,
12,
25263,
54192,
1837,
2405,
7032,
284,
3056,
1235,
341,
197,
11609,
1698,
914,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExportDictionaryValue(t *testing.T) {
t.Parallel()
t.Run("Empty", func(t *testing.T) {
t.Parallel()
script := `
access(all) fun main(): {String: Int} {
return {}
}
`
actual := exportValueFromScript(t, script)
expected := cadence.NewDictionary([]cadence.KeyValuePair{})
assert.Equal(t, expected, actual)
})
t.Run("Non-empty", func(t *testing.T) {
t.Parallel()
script := `
access(all) fun main(): {String: Int} {
return {
"a": 1,
"b": 2
}
}
`
actual := exportValueFromScript(t, script)
expected := cadence.NewDictionary([]cadence.KeyValuePair{
{
Key: cadence.NewString("a"),
Value: cadence.NewInt(1),
},
{
Key: cadence.NewString("b"),
Value: cadence.NewInt(2),
},
})
assert.Equal(t, expected, actual)
})
} | explode_data.jsonl/4623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 478
} | [
2830,
3393,
16894,
8517,
1130,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
3244,
16708,
445,
3522,
497,
2915,
1155,
353,
8840,
836,
8,
1476,
197,
3244,
41288,
7957,
2822,
197,
86956,
1669,
22074,
310,
2615,
20388,
8,
2464,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpanLink_MoveTo(t *testing.T) {
ms := generateTestSpanLink()
dest := NewSpanLink()
ms.MoveTo(dest)
assert.EqualValues(t, NewSpanLink(), ms)
assert.EqualValues(t, generateTestSpanLink(), dest)
} | explode_data.jsonl/63294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
12485,
3939,
66352,
1249,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
6923,
2271,
12485,
3939,
741,
49616,
1669,
1532,
12485,
3939,
741,
47691,
31195,
1249,
27010,
340,
6948,
12808,
6227,
1155,
11,
1532,
12485,
3939,
1507,
9829... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserCountsWithPostsByDay(t *testing.T) {
Setup()
t1 := &model.Team{}
t1.DisplayName = "DisplayName"
t1.Name = "zz" + model.NewId() + "b"
t1.Email = model.NewId() + "@nowhere.com"
t1.Type = model.TEAM_OPEN
t1 = Must(store.Team().Save(t1)).(*model.Team)
c1 := &model.Channel{}
c1.TeamId = t1.Id
c1.DisplayName = "Channel2"
c1.Name = "zz" + model.NewId() + "b"
c1.Type = model.CHANNEL_OPEN
c1 = Must(store.Channel().Save(c1)).(*model.Channel)
o1 := &model.Post{}
o1.ChannelId = c1.Id
o1.UserId = model.NewId()
o1.CreateAt = utils.MillisFromTime(utils.Yesterday())
o1.Message = "zz" + model.NewId() + "b"
o1 = Must(store.Post().Save(o1)).(*model.Post)
o1a := &model.Post{}
o1a.ChannelId = c1.Id
o1a.UserId = model.NewId()
o1a.CreateAt = o1.CreateAt
o1a.Message = "zz" + model.NewId() + "b"
o1a = Must(store.Post().Save(o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = model.NewId()
o2.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24)
o2.Message = "zz" + model.NewId() + "b"
o2 = Must(store.Post().Save(o2)).(*model.Post)
o2a := &model.Post{}
o2a.ChannelId = c1.Id
o2a.UserId = o2.UserId
o2a.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24)
o2a.Message = "zz" + model.NewId() + "b"
o2a = Must(store.Post().Save(o2a)).(*model.Post)
if r1 := <-store.Post().AnalyticsUserCountsWithPostsByDay(t1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
row1 := r1.Data.(model.AnalyticsRows)[0]
if row1.Value != 2 {
t.Fatal("wrong value")
}
row2 := r1.Data.(model.AnalyticsRows)[1]
if row2.Value != 1 {
t.Fatal("wrong value")
}
}
} | explode_data.jsonl/55952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 762
} | [
2830,
3393,
1474,
2507,
16056,
19631,
1359,
10159,
1155,
353,
8840,
836,
8,
341,
197,
21821,
2822,
3244,
16,
1669,
609,
2528,
65842,
16094,
3244,
16,
77574,
284,
330,
26456,
698,
3244,
16,
2967,
284,
330,
10400,
1,
488,
1614,
7121,
76... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleMultiValueAttribute(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := []string{
"select c1,c2,c3,c4 from tab1 where col_id REGEXP '[[:<:]]12[[:>:]]'",
}
for _, sql := range sqls {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleMultiValueAttribute()
if rule.Item != "LIT.003" {
t.Error("Rule not match:", rule.Item, "Expect : LIT.003")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76780 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
11337,
20358,
1130,
3907,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
3056,
917,
515,
197,
197,
1,
1742,
272,
16,
10109,
17,
10109,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSystemRootsError(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Windows does not use (or support) systemRoots")
}
defer func(oldSystemRoots *CertPool) { systemRoots = oldSystemRoots }(systemRootsPool())
opts := VerifyOptions{
Intermediates: NewCertPool(),
DNSName: "www.google.com",
CurrentTime: time.Unix(1395785200, 0),
}
if ok := opts.Intermediates.AppendCertsFromPEM([]byte(giag2Intermediate)); !ok {
t.Fatalf("failed to parse intermediate")
}
leaf, err := certificateFromPEM(googleLeaf)
if err != nil {
t.Fatalf("failed to parse leaf: %v", err)
}
systemRoots = nil
_, err = leaf.Verify(opts)
if _, ok := err.(SystemRootsError); !ok {
t.Errorf("error was not SystemRootsError: %v", err)
}
} | explode_data.jsonl/29007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
2320,
8439,
82,
1454,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
445,
13164,
1558,
537,
990,
320,
269,
1824,
8,
1849,
8439,
82,
1138,
197,
630,
16867,
2915,
21972,
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 TestCatchUpClient_GetBlocks(t *testing.T) {
lg, err := logger.New(&logger.Config{
Level: "info",
OutputPath: []string{"stdout"},
ErrOutputPath: []string{"stderr"},
Encoding: "console",
})
require.NoError(t, err)
localConfigs, sharedConfig := newTestSetup(t, 2)
tr1, err := startTransportWithLedger(t, lg, localConfigs, sharedConfig, 0, 5)
require.NoError(t, err)
defer tr1.Close()
cc := comm.NewCatchUpClient(lg, nil)
require.NotNil(t, cc)
err = cc.UpdateMembers(sharedConfig.ConsensusConfig.Members)
require.NoError(t, err)
blocks, err := cc.GetBlocks(context.Background(), 1, 2, 4)
require.NoError(t, err)
require.Equal(t, 3, len(blocks))
blocks, err = cc.GetBlocks(context.Background(), 2, 2, 4)
require.EqualError(t, err, "Get \"http://127.0.0.1:33001/bcdb-peer/blocks?end=4&start=2\": dial tcp 127.0.0.1:33001: connect: connection refused")
tr2, err := startTransportWithLedger(t, lg, localConfigs, sharedConfig, 1, 5)
require.NoError(t, err)
defer tr2.Close()
blocks, err = cc.GetBlocks(context.Background(), 2, 2, 4)
require.NoError(t, err)
require.Equal(t, 3, len(blocks))
} | explode_data.jsonl/70494 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
57760,
2324,
2959,
13614,
29804,
1155,
353,
8840,
836,
8,
341,
8810,
70,
11,
1848,
1669,
5925,
7121,
2099,
9786,
10753,
515,
197,
197,
4449,
25,
260,
330,
2733,
756,
197,
80487,
1820,
25,
262,
3056,
917,
4913,
36358,
7115,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLabelsChanged(t *testing.T) {
g := Gmail{cache: newTestCache()}
g.cache.SetMsgLabels("id", []string{"a", "b"})
if !g.labelsChanged("id", []string{"a"}) {
t.Error(`labelsChanged("id", {"a"}) = false, expected true`)
}
if g.labelsChanged("id", []string{"a", "b"}) {
t.Error(`labelsChanged("id", {"a", "b"}) = true, expected false`)
}
if !g.labelsChanged("id", []string{}) {
t.Error(`labelsChanged("id", {}) = false, expected true`)
}
if !g.labelsChanged("id", []string{"a", "b", "c"}) {
t.Error(`labelsChanged("id", {"a", "b", "c"}) = false, expected true`)
}
} | explode_data.jsonl/903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 251
} | [
2830,
3393,
23674,
5389,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
60946,
90,
9360,
25,
501,
2271,
8233,
23509,
3174,
20087,
4202,
6611,
23674,
445,
307,
497,
3056,
917,
4913,
64,
497,
330,
65,
23625,
743,
753,
70,
39168,
5389,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParser2(t *testing.T) {
gobatis.RegisterTemplateFile("./sql.tpl")
t.Run("select", func(t *testing.T) {
p, ok := gobatis.FindTemplateSqlParser("selectTestTable")
if !ok {
t.Fatal(ok)
}
md, err := p.ParseMetadata("mysql", TestTable{Id: 1, UserName: "user", Password: "pw", Status: 10})
if err != nil {
t.Fatal(err)
}
t.Log(md)
})
t.Run("insert", func(t *testing.T) {
p, ok := gobatis.FindTemplateSqlParser("insertTestTable")
if !ok {
t.Fatal(ok)
}
md, err := p.ParseMetadata("mysql", TestTable{Id: 1, UserName: "user", Password: "pw", Status: 10})
if err != nil {
t.Fatal(err)
}
t.Log(md)
})
t.Run("insertBatch", func(t *testing.T) {
p, ok := gobatis.FindTemplateSqlParser("insertBatchTestTable")
if !ok {
t.Fatal(ok)
}
md, err := p.ParseMetadata("mysql", []TestTable{
{Id: 11, UserName: "user11", Password: "pw11"},
{Id: 12, UserName: "user12", Password: "pw12"},
})
if err != nil {
t.Fatal(err)
}
t.Log(md)
})
t.Run("update", func(t *testing.T) {
p, ok := gobatis.FindTemplateSqlParser("updateTestTable")
if !ok {
t.Fatal(ok)
}
md, err := p.ParseMetadata("mysql", TestTable{Id: 1, UserName: "user", Password: "pw", Status: 10})
if err != nil {
t.Fatal(err)
}
t.Log(md)
})
t.Run("delete", func(t *testing.T) {
p, ok := gobatis.FindTemplateSqlParser("deleteTestTable")
if !ok {
t.Fatal(ok)
}
md, err := p.ParseMetadata("mysql", TestTable{Id: 1, UserName: "user", Password: "pw", Status: 10})
if err != nil {
t.Fatal(err)
}
t.Log(md)
})
} | explode_data.jsonl/60507 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 740
} | [
2830,
3393,
6570,
17,
1155,
353,
8840,
836,
8,
341,
3174,
674,
3605,
19983,
7275,
1703,
13988,
3544,
34066,
1138,
3244,
16708,
445,
1742,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3223,
11,
5394,
1669,
74417,
3605,
9998,
7275,
826... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMiddleware_GraphQLBasicAuth(t *testing.T) {
env.SetEnv(env.Env{BasicAuthUsername: basicUsername, BasicAuthPassword: basicPass})
mw := &Middleware{}
t.Run("Testcase #1: Positive", func(t *testing.T) {
ctx := context.WithValue(context.Background(), candishared.ContextKeyHTTPHeader, http.Header{
"Authorization": []string{"Basic " + validBasicAuth},
})
assert.NotPanics(t, func() { mw.GraphQLBasicAuth(ctx) })
})
t.Run("Testcase #2: Negative", func(t *testing.T) {
ctx := context.WithValue(context.Background(), candishared.ContextKeyHTTPHeader, http.Header{
"Authorization": []string{},
})
assert.Panics(t, func() { mw.GraphQLBasicAuth(ctx) })
})
t.Run("Testcase #3: Negative", func(t *testing.T) {
ctx := context.WithValue(context.Background(), candishared.ContextKeyHTTPHeader, http.Header{
"Authorization": []string{"Basic xxx"},
})
assert.Panics(t, func() { mw.GraphQLBasicAuth(ctx) })
})
} | explode_data.jsonl/44827 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
24684,
2646,
1935,
3588,
15944,
5087,
1155,
353,
8840,
836,
8,
341,
57538,
4202,
14359,
16978,
81214,
90,
15944,
5087,
11115,
25,
6770,
11115,
11,
14625,
5087,
4876,
25,
6770,
12187,
3518,
2109,
86,
1669,
609,
24684,
31483,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPreparedStatementWithStdlib(t *testing.T) {
db, cleanup := testCreateDB(t, 3)
defer cleanup()
var tm time.Time
if err := db.QueryRow("select_row").Scan(&tm); err != nil {
t.Fatal(err)
}
t.Log(tm)
} | explode_data.jsonl/74281 | {
"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,
45405,
2354,
22748,
2740,
1155,
353,
8840,
836,
8,
341,
20939,
11,
21290,
1669,
1273,
4021,
3506,
1155,
11,
220,
18,
340,
16867,
21290,
2822,
2405,
17333,
882,
16299,
198,
743,
1848,
1669,
2927,
15685,
3102,
445,
1742,
8530,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewClusterComplexNameFromKubeClusterName(t *testing.T) {
tests := []struct {
name string
inputName string
expectedName string
expectedType string
}{
{
name: "single-word",
inputName: "myCluster",
expectedName: "myCluster",
expectedType: config.AirshipDefaultClusterType,
},
{
name: "multi-word",
inputName: "myCluster_two",
expectedName: "myCluster_two",
expectedType: config.AirshipDefaultClusterType,
},
{
name: "cluster-appended",
inputName: "myCluster_ephemeral",
expectedName: "myCluster",
expectedType: config.Ephemeral,
},
{
name: "multi-word-cluster-appended",
inputName: "myCluster_two_ephemeral",
expectedName: "myCluster_two",
expectedType: config.Ephemeral,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
complexName := config.NewClusterComplexNameFromKubeClusterName(tt.inputName)
assert.Equal(t, tt.expectedName, complexName.Name)
assert.Equal(t, tt.expectedType, complexName.Type)
})
}
} | explode_data.jsonl/57912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 485
} | [
2830,
3393,
3564,
28678,
31137,
675,
3830,
42,
3760,
28678,
675,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
22427,
675,
262,
914,
198,
197,
42400,
675,
914,
198,
197,
42400,
929,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMissingTables(t *testing.T) {
if testing.Short() {
t.Skip()
}
engine.se.Reload(context.Background())
execStatements(t, []string{
"create table t1(id11 int, id12 int, primary key(id11))",
"create table shortlived(id31 int, id32 int, primary key(id31))",
})
defer execStatements(t, []string{
"drop table t1",
"drop table _shortlived",
})
startPos := primaryPosition(t)
execStatements(t, []string{
"insert into shortlived values (1,1), (2,2)",
"alter table shortlived rename to _shortlived",
})
engine.se.Reload(context.Background())
filter := &binlogdatapb.Filter{
Rules: []*binlogdatapb.Rule{{
Match: "t1",
Filter: "select * from t1",
}},
}
testcases := []testcase{
{
input: []string{},
output: [][]string{},
},
{
input: []string{
"insert into t1 values (101, 1010)",
},
output: [][]string{
{
"begin",
"gtid",
"commit",
},
{
"gtid",
"type:OTHER",
},
{
"begin",
"type:FIELD field_event:{table_name:\"t1\" fields:{name:\"id11\" type:INT32 table:\"t1\" org_table:\"t1\" database:\"vttest\" org_name:\"id11\" column_length:11 charset:63 column_type:\"int(11)\"} fields:{name:\"id12\" type:INT32 table:\"t1\" org_table:\"t1\" database:\"vttest\" org_name:\"id12\" column_length:11 charset:63 column_type:\"int(11)\"}}",
"type:ROW row_event:{table_name:\"t1\" row_changes:{after:{lengths:3 lengths:4 values:\"1011010\"}}}",
"gtid",
"commit",
},
},
},
}
runCases(t, filter, testcases, startPos, nil)
} | explode_data.jsonl/10402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 692
} | [
2830,
3393,
25080,
21670,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
741,
197,
532,
80118,
4523,
38939,
2731,
5378,
19047,
2398,
67328,
93122,
1155,
11,
3056,
917,
515,
197,
197,
1,
3182,
1965,
259,
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 TestNoopState(t *testing.T) {
noop := &noOp{}
require.Equal(t, "noop", noop.Name())
t.Run("must not transition to any state", func(t *testing.T) {
all := []state{&null{}, &invited{}, &requested{}, &responded{}, &completed{}}
for _, s := range all {
require.False(t, noop.CanTransitionTo(s))
}
})
} | explode_data.jsonl/2084 | {
"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,
2753,
453,
1397,
1155,
353,
8840,
836,
8,
341,
197,
40162,
1669,
609,
2152,
7125,
16094,
17957,
12808,
1155,
11,
330,
40162,
497,
60829,
2967,
12367,
3244,
16708,
445,
24812,
537,
9142,
311,
894,
1584,
497,
2915,
1155,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestError(t *testing.T) {
var message = "The request was faulty"
var errorData = "This is a error"
err := errors.New(errorData)
response := Error(message, err)
if response.Code != 400 {
t.Error("Expected status code to be 400")
}
if response.Status != StatusError {
t.Error("Expected the status to be error")
}
if response.Message != message {
t.Error("Expected the message to equal our message")
}
if response.Data != err {
t.Error("Expeted the data to contain the error-information")
}
} | explode_data.jsonl/71747 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
1454,
1155,
353,
8840,
836,
8,
1476,
2405,
1943,
284,
330,
785,
1681,
572,
57571,
698,
2405,
1465,
1043,
284,
330,
1986,
374,
264,
1465,
1837,
9859,
1669,
5975,
7121,
6390,
1043,
340,
21735,
1669,
4600,
7333,
11,
1848,
692... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDeletePostWithFileAttachments(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
// Create a post with a file attachment.
teamID := th.BasicTeam.Id
channelID := th.BasicChannel.Id
userID := th.BasicUser.Id
filename := "test"
data := []byte("abcd")
info1, err := th.App.DoUploadFile(th.Context, time.Date(2007, 2, 4, 1, 2, 3, 4, time.Local), teamID, channelID, userID, filename, data)
require.Nil(t, err)
defer func() {
th.App.Srv().Store.FileInfo().PermanentDelete(info1.Id)
th.App.RemoveFile(info1.Path)
}()
post := &model.Post{
Message: "asd",
ChannelId: channelID,
PendingPostId: model.NewId() + ":" + fmt.Sprint(model.GetMillis()),
UserId: userID,
CreateAt: 0,
FileIds: []string{info1.Id},
}
post, err = th.App.CreatePost(th.Context, post, th.BasicChannel, false, true)
assert.Nil(t, err)
// Delete the post.
post, err = th.App.DeletePost(post.Id, userID)
assert.Nil(t, err)
// Wait for the cleanup routine to finish.
time.Sleep(time.Millisecond * 100)
// Check that the file can no longer be reached.
_, err = th.App.GetFileInfo(info1.Id)
assert.NotNil(t, err)
} | explode_data.jsonl/26433 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
6435,
4133,
2354,
1703,
75740,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
197,
322,
4230,
264,
1736,
448,
264,
1034,
19984,
624,
197,
9196,
915,
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... | 1 |
func Test_hcsTask_ID(t *testing.T) {
lt, _, _ := setupTestHcsTask(t)
if lt.ID() != t.Name() {
t.Fatalf("expect ID: '%s', got: '%s'", t.Name(), lt.ID())
}
} | explode_data.jsonl/56368 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
1523,
4837,
6262,
3450,
1155,
353,
8840,
836,
8,
341,
197,
4832,
11,
8358,
716,
1669,
6505,
2271,
39,
4837,
6262,
1155,
692,
743,
25175,
9910,
368,
961,
259,
2967,
368,
341,
197,
3244,
30762,
445,
17119,
3034,
25,
7677,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExampleSearchErr(t *testing.T) {
data := []byte(` { "xx" : [] ,"yy" :{ }, "test" : [ true , 0.1 , "abc", ["h"], {"a":"bc"} ] } `)
node, e := Get(data, "zz")
if e == nil {
t.Fatalf("node: %v, err: %v", node, e)
}
fmt.Println(e)
node, e = Get(data, "xx", 4)
if e == nil {
t.Fatalf("node: %v, err: %v", node, e)
}
fmt.Println(e)
node, e = Get(data, "yy", "a")
if e == nil {
t.Fatalf("node: %v, err: %v", node, e)
}
fmt.Println(e)
node, e = Get(data, "test", 4, "x")
if e == nil {
t.Fatalf("node: %v, err: %v", node, e)
}
fmt.Println(e)
} | explode_data.jsonl/62341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
13314,
5890,
7747,
1155,
353,
8840,
836,
8,
341,
262,
821,
1669,
3056,
3782,
5809,
314,
330,
4146,
1,
549,
3056,
33821,
4807,
1,
549,
90,
2470,
330,
1944,
1,
549,
508,
830,
1154,
220,
15,
13,
16,
1154,
330,
13683,
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 TestInputService2ProtocolTestSerializeOtherScalarTypesCase1(t *testing.T) {
sess := session.New()
svc := NewInputService2ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService2TestShapeInputService2TestCaseOperation1Input{
First: aws.Bool(true),
Fourth: aws.Int64(3),
Second: aws.Bool(false),
Third: aws.Float64(1.2),
}
req, _ := svc.InputService2TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
restxml.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body := util.SortXML(r.Body)
awstesting.AssertXML(t, `<OperationRequest xmlns="https://foo/"><First xmlns="https://foo/">true</First><Fourth xmlns="https://foo/">3</Fourth><Second xmlns="https://foo/">false</Second><Third xmlns="https://foo/">1.2</Third></OperationRequest>`, util.Trim(string(body)), InputService2TestShapeInputService2TestCaseOperation1Input{})
// assert URL
awstesting.AssertURL(t, "https://test/2014-01-01/hostedzone", r.URL.String())
// assert headers
} | explode_data.jsonl/46471 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
2505,
1860,
17,
20689,
2271,
15680,
11409,
20639,
4173,
4207,
16,
1155,
353,
8840,
836,
8,
341,
1903,
433,
1669,
3797,
7121,
741,
1903,
7362,
1669,
1532,
2505,
1860,
17,
20689,
2271,
57223,
11,
609,
8635,
10753,
90,
27380,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreCreate(t *testing.T) {
podA := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "test"},
Spec: api.PodSpec{NodeName: "machine"},
}
podB := &api.Pod{
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "test"},
Spec: api.PodSpec{NodeName: "machine2"},
}
testContext := api.WithNamespace(api.NewContext(), "test")
server, registry := NewTestGenericStoreRegistry(t)
defer server.Terminate(t)
// create the object
objA, err := registry.Create(testContext, podA)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
// get the object
checkobj, err := registry.Get(testContext, podA.Name)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
// verify objects are equal
if e, a := objA, checkobj; !reflect.DeepEqual(e, a) {
t.Errorf("Expected %#v, got %#v", e, a)
}
// now try to create the second pod
_, err = registry.Create(testContext, podB)
if !errors.IsAlreadyExists(err) {
t.Errorf("Unexpected error: %v", err)
}
} | explode_data.jsonl/228 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 394
} | [
2830,
3393,
6093,
4021,
1155,
353,
8840,
836,
8,
341,
3223,
347,
32,
1669,
609,
2068,
88823,
515,
197,
23816,
12175,
25,
6330,
80222,
63121,
25,
330,
7975,
497,
41962,
25,
330,
1944,
7115,
197,
7568,
992,
25,
981,
6330,
88823,
8327,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChangeTrustValidateInvalidLimit(t *testing.T) {
kp0 := newKeypair0()
txSourceAccount := NewSimpleAccount(kp0.Address(), int64(9605939170639898))
changeTrust := ChangeTrust{
Line: CreditAsset{"ABCD", kp0.Address()},
Limit: "-1",
}
tx := Transaction{
SourceAccount: &txSourceAccount,
Operations: []Operation{&changeTrust},
Timebounds: NewInfiniteTimeout(),
Network: network.TestNetworkPassphrase,
}
err := tx.Build()
if assert.Error(t, err) {
expected := "validation failed for *txnbuild.ChangeTrust operation: Field: Limit, Error: amount can not be negative"
assert.Contains(t, err.Error(), expected)
}
} | explode_data.jsonl/62200 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
4072,
45548,
17926,
7928,
16527,
1155,
353,
8840,
836,
8,
341,
16463,
79,
15,
1669,
501,
6608,
1082,
1310,
15,
741,
46237,
3608,
7365,
1669,
1532,
16374,
7365,
5969,
79,
15,
26979,
1507,
526,
21,
19,
7,
24,
21,
15,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewRoleBinding(t *testing.T) {
want := &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: rbName,
Namespace: testNS,
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",
Name: crName,
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Namespace: testNS,
Name: serviceAccount,
},
},
}
sa := MakeServiceAccount(testNS, serviceAccount)
got := MakeRoleBinding(testNS, rbName, sa, crName)
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("unexpected condition (-want, +got) = %v", diff)
}
} | explode_data.jsonl/44204 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
3564,
9030,
15059,
1155,
353,
8840,
836,
8,
341,
50780,
1669,
609,
10681,
580,
85,
16,
35955,
15059,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
18717,
675,
345,
298,
90823,
25,
1273,
2448,
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... | 2 |
func TestRegisterHandler(t *testing.T) {
// Reset Register
HandlerRegister = make(map[string]func() handlers.Handler)
err := Register("printer", NewTestHandler)
if err != nil {
t.Fatalf("Error should have been an HandlerAlreadyRegistered, not this : %v", err)
}
err = Register("printer", NewTestHandler)
if !errors.Is(err, ErrHandlerAlreadyRegistered) {
t.Fatalf("Expected ErrHandlerAlreadyRegistered, not this: %v", err)
}
} | explode_data.jsonl/75191 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
8690,
3050,
1155,
353,
8840,
836,
8,
1476,
197,
322,
16932,
8451,
198,
197,
3050,
8690,
284,
1281,
9147,
14032,
60,
2830,
368,
24083,
31010,
692,
9859,
1669,
8451,
445,
62956,
497,
1532,
2271,
3050,
340,
743,
1848,
961,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConfig_GetYamlAttribute(t *testing.T) {
c := &Config{
ConnectEnabled: false,
}
if err := c.SetBoolValueByYamlAttribute("connect_enabled", true); err != nil {
t.Errorf("unable to update config value: %s", err)
}
assert.True(t, c.ConnectEnabled)
assert.Error(t, c.SetBoolValueByYamlAttribute("no_a_value", false))
} | explode_data.jsonl/22928 | {
"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,
2648,
13614,
56,
9467,
3907,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
2648,
515,
197,
197,
14611,
5462,
25,
895,
345,
197,
532,
743,
1848,
1669,
272,
57197,
1130,
1359,
56,
9467,
3907,
445,
6459,
18220,
497,
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... | 2 |
func TestQuadriWeekly(t *testing.T) {
doTestNWeekly(t, "[] bla (every 4th thursday)", moment.RecurQuadriWeekly, 4, tu.DtUtc("01.11.2019"), tu.DtUtc("31.10.2019"))
} | explode_data.jsonl/67521 | {
"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,
43474,
461,
80516,
1155,
353,
8840,
836,
8,
341,
19935,
2271,
45,
80516,
1155,
11,
330,
1294,
84541,
320,
29015,
220,
19,
339,
270,
7181,
11583,
4445,
2817,
2352,
43474,
461,
80516,
11,
220,
19,
11,
9765,
909,
83,
97768,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetAtNeverBreaksSorting(t *testing.T) {
s := newSummary(10)
for _, i := range []float64{10, 10, 10, 10, 10} {
_ = s.Add(i, 1)
}
s.setAt(0, 30, 1)
checkSorted(s, t)
s.setAt(s.Len()-1, 0, 1)
checkSorted(s, t)
s.setAt(3, 10.1, 1)
checkSorted(s, t)
s.setAt(3, 9.9, 1)
checkSorted(s, t)
} | explode_data.jsonl/77560 | {
"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,
1649,
1655,
26155,
22524,
82,
71681,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
19237,
7,
16,
15,
692,
2023,
8358,
600,
1669,
2088,
3056,
3649,
21,
19,
90,
16,
15,
11,
220,
16,
15,
11,
220,
16,
15,
11,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMembershipInfoProvider(t *testing.T) {
peerSelfSignedData := common.SignedData{
Identity: []byte("peer0"),
Signature: []byte{1, 2, 3},
Data: []byte{4, 5, 6},
}
identityDeserializer := func(chainID string) msp.IdentityDeserializer {
return &mockDeserializer{}
}
//验证成员身份提供程序是否返回true
membershipProvider := NewMembershipInfoProvider(peerSelfSignedData, identityDeserializer)
res, err := membershipProvider.AmMemberOf("test1", getAccessPolicy([]string{"peer0", "peer1"}))
assert.True(t, res)
assert.Nil(t, err)
//验证成员身份提供程序是否返回false
res, err = membershipProvider.AmMemberOf("test1", getAccessPolicy([]string{"peer2", "peer3"}))
assert.False(t, res)
assert.Nil(t, err)
//验证成员身份提供程序返回nil,并且当收集策略配置为nil时出错
res, err = membershipProvider.AmMemberOf("test1", nil)
assert.False(t, res)
assert.Error(t, err)
assert.Equal(t, "Collection policy config is nil", err.Error())
} | explode_data.jsonl/43708 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
80904,
1731,
5179,
1155,
353,
8840,
836,
8,
341,
197,
16537,
12092,
49312,
1043,
1669,
4185,
808,
1542,
1043,
515,
197,
197,
18558,
25,
220,
3056,
3782,
445,
16537,
15,
4461,
197,
197,
25088,
25,
3056,
3782,
90,
16,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSumPerKeyWithPartitionsNegativeBoundsFloat(t *testing.T) {
// We have two test cases, one for public partitions as a PCollection and one for public partitions as a slice (i.e., in-memory).
for _, tc := range []struct {
inMemory bool
}{
{true},
{false},
} {
triples := testutils.ConcatenateTriplesWithFloatValue(
testutils.MakeTripleWithFloatValue(21, 1, -1.0), // should be clamped down to -2.0
testutils.MakeTripleWithFloatValue(50, 2, -4.0)) // should be clamped up to -3.0
result := []testutils.TestFloat64Metric{
{1, -42.0},
{2, -150.0},
}
p, s, col, want := ptest.CreateList2(triples, result)
col = beam.ParDo(s, testutils.ExtractIDFromTripleWithFloatValue, col)
publicPartitionsSlice := []int{1, 2}
var publicPartitions interface{}
if tc.inMemory {
publicPartitions = publicPartitionsSlice
} else {
publicPartitions = beam.CreateList(s, publicPartitionsSlice)
}
// We have ε=50, δ=0 and l1Sensitivity=6.
// We have 2 partitions. So, to get an overall flakiness of 10⁻²³,
// we need to have each partition pass with 1-10⁻²⁵ probability (k=25).
epsilon, delta, k, l1Sensitivity := 50.0, 0.0, 25.0, 6.0
pcol := MakePrivate(s, col, NewPrivacySpec(epsilon, delta))
pcol = ParDo(s, testutils.TripleWithFloatValueToKV, pcol)
sumParams := SumParams{MaxPartitionsContributed: 2, MinValue: -3.0, MaxValue: -2.0, NoiseKind: LaplaceNoise{}, PublicPartitions: publicPartitions}
got := SumPerKey(s, pcol, sumParams)
want = beam.ParDo(s, testutils.Float64MetricToKV, want)
if err := testutils.ApproxEqualsKVFloat64(s, got, want, testutils.LaplaceTolerance(k, l1Sensitivity, epsilon)); err != nil {
t.Fatalf("TestSumPerKeyWithPartitionsNegativeBoundsFloat in-memory=%t: %v", tc.inMemory, err)
}
if err := ptest.Run(p); err != nil {
t.Errorf("TestSumPerKeyWithPartitionsNegativeBoundsFloat in-memory=%t: SumPerKey(%v) = %v, expected %v: %v", tc.inMemory, col, got, want, err)
}
}
} | explode_data.jsonl/42961 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 775
} | [
2830,
3393,
9190,
3889,
1592,
2354,
5800,
5930,
38489,
11394,
5442,
1155,
353,
8840,
836,
8,
341,
197,
322,
1205,
614,
1378,
1273,
5048,
11,
825,
369,
584,
46688,
438,
264,
393,
6482,
323,
825,
369,
584,
46688,
438,
264,
15983,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSingleBothWaysPolicySinglePod(t *testing.T) {
gomega.RegisterTestingT(t)
logger := logrus.DefaultLogger()
logger.SetLevel(logging.DebugLevel)
logger.Debug("TestSingleBothWaysPolicySinglePod")
// Prepare input data.
const (
namespace = "default"
pod1Name = "pod1"
pod2Name = "pod2"
pod1IP = "192.168.1.1"
pod2IP = "192.168.1.2"
)
pod1 := podmodel.ID{Name: pod1Name, Namespace: namespace}
pod2 := podmodel.ID{Name: pod2Name, Namespace: namespace}
policy1 := &ContivPolicy{
ID: policymodel.ID{Name: "policy1", Namespace: namespace},
Type: PolicyAll,
Matches: []Match{
{
Type: MatchIngress,
Pods: []podmodel.ID{
pod2,
},
IPBlocks: []IPBlock{
{
Network: parseIPNet("10.5.0.0/16"),
Except: []net.IPNet{
parseIPNet("10.5.1.0/24"),
parseIPNet("10.5.2.0/24"),
parseIPNet("10.5.3.0/24"),
},
},
},
Ports: []Port{
{Protocol: UDP, Number: 333},
{Protocol: UDP, Number: 777},
{Protocol: TCP, Number: 0}, /* any */
},
},
{
Type: MatchEgress,
Pods: []podmodel.ID{
pod2,
},
Ports: []Port{
{Protocol: TCP, Number: 80},
{Protocol: TCP, Number: 443},
},
},
},
}
pod1Policies := []*ContivPolicy{policy1}
// Initialize mocks.
cache := NewMockPolicyCache()
cache.AddPodConfig(pod1, pod1IP)
cache.AddPodConfig(pod2, pod2IP)
ipam := &ipamMock{}
ipam.SetNatLoopbackIP(natLoopbackIP)
renderer := NewMockRenderer("A", logger)
// Initialize configurator.
configurator := &PolicyConfigurator{
Deps: Deps{
Log: logger,
Cache: cache,
IPAM: ipam,
},
}
configurator.Init(false)
// Register one renderer.
err := configurator.RegisterRenderer(renderer)
gomega.Expect(err).To(gomega.BeNil())
// Run single transaction.
txn := configurator.NewTxn(false)
txn.Configure(pod1, pod1Policies)
err = txn.Commit()
gomega.Expect(err).To(gomega.BeNil())
// Test IP address provided by the configurator.
ip, masklen := renderer.GetPodIP(pod1)
gomega.Expect(masklen).To(gomega.BeEquivalentTo(net.IPv4len * 8))
gomega.Expect(ip).To(gomega.BeEquivalentTo(pod1IP))
// Test with fake traffic.
// Allowed by policy1.
action := renderer.TestTraffic(pod1, IngressTraffic,
parseIP(pod1IP), parseIP(pod2IP), rendererAPI.TCP, 123, 80)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, IngressTraffic,
parseIP(pod1IP), parseIP(pod2IP), rendererAPI.TCP, 456, 443)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(pod2IP), parseIP(pod1IP), rendererAPI.UDP, 123, 333)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(pod2IP), parseIP(pod1IP), rendererAPI.UDP, 456, 777)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP("10.5.6.7"), parseIP(pod1IP), rendererAPI.UDP, 456, 777)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(pod2IP), parseIP(pod1IP), rendererAPI.TCP, 456, 5000)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(pod2IP), parseIP(pod1IP), rendererAPI.TCP, 456, 6000)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Allowed by policy1.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP("10.5.6.7"), parseIP(pod1IP), rendererAPI.TCP, 456, 6000)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Always allowed from NAT-loopback.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(natLoopbackIP), parseIP(pod1IP), rendererAPI.TCP, 456, 100)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(natLoopbackIP), parseIP(pod1IP), rendererAPI.OTHER, 0, 0)
gomega.Expect(action).To(gomega.BeEquivalentTo(AllowedTraffic))
// Blocked by policy1 - TCP:100 not allowed.
action = renderer.TestTraffic(pod1, IngressTraffic,
parseIP(pod1IP), parseIP(pod2IP), rendererAPI.TCP, 789, 100)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
// Blocked by policy1 - UDP not allowed.
action = renderer.TestTraffic(pod1, IngressTraffic,
parseIP(pod1IP), parseIP(pod2IP), rendererAPI.UDP, 789, 100)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
// Blocked by policy1 - destination 192.168.1.5 not allowed.
action = renderer.TestTraffic(pod1, IngressTraffic,
parseIP(pod1IP), parseIP("192.168.1.5"), rendererAPI.TCP, 456, 443)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
// Blocked by policy1 - source 192.168.1.5 not allowed.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP("192.168.2.5"), parseIP(pod1IP), rendererAPI.UDP, 123, 333)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
// Blocked by policy1 - UDP:444 not allowed.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(pod2IP), parseIP(pod1IP), rendererAPI.UDP, 123, 444)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
// Blocked by policy1 - source 10.5.1.1 not allowed.
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP("10.5.1.1"), parseIP(pod1IP), rendererAPI.UDP, 123, 333)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
// Blocked by policy1 - pod1 is isolated wrt. other protocols.
action = renderer.TestTraffic(pod1, IngressTraffic,
parseIP(pod1IP), parseIP(pod2IP), rendererAPI.OTHER, 0, 0)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
action = renderer.TestTraffic(pod1, EgressTraffic,
parseIP(pod2IP), parseIP(pod1IP), rendererAPI.OTHER, 0, 0)
gomega.Expect(action).To(gomega.BeEquivalentTo(DeniedTraffic))
} | explode_data.jsonl/19621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2581
} | [
2830,
3393,
10888,
20629,
54,
942,
13825,
10888,
23527,
1155,
353,
8840,
836,
8,
341,
3174,
32696,
19983,
16451,
51,
1155,
340,
17060,
1669,
1487,
20341,
13275,
7395,
741,
17060,
4202,
4449,
51687,
20345,
4449,
340,
17060,
20345,
445,
227... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegrationOBFS4ParseArgsError(t *testing.T) {
ctx := context.Background()
config := obfs4config()
config.Params = make(map[string][]string) // cause ParseArgs error
results := OBFS4Connect(ctx, config)
if results.Error.Error() != "missing argument 'node-id'" {
t.Fatal("not the error we expected")
}
} | explode_data.jsonl/53552 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
52464,
20608,
8485,
19,
14463,
4117,
1454,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
25873,
1669,
1508,
3848,
19,
1676,
741,
25873,
58268,
284,
1281,
9147,
14032,
45725,
917,
8,
442,
5240,
14775,
4117,
146... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClient_GetServerTLSConfig_renew(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
// Start CA
ca := startCATestServer()
defer ca.Close()
clientDomain := "test.domain"
client, sr, pk := signDuration(ca, "127.0.0.1", 1*time.Minute)
// Start mTLS server
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
tlsConfig, err := client.GetServerTLSConfig(ctx, sr, pk)
if err != nil {
t.Fatalf("Client.GetServerTLSConfig() error = %v", err)
}
srvMTLS := startTestServer(tlsConfig, serverHandler(t, clientDomain))
defer srvMTLS.Close()
// Start TLS server
ctx, cancel = context.WithCancel(context.Background())
defer cancel()
tlsConfig, err = client.GetServerTLSConfig(ctx, sr, pk, VerifyClientCertIfGiven())
if err != nil {
t.Fatalf("Client.GetServerTLSConfig() error = %v", err)
}
srvTLS := startTestServer(tlsConfig, serverHandler(t, clientDomain))
defer srvTLS.Close()
// Transport
client, sr, pk = signDuration(ca, clientDomain, 1*time.Minute)
tr1, err := client.Transport(context.Background(), sr, pk)
if err != nil {
t.Fatalf("Client.Transport() error = %v", err)
}
// Transport with tlsConfig
client, sr, pk = signDuration(ca, clientDomain, 1*time.Minute)
tlsConfig, err = client.GetClientTLSConfig(context.Background(), sr, pk)
if err != nil {
t.Fatalf("Client.GetClientTLSConfig() error = %v", err)
}
tr2, err := getDefaultTransport(tlsConfig)
if err != nil {
t.Fatalf("getDefaultTransport() error = %v", err)
}
// No client cert
root, err := RootCertificate(sr)
if err != nil {
t.Fatalf("RootCertificate() error = %v", err)
}
tlsConfig = getDefaultTLSConfig(sr)
tlsConfig.RootCAs = x509.NewCertPool()
tlsConfig.RootCAs.AddCert(root)
tr3, err := getDefaultTransport(tlsConfig)
if err != nil {
t.Fatalf("getDefaultTransport() error = %v", err)
}
// Disable keep alives to force TLS handshake
tr1.DisableKeepAlives = true
tr2.DisableKeepAlives = true
tr3.DisableKeepAlives = true
tests := []struct {
name string
client *http.Client
wantErr map[string]bool
}{
{"with transport", &http.Client{Transport: tr1}, map[string]bool{
srvTLS.URL: false,
srvMTLS.URL: false,
}},
{"with tlsConfig", &http.Client{Transport: tr2}, map[string]bool{
srvTLS.URL: false,
srvMTLS.URL: false,
}},
{"with no ClientCert", &http.Client{Transport: tr3}, map[string]bool{
srvTLS.URL + "/no-cert": false,
srvMTLS.URL + "/no-cert": true,
}},
{"fail with default", &http.Client{}, map[string]bool{
srvTLS.URL + "/no-cert": true,
srvMTLS.URL + "/no-cert": true,
}},
}
// To count different cert fingerprints
fingerprints := map[string]struct{}{}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for path, wantErr := range tt.wantErr {
t.Run(path, func(t *testing.T) {
resp, err := tt.client.Get(path)
if (err != nil) != wantErr {
t.Errorf("http.Client.Get() error = %v", err)
return
}
if wantErr {
return
}
if fp := resp.Header.Get("x-fingerprint"); fp != "" {
fingerprints[fp] = struct{}{}
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("ioutil.RealAdd() error = %v", err)
return
}
if !bytes.Equal(b, []byte("ok")) {
t.Errorf("response body unexpected, got %s, want ok", b)
return
}
})
}
})
}
if l := len(fingerprints); l != 2 {
t.Errorf("number of fingerprints unexpected, got %d, want 2", l)
}
// Wait for renewal 40s == 1m-1m/3
log.Printf("Sleeping for %s ...\n", 40*time.Second)
time.Sleep(40 * time.Second)
for _, tt := range tests {
t.Run("renewed "+tt.name, func(t *testing.T) {
for path, wantErr := range tt.wantErr {
t.Run(path, func(t *testing.T) {
resp, err := tt.client.Get(path)
if (err != nil) != wantErr {
t.Errorf("http.Client.Get() error = %v", err)
return
}
if wantErr {
return
}
if fp := resp.Header.Get("x-fingerprint"); fp != "" {
fingerprints[fp] = struct{}{}
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("ioutil.RealAdd() error = %v", err)
return
}
if !bytes.Equal(b, []byte("ok")) {
t.Errorf("response body unexpected, got %s, want ok", b)
return
}
})
}
})
}
if l := len(fingerprints); l != 4 {
t.Errorf("number of fingerprints unexpected, got %d, want 4", l)
}
} | explode_data.jsonl/58876 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1967
} | [
2830,
3393,
2959,
13614,
5475,
45439,
2648,
1288,
931,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
304,
2805,
3856,
13053,
197,
630,
197,
322,
5145,
9183,
198,
197,
924,
1669,
119... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.