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 TestClient_Init(t *testing.T) {
tests := []struct {
name string
cfg config.Metadata
wantErr bool
}{
{
name: "init",
cfg: config.Metadata{
Name: "http-target",
Kind: "",
Properties: map[string]string{
"auth_type": "basic",
"username": "username",
"password": "password",
"token": "token",
"proxy": "proxy",
"retry_count": "1",
"retry_wait_seconds": "1",
"root_certificate": "some-certificate",
"client_private_key": "",
"client_public_key": "",
"default_headers": "",
},
},
wantErr: false,
},
{
name: "init - error on client certificate",
cfg: config.Metadata{
Name: "http-target",
Kind: "",
Properties: map[string]string{
"auth_type": "auth_token",
"username": "username",
"password": "password",
"token": "token",
"proxy": "proxy",
"retry_count": "1",
"retry_wait_seconds": "1",
"root_certificate": "some-certificate",
"client_private_key": "some-certificate",
"client_public_key": "some-certificate",
"default_headers": "",
},
},
wantErr: true,
},
{
name: "init - error on bad options 1",
cfg: config.Metadata{
Name: "http-target",
Kind: "",
Properties: map[string]string{
"retry_wait_seconds": "-1",
},
},
wantErr: true,
},
{
name: "init - error on bad options 2",
cfg: config.Metadata{
Name: "http-target",
Kind: "",
Properties: map[string]string{
"default_headers": "bad format",
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
c := New()
if err := c.Init(ctx, tt.cfg); (err != nil) != tt.wantErr {
t.Errorf("Init() error = %v, wantErr %v", err, tt.wantErr)
return
}
require.EqualValues(t, tt.cfg.Name, c.Name())
})
}
} | explode_data.jsonl/48295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1070
} | [
2830,
3393,
2959,
15644,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
50286,
257,
2193,
46475,
198,
197,
50780,
7747,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
2327,
756... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPerimeter(t *testing.T) {
rectangle := Rectangle{10.0, 10.0}
got := Perimeter(rectangle)
want := 40.0
if got != want {
t.Errorf("got %.2f want %.2f", got, want)
}
} | explode_data.jsonl/60535 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
3889,
25334,
1155,
353,
8840,
836,
8,
220,
341,
197,
55316,
1669,
19280,
90,
16,
15,
13,
15,
11,
220,
16,
15,
13,
15,
532,
3174,
354,
1669,
3616,
25334,
30354,
4044,
340,
50780,
1669,
220,
19,
15,
13,
15,
271,
743,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUAllAccountOrders(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("skipping test: api keys not set")
}
_, err := b.UAllAccountOrders(context.Background(), currency.EMPTYPAIR, 0, 0, time.Time{}, time.Time{})
if err != nil {
t.Error(err)
}
_, err = b.UAllAccountOrders(context.Background(), currency.NewPair(currency.BTC, currency.USDT), 0, 5, time.Now().Add(-time.Hour*4), time.Now())
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
52,
2403,
7365,
24898,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
25,
6330,
6894,
537,
738,
1138,
197,
532,
197,
6878,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderTappx, config.Adapter{
Endpoint: "http://{{.Host}}"})
if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}
adapterstest.RunJSONBidderTest(t, "tappxtest", bidder)
} | explode_data.jsonl/51703 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
5014,
39571,
1155,
353,
8840,
836,
8,
341,
2233,
307,
1107,
11,
1936,
7747,
1669,
20626,
30981,
3342,
65,
9927,
1785,
307,
1107,
51,
676,
87,
11,
2193,
34190,
515,
197,
197,
27380,
25,
330,
1254,
1110,
2979,
13,
9296,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewDNSProvider(t *testing.T) {
testCases := []struct {
desc string
envVars map[string]string
expected string
}{
{
desc: "success",
envVars: map[string]string{
EnvAPIUser: "123",
EnvAPIPassword: "456",
},
},
{
desc: "missing credentials",
envVars: map[string]string{
EnvAPIUser: "",
EnvAPIPassword: "",
},
expected: "autodns: some credentials information are missing: AUTODNS_API_USER,AUTODNS_API_PASSWORD",
},
{
desc: "missing user id",
envVars: map[string]string{
EnvAPIUser: "",
EnvAPIPassword: "456",
},
expected: "autodns: some credentials information are missing: AUTODNS_API_USER",
},
{
desc: "missing key",
envVars: map[string]string{
EnvAPIUser: "123",
EnvAPIPassword: "",
},
expected: "autodns: some credentials information are missing: AUTODNS_API_PASSWORD",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
defer envTest.RestoreEnv()
envTest.ClearEnv()
envTest.Apply(test.envVars)
p, err := NewDNSProvider()
if len(test.expected) == 0 {
require.NoError(t, err)
require.NotNil(t, p)
require.NotNil(t, p.config)
} else {
require.EqualError(t, err, test.expected)
}
})
}
} | explode_data.jsonl/34728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 599
} | [
2830,
3393,
3564,
61088,
5179,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
57538,
28305,
220,
2415,
14032,
30953,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
41653,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMakeString(t *testing.T) {
tests := []struct{ in, out string }{
{"und", "und"},
{"und", "und-CW"},
{"nl", "nl-NL"},
{"de-1901", "nl-1901"},
{"de-1901", "de-Arab-1901"},
{"x-a-b", "de-Arab-x-a-b"},
{"x-a-b", "x-a-b"},
}
for i, tt := range tests {
id, _ := Parse(tt.in)
mod, _ := Parse(tt.out)
id.setTagsFrom(mod)
for j := 0; j < 2; j++ {
id.remakeString()
if str := id.String(); str != tt.out {
t.Errorf("%d:%d: found %s; want %s", i, j, id.String(), tt.out)
}
}
// The bytes to string conversion as used in remakeString
// occasionally measures as more than one alloc, breaking this test.
// To alleviate this we set the number of runs to more than 1.
if n := testtext.AllocsPerRun(8, id.remakeString); n > 1 {
t.Errorf("%d: # allocs got %.1f; want <= 1", i, n)
}
}
} | explode_data.jsonl/27913 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
8078,
703,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
90,
304,
11,
700,
914,
335,
515,
197,
197,
4913,
1241,
497,
330,
1241,
7115,
197,
197,
4913,
1241,
497,
330,
1241,
7658,
54,
7115,
197,
197,
4913,
15643,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTokenAuth200Status(t *testing.T) {
var (
baseTransport = &http.Transport{}
gun data.GUN = "test"
)
s := httptest.NewServer(http.HandlerFunc(NotAuthorizedTestHandler))
defer s.Close()
auth, err := tokenAuth(s.URL, baseTransport, gun, readOnly)
require.NoError(t, err)
require.NotNil(t, auth)
} | explode_data.jsonl/77487 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
3323,
5087,
17,
15,
15,
2522,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
24195,
27560,
688,
284,
609,
1254,
87669,
16094,
197,
3174,
359,
1843,
821,
1224,
1861,
284,
330,
1944,
698,
197,
340,
1903,
1669,
54320,
70334,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiRemove(t *testing.T) {
err := Mkdir(dirs, 0755)
if err != nil {
panic(err)
}
if !Exists(dirs) {
t.Error("Multi Remove test failed!")
}
err = Remove(dirs)
if err != nil {
panic(err)
}
if Exists(dirs) {
t.Error("Multi Remove test failed!")
}
} | explode_data.jsonl/34165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
20358,
13021,
1155,
353,
8840,
836,
8,
1476,
9859,
1669,
386,
12438,
14161,
82,
11,
220,
15,
22,
20,
20,
340,
743,
1848,
961,
2092,
341,
197,
30764,
3964,
340,
197,
532,
743,
753,
15575,
14161,
82,
8,
341,
197,
3244,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestServeMembersFails(t *testing.T) {
tests := []struct {
method string
wcode int
}{
{
"POST",
http.StatusMethodNotAllowed,
},
{
"DELETE",
http.StatusMethodNotAllowed,
},
{
"BAD",
http.StatusMethodNotAllowed,
},
}
for i, tt := range tests {
rw := httptest.NewRecorder()
h := &peerMembersHandler{cluster: nil}
h.ServeHTTP(rw, &http.Request{Method: tt.method})
if rw.Code != tt.wcode {
t.Errorf("#%d: code=%d, want %d", i, rw.Code, tt.wcode)
}
}
} | explode_data.jsonl/566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
60421,
24371,
37,
6209,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42257,
914,
198,
197,
6692,
1851,
220,
526,
198,
197,
59403,
197,
197,
515,
298,
197,
1,
2946,
756,
298,
28080,
10538,
3523,
97634,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMaxHeap(t *testing.T) {
for _, tt := range heapTests {
t.Run(tt.name, func(t *testing.T) {
capacity := tt.capacity
h := NewFloatHeap(true, capacity)
assert.Equal(t, capacity, h.Cap())
_, seen := h.Peek()
assert.False(t, seen)
for i, v := range tt.values {
h.Push(v, i)
if capacity < 1 {
// No max size; length should be index + 1
assert.Equal(t, i+1, h.Len(), "capacity <= 0, no max capacity")
} else {
assert.True(t, h.Len() <= capacity, "length is larger than capacity")
}
}
peek, seen := h.Peek()
assert.True(t, seen)
assert.Equal(t, peek, tt.expectedMax[0])
// Flush and sort results (Flush does not care about order)
actual := h.Flush()
sort.Sort(maxSlice(actual))
assert.Equal(t, tt.expectedMax, actual)
// Assert Flush flushes the heap
assert.Equal(t, 0, h.floatHeap.Len())
_, seen = h.Peek()
assert.False(t, seen)
})
}
} | explode_data.jsonl/68386 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
5974,
27909,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
17364,
18200,
341,
197,
3244,
16708,
47152,
2644,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
1444,
391,
4018,
1669,
17853,
59168,
198,
298,
9598,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestABCIValidatorUpdateZero(t *testing.T) {
validator := newValidator(t, valAddr1, pk1)
abciVal := validator.ABCIValidatorUpdateZero()
pk, err := validator.TmConsPublicKey()
require.NoError(t, err)
require.Equal(t, pk, abciVal.PubKey)
require.Equal(t, int64(0), abciVal.Power)
} | explode_data.jsonl/2325 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
1867,
11237,
14256,
4289,
17999,
1155,
353,
8840,
836,
8,
341,
197,
16112,
1669,
501,
14256,
1155,
11,
1044,
13986,
16,
11,
22458,
16,
340,
197,
370,
5855,
2208,
1669,
22935,
875,
4897,
40,
14256,
4289,
17999,
741,
3223,
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 TestGetTrustPinningErrors(t *testing.T) {
setUp(t)
invalidTrustPinConfig := tempDirWithConfig(t, `{
"trust_pinning": {
"certs": {
"repo3": [60, "abc", [1, 2, 3]]
}
}
}`)
defer os.RemoveAll(invalidTrustPinConfig)
tc := &tufCommander{
// returns a nil pointer
configGetter: func() (*viper.Viper, error) {
v := viper.New()
v.SetConfigFile(filepath.Join(invalidTrustPinConfig, "config.json"))
v.ReadInConfig()
return v, nil
},
}
require.Error(t, tc.tufStatus(&cobra.Command{}, []string{"gun"}))
tc.resetAll = true
require.Error(t, tc.tufReset(&cobra.Command{}, []string{"gun"}))
require.Error(t, tc.tufInit(&cobra.Command{}, []string{"gun"}))
require.Error(t, tc.tufPublish(&cobra.Command{}, []string{"gun"}))
require.Error(t, tc.tufVerify(&cobra.Command{}, []string{"gun", "target", "file"}))
require.Error(t, tc.tufLookup(&cobra.Command{}, []string{"gun", "target"}))
require.Error(t, tc.tufList(&cobra.Command{}, []string{"gun"}))
require.Error(t, tc.tufAdd(&cobra.Command{}, []string{"gun", "target", "file"}))
require.Error(t, tc.tufRemove(&cobra.Command{}, []string{"gun", "target", "file"}))
require.Error(t, tc.tufWitness(&cobra.Command{}, []string{"gun", "targets/role"}))
tc.sha256 = "88b76b34ab83a9e4d5abe3697950fb73f940aab1aa5b534f80cf9de9708942be"
require.Error(t, tc.tufAddByHash(&cobra.Command{}, []string{"gun", "test1", "100"}))
} | explode_data.jsonl/77497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 614
} | [
2830,
3393,
1949,
45548,
47,
19770,
13877,
1155,
353,
8840,
836,
8,
341,
8196,
2324,
1155,
340,
197,
11808,
45548,
19861,
2648,
1669,
2730,
6184,
2354,
2648,
1155,
11,
1565,
515,
197,
197,
1,
56655,
620,
19770,
788,
341,
6449,
330,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseCacheControl(t *testing.T) {
resetTest()
h := http.Header{}
for range parseCacheControl(h) {
t.Fatal("cacheControl should be empty")
}
h.Set("cache-control", "no-cache")
{
cc := parseCacheControl(h)
if _, ok := cc["foo"]; ok {
t.Error(`Value "foo" shouldn't exist`)
}
noCache, ok := cc["no-cache"]
if !ok {
t.Fatalf(`"no-cache" value isn't set`)
}
if noCache != "" {
t.Fatalf(`"no-cache" value isn't blank: %v`, noCache)
}
}
h.Set("cache-control", "no-cache, max-age=3600")
{
cc := parseCacheControl(h)
noCache, ok := cc["no-cache"]
if !ok {
t.Fatalf(`"no-cache" value isn't set`)
}
if noCache != "" {
t.Fatalf(`"no-cache" value isn't blank: %v`, noCache)
}
if cc["max-age"] != "3600" {
t.Fatalf(`"max-age" value isn't "3600": %v`, cc["max-age"])
}
}
} | explode_data.jsonl/77627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
14463,
8233,
3273,
1155,
353,
8840,
836,
8,
341,
70343,
2271,
741,
9598,
1669,
1758,
15753,
16094,
2023,
2088,
4715,
8233,
3273,
3203,
8,
341,
197,
3244,
26133,
445,
9360,
3273,
1265,
387,
4287,
1138,
197,
630,
9598,
4202,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParallelPropagateChannelStatuses(t *testing.T) {
tests := []struct {
name string
ichannel *duckv1alpha1.Channelable
channels []*duckv1alpha1.Channelable
want corev1.ConditionStatus
}{{
name: "ingress false, empty",
ichannel: getChannelable(false),
channels: []*duckv1alpha1.Channelable{},
want: corev1.ConditionFalse,
}, {
name: "ingress false, one channelable not ready",
ichannel: getChannelable(false),
channels: []*duckv1alpha1.Channelable{getChannelable(false)},
want: corev1.ConditionFalse,
}, {
name: "ingress true, one channelable not ready",
ichannel: getChannelable(true),
channels: []*duckv1alpha1.Channelable{getChannelable(false)},
want: corev1.ConditionFalse,
}, {
name: "ingress false, one channelable ready",
ichannel: getChannelable(false),
channels: []*duckv1alpha1.Channelable{getChannelable(true)},
want: corev1.ConditionFalse,
}, {
name: "ingress true, one channelable ready",
ichannel: getChannelable(true),
channels: []*duckv1alpha1.Channelable{getChannelable(true)},
want: corev1.ConditionTrue,
}, {
name: "ingress true, one channelable ready, one not",
ichannel: getChannelable(true),
channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(false)},
want: corev1.ConditionFalse,
}, {
name: "ingress true, two channelables ready",
ichannel: getChannelable(true),
channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)},
want: corev1.ConditionTrue,
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ps := ParallelStatus{}
ps.PropagateChannelStatuses(test.ichannel, test.channels)
got := ps.GetCondition(ParallelConditionChannelsReady).Status
want := test.want
if want != got {
t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got)
}
})
}
} | explode_data.jsonl/29238 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 763
} | [
2830,
3393,
16547,
2008,
46836,
9629,
2522,
288,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
197,
713,
2594,
353,
72970,
85,
16,
7141,
16,
38716,
480,
198,
197,
23049,
6680,
29838,
72970... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRSAPSSSaltLengthCompatibility(t *testing.T) {
// Fails token verify, if salt length is auto.
ps256SaltLengthEqualsHash := &jwt.SigningMethodRSAPSS{
SigningMethodRSA: jwt.SigningMethodPS256.SigningMethodRSA,
Options: &rsa.PSSOptions{
SaltLength: rsa.PSSSaltLengthEqualsHash,
},
}
// Behaves as before https://github.com/KinakoExE/jwt-go/issues/285 fix.
ps256SaltLengthAuto := &jwt.SigningMethodRSAPSS{
SigningMethodRSA: jwt.SigningMethodPS256.SigningMethodRSA,
Options: &rsa.PSSOptions{
SaltLength: rsa.PSSSaltLengthAuto,
},
}
if !verify(jwt.SigningMethodPS256, makeToken(ps256SaltLengthEqualsHash)) {
t.Error("SigningMethodPS256 should accept salt length that is defined in RFC")
}
if !verify(ps256SaltLengthEqualsHash, makeToken(jwt.SigningMethodPS256)) {
t.Error("Sign by SigningMethodPS256 should have salt length that is defined in RFC")
}
if !verify(jwt.SigningMethodPS256, makeToken(ps256SaltLengthAuto)) {
t.Error("SigningMethodPS256 should accept auto salt length to be compatible with previous versions")
}
if !verify(ps256SaltLengthAuto, makeToken(jwt.SigningMethodPS256)) {
t.Error("Sign by SigningMethodPS256 should be accepted by previous versions")
}
if verify(ps256SaltLengthEqualsHash, makeToken(ps256SaltLengthAuto)) {
t.Error("Auto salt length should be not accepted, when RFC salt length is required")
}
} | explode_data.jsonl/10574 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
11451,
2537,
1220,
47318,
4373,
85880,
1155,
353,
8840,
836,
8,
341,
197,
322,
434,
6209,
3950,
10146,
11,
421,
12021,
3084,
374,
3233,
624,
35009,
17,
20,
21,
47318,
4373,
4315,
6370,
1669,
609,
41592,
41152,
287,
3523,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStorageKey_Hex(t *testing.T) {
assertEncodeToHex(t, []encodeToHexAssert{
{NewStorageKey([]byte{0, 0, 0}), "0x000000"},
{NewStorageKey([]byte{171, 18, 52}), "0xab1234"},
{NewStorageKey([]byte{0, 1}), "0x0001"},
{NewStorageKey([]byte{18, 52, 86}), "0x123456"},
})
} | explode_data.jsonl/3064 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
5793,
1592,
2039,
327,
1155,
353,
8840,
836,
8,
341,
6948,
32535,
1249,
20335,
1155,
11,
3056,
6180,
1249,
20335,
8534,
515,
197,
197,
90,
3564,
5793,
1592,
10556,
3782,
90,
15,
11,
220,
15,
11,
220,
15,
38842,
330,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExpiredReset(t *testing.T) {
MockMode = true
timer := NewTimer(5 * time.Second)
done := make(chan struct{})
go func() {
<-timer.C()
done <- struct{}{}
}()
Elapse(5 * time.Second)
<-done
timer.Reset(3 * time.Second)
go func() {
<-timer.C()
done <- struct{}{}
}()
Elapse(2 * time.Second)
select {
case <-done:
t.Fatal("Timer fired at its old end time after being reset.")
case <-time.After(50 * time.Millisecond):
t.Log("Timer correctly didn't fire at its old end time after being reset.")
}
Elapse(1 * time.Second)
select {
case <-done:
t.Log("Timer correctly fired at its new end time after being reset.")
case <-time.After(50 * time.Millisecond):
t.Fatal("Timer didn't fire at its new end time after being reset.")
}
} | explode_data.jsonl/68931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 291
} | [
2830,
3393,
54349,
14828,
1155,
353,
8840,
836,
8,
341,
9209,
1176,
3636,
284,
830,
198,
51534,
1669,
1532,
10105,
7,
20,
353,
882,
32435,
340,
40495,
1669,
1281,
35190,
2036,
6257,
692,
30680,
2915,
368,
341,
197,
197,
45342,
19278,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOverrideAndroidAppDependency(t *testing.T) {
ctx, _ := testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
sdk_version: "current",
}
override_android_app {
name: "bar",
base: "foo",
package_name: "org.dandroid.bp",
}
android_test {
name: "baz",
srcs: ["b.java"],
instrumentation_for: "foo",
}
android_test {
name: "qux",
srcs: ["b.java"],
instrumentation_for: "bar",
}
`)
// Verify baz, which depends on the overridden module foo, has the correct classpath javac arg.
javac := ctx.ModuleForTests("baz", "android_common").Rule("javac")
fooTurbine := "out/soong/.intermediates/foo/android_common/turbine-combined/foo.jar"
if !strings.Contains(javac.Args["classpath"], fooTurbine) {
t.Errorf("baz classpath %v does not contain %q", javac.Args["classpath"], fooTurbine)
}
// Verify qux, which depends on the overriding module bar, has the correct classpath javac arg.
javac = ctx.ModuleForTests("qux", "android_common").Rule("javac")
barTurbine := "out/soong/.intermediates/foo/android_common_bar/turbine-combined/foo.jar"
if !strings.Contains(javac.Args["classpath"], barTurbine) {
t.Errorf("qux classpath %v does not contain %q", javac.Args["classpath"], barTurbine)
}
} | explode_data.jsonl/58498 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 518
} | [
2830,
3393,
2177,
21831,
2164,
36387,
1155,
353,
8840,
836,
8,
341,
20985,
11,
716,
1669,
1273,
15041,
1155,
11,
22074,
197,
197,
5954,
8191,
341,
298,
11609,
25,
330,
7975,
756,
298,
41144,
82,
25,
4383,
64,
10848,
8097,
298,
1903,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcile(t *testing.T) {
table := TableTest{{
Name: "bad workqueue key",
Key: "too/many/parts",
SkipNamespaceValidation: true,
}, {
Name: "key not found",
Key: "foo/not-found",
SkipNamespaceValidation: true,
}, {
Name: "skip ingress not matching class key",
SkipNamespaceValidation: true,
Objects: []runtime.Object{
addAnnotations(ingress("no-virtualservice-yet", 1234),
map[string]string{networking.IngressClassAnnotationKey: "fake-controller"}),
},
}, {
Name: "create VirtualService matching ClusterIngress",
SkipNamespaceValidation: true,
Objects: []runtime.Object{
ingress("no-virtualservice-yet", 1234),
},
WantCreates: []metav1.Object{
resources.MakeVirtualService(ingress("no-virtualservice-yet", 1234),
[]string{"knative-shared-gateway", "knative-ingress-gateway"}),
},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Object: ingressWithStatus("no-virtualservice-yet", 1234,
v1alpha1.IngressStatus{
LoadBalancer: &v1alpha1.LoadBalancerStatus{
Ingress: []v1alpha1.LoadBalancerIngressStatus{
{DomainInternal: network.GetServiceHostname("knative-ingressgateway", "istio-system")},
},
},
Status: duckv1beta1.Status{
Conditions: duckv1beta1.Conditions{{
Type: v1alpha1.ClusterIngressConditionLoadBalancerReady,
Status: corev1.ConditionTrue,
Severity: apis.ConditionSeverityError,
}, {
Type: v1alpha1.ClusterIngressConditionNetworkConfigured,
Status: corev1.ConditionTrue,
Severity: apis.ConditionSeverityError,
}, {
Type: v1alpha1.ClusterIngressConditionReady,
Status: corev1.ConditionTrue,
Severity: apis.ConditionSeverityError,
}},
},
},
),
}},
WantEvents: []string{
Eventf(corev1.EventTypeNormal, "Created", "Created VirtualService %q", "no-virtualservice-yet"),
},
Key: "no-virtualservice-yet",
}, {
Name: "reconcile VirtualService to match desired one",
SkipNamespaceValidation: true,
Objects: []runtime.Object{
ingress("reconcile-virtualservice", 1234),
&v1alpha3.VirtualService{
ObjectMeta: metav1.ObjectMeta{
Name: "reconcile-virtualservice",
Namespace: system.Namespace(),
Labels: map[string]string{
networking.IngressLabelKey: "reconcile-virtualservice",
serving.RouteLabelKey: "test-route",
serving.RouteNamespaceLabelKey: "test-ns",
},
OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(ingress("reconcile-virtualservice", 1234))},
},
Spec: v1alpha3.VirtualServiceSpec{},
},
},
WantUpdates: []clientgotesting.UpdateActionImpl{{
Object: resources.MakeVirtualService(ingress("reconcile-virtualservice", 1234),
[]string{"knative-shared-gateway", "knative-ingress-gateway"}),
}},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Object: ingressWithStatus("reconcile-virtualservice", 1234,
v1alpha1.IngressStatus{
LoadBalancer: &v1alpha1.LoadBalancerStatus{
Ingress: []v1alpha1.LoadBalancerIngressStatus{
{DomainInternal: network.GetServiceHostname("knative-ingressgateway", "istio-system")},
},
},
Status: duckv1beta1.Status{
Conditions: duckv1beta1.Conditions{{
Type: v1alpha1.ClusterIngressConditionLoadBalancerReady,
Status: corev1.ConditionTrue,
Severity: apis.ConditionSeverityError,
}, {
Type: v1alpha1.ClusterIngressConditionNetworkConfigured,
Status: corev1.ConditionTrue,
Severity: apis.ConditionSeverityError,
}, {
Type: v1alpha1.ClusterIngressConditionReady,
Status: corev1.ConditionTrue,
Severity: apis.ConditionSeverityError,
}},
},
},
),
}},
WantEvents: []string{
Eventf(corev1.EventTypeNormal, "Updated", "Updated status for VirtualService %q/%q",
system.Namespace(), "reconcile-virtualservice"),
},
Key: "reconcile-virtualservice",
}}
defer logtesting.ClearAll()
table.Test(t, MakeFactory(func(listers *Listers, opt reconciler.Options) controller.Reconciler {
return &Reconciler{
Base: reconciler.NewBase(opt, controllerAgentName),
virtualServiceLister: listers.GetVirtualServiceLister(),
clusterIngressLister: listers.GetClusterIngressLister(),
gatewayLister: listers.GetGatewayLister(),
enableReconcilingGateway: false,
configStore: &testConfigStore{
config: ReconcilerTestConfig(),
},
}
}))
} | explode_data.jsonl/53668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2042
} | [
2830,
3393,
693,
40446,
457,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
6633,
2271,
90,
515,
197,
21297,
25,
503,
330,
13855,
975,
4584,
1376,
756,
197,
55242,
25,
3824,
330,
36127,
14,
34576,
4322,
7038,
756,
197,
7568,
13389,
22699,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteOrderByClientID(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() || !canManipulateRealOrders {
t.Skip("skipping test, either api keys or canManipulateRealOrders isnt set correctly")
}
_, err := f.DeleteOrderByClientID(context.Background(), "clientID123")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15194 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
6435,
34605,
2959,
915,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
1369,
753,
4814,
92876,
6334,
12768,
24898,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
11,
2987,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAcceptAfterCloseFails(t *testing.T) {
l, err := ListenPipe(testPipeName, nil)
if err != nil {
t.Fatal(err)
}
l.Close()
_, err = l.Accept()
if err != ErrPipeListenerClosed {
t.Fatalf("expected ErrPipeListenerClosed, got %v", err)
}
} | explode_data.jsonl/11429 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
16646,
6025,
7925,
37,
6209,
1155,
353,
8840,
836,
8,
341,
8810,
11,
1848,
1669,
32149,
34077,
8623,
34077,
675,
11,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
8810,
10421,
741,
197,
6878,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnswerMatches(t *testing.T) {
prf := NewForwardProbe("example.org")
if !prf.AnswerMatches(prf.Answer()) {
t.Error("Forward Answer doesn't match self", prf.Answer())
}
prr, _ := newReverse("192.0.2.44/24")
if !prr.AnswerMatches(prr.Answer()) {
t.Error("Reverse Answer doesn't match self", prr.Answer())
}
prr, _ = newReverse("2001:db8::1/64")
if !prr.AnswerMatches(prr.Answer()) {
t.Error("Reverse Answer doesn't match self", prr.Answer())
}
ptr := prr.Answer().(*dns.PTR)
if ptr == nil {
t.Fatal("Setup error")
}
a := &dns.PTR{Ptr: ptr.Ptr}
a.Hdr.Ttl = niceShortTTL * 100
if prr.AnswerMatches(a) {
t.Error("Reverse Answer unexpectedly matches", a, prr.Answer())
}
a.Hdr.Name = ptr.Hdr.Name
if prr.AnswerMatches(a) {
t.Error("Reverse Answer unexpectedly matches", a, prr.Answer())
}
a.Hdr.Rrtype = ptr.Hdr.Rrtype
if prr.AnswerMatches(a) {
t.Error("Reverse Answer unexpectedly matches", a, prr.Answer())
}
a.Hdr.Class = ptr.Hdr.Class
if !prr.AnswerMatches(a) {
t.Error("Reverse Answer should match now", a, prr.Answer())
}
} | explode_data.jsonl/14931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 462
} | [
2830,
3393,
16141,
42470,
1155,
353,
8840,
836,
8,
341,
25653,
69,
1669,
1532,
25925,
81426,
445,
8687,
2659,
1138,
743,
753,
649,
69,
8624,
3559,
42470,
24974,
69,
8624,
3559,
2140,
341,
197,
3244,
6141,
445,
25925,
21806,
3171,
944,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestFetch(t *testing.T) {
const path = "testdata/"
type testcase struct {
source, execName string
}
for _, tc := range []testcase{
{path + "go.crc32.cpu", ""},
{path + "go.nomappings.crash", "/bin/gotest.exe"},
{"http://localhost/profile?file=cppbench.cpu", ""},
} {
p, _, _, err := grabProfile(&source{ExecName: tc.execName}, tc.source, nil, testObj{}, &proftest.TestUI{T: t}, &httpTransport{})
if err != nil {
t.Fatalf("%s: %s", tc.source, err)
}
if len(p.Sample) == 0 {
t.Errorf("%s: want non-zero samples", tc.source)
}
if e := tc.execName; e != "" {
switch {
case len(p.Mapping) == 0 || p.Mapping[0] == nil:
t.Errorf("%s: want mapping[0].execName == %s, got no mappings", tc.source, e)
case p.Mapping[0].File != e:
t.Errorf("%s: want mapping[0].execName == %s, got %s", tc.source, e, p.Mapping[0].File)
}
}
}
} | explode_data.jsonl/36297 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
20714,
1155,
353,
8840,
836,
8,
341,
4777,
1815,
284,
330,
92425,
29555,
13158,
70080,
2036,
341,
197,
47418,
11,
3883,
675,
914,
198,
197,
630,
2023,
8358,
17130,
1669,
2088,
3056,
1944,
5638,
515,
197,
197,
90,
2343,
488... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestBQSerializationStateChecks(t *testing.T) {
for _, tc := range []struct {
state aggregationState
wantErr bool
}{
{defaultState, false},
{merged, true},
{serialized, false},
{resultReturned, true},
} {
lower, upper := -5.0, 5.0
bq := getNoiselessBQ(t, lower, upper)
bq.state = tc.state
if _, err := bq.GobEncode(); (err != nil) != tc.wantErr {
t.Errorf("GobEncode: when state %v for err got %v, wantErr %t", tc.state, err, tc.wantErr)
}
}
} | explode_data.jsonl/80646 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
33,
48,
35865,
1397,
49820,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
24291,
256,
51629,
1397,
198,
197,
50780,
7747,
1807,
198,
197,
59403,
197,
197,
90,
2258,
1397,
11,
895,
1583,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlayerFlashed_FlashDuration_Over(t *testing.T) {
pl := newPlayer(128 * 3)
pl.FlashDuration = 1.9
pl.FlashTick = 128
assert.False(t, pl.IsBlinded(), "Should not be flashed")
} | explode_data.jsonl/12165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
4476,
3882,
13571,
1400,
24686,
12945,
62,
1918,
1155,
353,
8840,
836,
8,
341,
72213,
1669,
501,
4476,
7,
16,
17,
23,
353,
220,
18,
692,
72213,
991,
24686,
12945,
284,
220,
16,
13,
24,
198,
72213,
991,
24686,
22213,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEncodeAndDecode(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
t.Assert(gurl.Encode(urlStr), urlEncode)
res, err := gurl.Decode(urlEncode)
if err != nil {
t.Errorf("decode failed. %v", err)
return
}
t.Assert(res, urlStr)
})
} | explode_data.jsonl/52548 | {
"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,
32535,
3036,
32564,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
3244,
11711,
3268,
1085,
50217,
6522,
2580,
701,
2515,
32535,
692,
197,
10202,
11,
1848,
1669,
342,
108... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_SalesReports_Filter_IsValid(t *testing.T) {
filter := &SalesReportsFilter{}
date, _ := time.Parse("2006-01-02", "2020-05-05")
filter.Daily().TypeSales().SubTypeSummary().Version10().SetReportDate(date)
err := filter.IsValid()
assert.Nil(t, err)
} | explode_data.jsonl/60789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
1098,
3831,
23748,
68935,
31879,
4088,
1155,
353,
8840,
836,
8,
341,
50108,
1669,
609,
35418,
23748,
5632,
16094,
44086,
11,
716,
1669,
882,
8937,
445,
17,
15,
15,
21,
12,
15,
16,
12,
15,
17,
497,
330,
17,
15,
17,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPartialCached(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithTemplatesAdded(
"index.html", `
{{ $key1 := (dict "a" "av" ) }}
{{ $key2 := (dict "a" "av2" ) }}
Partial cached1: {{ partialCached "p1" "input1" $key1 }}
Partial cached2: {{ partialCached "p1" "input2" $key1 }}
Partial cached3: {{ partialCached "p1" "input3" $key2 }}
`,
"partials/p1.html", `partial: {{ . }}`,
)
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", `
Partial cached1: partial: input1
Partial cached2: partial: input1
Partial cached3: partial: input3
`)
} | explode_data.jsonl/60658 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
37314,
70293,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
501,
2271,
93690,
3297,
1155,
692,
2233,
26124,
51195,
19337,
1006,
197,
197,
1,
1252,
2564,
497,
22074,
2979,
400,
792,
16,
1669,
320,
8477,
330,
64,
1,
330,
402,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTimestampToTime(t *testing.T) {
time, err := TimestampStrToTime("522675441.31045401")
wantErr := false
if (err != nil) != wantErr {
t.Errorf("TimestampStrToTime() wantErr: %v, got: %v", wantErr, err)
}
want := []int{
2017,
7,
25,
11,
37,
21,
}
got := []int{
time.Year(),
int(time.Month()),
time.Day(),
time.Hour(),
time.Minute(),
time.Second(),
}
if !reflect.DeepEqual(want, got) {
t.Errorf("TimestampStrToTime() want: %v, got: %v", want, got)
}
} | explode_data.jsonl/12516 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
20812,
1249,
1462,
1155,
353,
8840,
836,
8,
341,
21957,
11,
1848,
1669,
32758,
2580,
1249,
1462,
445,
20,
17,
17,
21,
22,
20,
19,
19,
16,
13,
18,
16,
15,
19,
20,
19,
15,
16,
1138,
50780,
7747,
1669,
895,
198,
743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCurveImpl(t *testing.T) {
pool := new(bnPool)
g := &curvePoint{
pool.Get().SetInt64(1),
pool.Get().SetInt64(-2),
pool.Get().SetInt64(1),
pool.Get().SetInt64(0),
}
x := pool.Get().SetInt64(32498273234)
X := newCurvePoint(pool).Mul(g, x, pool)
y := pool.Get().SetInt64(98732423523)
Y := newCurvePoint(pool).Mul(g, y, pool)
s1 := newCurvePoint(pool).Mul(X, y, pool).MakeAffine(pool)
s2 := newCurvePoint(pool).Mul(Y, x, pool).MakeAffine(pool)
if s1.x.Cmp(s2.x) != 0 ||
s2.x.Cmp(s1.x) != 0 {
t.Errorf("DH points don't match: (%s, %s) (%s, %s)", s1.x, s1.y, s2.x, s2.y)
}
pool.Put(x)
X.Put(pool)
pool.Put(y)
Y.Put(pool)
s1.Put(pool)
s2.Put(pool)
g.Put(pool)
if c := pool.Count(); c > 0 {
t.Errorf("Pool count non-zero: %d\n", c)
}
} | explode_data.jsonl/52896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
31325,
9673,
1155,
353,
8840,
836,
8,
341,
85273,
1669,
501,
1883,
77,
10551,
692,
3174,
1669,
609,
50051,
2609,
515,
197,
85273,
2234,
1005,
1649,
1072,
21,
19,
7,
16,
1326,
197,
85273,
2234,
1005,
1649,
1072,
21,
19,
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 TestInputService16ProtocolTestStructurePayloadCase1(t *testing.T) {
sess := session.New()
svc := NewInputService16ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService16TestShapeInputShape{
Foo: &InputService16TestShapeFooShape{
Baz: aws.String("bar"),
},
}
req, _ := svc.InputService16TestCaseOperation1Request(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, `<foo><baz>bar</baz></foo>`, util.Trim(string(body)), InputService16TestShapeInputShape{})
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
} | explode_data.jsonl/46487 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
2505,
1860,
16,
21,
20689,
2271,
22952,
29683,
4207,
16,
1155,
353,
8840,
836,
8,
341,
1903,
433,
1669,
3797,
7121,
741,
1903,
7362,
1669,
1532,
2505,
1860,
16,
21,
20689,
2271,
57223,
11,
609,
8635,
10753,
90,
27380,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInvalidCommitSigError(t *testing.T) {
t.Parallel()
// First, we'll make a channel between Alice and Bob.
aliceChannel, bobChannel, cleanUp, err := CreateTestChannels()
if err != nil {
t.Fatalf("unable to create test channels: %v", err)
}
defer cleanUp()
// With the channel established, we'll now send a single HTLC from
// Alice to Bob.
var htlcAmt lnwire.MilliSatoshi = 100000
htlc, _ := createHTLC(0, htlcAmt)
if _, err := aliceChannel.AddHTLC(htlc, nil); err != nil {
t.Fatalf("unable to add htlc: %v", err)
}
if _, err := bobChannel.ReceiveHTLC(htlc); err != nil {
t.Fatalf("unable to recv htlc: %v", err)
}
// Alice will now attempt to initiate a state transition.
aliceSig, aliceHtlcSigs, err := aliceChannel.SignNextCommitment()
if err != nil {
t.Fatalf("unable to sign new commit: %v", err)
}
// Before the signature gets to Bob, we'll mutate it, such that the
// signature is now actually invalid.
aliceSig[0] ^= 88
// Bob should reject this new state, and return the proper error.
err = bobChannel.ReceiveNewCommitment(aliceSig, aliceHtlcSigs)
if err == nil {
t.Fatalf("bob accepted invalid state but shouldn't have")
}
if _, ok := err.(*InvalidCommitSigError); !ok {
t.Fatalf("bob sent incorrect error, expected %T, got %T",
&InvalidCommitSigError{}, err)
}
} | explode_data.jsonl/46445 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 494
} | [
2830,
3393,
7928,
33441,
47246,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
5512,
11,
582,
3278,
1281,
264,
5496,
1948,
29405,
323,
14261,
624,
197,
63195,
9629,
11,
35192,
9629,
11,
4240,
2324,
11,
1848,
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... | 7 |
func TestSelectStatement_RewriteRegexConditions(t *testing.T) {
var tests = []struct {
in string
out string
}{
{in: `SELECT value FROM cpu`, out: `SELECT value FROM cpu`},
{in: `SELECT value FROM cpu WHERE host='server-1'`, out: `SELECT value FROM cpu WHERE host='server-1'`},
{in: `SELECT value FROM cpu WHERE host = 'server-1'`, out: `SELECT value FROM cpu WHERE host = 'server-1'`},
{in: `SELECT value FROM cpu WHERE host != 'server-1'`, out: `SELECT value FROM cpu WHERE host != 'server-1'`},
// Non matching regex
{in: `SELECT value FROM cpu WHERE host =~ /server-1|server-2|server-3/`, out: `SELECT value FROM cpu WHERE host =~ /server-1|server-2|server-3/`},
{in: `SELECT value FROM cpu WHERE host =~ /server-1/`, out: `SELECT value FROM cpu WHERE host =~ /server-1/`},
{in: `SELECT value FROM cpu WHERE host !~ /server-1/`, out: `SELECT value FROM cpu WHERE host !~ /server-1/`},
{in: `SELECT value FROM cpu WHERE host =~ /^server-1/`, out: `SELECT value FROM cpu WHERE host =~ /^server-1/`},
{in: `SELECT value FROM cpu WHERE host =~ /server-1$/`, out: `SELECT value FROM cpu WHERE host =~ /server-1$/`},
{in: `SELECT value FROM cpu WHERE host !~ /\^server-1$/`, out: `SELECT value FROM cpu WHERE host !~ /\^server-1$/`},
{in: `SELECT value FROM cpu WHERE host !~ /\^$/`, out: `SELECT value FROM cpu WHERE host !~ /\^$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^server-1\$/`, out: `SELECT value FROM cpu WHERE host !~ /^server-1\$/`},
{in: `SELECT value FROM cpu WHERE host =~ /^\$/`, out: `SELECT value FROM cpu WHERE host =~ /^\$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^a/`, out: `SELECT value FROM cpu WHERE host !~ /^a/`},
// These regexes are not supported due to the presence of escaped or meta characters.
{in: `SELECT value FROM cpu WHERE host !~ /^(foo|bar)$/`, out: `SELECT value FROM cpu WHERE host !~ /^(foo|bar)$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^?a$/`, out: `SELECT value FROM cpu WHERE host !~ /^?a$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^[a-z]$/`, out: `SELECT value FROM cpu WHERE host !~ /^[a-z]$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^\d$/`, out: `SELECT value FROM cpu WHERE host !~ /^\d$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^a*$/`, out: `SELECT value FROM cpu WHERE host !~ /^a*$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^a.b$/`, out: `SELECT value FROM cpu WHERE host !~ /^a.b$/`},
{in: `SELECT value FROM cpu WHERE host !~ /^ab+$/`, out: `SELECT value FROM cpu WHERE host !~ /^ab+$/`},
{in: `SELECT value FROM cpu WHERE host =~ /^hello\world$/`, out: `SELECT value FROM cpu WHERE host =~ /^hello\world$/`},
// These regexes all match and will be rewritten.
{in: `SELECT value FROM cpu WHERE host !~ /^a[2]$/`, out: `SELECT value FROM cpu WHERE host != 'a2'`},
{in: `SELECT value FROM cpu WHERE host =~ /^server-1$/`, out: `SELECT value FROM cpu WHERE host = 'server-1'`},
{in: `SELECT value FROM cpu WHERE host !~ /^server-1$/`, out: `SELECT value FROM cpu WHERE host != 'server-1'`},
{in: `SELECT value FROM cpu WHERE host =~ /^server 1$/`, out: `SELECT value FROM cpu WHERE host = 'server 1'`},
{in: `SELECT value FROM cpu WHERE host =~ /^$/`, out: `SELECT value FROM cpu WHERE host = ''`},
{in: `SELECT value FROM cpu WHERE host !~ /^$/`, out: `SELECT value FROM cpu WHERE host != ''`},
{in: `SELECT value FROM cpu WHERE host =~ /^server-1$/ OR host =~ /^server-2$/`, out: `SELECT value FROM cpu WHERE host = 'server-1' OR host = 'server-2'`},
{in: `SELECT value FROM cpu WHERE host =~ /^server-1$/ OR host =~ /^server]a$/`, out: `SELECT value FROM cpu WHERE host = 'server-1' OR host = 'server]a'`},
{in: `SELECT value FROM cpu WHERE host =~ /^hello\?$/`, out: `SELECT value FROM cpu WHERE host = 'hello?'`},
{in: `SELECT value FROM cpu WHERE host !~ /^\\$/`, out: `SELECT value FROM cpu WHERE host != '\\'`},
{in: `SELECT value FROM cpu WHERE host !~ /^\\\$$/`, out: `SELECT value FROM cpu WHERE host != '\\$'`},
}
for i, test := range tests {
stmt, err := influxql.NewParser(strings.NewReader(test.in)).ParseStatement()
if err != nil {
t.Fatalf("[Example %d], %v", i, err)
}
// Rewrite any supported regex conditions.
stmt.(*influxql.SelectStatement).RewriteRegexConditions()
// Get the expected rewritten statement.
expStmt, err := influxql.NewParser(strings.NewReader(test.out)).ParseStatement()
if err != nil {
t.Fatalf("[Example %d], %v", i, err)
}
// Compare the (potentially) rewritten AST to the expected AST.
if got, exp := stmt, expStmt; !reflect.DeepEqual(got, exp) {
t.Errorf("[Example %d]\nattempting %v\ngot %v\n%s\n\nexpected %v\n%s\n", i+1, test.in, got, mustMarshalJSON(got), exp, mustMarshalJSON(exp))
}
}
} | explode_data.jsonl/28567 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1728
} | [
2830,
3393,
3379,
8636,
2568,
365,
1247,
32464,
35435,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
17430,
220,
914,
198,
197,
13967,
914,
198,
197,
59403,
197,
197,
90,
258,
25,
1565,
4858,
897,
4295,
17319,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDatetimerfc1123Wrapper(t *testing.T) {
now := time.Now()
dtw := Datetimerfc1123Wrapper{
Field: azcore.NullValue(&time.Time{}).(*time.Time),
Now: &now,
}
b, err := json.Marshal(dtw)
if err != nil {
t.Fatal(err)
}
var dtw2 Datetimerfc1123Wrapper
if err = json.Unmarshal(b, &dtw2); err != nil {
t.Fatal(err)
}
if dtw2.Field != nil {
t.Fatal("expected nil Field")
}
if r := cmp.Diff(dtw2.Now.Format(time.RFC1123), dtw.Now.Format(time.RFC1123)); r != "" {
t.Fatal(r)
}
} | explode_data.jsonl/61691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
45696,
295,
3134,
8316,
16,
16,
17,
18,
11542,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
882,
13244,
741,
2698,
15560,
1669,
21631,
295,
3134,
8316,
16,
16,
17,
18,
11542,
515,
197,
94478,
25,
12376,
2153,
23979,
1130,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubjectInformational(t *testing.T) {
testCases := []struct {
name string
inputPath string
result lint.LintStatus
}{
{
name: "simple all legal",
inputPath: "legalChar.pem",
result: lint.Pass,
},
{
name: "subject with metadata only",
inputPath: "illegalChar.pem",
result: lint.Error,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
out := test.TestLint("e_subject_contains_noninformational_value", tc.inputPath)
if out.Status != tc.result {
t.Errorf("%s: expected %s, got %s", tc.inputPath, tc.result, out.Status)
}
})
}
} | explode_data.jsonl/34621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
13019,
14873,
278,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
22427,
1820,
914,
198,
197,
9559,
262,
57920,
1214,
396,
2522,
198,
197,
59403,
197,
197,
515,
298,
1160... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestForEachMethodsMap(t *testing.T) {
for k, v := range MethodsMap {
t.Log(k.String())
for k1, v1 := range v {
t.Log("\r", k1.String(), v1)
}
}
} | explode_data.jsonl/4104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
91392,
17856,
2227,
1155,
353,
8840,
836,
8,
341,
2023,
595,
11,
348,
1669,
2088,
18801,
2227,
341,
197,
3244,
5247,
5969,
6431,
2398,
197,
2023,
595,
16,
11,
348,
16,
1669,
2088,
348,
341,
298,
3244,
5247,
4921,
81,
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
] | 3 |
func TestLoadJSONUnpacked(t *testing.T) {
repo, cleanup := repository.TestRepository(t)
defer cleanup()
if rtest.BenchArchiveDirectory == "" {
t.Skip("benchdir not set, skipping")
}
// archive a snapshot
sn := restic.Snapshot{}
sn.Hostname = "foobar"
sn.Username = "test!"
id, err := repo.SaveJSONUnpacked(context.TODO(), restic.SnapshotFile, &sn)
rtest.OK(t, err)
var sn2 restic.Snapshot
// restore
err = repo.LoadJSONUnpacked(context.TODO(), restic.SnapshotFile, id, &sn2)
rtest.OK(t, err)
rtest.Equals(t, sn.Hostname, sn2.Hostname)
rtest.Equals(t, sn.Username, sn2.Username)
} | explode_data.jsonl/71940 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
5879,
5370,
1806,
50321,
1155,
353,
8840,
836,
8,
341,
17200,
5368,
11,
21290,
1669,
12542,
8787,
4624,
1155,
340,
16867,
21290,
2822,
743,
435,
1944,
1785,
19762,
42502,
9310,
621,
1591,
341,
197,
3244,
57776,
445,
27024,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetImageStreams(t *testing.T) {
type args struct {
name string
namespace string
}
tests := []struct {
name string
args args
want []imagev1.ImageStream
wantErr bool
}{
{
name: "case 1: testing a valid imagestream",
args: args{
name: "ruby",
namespace: "testing",
},
want: []imagev1.ImageStream{
{
ObjectMeta: metav1.ObjectMeta{
Name: "ruby",
Namespace: "testing",
},
Status: imagev1.ImageStreamStatus{
Tags: []imagev1.NamedTagEventList{
{
Tag: "latest",
Items: []imagev1.TagEvent{
{
DockerImageReference: "example/ruby:latest",
Generation: 1,
Image: "sha256:9579a93ee",
},
},
},
},
},
},
},
wantErr: false,
},
// TODO: Currently fails. Enable once fixed
// {
// name: "case 2: empty namespace",
// args: args{
// name: "ruby",
// namespace: "",
// },
// wantErr: true,
// },
// {
// name: "case 3: empty name",
// args: args{
// name: "",
// namespace: "testing",
// },
// wantErr: true,
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client, fkclientset := FakeNew()
fkclientset.ImageClientset.PrependReactor("list", "imagestreams", func(action ktesting.Action) (bool, runtime.Object, error) {
return true, fakeImageStreams(tt.args.name, tt.args.namespace), nil
})
got, err := client.GetImageStreams(tt.args.namespace)
if (err != nil) != tt.wantErr {
t.Errorf("GetImageStreams() error = %#v, wantErr %#v", err, tt.wantErr)
return
}
if len(fkclientset.ImageClientset.Actions()) != 1 {
t.Errorf("expected 1 action in GetImageStreams got: %v", fkclientset.ImageClientset.Actions())
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetImageStreams() = %#v, want %#v", got, tt.want)
}
})
}
} | explode_data.jsonl/65160 | {
"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,
1949,
1906,
73576,
1155,
353,
8840,
836,
8,
1476,
13158,
2827,
2036,
341,
197,
11609,
414,
914,
198,
197,
56623,
914,
198,
197,
630,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
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... | 1 |
func TestNewPgpSigner(t *testing.T) {
tcs := []struct {
name string
privateKey []byte
expectedErr bool
}{
{
name: "valid private key",
privateKey: []byte(gpgPrivateKey),
expectedErr: false,
},
{
name: "invalid private key",
privateKey: []byte("invalid-private-key"),
expectedErr: true,
},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
_, err := NewPgpSigner(tc.privateKey)
if tc.expectedErr {
if err == nil {
t.Fatalf("Expected error but returned none")
}
} else {
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
}
})
}
} | explode_data.jsonl/48094 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
3564,
47,
21888,
7264,
261,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
2455,
1592,
220,
3056,
3782,
198,
197,
42400,
7747,
1807,
198,
197,
59403,
197,
197,
515,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestBasicLookupd(t *testing.T) {
opts := NewOptions()
opts.Logger = newTestLogger(t)
tcpAddr, httpAddr, nsqlookupd := mustStartLookupd(opts)
defer nsqlookupd.Exit()
topics := nsqlookupd.DB.FindRegistrations("topic", "*", "*")
equal(t, len(topics), 0)
topicName := "connectmsg"
conn := mustConnectLookupd(t, tcpAddr)
tcpPort := 5000
httpPort := 5555
identify(t, conn, "ip.address", tcpPort, httpPort, "fake-version")
nsq.Register(topicName, "channel1").WriteTo(conn)
v, err := nsq.ReadResponse(conn)
equal(t, err, nil)
equal(t, v, []byte("OK"))
endpoint := fmt.Sprintf("http://%s/nodes", httpAddr)
data, err := http_api.NegotiateV1("GET", endpoint, nil)
t.Logf("got %v", data)
returnedProducers, err := data.Get("producers").Array()
equal(t, err, nil)
equal(t, len(returnedProducers), 1)
topics = nsqlookupd.DB.FindRegistrations("topic", topicName, "")
equal(t, len(topics), 1)
producers := nsqlookupd.DB.FindProducers("topic", topicName, "")
equal(t, len(producers), 1)
producer := producers[0]
equal(t, producer.peerInfo.BroadcastAddress, "ip.address")
equal(t, producer.peerInfo.Hostname, "ip.address")
equal(t, producer.peerInfo.TCPPort, tcpPort)
equal(t, producer.peerInfo.HTTPPort, httpPort)
endpoint = fmt.Sprintf("http://%s/topics", httpAddr)
data, err = http_api.NegotiateV1("GET", endpoint, nil)
equal(t, err, nil)
returnedTopics, err := data.Get("topics").Array()
t.Logf("got returnedTopics %v", returnedTopics)
equal(t, err, nil)
equal(t, len(returnedTopics), 1)
endpoint = fmt.Sprintf("http://%s/lookup?topic=%s", httpAddr, topicName)
data, err = http_api.NegotiateV1("GET", endpoint, nil)
equal(t, err, nil)
returnedChannels, err := data.Get("channels").Array()
equal(t, err, nil)
equal(t, len(returnedChannels), 1)
returnedProducers, err = data.Get("producers").Array()
t.Logf("got returnedProducers %v", returnedProducers)
equal(t, err, nil)
equal(t, len(returnedProducers), 1)
for i := range returnedProducers {
producer := data.Get("producers").GetIndex(i)
t.Logf("producer %v", producer)
port, err := producer.Get("tcp_port").Int()
equal(t, err, nil)
equal(t, port, tcpPort)
port, err = producer.Get("http_port").Int()
equal(t, err, nil)
equal(t, port, httpPort)
broadcastaddress, err := producer.Get("broadcast_address").String()
equal(t, err, nil)
equal(t, broadcastaddress, "ip.address")
ver, err := producer.Get("version").String()
equal(t, err, nil)
equal(t, ver, "fake-version")
}
conn.Close()
time.Sleep(10 * time.Millisecond)
// now there should be no producers, but still topic/channel entries
data, err = http_api.NegotiateV1("GET", endpoint, nil)
equal(t, err, nil)
returnedChannels, err = data.Get("channels").Array()
equal(t, err, nil)
equal(t, len(returnedChannels), 1)
returnedProducers, err = data.Get("producers").Array()
equal(t, err, nil)
equal(t, len(returnedProducers), 0)
} | explode_data.jsonl/12598 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1138
} | [
2830,
3393,
15944,
34247,
67,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
1532,
3798,
741,
64734,
12750,
284,
501,
2271,
7395,
1155,
340,
3244,
4672,
13986,
11,
1758,
13986,
11,
12268,
80,
21020,
67,
1669,
1969,
3479,
34247,
67,
30885,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCanGetBoxFileLocationForCurrent(t *testing.T) {
assert := assert.New(t)
bh := BoxHandler{}
boxes := []SimpleBox{SimpleBox{Boxname: "dev", Username: "benphegan", Provider: "virtualbox", Version: "2.0", Location: "/tmp/benphegan-VAGRANTSLASH-dev__2.0__virtualbox.box"},
SimpleBox{Boxname: "dev", Username: "benphegan", Provider: "virtualbox", Version: "1.0", Location: "/tmp/benphegan-VAGRANTSLASH-dev__1.0__virtualbox.box"},
SimpleBox{Boxname: "dev", Username: "benphegan", Provider: "virtualbox", Version: "4.1", Location: "/tmp/benphegan-VAGRANTSLASH-dev__4.1__virtualbox.box"}}
host := "localhost"
bh.createBoxes(boxes, 80, &host)
assert.Equal("/tmp/benphegan-VAGRANTSLASH-dev__4.1__virtualbox.box", bh.GetBoxFileLocation("benphegan", "dev", "virtualbox", "4.1"))
} | explode_data.jsonl/51589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
6713,
1949,
1611,
1703,
4707,
2461,
5405,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
2233,
71,
1669,
8261,
3050,
16094,
197,
22204,
1669,
3056,
16374,
1611,
90,
16374,
1611,
90,
1611,
606,
25,
330,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewHealthChecker(t *testing.T) {
c := &Cluster{spec: cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{}}}
time10s, _ := time.ParseDuration("10s")
c10s := &Cluster{spec: cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Monitor: cephv1.HealthCheckSpec{Interval: "10s"}}}}}
type args struct {
monCluster *Cluster
}
tests := []struct {
name string
args args
want *HealthChecker
}{
{"default-interval", args{c}, &HealthChecker{c, HealthCheckInterval}},
{"10s-interval", args{c10s}, &HealthChecker{c10s, time10s}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewHealthChecker(tt.args.monCluster); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewHealthChecker() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/36577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
3564,
14542,
35188,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
28678,
90,
9535,
25,
272,
23544,
85,
16,
72883,
8327,
90,
14542,
3973,
25,
272,
23544,
85,
16,
727,
23544,
28678,
14542,
3973,
8327,
90,
3417,
532,
21957,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRatSign(t *testing.T) {
zero := NewRat(0, 1)
for _, a := range setStringTests {
x, ok := new(Rat).SetString(a.in)
if !ok {
continue
}
s := x.Sign()
e := x.Cmp(zero)
if s != e {
t.Errorf("got %d; want %d for z = %v", s, e, &x)
}
}
} | explode_data.jsonl/35069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
49,
266,
7264,
1155,
353,
8840,
836,
8,
341,
197,
14154,
1669,
1532,
49,
266,
7,
15,
11,
220,
16,
340,
2023,
8358,
264,
1669,
2088,
738,
703,
18200,
341,
197,
10225,
11,
5394,
1669,
501,
2785,
266,
568,
1649,
703,
2877... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigPath(t *testing.T) {
os.Unsetenv(xdg.ConfigHomeEnvVar)
expected := filepath.Join(homedir.HomeDir(), "Library", "Preferences", appName, testFile)
if lazy.configPath(testFile) != expected {
t.Errorf("expected '%s', got '%s'", expected, lazy.configPath(testFile))
}
os.Setenv(xdg.ConfigHomeEnvVar, "/tmp")
expected = filepath.Join("/tmp", appName, testFile)
if lazy.configPath(testFile) != expected {
t.Errorf("expected '%s', got '%s'", expected, lazy.configPath(testFile))
}
} | explode_data.jsonl/26076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
2648,
1820,
1155,
353,
8840,
836,
8,
341,
25078,
10616,
746,
3160,
2075,
35138,
10753,
7623,
14359,
3962,
692,
42400,
1669,
26054,
22363,
3203,
24139,
404,
59965,
6184,
1507,
330,
16915,
497,
330,
14306,
497,
67819,
11,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExpand(t *testing.T) {
var expressions = []struct {
params map[string]string
input string
output string
}{
// text-only
{
params: map[string]string{},
input: "abcdEFGH28ij",
output: "abcdEFGH28ij",
},
// length
{
params: map[string]string{"var01": "abcdEFGH28ij"},
input: "${#var01}",
output: "12",
},
// uppercase first
{
params: map[string]string{"var01": "abcdEFGH28ij"},
input: "${var01^}",
output: "AbcdEFGH28ij",
},
// uppercase
{
params: map[string]string{"var01": "abcdEFGH28ij"},
input: "${var01^^}",
output: "ABCDEFGH28IJ",
},
// lowercase first
{
params: map[string]string{"var01": "ABCDEFGH28IJ"},
input: "${var01,}",
output: "aBCDEFGH28IJ",
},
// lowercase
{
params: map[string]string{"var01": "ABCDEFGH28IJ"},
input: "${var01,,}",
output: "abcdefgh28ij",
},
// substring with position
{
params: map[string]string{"path_name": "/home/bozo/ideas/thoughts.for.today"},
input: "${path_name:11}",
output: "ideas/thoughts.for.today",
},
// substring with position and length
{
params: map[string]string{"path_name": "/home/bozo/ideas/thoughts.for.today"},
input: "${path_name:11:5}",
output: "ideas",
},
// default not used
{
params: map[string]string{"var": "abc"},
input: "${var=xyz}",
output: "abc",
},
// default used
{
params: map[string]string{},
input: "${var=xyz}",
output: "xyz",
},
{
params: map[string]string{"default_var": "foo"},
input: "something ${var=${default_var}}",
output: "something foo",
},
{
params: map[string]string{"default_var": "foo1"},
input: `foo: ${var=${default_var}-suffix}`,
output: "foo: foo1-suffix",
},
{
params: map[string]string{"default_var": "foo1"},
input: `foo: ${var=prefix${default_var}-suffix}`,
output: "foo: prefixfoo1-suffix",
},
{
params: map[string]string{},
input: "${var:=xyz}",
output: "xyz",
},
// replace suffix
{
params: map[string]string{"stringZ": "abcABC123ABCabc"},
input: "${stringZ/%abc/XYZ}",
output: "abcABC123ABCXYZ",
},
// replace prefix
{
params: map[string]string{"stringZ": "abcABC123ABCabc"},
input: "${stringZ/#abc/XYZ}",
output: "XYZABC123ABCabc",
},
// replace all
{
params: map[string]string{"stringZ": "abcABC123ABCabc"},
input: "${stringZ//abc/xyz}",
output: "xyzABC123ABCxyz",
},
// replace first
{
params: map[string]string{"stringZ": "abcABC123ABCabc"},
input: "${stringZ/abc/xyz}",
output: "xyzABC123ABCabc",
},
// delete shortest match prefix
{
params: map[string]string{"filename": "bash.string.txt"},
input: "${filename#*.}",
output: "string.txt",
},
{
params: map[string]string{"filename": "path/to/file"},
input: "${filename#*/}",
output: "to/file",
},
{
params: map[string]string{"filename": "/path/to/file"},
input: "${filename#*/}",
output: "path/to/file",
},
// delete longest match prefix
{
params: map[string]string{"filename": "bash.string.txt"},
input: "${filename##*.}",
output: "txt",
},
{
params: map[string]string{"filename": "path/to/file"},
input: "${filename##*/}",
output: "file",
},
{
params: map[string]string{"filename": "/path/to/file"},
input: "${filename##*/}",
output: "file",
},
// delete shortest match suffix
{
params: map[string]string{"filename": "bash.string.txt"},
input: "${filename%.*}",
output: "bash.string",
},
// delete longest match suffix
{
params: map[string]string{"filename": "bash.string.txt"},
input: "${filename%%.*}",
output: "bash",
},
// nested parameters
{
params: map[string]string{"var01": "abcdEFGH28ij"},
input: "${var=${var01^^}}",
output: "ABCDEFGH28IJ",
},
// escaped
{
params: map[string]string{"var01": "abcdEFGH28ij"},
input: "$${var01}",
output: "${var01}",
},
{
params: map[string]string{"var01": "abcdEFGH28ij"},
input: "some text ${var01}$${var$${var01}$var01${var01}",
output: "some text abcdEFGH28ij${var${var01}$var01abcdEFGH28ij",
},
{
params: map[string]string{"default_var": "foo"},
input: "something $${var=${default_var}}",
output: "something ${var=foo}",
},
// some common escaping use cases
{
params: map[string]string{"stringZ": "foo/bar"},
input: `${stringZ/\//-}`,
output: "foo-bar",
},
{
params: map[string]string{"stringZ": "foo/bar/baz"},
input: `${stringZ//\//-}`,
output: "foo-bar-baz",
},
// escape outside of expansion shouldn't be processed
{
params: map[string]string{"default_var": "foo"},
input: "\\\\something ${var=${default_var}}",
output: "\\\\something foo",
},
// substitute with a blank string
{
params: map[string]string{"stringZ": "foo.bar"},
input: `${stringZ/./}`,
output: "foobar",
},
}
for _, expr := range expressions {
t.Run(expr.input, func(t *testing.T) {
t.Logf(expr.input)
output, err := Eval(expr.input, func(s string) string {
return expr.params[s]
})
if err != nil {
t.Errorf("Want %q expanded but got error %q", expr.input, err)
}
if output != expr.output {
t.Errorf("Want %q expanded to %q, got %q",
expr.input,
expr.output,
output)
}
})
}
} | explode_data.jsonl/18983 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2393
} | [
2830,
3393,
38946,
1155,
353,
8840,
836,
8,
341,
2405,
23393,
284,
3056,
1235,
341,
197,
25856,
2415,
14032,
30953,
198,
197,
22427,
220,
914,
198,
197,
21170,
914,
198,
197,
59403,
197,
197,
322,
1467,
15382,
198,
197,
197,
515,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBQNoInput(t *testing.T) {
lower, upper := -5.0, 5.0
bq := getNoiselessBQ(t, lower, upper)
got, err := bq.Result(0.5)
if err != nil {
t.Fatalf("Couldn't compute dp result for rank=0.5: %v", err)
}
want := 0.0 // When there are no inputs, we linearly interpolate.
if !ApproxEqual(got, want) {
t.Errorf("Result: when there is no input data got=%f, want=%f", got, want)
}
} | explode_data.jsonl/80633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 167
} | [
2830,
3393,
33,
48,
2753,
2505,
1155,
353,
8840,
836,
8,
341,
8810,
1202,
11,
8416,
1669,
481,
20,
13,
15,
11,
220,
20,
13,
15,
198,
2233,
80,
1669,
633,
61819,
1717,
33,
48,
1155,
11,
4722,
11,
8416,
340,
3174,
354,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSketchSeriesListMarshal(t *testing.T) {
sl := make(SketchSeriesList, 2)
for i := range sl {
sl[i] = Makeseries(i)
}
b, err := sl.Marshal()
if err != nil {
t.Fatal(err)
}
pl := new(gogen.SketchPayload)
if err := pl.Unmarshal(b); err != nil {
t.Fatal(err)
}
require.Len(t, pl.Sketches, len(sl))
for i, pb := range pl.Sketches {
in := sl[i]
require.Equal(t, Makeseries(i), in, "make sure we don't modify input")
assert.Equal(t, in.Host, pb.Host)
assert.Equal(t, in.Name, pb.Metric)
assert.Equal(t, in.Tags, pb.Tags)
assert.Len(t, pb.Distributions, 0)
require.Len(t, pb.Dogsketches, len(in.Points))
for j, pointPb := range pb.Dogsketches {
check(t, in.Points[j], pointPb)
// require.Equal(t, pointIn.Ts, pointPb.Ts)
// require.Equal(t, pointIn.Ts, pointPb.Ts)
// fmt.Printf("%#v %#v\n", pin, s)
}
}
} | explode_data.jsonl/34959 | {
"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,
75288,
25544,
852,
55438,
1155,
353,
8840,
836,
8,
341,
78626,
1669,
1281,
3759,
74,
2995,
25544,
852,
11,
220,
17,
692,
2023,
600,
1669,
2088,
1739,
341,
197,
78626,
989,
60,
284,
36870,
4699,
1956,
340,
197,
630,
2233,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSummary(t *testing.T) {
v115 := semver.MustParse("1.15.0")
var tests = []struct {
desc string
SummaryOpts
registryVersion *semver.Version
expectedMetricCount int
expectedHelp string
}{
{
desc: "Test non deprecated",
SummaryOpts: SummaryOpts{
Namespace: "namespace",
Name: "metric_test_name",
Subsystem: "subsystem",
Help: "summary help message",
StabilityLevel: ALPHA,
},
registryVersion: &v115,
expectedMetricCount: 1,
expectedHelp: "[ALPHA] summary help message",
},
{
desc: "Test deprecated",
SummaryOpts: SummaryOpts{
Namespace: "namespace",
Name: "metric_test_name",
Subsystem: "subsystem",
Help: "summary help message",
DeprecatedVersion: "1.15.0",
StabilityLevel: ALPHA,
},
registryVersion: &v115,
expectedMetricCount: 1,
expectedHelp: "[ALPHA] (Deprecated since 1.15.0) summary help message",
},
{
desc: "Test hidden",
SummaryOpts: SummaryOpts{
Namespace: "namespace",
Name: "metric_test_name",
Subsystem: "subsystem",
Help: "summary help message",
DeprecatedVersion: "1.14.0",
},
registryVersion: &v115,
expectedMetricCount: 0,
expectedHelp: "summary help message",
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
registry := NewKubeRegistry(apimachineryversion.Info{
Major: "1",
Minor: "15",
GitVersion: "v1.15.0-alpha-1.12345",
})
c := NewSummary(&test.SummaryOpts)
registry.MustRegister(c)
ms, err := registry.Gather()
if len(ms) != test.expectedMetricCount {
t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount)
}
if err != nil {
t.Fatalf("Gather failed %v", err)
}
for _, metric := range ms {
if metric.GetHelp() != test.expectedHelp {
t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp)
}
}
// let's increment the counter and verify that the metric still works
c.Observe(1)
c.Observe(2)
c.Observe(3)
c.Observe(1.5)
expected := 4
ms, err = registry.Gather()
if err != nil {
t.Fatalf("Gather failed %v", err)
}
for _, mf := range ms {
for _, m := range mf.GetMetric() {
if int(m.GetSummary().GetSampleCount()) != expected {
t.Errorf("Got %v, want %v as the sample count", m.GetHistogram().GetSampleCount(), expected)
}
}
}
})
}
} | explode_data.jsonl/34969 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1217
} | [
2830,
3393,
19237,
1155,
353,
8840,
836,
8,
341,
5195,
16,
16,
20,
1669,
5234,
423,
50463,
14463,
445,
16,
13,
16,
20,
13,
15,
1138,
2405,
7032,
284,
3056,
1235,
341,
197,
41653,
914,
198,
197,
7568,
372,
1534,
43451,
198,
197,
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... | 9 |
func TestArtifactRepositoryRef_String(t *testing.T) {
var l *ArtifactRepositoryRef
assert.Equal(t, "nil", l.String())
assert.Equal(t, "#", (&ArtifactRepositoryRef{}).String())
assert.Equal(t, "my-cm#my-key", (&ArtifactRepositoryRef{ConfigMap: "my-cm", Key: "my-key"}).String())
} | explode_data.jsonl/26032 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
85578,
4624,
3945,
31777,
1155,
353,
8840,
836,
8,
341,
2405,
326,
353,
85578,
4624,
3945,
198,
6948,
12808,
1155,
11,
330,
8385,
497,
326,
6431,
2398,
6948,
12808,
1155,
11,
5869,
497,
15899,
85578,
4624,
3945,
6257,
568,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBloomCachedChan(t *testing.T) {
assert := assert.New(t)
c := NewBloomCachedChan()
c.Send("1.2.3.4", "80")
assert.Equal(1, len(c.Recv()))
c.Send("5.6.7.8", "80")
assert.Equal(2, len(c.Recv()))
// filtered by bloom
c.Send("5.6.7.8", "80")
assert.Equal(2, len(c.Recv()))
} | explode_data.jsonl/76416 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
33,
18474,
70293,
46019,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
1444,
1669,
1532,
33,
18474,
70293,
46019,
741,
1444,
20176,
445,
16,
13,
17,
13,
18,
13,
19,
497,
330,
23,
15,
1138,
6948,
12808,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTxOrmRollbackUnlessCommit(t *testing.T) {
o := NewOrm()
var tag Tag
// test not commited and call RollbackUnlessCommit
to, err := o.Begin()
assert.Nil(t, err)
tag.Name = "rollback unless commit"
rows, err := to.Insert(&tag)
assert.Nil(t, err)
assert.True(t, rows > 0)
err = to.RollbackUnlessCommit()
assert.Nil(t, err)
num, err := o.QueryTable("tag").Filter("name", tag.Name).Delete()
assert.Nil(t, err)
assert.Equal(t, int64(0), num)
// test commit and call RollbackUnlessCommit
to, err = o.Begin()
assert.Nil(t, err)
tag.Name = "rollback unless commit"
rows, err = to.Insert(&tag)
assert.Nil(t, err)
assert.True(t, rows > 0)
err = to.Commit()
assert.Nil(t, err)
err = to.RollbackUnlessCommit()
assert.Nil(t, err)
num, err = o.QueryTable("tag").Filter("name", tag.Name).Delete()
assert.Nil(t, err)
assert.Equal(t, int64(1), num)
} | explode_data.jsonl/18155 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 361
} | [
2830,
3393,
31584,
80405,
32355,
1419,
35587,
33441,
1155,
353,
8840,
836,
8,
341,
22229,
1669,
1532,
80405,
741,
2405,
4772,
12353,
271,
197,
322,
1273,
537,
1063,
1608,
323,
1618,
14686,
1419,
35587,
33441,
198,
31709,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateReadDeleteUpdate(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
t.Parallel()
sf := newTestFile()
update := sf.createDeleteUpdate()
// Read update
path := readDeleteUpdate(update)
// Compare values
if path != sf.siaFilePath {
t.Error("paths doesn't match")
}
} | explode_data.jsonl/14690 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
4021,
4418,
6435,
4289,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
7039,
741,
197,
532,
3244,
41288,
7957,
2822,
53024,
1669,
501,
2271,
1703,
741,
27175,
1669,
13124,
2520,
6435,
4289,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestParseVar(t *testing.T) {
for _, tt := range []struct {
in string
expectedIndex int
expectedDefault string
}{
{"$13", 13, ""},
{"${0}", 0, ""},
{"${2}", 2, ""},
{"${1:fn}", 1, "fn"},
{"${10:someUrl}", 10, "someUrl"},
} {
t.Run(tt.in, func(t *testing.T) {
i, dv, err := parseVar(tt.in)
if i != tt.expectedIndex {
t.Errorf("got %d, want %d", i, tt.expectedIndex)
}
if dv != tt.expectedDefault {
t.Errorf("got %q, want %q", dv, tt.expectedDefault)
}
if err != nil {
t.Errorf("got %s", err)
}
})
}
} | explode_data.jsonl/40127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
14463,
3962,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
17430,
1060,
914,
198,
197,
42400,
1552,
256,
526,
198,
197,
42400,
3675,
914,
198,
197,
59403,
197,
197,
4913,
3,
16,
18,
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 TestSendDBMultipart(t *testing.T) {
tempDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatalf("unexpected error creating temp dir: %s", err)
}
defer os.RemoveAll(tempDir)
const maxPayloadSizeBytes = 1000
var fullContents []byte
for i := 0; i < maxPayloadSizeBytes/10*5; i++ {
fullContents = append(fullContents, []byte(fmt.Sprintf("payload %02d\n", i%10))...)
}
var paths []string
var sentContent []byte
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
paths = append(paths, r.URL.Path)
if r.URL.Path == "/dbs/42/stitch" {
return
}
rawContent, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatalf("unexpected error reading payload: %s", err)
}
if len(rawContent) > maxPayloadSizeBytes {
t.Errorf("oversized payload. want<%d have=%d", maxPayloadSizeBytes, len(rawContent))
}
gzipReader, err := gzip.NewReader(bytes.NewReader(rawContent))
if err != nil {
t.Fatalf("unexpected error decompressing payload: %s", err)
}
defer gzipReader.Close()
content, err := ioutil.ReadAll(gzipReader)
if err != nil {
t.Fatalf("unexpected error reading decompressed payload: %s", err)
}
sentContent = append(sentContent, content...)
w.Write([]byte(`{"size": 100}`))
}))
defer ts.Close()
filename := filepath.Join(tempDir, "test")
if err := ioutil.WriteFile(filename, fullContents, os.ModePerm); err != nil {
t.Fatalf("unexpected error writing temp file: %s", err)
}
client := &bundleManagerClientImpl{bundleManagerURL: ts.URL, maxPayloadSizeBytes: maxPayloadSizeBytes}
if err := client.SendDB(context.Background(), 42, filename); err != nil {
t.Fatalf("unexpected error sending db: %s", err)
}
if len(paths) < 5 {
t.Errorf("unexpected number of requests. want>=%d have=%d", 5, len(paths))
}
if paths[len(paths)-1] != "/dbs/42/stitch" {
t.Errorf("unexpected final request path. want=%s have=%s", "/dbs/42/stitch", paths[len(paths)-1])
}
if diff := cmp.Diff(sentContent, fullContents); diff != "" {
t.Errorf("unexpected contents (-want +got):\n%s", diff)
}
} | explode_data.jsonl/21436 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 807
} | [
2830,
3393,
11505,
3506,
44,
18204,
1155,
353,
8840,
836,
8,
341,
16280,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
53859,
1465,
6825,
2730,
5419,
25,
1018,
82,
497,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestGetDurationOption(t *testing.T) {
for _, tc := range []struct {
name string
envName string
exportEnv map[string]string
option string
options map[string]interface{}
defaultValue time.Duration
expectedDuration time.Duration
expectedError bool
}{
{
name: "no option, no env",
defaultValue: time.Minute,
option: "opt",
expectedDuration: time.Minute,
},
{
name: "given option",
defaultValue: time.Minute,
option: "opt",
options: map[string]interface{}{"opt": "4000ns"},
expectedDuration: 4000,
},
{
name: "env value with missing option",
defaultValue: time.Minute,
option: "opt",
envName: "VAR",
exportEnv: map[string]string{"VAR": "1s"},
expectedDuration: time.Second,
},
{
name: "given option and env var",
defaultValue: time.Minute,
option: "opt",
options: map[string]interface{}{"opt": "4000us"},
envName: "VAR",
exportEnv: map[string]string{"VAR": "1s"},
expectedDuration: time.Second,
},
{
name: "given option with bad env value",
defaultValue: time.Minute,
option: "opt",
options: map[string]interface{}{"opt": "1s"},
envName: "VAR",
exportEnv: map[string]string{"VAR": "bad"},
expectedDuration: time.Second,
expectedError: true,
},
{
name: "env value with wrong option type",
defaultValue: time.Minute,
option: "opt",
options: map[string]interface{}{"opt": false},
envName: "VAR",
exportEnv: map[string]string{"VAR": "2s"},
expectedDuration: time.Second * 2,
expectedError: true,
},
{
name: "env value with bad option value",
defaultValue: time.Minute,
option: "opt",
options: map[string]interface{}{"opt": "bad"},
envName: "VAR",
exportEnv: map[string]string{"VAR": "2s"},
expectedDuration: time.Second * 2,
expectedError: true,
},
{
name: "bad env value with bad option value",
defaultValue: time.Minute,
option: "opt",
options: map[string]interface{}{"opt": "bad"},
envName: "VAR",
exportEnv: map[string]string{"VAR": "bad"},
expectedDuration: time.Minute,
expectedError: true,
},
} {
for key, value := range tc.exportEnv {
os.Setenv(key, value)
}
d, err := getDurationOption(tc.envName, tc.option, tc.defaultValue, tc.options)
if err == nil && tc.expectedError {
t.Errorf("[%s] unexpected non-error", tc.name)
} else if err != nil && !tc.expectedError {
t.Errorf("[%s] unexpected error: %v", tc.name, err)
}
if d != tc.expectedDuration {
t.Errorf("[%s] got unexpected duration: %s != %s", tc.name, d.String(), tc.expectedDuration.String())
}
}
} | explode_data.jsonl/63537 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1486
} | [
2830,
3393,
1949,
12945,
5341,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
11609,
1797,
914,
198,
197,
57538,
675,
688,
914,
198,
197,
59440,
14359,
286,
2415,
14032,
30953,
198,
197,
80845,
1843,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRun(t *testing.T) {
tests := []struct{
Values []idiom_string.Type
Expected string
}{
{
Values: []idiom_string.Type{},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something(""),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something(""),
idiom_string.Something(""),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
idiom_string.Something(""),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("ap"),
},
Expected: "ap",
},
{
Values: []idiom_string.Type{
idiom_string.Something("ap"),
idiom_string.Something("p"),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("ap"),
idiom_string.Something("p"),
idiom_string.Something("le"),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("B"),
},
Expected: "B",
},
{
Values: []idiom_string.Type{
idiom_string.Something("B"),
idiom_string.Something("ANA"),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("B"),
idiom_string.Something("ANA"),
idiom_string.Something("NA"),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("Cherry"),
},
Expected: "Cherry",
},
{
Values: []idiom_string.Type{
idiom_string.Something("d"),
},
Expected: "d",
},
{
Values: []idiom_string.Type{
idiom_string.Something("d"),
idiom_string.Something("A"),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("d"),
idiom_string.Something("A"),
idiom_string.Something("t"),
},
Expected: "",
},
{
Values: []idiom_string.Type{
idiom_string.Something("d"),
idiom_string.Something("A"),
idiom_string.Something("t"),
idiom_string.Something("E"),
},
Expected: "",
},
}
for testNumber, test := range tests {
var output strings.Builder
result := run(&output, test.Values...)
if 1 > len(test.Values) {
if expected, actual := idiom_string.Error("expected 1 parameter(s), but actually got 0"), result; expected != actual {
t.Errorf("For test #%d, expected a specific error, but did not actually get it.", testNumber)
t.Logf("EXPECTED: %#v", expected)
t.Logf("ACTUAL: %#v", actual)
t.Logf("EXPECTED")
}
continue
}
if length := len(test.Values); 1 < length {
if expected, actual := idiom_string.Errorf("expected 1 parameter(s), but actually got %d", length), result; expected != actual {
t.Errorf("For test #%d, expected a specific error, but did not actually get it.", testNumber)
t.Logf("EXPECTED: %#v", expected)
t.Logf("ACTUAL: %#v", actual)
t.Logf("EXPECTED")
}
continue
}
if expected, actual := test.Values[0], result; expected != actual {
t.Errorf("For test #%d, the actual value is not what was expected.", testNumber)
t.Logf("EXPECTED: %#v", expected)
t.Logf("ACTUAL: %#v", actual)
continue
}
if expected, actual := test.Expected, output.String(); expected != actual {
t.Errorf("For test #%d, the actual value of what was outputted is not what was expected.", testNumber)
t.Logf("EXPECTED: %#v", expected)
t.Logf("ACTUAL: %#v", actual)
continue
}
}
} | explode_data.jsonl/48640 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1875
} | [
2830,
3393,
6727,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
515,
197,
197,
6227,
3056,
12278,
316,
3904,
10184,
198,
197,
197,
18896,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
6227,
25,
3056,
12278,
316,
3904,
10184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObserver(t *testing.T) {
var s Subject
v := s.Set(1)
if v.Value.(int) != 1 {
t.Fatal("required", 1)
}
v2, v2n := s.Set(2), v.Next()
if v2 != v2n {
t.Fatalf("%v != %v", v2, v2n)
}
var wg sync.WaitGroup
threes := make([]int, 8)
for i := range threes {
i := i
wg.Add(1)
go func() {
threes[i] = v2.Next().Value.(int)
wg.Done()
}()
}
s.Set(3)
wg.Wait()
for i, three := range threes {
if three != 3 {
t.Fatalf("threes[%d] == %d, want 3", i, three)
}
}
for i := 4; i < 66; i++ {
s.Set(i)
}
v65 := s.View()
if v65.Value.(int) != 65 {
t.Fatal("required", 65)
}
//t.Logf("%+v", v.frame)
//t.Logf("%+v", v65.frame)
// Check length matches.
l := v.Len()
if v65.Value != l {
t.Fatalf("%v !=len(v) -> %v", v65, l)
}
for i := 0; i < 1000; i++ {
s.Set(66 + i)
l = v.Len()
if l != 66+i {
t.Fatalf("Got %v want %v for len", l, 66+i)
}
}
} | explode_data.jsonl/81190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
17151,
1155,
353,
8840,
836,
8,
341,
2405,
274,
17450,
198,
5195,
1669,
274,
4202,
7,
16,
692,
743,
348,
6167,
12832,
396,
8,
961,
220,
16,
341,
197,
3244,
26133,
445,
6279,
497,
220,
16,
340,
197,
630,
5195,
17,
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 TestStorage(t *testing.T) {
cls := newMockCluster()
store := newStorage(cls)
store.put("prefix_1", "1")
store.put("prefix_2", "2")
val, err := store.get("prefix_1")
if err != nil || *val != "1" {
t.Errorf("get wrong val")
}
valmap, err := store.getPrefix("prefix", false)
if err != nil || !reflect.DeepEqual(valmap, map[string]string{"prefix_1": "1", "prefix_2": "2"}) {
t.Errorf("get wrong prefix val")
}
ch, _, err := store.watchDelete("prefix")
if err != nil {
t.Errorf("create watch delete failed %v", err)
}
store.delete("prefix_1")
delKv := <-ch
v, ok := delKv["prefix_1"]
if !ok {
t.Errorf("watch delete failed")
} else {
if *v != "1" {
t.Errorf("get wrong watch result, expected %v, got %v", "1", *v)
}
}
} | explode_data.jsonl/82205 | {
"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,
5793,
1155,
353,
8840,
836,
8,
341,
197,
18074,
1669,
501,
11571,
28678,
741,
57279,
1669,
501,
5793,
20398,
340,
57279,
3597,
445,
11849,
62,
16,
497,
330,
16,
1138,
57279,
3597,
445,
11849,
62,
17,
497,
330,
17,
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... | 8 |
func TestKpt_ExcludeKptFn(t *testing.T) {
// A declarative fn.
testFn1 := []byte(`apiVersion: v1
data:
annotation_name: k1
annotation_value: v1
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/function: fake`)
// A declarative fn which has `local-config` annotation specified.
testFn2 := []byte(`apiVersion: v1
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/function: fake
config.kubernetes.io/local-config: "false"
data:
annotation_name: k2
annotation_value: v2`)
testPod := []byte(`apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/project/image1
name: image1`)
tests := []struct {
description string
manifests manifest.ManifestList
expected manifest.ManifestList
}{
{
description: "Add `local-config` annotation to kpt fn",
manifests: manifest.ManifestList{testFn1},
expected: manifest.ManifestList{[]byte(`apiVersion: v1
data:
annotation_name: k1
annotation_value: v1
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/function: fake
config.kubernetes.io/local-config: "true"`)},
},
{
description: "Skip preset `local-config` annotation",
manifests: manifest.ManifestList{testFn2},
expected: manifest.ManifestList{[]byte(`apiVersion: v1
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/function: fake
config.kubernetes.io/local-config: "false"
data:
annotation_name: k2
annotation_value: v2`)},
},
{
description: "Valid in kpt fn pipeline.",
manifests: manifest.ManifestList{testFn1, testFn2, testPod},
expected: manifest.ManifestList{[]byte(`apiVersion: v1
data:
annotation_name: k1
annotation_value: v1
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/function: fake
config.kubernetes.io/local-config: "true"`), []byte(`apiVersion: v1
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/function: fake
config.kubernetes.io/local-config: "false"
data:
annotation_name: k2
annotation_value: v2`), []byte(`apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/project/image1
name: image1`)},
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
k := NewDeployer(&kptConfig{}, nil, deploy.NoopComponentProvider, nil)
actualManifest, err := k.excludeKptFn(test.manifests)
t.CheckErrorAndDeepEqual(false, err, test.expected.String(), actualManifest.String())
})
}
} | explode_data.jsonl/9528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 966
} | [
2830,
3393,
42,
417,
62531,
857,
42,
417,
24911,
1155,
353,
8840,
836,
8,
341,
197,
322,
362,
9445,
1388,
5168,
624,
18185,
24911,
16,
1669,
3056,
3782,
5809,
2068,
5637,
25,
348,
16,
198,
691,
510,
220,
21223,
1269,
25,
595,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResolve(t *testing.T) {
dispatcher := &clientmocks.MockDispatcher{}
ctx := mocks.NewMockContext(mockmsp.NewMockSigningIdentity("test", org1MSP))
config := &mocks.MockConfig{}
config.SetCustomChannelConfig(channelID, &fab.ChannelEndpointConfig{
Policies: fab.ChannelPolicies{
EventService: fab.EventServicePolicy{
Balancer: fab.RoundRobin,
},
},
})
ctx.SetEndpointConfig(config)
ctx.SetEndpointConfig(config)
resolver := New(dispatcher, ctx, channelID)
chosenPeers := make(map[string]struct{})
for i := 0; i < len(peers); i++ {
peer, err := resolver.Resolve(peers)
require.NoError(t, err)
chosenPeers[peer.URL()] = struct{}{}
}
assert.Equalf(t, 3, len(chosenPeers), "expecting all 3 peers to have been chosen")
} | explode_data.jsonl/1508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 299
} | [
2830,
3393,
56808,
1155,
353,
8840,
836,
8,
341,
60072,
261,
1669,
609,
2972,
16712,
82,
24664,
21839,
16094,
20985,
1669,
68909,
7121,
11571,
1972,
30389,
92545,
7121,
11571,
93358,
18558,
445,
1944,
497,
1240,
16,
44,
4592,
1171,
25873,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceEmitterCrashing(t *testing.T) {
if dipper.Logger == nil {
f, _ := os.OpenFile(os.DevNull, os.O_APPEND, 0o777)
defer f.Close()
dipper.GetLogger("test service", "DEBUG", f, f)
}
svc := &Service{
name: "testsvc",
driverRuntimes: map[string]*driver.Runtime{
"driver:d1": {
State: driver.DriverAlive,
Handler: driver.NewDriver(map[string]interface{}{
"name": "d1",
"type": "builtin",
"handlerData": map[string]interface{}{
"shortName": "testdriver1",
},
}),
},
"emitter": {
State: driver.DriverAlive,
Handler: driver.NewDriver(map[string]interface{}{
"name": "test-emitter",
"type": "builtin",
"handlerData": map[string]interface{}{
"shortName": "testdriver1",
},
}),
Feature: "emitter",
},
},
Route: func(m *dipper.Message) []RoutedMessage {
return nil
},
}
daemon.Emitters["testsvc"] = svc
daemon.ShuttingDown = false
svc.driverRuntimes["driver:d1"].Stream = make(chan dipper.Message, 1)
svc.driverRuntimes["driver:d1"].Output, _ = os.OpenFile(os.DevNull, os.O_APPEND, 0o777)
svc.driverRuntimes["emitter"].Stream = make(chan dipper.Message, 1)
svc.driverRuntimes["emitter"].Output, _ = os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, 0o777)
go func() {
assert.NotPanics(t, svc.serviceLoop, "service loop should recover panic if emitter crashes")
}()
go func() {
daemon.Children.Add(1)
defer daemon.Children.Done()
assert.NotPanics(t, func() {
for i := 0; i < 50; i++ {
select {
case svc.driverRuntimes["driver:d1"].Stream <- dipper.Message{
Channel: "test",
Subject: "noerror",
}:
dipper.Logger.Infof("written msg no. %+v", i)
time.Sleep(10 * time.Millisecond)
default:
dipper.Logger.Infof("unable to write, server shutdown")
}
}
}, "sending message to service should not panic when emitter crashes")
}()
time.Sleep(100 * time.Millisecond)
// mark it as failed to avoid restarting the driver
svc.driverRuntimes["emitter"].State = driver.DriverFailed
// crash emitter
svc.driverRuntimes["emitter"].Output.Close()
close(svc.driverRuntimes["emitter"].Stream)
time.Sleep(100 * time.Millisecond)
daemon.ShutDown()
} | explode_data.jsonl/12390 | {
"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,
1860,
21971,
16001,
19049,
1155,
353,
8840,
836,
8,
341,
743,
23604,
712,
12750,
621,
2092,
341,
197,
1166,
11,
716,
1669,
2643,
12953,
1703,
9638,
77611,
3280,
11,
2643,
8382,
65851,
11,
220,
15,
78,
22,
22,
22,
340,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetUser(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/users/test_user", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{ "type": "t", "name": "n", "created_at": "2011-03-19T15:42:22Z", "updated_at": "2012-06-14T00:14:27Z", "logo": "l", "_id": 1, "display_name": "d", "bio": "b" }`)
})
want := &User{
ID: intPtr(1),
Type: stringPtr("t"),
Name: stringPtr("n"),
Logo: stringPtr("l"),
DisplayName: stringPtr("d"),
Bio: stringPtr("b"),
CreatedAt: stringPtr("2011-03-19T15:42:22Z"),
UpdatedAt: stringPtr("2012-06-14T00:14:27Z"),
}
got, _, err := client.Users.GetUser("test_user")
if err != nil {
t.Errorf("Users.GetUser: request returned error %+v", err)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Users.GetUser response did not match:\nwant: %+v\ngot: %+v", want, got)
}
} | explode_data.jsonl/62969 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 429
} | [
2830,
3393,
1949,
1474,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
741,
2109,
2200,
63623,
4283,
4218,
12697,
3317,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
18185,
3523,
1155,
11,
435,
11,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInputService14ProtocolTestTimestampValuesCase2(t *testing.T) {
sess := session.New()
svc := NewInputService14ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService14TestShapeInputShape{
TimeArgInHeader: aws.Time(time.Unix(1422172800, 0)),
}
req, _ := svc.InputService14TestCaseOperation2Request(input)
r := req.HTTPRequest
// build request
restjson.Build(req)
assert.NoError(t, req.Error)
// assert URL
awstesting.AssertURL(t, "https://test/path", r.URL.String())
// assert headers
assert.Equal(t, "Sun, 25 Jan 2015 08:00:00 GMT", r.Header.Get("x-amz-timearg"))
} | explode_data.jsonl/8025 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
2505,
1860,
16,
19,
20689,
2271,
20812,
6227,
4207,
17,
1155,
353,
8840,
836,
8,
341,
1903,
433,
1669,
3797,
7121,
741,
1903,
7362,
1669,
1532,
2505,
1860,
16,
19,
20689,
2271,
57223,
11,
609,
8635,
10753,
90,
27380,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSaveConfigFile(t *testing.T) {
c, err := NewContainer(ContainerName)
if err != nil {
t.Errorf(err.Error())
}
if err := c.SaveConfigFile(c.ConfigFileName()); err != nil {
t.Errorf(err.Error())
}
} | explode_data.jsonl/2770 | {
"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,
8784,
2648,
1703,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
4502,
75145,
675,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
3964,
6141,
2398,
197,
630,
743,
1848,
1669,
272,
13599,
2648,
1703,
1337,
107... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExportFile(t *testing.T) {
// This used to trigger the log.Fatal in loadFromExportData.
// See go.dev/issue/45584.
cfg := new(packages.Config)
cfg.Mode = packages.NeedTypes
packages.Load(cfg, "fmt")
} | explode_data.jsonl/52479 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
16894,
1703,
1155,
353,
8840,
836,
8,
341,
197,
322,
1096,
1483,
311,
8183,
279,
1487,
26133,
304,
2795,
3830,
16894,
1043,
624,
197,
322,
3496,
728,
21523,
14,
11159,
14,
19,
20,
20,
23,
19,
624,
50286,
1669,
501,
1295,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMinimumNArgs(t *testing.T) {
tests := []struct {
name string
args []string
wantErr bool
}{
{
name: "no args",
args: []string{},
wantErr: true,
},
{
name: "with less args",
args: []string{"a"},
wantErr: true,
},
{
name: "with valid args",
args: []string{"a", "b"},
wantErr: false,
},
{
name: "with more args",
args: []string{"a", "b", "c"},
wantErr: false,
},
}
for _, tt := range tests {
args := tt.args
wantErr := tt.wantErr
t.Run(tt.name, func(t *testing.T) {
c := &cobra.Command{Use: "c", Args: MinimumNArgs(2), Run: emptyRun}
if _, err := executeCommand(c, args...); (err != nil) != wantErr {
t.Errorf("MinimumNArgs() error = %v, wantErr %v", err, wantErr)
}
})
}
} | explode_data.jsonl/59321 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 398
} | [
2830,
3393,
28695,
45,
4117,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
3056,
917,
198,
197,
50780,
7747,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
262,
330,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestProjectResourceHandler_GetProjectResource(t *testing.T) {
type fields struct {
ProjectResourceManager *handler_mock.IResourceManagerMock
}
tests := []struct {
name string
fields fields
request *http.Request
wantParams *models.GetResourceParams
wantResult *models.GetResourceResponse
wantStatus int
}{
{
name: "get resource",
fields: fields{
ProjectResourceManager: &handler_mock.IResourceManagerMock{
GetResourceFunc: func(params models.GetResourceParams) (*models.GetResourceResponse, error) {
return &testGetResourceResponse, nil
},
},
},
request: httptest.NewRequest(http.MethodGet, "/project/my-project/resource/my-resource.yaml?gitCommitID=commit-id", nil),
wantParams: &models.GetResourceParams{
ResourceContext: models.ResourceContext{
Project: models.Project{ProjectName: "my-project"},
},
ResourceURI: "my-resource.yaml",
GetResourceQuery: models.GetResourceQuery{
GitCommitID: "commit-id",
},
},
wantResult: &testGetResourceResponse,
wantStatus: http.StatusOK,
},
{
name: "get resource in parent directory- should return error",
fields: fields{
ProjectResourceManager: &handler_mock.IResourceManagerMock{
GetResourceFunc: func(params models.GetResourceParams) (*models.GetResourceResponse, error) {
return &testGetResourceResponse, nil
},
},
},
request: httptest.NewRequest(http.MethodGet, "/project/my-project/resource/..my-resource.yaml?gitCommitID=commit-id", nil),
wantParams: nil,
wantResult: nil,
wantStatus: http.StatusBadRequest,
},
{
name: "resource not found",
fields: fields{
ProjectResourceManager: &handler_mock.IResourceManagerMock{
GetResourceFunc: func(params models.GetResourceParams) (*models.GetResourceResponse, error) {
return nil, errors2.ErrResourceNotFound
},
},
},
request: httptest.NewRequest(http.MethodGet, "/project/my-project/resource/my-resource.yaml?gitCommitID=commit-id", nil),
wantParams: &models.GetResourceParams{
ResourceContext: models.ResourceContext{
Project: models.Project{ProjectName: "my-project"},
},
ResourceURI: "my-resource.yaml",
GetResourceQuery: models.GetResourceQuery{
GitCommitID: "commit-id",
},
},
wantResult: nil,
wantStatus: http.StatusNotFound,
},
{
name: "project not found",
fields: fields{
ProjectResourceManager: &handler_mock.IResourceManagerMock{
GetResourceFunc: func(params models.GetResourceParams) (*models.GetResourceResponse, error) {
return nil, errors2.ErrProjectNotFound
},
},
},
request: httptest.NewRequest(http.MethodGet, "/project/my-project/resource/my-resource.yaml?gitCommitID=commit-id", nil),
wantParams: &models.GetResourceParams{
ResourceContext: models.ResourceContext{
Project: models.Project{ProjectName: "my-project"},
},
ResourceURI: "my-resource.yaml",
GetResourceQuery: models.GetResourceQuery{
GitCommitID: "commit-id",
},
},
wantResult: nil,
wantStatus: http.StatusNotFound,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ph := NewProjectResourceHandler(tt.fields.ProjectResourceManager)
router := gin.Default()
router.GET("/project/:projectName/resource/:resourceURI", ph.GetProjectResource)
resp := performRequest(router, tt.request)
if tt.wantParams != nil {
require.Len(t, tt.fields.ProjectResourceManager.GetResourceCalls(), 1)
require.Equal(t, *tt.wantParams, tt.fields.ProjectResourceManager.GetResourceCalls()[0].Params)
} else {
require.Empty(t, tt.fields.ProjectResourceManager.GetResourceCalls())
}
require.Equal(t, tt.wantStatus, resp.Code)
if tt.wantResult != nil {
result := &models.GetResourceResponse{}
err := json.Unmarshal(resp.Body.Bytes(), result)
require.Nil(t, err)
require.Equal(t, tt.wantResult, result)
}
})
}
} | explode_data.jsonl/7380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1550
} | [
2830,
3393,
7849,
4783,
3050,
13614,
7849,
4783,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
7849,
32498,
353,
17905,
34134,
2447,
32498,
11571,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
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 TestPessimisticTxnWithDDLAddDropColumn(t *testing.T) {
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk2.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1 (c1 int primary key, c2 int)")
tk.MustExec("insert t1 values (1, 77), (2, 88)")
tk.MustExec("alter table t1 add index k2(c2)")
tk.MustExec("alter table t1 drop index k2")
// tk2 starts a pessimistic transaction and make some changes on table t1.
// tk executes some ddl statements add/drop column on table t1.
tk.MustExec("set tidb_enable_amend_pessimistic_txn = 1;")
tk.MustExec("begin pessimistic")
tk.MustExec("update t1 set c2 = c1 * 10")
tk2.MustExec("alter table t1 add column c3 int after c1")
tk.MustExec("commit")
tk.MustExec("admin check table t1")
tk.MustQuery("select * from t1").Check(testkit.Rows("1 <nil> 10", "2 <nil> 20"))
tk.MustExec("begin pessimistic")
tk.MustExec("insert into t1 values(5, 5, 5)")
tk2.MustExec("alter table t1 drop column c3")
tk2.MustExec("alter table t1 drop column c2")
tk.MustExec("commit")
tk.MustQuery("select * from t1").Check(testkit.Rows("1", "2", "5"))
} | explode_data.jsonl/12490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 463
} | [
2830,
3393,
47,
66733,
4532,
31584,
77,
2354,
58781,
2212,
19871,
2933,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1855,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIsFolder(t *testing.T) {
t.Parallel()
tests := []struct {
give string
want bool
}{
{
give: "/",
want: true,
},
{
give: "a/",
want: true,
},
{
give: "a/b/",
want: true,
},
{
give: "",
want: false,
},
{
give: "a",
want: false,
},
{
give: "a/b",
want: false,
},
{
give: "123/456",
want: false,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.give, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.want, IsFolder(tt.give))
})
}
} | explode_data.jsonl/81326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
3872,
13682,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
3174,
533,
914,
198,
197,
50780,
1807,
198,
197,
59403,
197,
197,
515,
298,
3174,
533,
25,
3521,
756,
298,
50780,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue37978(t *testing.T) {
runner.Run(t, exampleProgram, func(t *testing.T, env *Env) {
// Create a new workspace-level directory and empty file.
env.CreateBuffer("c/c.go", "")
// Write the file contents with a missing import.
env.EditBuffer("c/c.go", fake.Edit{
Text: `package c
const a = http.MethodGet
`,
})
env.Await(
env.DiagnosticAtRegexp("c/c.go", "http.MethodGet"),
)
// Save file, which will organize imports, adding the expected import.
// Expect the diagnostics to clear.
env.SaveBuffer("c/c.go")
env.Await(
EmptyDiagnostics("c/c.go"),
)
})
} | explode_data.jsonl/38905 | {
"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,
42006,
18,
22,
24,
22,
23,
1155,
353,
8840,
836,
8,
341,
197,
41736,
16708,
1155,
11,
3110,
10690,
11,
2915,
1155,
353,
8840,
836,
11,
6105,
353,
14359,
8,
341,
197,
197,
322,
4230,
264,
501,
27514,
11591,
6220,
323,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDisplaySettingsIsValidCustomUrlSchemes(t *testing.T) {
tests := []struct {
name string
value []string
valid bool
}{
{
name: "empty",
value: []string{},
valid: true,
},
{
name: "custom protocol",
value: []string{"steam"},
valid: true,
},
{
name: "multiple custom protocols",
value: []string{"bitcoin", "rss", "redis"},
valid: true,
},
{
name: "containing numbers",
value: []string{"ut2004", "ts3server", "h323"},
valid: true,
},
{
name: "containing period",
value: []string{"iris.beep"},
valid: true,
},
{
name: "containing hyphen",
value: []string{"ms-excel"},
valid: true,
},
{
name: "containing plus",
value: []string{"coap+tcp", "coap+ws"},
valid: true,
},
{
name: "starting with number",
value: []string{"4four"},
valid: false,
},
{
name: "starting with period",
value: []string{"data", ".dot"},
valid: false,
},
{
name: "starting with hyphen",
value: []string{"-hyphen", "dns"},
valid: false,
},
{
name: "invalid symbols",
value: []string{"!!fun!!"},
valid: false,
},
{
name: "invalid letters",
value: []string{"école"},
valid: false,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ds := &DisplaySettings{}
ds.SetDefaults()
ds.CustomUrlSchemes = test.value
if err := ds.isValid(); err != nil && test.valid {
t.Error("Expected CustomUrlSchemes to be valid but got error:", err)
} else if err == nil && !test.valid {
t.Error("Expected CustomUrlSchemes to be invalid but got no error")
}
})
}
} | explode_data.jsonl/50697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 721
} | [
2830,
3393,
7020,
6086,
55470,
10268,
2864,
50,
66346,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
16309,
3056,
917,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
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... | 5 |
func TestMerge(t *testing.T) {
tests := []struct {
obj runtime.Object
fragment string
expected runtime.Object
expectErr bool
}{
{
obj: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
},
fragment: fmt.Sprintf(`{ "apiVersion": "%s" }`, "v1"),
expected: &corev1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: corev1.PodSpec{},
},
},
{
obj: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
},
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, "v1"),
expected: &corev1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
Name: "v1",
},
{
Name: "v2",
},
},
},
},
},
{
obj: &corev1.Pod{},
fragment: "invalid json",
expected: &corev1.Pod{},
expectErr: true,
},
{
obj: &corev1.Service{},
fragment: `{ "apiVersion": "badVersion" }`,
expectErr: true,
},
{
obj: &corev1.Service{
Spec: corev1.ServiceSpec{},
},
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "ports": [ { "port": 0 } ] } }`, "v1"),
expected: &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Port: 0,
},
},
},
},
},
{
obj: &corev1.Service{
Spec: corev1.ServiceSpec{
Selector: map[string]string{
"version": "v1",
},
},
},
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "selector": { "version": "v2" } } }`, "v1"),
expected: &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
Spec: corev1.ServiceSpec{
Selector: map[string]string{
"version": "v2",
},
},
},
},
}
codec := runtime.NewCodec(scheme.DefaultJSONEncoder(),
scheme.Codecs.UniversalDecoder(scheme.Scheme.PrioritizedVersionsAllGroups()...))
for i, test := range tests {
out, err := Merge(codec, test.obj, test.fragment)
if !test.expectErr {
if err != nil {
t.Errorf("testcase[%d], unexpected error: %v", i, err)
} else if !apiequality.Semantic.DeepEqual(test.expected, out) {
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out))
}
}
if test.expectErr && err == nil {
t.Errorf("testcase[%d], unexpected non-error", i)
}
}
} | explode_data.jsonl/38770 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1440
} | [
2830,
3393,
52096,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22671,
981,
15592,
8348,
198,
197,
1166,
6017,
220,
914,
198,
197,
42400,
220,
15592,
8348,
198,
197,
24952,
7747,
1807,
198,
197,
59403,
197,
197,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestRedis_SetBit(t *testing.T) {
runOnRedis(t, func(client *Redis) {
err := NewRedis(client.Addr, "").SetBit("key", 1, 1)
assert.NotNil(t, err)
err = client.SetBit("key", 1, 1)
assert.Nil(t, err)
})
} | explode_data.jsonl/39171 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
48137,
14812,
8344,
1155,
353,
8840,
836,
8,
341,
56742,
1925,
48137,
1155,
11,
2915,
12805,
353,
48137,
8,
341,
197,
9859,
1669,
1532,
48137,
12805,
93626,
11,
35229,
1649,
8344,
445,
792,
497,
220,
16,
11,
220,
16,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNonDuplicateNaNDatapointsCausesAmendError(t *testing.T) {
db, delete := openTestDB(t, nil)
defer func() {
testutil.Ok(t, db.Close())
delete()
}()
app := db.Appender()
_, err := app.Add(labels.Labels{}, 0, math.Float64frombits(0x7ff0000000000001))
testutil.Ok(t, err)
testutil.Ok(t, app.Commit())
app = db.Appender()
_, err = app.Add(labels.Labels{}, 0, math.Float64frombits(0x7ff0000000000002))
testutil.Equals(t, ErrAmendSample, err)
} | explode_data.jsonl/64367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
8121,
53979,
16193,
8065,
266,
391,
14399,
22571,
4776,
6091,
408,
1454,
1155,
353,
8840,
836,
8,
341,
20939,
11,
3698,
1669,
1787,
2271,
3506,
1155,
11,
2092,
340,
16867,
2915,
368,
341,
197,
18185,
1314,
54282,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTimedMetricListFlushConsumingAndCollectingTimedMetrics(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
var (
errTestFlush = errors.New("foo")
cutoverNanos = int64(0)
cutoffNanos = int64(math.MaxInt64)
count int
flushLock sync.Mutex
flushed []aggregated.ChunkedMetricWithStoragePolicy
)
// Intentionally cause a one-time error during encoding.
writeFn := func(mp aggregated.ChunkedMetricWithStoragePolicy) error {
flushLock.Lock()
defer flushLock.Unlock()
if count == 0 {
count++
return errTestFlush
}
flushed = append(flushed, mp)
return nil
}
w := writer.NewMockWriter(ctrl)
w.EXPECT().Write(gomock.Any()).DoAndReturn(writeFn).AnyTimes()
w.EXPECT().Flush().Return(nil).AnyTimes()
handler := handler.NewMockHandler(ctrl)
handler.EXPECT().NewWriter(gomock.Any()).Return(w, nil).AnyTimes()
var (
now = time.Unix(216, 0).UnixNano()
nowTs = time.Unix(0, now)
resolution = testStoragePolicy.Resolution().Window
alignedTimeNanos = nowTs.Truncate(resolution).UnixNano()
bufferPast = 9 * time.Second
timedAggregationBufferPastFn = func(time.Duration) time.Duration { return bufferPast }
)
clockOpts := clock.NewOptions().SetNowFn(func() time.Time {
return time.Unix(0, atomic.LoadInt64(&now))
})
opts := testOptions(ctrl).
SetClockOptions(clockOpts).
SetFlushHandler(handler).
SetBufferForPastTimedMetricFn(timedAggregationBufferPastFn)
listID := timedMetricListID{
resolution: resolution,
}
l, err := newTimedMetricList(testShard, listID, opts)
require.NoError(t, err)
elemPairs := []struct {
elem metricElem
metric aggregated.Metric
}{
{
elem: MustNewCounterElem(ElemData{
ID: []byte("testTimedCounter"),
StoragePolicy: testStoragePolicy,
IDPrefixSuffixType: NoPrefixNoSuffix,
}, NewElemOptions(opts)),
metric: aggregated.Metric{
Type: metric.CounterType,
ID: []byte("testTimedCounter"),
TimeNanos: alignedTimeNanos,
Value: 123,
},
},
{
elem: MustNewGaugeElem(ElemData{
ID: []byte("testTimedGauge"),
StoragePolicy: testStoragePolicy,
IDPrefixSuffixType: NoPrefixNoSuffix,
}, NewElemOptions(opts)),
metric: aggregated.Metric{
Type: metric.GaugeType,
ID: []byte("testTimedGauge"),
TimeNanos: alignedTimeNanos,
Value: 1.762,
},
},
}
for _, ep := range elemPairs {
require.NoError(t, ep.elem.AddValue(time.Unix(0, ep.metric.TimeNanos), ep.metric.Value, nil))
require.NoError(t, ep.elem.AddValue(time.Unix(0, ep.metric.TimeNanos).Add(l.resolution), ep.metric.Value, nil))
_, err := l.PushBack(ep.elem)
require.NoError(t, err)
}
require.Equal(t, 0, l.forwardedWriter.Len())
// Force a flush.
l.Flush(flushRequest{
CutoverNanos: cutoverNanos,
CutoffNanos: cutoffNanos,
})
// Assert nothing has been flushed.
flushLock.Lock()
require.Equal(t, 0, len(flushed))
flushLock.Unlock()
for {
if nowTs.UnixNano() > alignedTimeNanos+bufferPast.Nanoseconds() {
break
}
// Move the time forward by one aggregation interval.
nowTs = nowTs.Add(l.resolution)
atomic.StoreInt64(&now, nowTs.UnixNano())
// Force a flush.
l.Flush(flushRequest{
CutoverNanos: cutoverNanos,
CutoffNanos: cutoffNanos,
})
// Assert nothing has been flushed.
flushLock.Lock()
require.Equal(t, 0, len(flushed))
flushLock.Unlock()
}
for i := 0; i < 2; i++ {
// Move the time forward by one aggregation interval.
nowTs = nowTs.Add(l.resolution)
atomic.StoreInt64(&now, nowTs.UnixNano())
// Force a flush.
l.Flush(flushRequest{
CutoverNanos: cutoverNanos,
CutoffNanos: cutoffNanos,
})
var expected []aggregated.ChunkedMetricWithStoragePolicy
alignedStart := (nowTs.Add(-bufferPast)).Truncate(l.resolution).UnixNano()
for _, ep := range elemPairs {
expected = append(expected, aggregated.ChunkedMetricWithStoragePolicy{
ChunkedMetric: aggregated.ChunkedMetric{
ChunkedID: id.ChunkedID{
Data: ep.metric.ID,
},
TimeNanos: alignedStart,
Value: ep.metric.Value,
},
StoragePolicy: testStoragePolicy,
})
}
// Skip the first item because we intentionally triggered
// an encoder error when encoding the first item.
if i == 0 {
expected = expected[1:]
}
flushLock.Lock()
require.NotNil(t, flushed)
require.Equal(t, expected, flushed)
flushed = flushed[:0]
flushLock.Unlock()
}
// Move the time forward by one aggregation interval.
nowTs = nowTs.Add(l.resolution)
atomic.StoreInt64(&now, nowTs.UnixNano())
// Force a flush.
l.Flush(flushRequest{
CutoverNanos: cutoverNanos,
CutoffNanos: cutoffNanos,
})
// Assert nothing has been flushed.
flushLock.Lock()
require.Equal(t, 0, len(flushed))
flushLock.Unlock()
require.Equal(t, 2, l.aggregations.Len())
// Mark all elements as tombstoned.
for e := l.aggregations.Front(); e != nil; e = e.Next() {
e.Value.(metricElem).MarkAsTombstoned()
}
// Move the time forward and force a flush.
nowTs = nowTs.Add(l.resolution)
atomic.StoreInt64(&now, nowTs.UnixNano())
l.Flush(flushRequest{
CutoverNanos: cutoverNanos,
CutoffNanos: cutoffNanos,
})
// Assert all elements have been collected.
require.Equal(t, 0, l.aggregations.Len())
// Assert there are no more forwarded metrics tracked by the writer.
require.Equal(t, 0, l.forwardedWriter.Len())
require.Equal(t, l.lastFlushedNanos, nowTs.UnixNano()-bufferPast.Nanoseconds())
} | explode_data.jsonl/43592 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2364
} | [
2830,
3393,
20217,
291,
54310,
852,
46874,
41966,
287,
3036,
47504,
287,
20217,
291,
27328,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
2405,
2399,
197,
9859,
2271,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNotifySemaphoreConfigUpdate(t *testing.T) {
assert := assert.New(t)
wf := unmarshalWF(wfWithSema)
wf1 := wf.DeepCopy()
wf1.Name = "one"
wf2 := wf.DeepCopy()
wf2.Name = "two"
wf2.Spec.Synchronization = nil
cancel, controller := newController(wf, wf1, wf2)
defer cancel()
cm := apiv1.ConfigMap{ObjectMeta: metav1.ObjectMeta{
Name: "my-config",
Namespace: "default",
}}
assert.Equal(3, controller.wfQueue.Len())
// Remove all Wf from Worker queue
for i := 0; i < 3; i++ {
key, _ := controller.wfQueue.Get()
controller.wfQueue.Done(key)
}
assert.Equal(0, controller.wfQueue.Len())
controller.notifySemaphoreConfigUpdate(&cm)
time.Sleep(2 * time.Second)
assert.Equal(2, controller.wfQueue.Len())
} | explode_data.jsonl/2871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
28962,
74614,
2648,
4289,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
6692,
69,
1669,
650,
27121,
32131,
3622,
69,
2354,
50,
9176,
340,
6692,
69,
16,
1669,
41248,
55602,
12106,
741,
6692,
69,
16,
2967,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_PrivateEndpointConnection_Status_Domain_SubResourceEmbedded_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip of PrivateEndpointConnection_Status_Domain_SubResourceEmbedded via JSON returns original",
prop.ForAll(RunJSONSerializationTestForPrivateEndpointConnectionStatusDomainSubResourceEmbedded, PrivateEndpointConnectionStatusDomainSubResourceEmbeddedGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
} | explode_data.jsonl/39621 | {
"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,
43830,
27380,
4526,
36449,
1557,
3121,
36359,
4783,
83466,
62,
4498,
77521,
78967,
98054,
2848,
4756,
2121,
2993,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBoolIndividual(t *testing.T) {
ind1 := NewBoolIndividual([]bool{true, true, true}, NewFitness([]float64{-1.0}))
ind2 := NewBoolIndividual([]bool{false, true, false}, NewFitness([]float64{-1.0}))
ind3 := NewBoolIndividual([]bool{true, true, true}, NewFitness([]float64{-1.0}))
ind4 := ind1.Clone().(Individual)
if !ind1.IsEqual(ind3) {
t.Errorf("ind1 isn't equal to ind3: %v %v", ind1, ind3)
}
if !ind3.IsEqual(ind4) {
t.Errorf("ind3 isn't equal to ind4: %v %v", ind3, ind4)
}
t.Log(ind1)
t.Log(ind2)
t.Log(ind3)
t.Log(ind4)
t.Log(ind1.GetChromosome())
t.Log(ind2.GetChromosome())
ind3.SetChromosome(ind2.GetChromosome())
t.Log(ind3)
} | explode_data.jsonl/30421 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
11233,
43159,
1155,
353,
8840,
836,
8,
341,
197,
484,
16,
1669,
1532,
11233,
43159,
10556,
2641,
90,
1866,
11,
830,
11,
830,
2137,
1532,
74863,
10556,
3649,
21,
19,
19999,
16,
13,
15,
44194,
197,
484,
17,
1669,
1532,
112... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubtract(t *testing.T) {
toFloat64 := func(n interface{}) float64 {
switch v := n.(type) {
case int:
return float64(v)
case int8:
return float64(v)
case int16:
return float64(v)
case int32:
return float64(v)
case int64:
return float64(v)
case float32:
return float64(v)
case float64:
return v
default:
return 0.0
}
}
values := []interface{}{
int(-3),
int8(14),
int16(81),
int32(-156),
int64(1528),
float32(3.5),
float64(-15.348),
}
for _, left := range values {
for _, right := range values {
expected := toFloat64(left) - toFloat64(right)
sub := Subtract(left, right)
assert.InDelta(t, expected, sub, 1e-3)
}
}
} | explode_data.jsonl/14316 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
3136,
2144,
1155,
353,
8840,
836,
8,
341,
31709,
5442,
21,
19,
1669,
2915,
1445,
3749,
28875,
2224,
21,
19,
341,
197,
8961,
348,
1669,
308,
12832,
1313,
8,
341,
197,
2722,
526,
510,
298,
853,
2224,
21,
19,
3747,
340,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestBindWithDelimiter_invalidType(t *testing.T) {
c := createTestContext("/search?param=1¶m=100", nil, nil)
b := QueryParamsBinder(c)
var dest []BindUnmarshaler
err := b.BindWithDelimiter("param", &dest, ",").BindError()
assert.Equal(t, []BindUnmarshaler(nil), dest)
assert.EqualError(t, err, "code=400, message=unsupported bind type, field=param")
} | explode_data.jsonl/82561 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
9950,
2354,
91098,
31433,
929,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1855,
2271,
1972,
4283,
1836,
30,
903,
28,
16,
5,
903,
28,
16,
15,
15,
497,
2092,
11,
2092,
340,
2233,
1669,
11361,
4870,
44055,
1337,
692,
2405,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApiV2GetDevices(t *testing.T) {
t.Parallel()
// enforce specific field naming in errors returned by API
updateRestErrorFieldName()
devs := []model.Device{
{
Id: "id1",
PubKey: "pubkey",
Status: model.DevStatusPending,
},
{
Id: "id2",
PubKey: "pubkey2",
Status: model.DevStatusRejected,
},
{
Id: "id3",
PubKey: "pubkey3",
Status: model.DevStatusRejected,
},
{
Id: "id4",
PubKey: "pubkey4",
Status: model.DevStatusAccepted,
},
{
Id: "id5",
PubKey: "pubkey5",
Status: model.DevStatusPreauth,
},
}
outDevs, err := devicesV2FromDbModel(devs)
assert.NoError(t, err)
tcases := map[string]struct {
req *http.Request
code int
body string
devices []model.Device
err error
skip uint
limit uint
}{
"ok": {
req: test.MakeSimpleRequest("GET",
"http://1.2.3.4/api/management/v2/devauth/devices", nil),
code: http.StatusOK,
devices: devs,
err: nil,
skip: 0,
limit: rest_utils.PerPageDefault + 1,
body: string(asJSON(outDevs)),
},
"no devices": {
req: test.MakeSimpleRequest("GET",
"http://1.2.3.4/api/management/v2/devauth/devices", nil),
code: http.StatusOK,
devices: []model.Device{},
skip: 0,
limit: rest_utils.PerPageDefault + 1,
err: nil,
body: "[]",
},
// this test does not check if the devices were skipped
// it is only checking if endpoint limits number of devices in the response
"limit number of devices": {
req: test.MakeSimpleRequest("GET",
"http://1.2.3.4/api/management/v2/devauth/devices?page=2&per_page=2", nil),
devices: devs,
skip: 2,
limit: 3,
code: http.StatusOK,
// reqquested 2 devices per page, so expect only 2
body: string(asJSON(outDevs[:2])),
},
"internal error": {
req: test.MakeSimpleRequest("GET",
"http://1.2.3.4/api/management/v2/devauth/devices?page=2&per_page=2", nil),
skip: 2,
limit: 3,
code: http.StatusInternalServerError,
err: errors.New("failed"),
body: RestError("internal error"),
},
}
for name := range tcases {
tc := tcases[name]
t.Run(fmt.Sprintf("tc %s", name), func(t *testing.T) {
t.Parallel()
da := &mocks.App{}
da.On("GetDevices",
mtest.ContextMatcher(),
tc.skip, tc.limit, mock.AnythingOfType("model.DeviceFilter")).Return(
tc.devices, tc.err)
apih := makeMockApiHandler(t, da, nil)
runTestRequest(t, apih, tc.req, tc.code, tc.body)
})
}
} | explode_data.jsonl/634 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1157
} | [
2830,
3393,
6563,
53,
17,
1949,
40835,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
28162,
3151,
2070,
34948,
304,
5975,
5927,
553,
5333,
198,
27175,
12416,
1454,
51241,
2822,
27302,
82,
1669,
3056,
2528,
43995,
515,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetQuerySnippetGETBody(t *testing.T) {
q := "SELECT column FROM table"
body := bytes.NewBufferString(q)
req, err := http.NewRequest("GET", "", body)
checkErr(t, err)
query := getQuerySnippet(req)
if query != q {
t.Fatalf("got: %q; expected: %q", query, q)
}
} | explode_data.jsonl/31700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
1949,
2859,
87852,
3806,
5444,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
330,
4858,
3250,
4295,
1965,
698,
35402,
1669,
5820,
7121,
4095,
703,
10583,
340,
24395,
11,
1848,
1669,
1758,
75274,
445,
3806,
497,
7342,
2487,
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... | 2 |
func TestRolesAssignToGroupOnProject(t *testing.T) {
clients.RequireAdmin(t)
client, err := clients.NewIdentityV3Client()
th.AssertNoErr(t, err)
project, err := CreateProject(t, client, nil)
th.AssertNoErr(t, err)
defer DeleteProject(t, client, project.ID)
roleCreateOpts := roles.CreateOpts{
DomainID: "default",
}
role, err := CreateRole(t, client, &roleCreateOpts)
th.AssertNoErr(t, err)
defer DeleteRole(t, client, role.ID)
groupCreateOpts := &groups.CreateOpts{
DomainID: "default",
}
group, err := CreateGroup(t, client, groupCreateOpts)
th.AssertNoErr(t, err)
defer DeleteGroup(t, client, group.ID)
t.Logf("Attempting to assign a role %s to a group %s on a project %s",
role.Name, group.Name, project.Name)
assignOpts := roles.AssignOpts{
GroupID: group.ID,
ProjectID: project.ID,
}
err = roles.Assign(client, role.ID, assignOpts).ExtractErr()
th.AssertNoErr(t, err)
t.Logf("Successfully assigned a role %s to a group %s on a project %s",
role.Name, group.Name, project.Name)
defer UnassignRole(t, client, role.ID, &roles.UnassignOpts{
GroupID: group.ID,
ProjectID: project.ID,
})
iTrue := true
lao := roles.ListAssignmentsOpts{
RoleID: role.ID,
ScopeProjectID: project.ID,
GroupID: group.ID,
IncludeNames: &iTrue,
}
allPages, err := roles.ListAssignments(client, lao).AllPages()
th.AssertNoErr(t, err)
allRoleAssignments, err := roles.ExtractRoleAssignments(allPages)
th.AssertNoErr(t, err)
t.Logf("Role assignments of group %s on project %s:", group.Name, project.Name)
var found bool
for _, roleAssignment := range allRoleAssignments {
tools.PrintResource(t, roleAssignment)
if roleAssignment.Role.ID == role.ID {
found = true
}
if roleAssignment.Scope.Project.Domain.ID == "" || roleAssignment.Group.Domain.ID == "" {
found = false
}
}
th.AssertEquals(t, found, true)
} | explode_data.jsonl/57732 | {
"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,
25116,
28933,
1249,
2808,
1925,
7849,
1155,
353,
8840,
836,
8,
341,
197,
31869,
81288,
7210,
1155,
692,
25291,
11,
1848,
1669,
8239,
7121,
18558,
53,
18,
2959,
741,
70479,
11711,
2753,
7747,
1155,
11,
1848,
692,
72470,
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... | 5 |
func Test(t *testing.T) {
lib.AssertCorrect(t, solution.Part1(), 1212510616)
lib.AssertCorrect(t, solution.Part2(), 171265123)
} | explode_data.jsonl/74076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 52
} | [
2830,
3393,
1155,
353,
8840,
836,
8,
341,
93459,
11711,
33092,
1155,
11,
6291,
52250,
16,
1507,
220,
16,
17,
16,
17,
20,
16,
15,
21,
16,
21,
340,
93459,
11711,
33092,
1155,
11,
6291,
52250,
17,
1507,
220,
16,
22,
16,
17,
21,
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 |
func TestGetPaddedDisplayStrings(t *testing.T) {
type scenario struct {
stringArrays [][]string
padWidths []int
expected []string
}
scenarios := []scenario{
{
[][]string{{"a", "b"}, {"c", "d"}},
[]int{1},
[]string{"a b", "c d"},
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, getPaddedDisplayStrings(s.stringArrays, s.padWidths))
}
} | explode_data.jsonl/11578 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
1949,
47,
16828,
7020,
20859,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
11357,
22182,
52931,
917,
198,
197,
3223,
329,
3327,
82,
262,
3056,
396,
198,
197,
42400,
257,
3056,
917,
198,
197,
630,
29928,
6049... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintStorageClass(t *testing.T) {
policyDelte := api.PersistentVolumeReclaimDelete
policyRetain := api.PersistentVolumeReclaimRetain
bindModeImmediate := storage.VolumeBindingImmediate
bindModeWait := storage.VolumeBindingWaitForFirstConsumer
tests := []struct {
sc storage.StorageClass
expected []metav1.TableRow
}{
{
sc: storage.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "sc1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Provisioner: "kubernetes.io/glusterfs",
},
expected: []metav1.TableRow{{Cells: []interface{}{"sc1", "kubernetes.io/glusterfs", "Delete",
"Immediate", false, "0s"}}},
},
{
sc: storage.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "sc2",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Provisioner: "kubernetes.io/nfs",
},
expected: []metav1.TableRow{{Cells: []interface{}{"sc2", "kubernetes.io/nfs", "Delete",
"Immediate", false, "5m"}}},
},
{
sc: storage.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "sc3",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Provisioner: "kubernetes.io/nfs",
ReclaimPolicy: &policyDelte,
},
expected: []metav1.TableRow{{Cells: []interface{}{"sc3", "kubernetes.io/nfs", "Delete",
"Immediate", false, "5m"}}},
},
{
sc: storage.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "sc4",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Provisioner: "kubernetes.io/nfs",
ReclaimPolicy: &policyRetain,
VolumeBindingMode: &bindModeImmediate,
},
expected: []metav1.TableRow{{Cells: []interface{}{"sc4", "kubernetes.io/nfs", "Retain",
"Immediate", false, "5m"}}},
},
{
sc: storage.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "sc5",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Provisioner: "kubernetes.io/nfs",
ReclaimPolicy: &policyRetain,
VolumeBindingMode: &bindModeWait,
},
expected: []metav1.TableRow{{Cells: []interface{}{"sc5", "kubernetes.io/nfs", "Retain",
"WaitForFirstConsumer", false, "5m"}}},
},
{
sc: storage.StorageClass{
ObjectMeta: metav1.ObjectMeta{
Name: "sc6",
CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)},
},
Provisioner: "kubernetes.io/nfs",
ReclaimPolicy: &policyRetain,
AllowVolumeExpansion: boolP(true),
VolumeBindingMode: &bindModeWait,
},
expected: []metav1.TableRow{{Cells: []interface{}{"sc6", "kubernetes.io/nfs", "Retain",
"WaitForFirstConsumer", true, "5m"}}},
},
}
for i, test := range tests {
rows, err := printStorageClass(&test.sc, printers.GenerateOptions{})
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21631 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1473
} | [
2830,
3393,
8994,
5793,
1957,
1155,
353,
8840,
836,
8,
341,
3223,
8018,
16532,
665,
1669,
6330,
61655,
18902,
693,
7859,
6435,
198,
3223,
8018,
12020,
466,
1669,
6330,
61655,
18902,
693,
7859,
12020,
466,
198,
2233,
484,
3636,
52734,
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... | 5 |
func TestValidateAndBuildNodeBIdKeySuccess(t *testing.T) {
nodeType := "ENB"
plmnId := "bbbb"
nbId := "cccc"
delimiter := ":"
key, err := ValidateAndBuildNodeBIdKey(nodeType, plmnId, nbId)
if err != nil{
t.Errorf("#utils_test.TestValidateAndBuildNodeBIdKey - failed to validate key parameter")
}
assert.Contains(t, key, nodeType)
assert.Contains(t, key, plmnId)
assert.Contains(t, key, nbId)
assert.Contains(t, key, delimiter)
} | explode_data.jsonl/33037 | {
"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,
17926,
3036,
11066,
1955,
33,
764,
1592,
7188,
1155,
353,
8840,
836,
8,
341,
20831,
929,
1669,
330,
953,
33,
698,
72213,
21775,
764,
1669,
330,
87609,
698,
9038,
65,
764,
1669,
330,
55597,
698,
69509,
17700,
1669,
13022,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInvalidInt64(t *testing.T) {
os.Setenv("INT64", "AAA")
defer os.Clearenv()
cfg := Config{}
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"Int64\" of type \"int64\": strconv.ParseInt: parsing \"AAA\": invalid syntax")
} | explode_data.jsonl/78766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
7928,
1072,
21,
19,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
445,
3221,
21,
19,
497,
330,
50107,
1138,
16867,
2643,
727,
273,
9151,
85,
2822,
50286,
1669,
5532,
16094,
6948,
12808,
1454,
1155,
11,
14775,
2099,
1407... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateIamRoleGlob(t *testing.T) {
t.Parallel()
cases := []struct {
account voyager.Account
serviceName voyager.ServiceName
want string
}{
{
account: voyager.Account("12345"),
serviceName: "test-svc",
want: "arn:aws:iam::12345:role/rps-test-svc-*",
},
}
for i, c := range cases {
t.Run(strconv.Itoa(i), func(t *testing.T) {
assert.Equal(t, c.want, generateIamRoleGlob(c.account, c.serviceName))
})
}
} | explode_data.jsonl/4286 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
31115,
40,
309,
9030,
38,
1684,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1444,
2264,
1669,
3056,
1235,
341,
197,
86866,
257,
23063,
1409,
30877,
198,
197,
52934,
675,
23063,
1409,
13860,
675,
198,
197,
50780,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestColumnSchemaDiff(t *testing.T) {
cases := []struct {
name string
old, new *ColumnSchema
requiresManualChange bool
}{
{
"type change",
mkCol("foo", TextColumn, false, false, nil),
mkCol("foo", SmallIntColumn, false, false, nil),
true,
},
{
"pk change",
mkCol("foo", TextColumn, true, false, nil),
mkCol("foo", TextColumn, false, false, nil),
true,
},
{
"not null change",
mkCol("foo", TextColumn, false, true, nil),
mkCol("foo", TextColumn, false, false, nil),
true,
},
{
"ref added",
mkCol("foo", TextColumn, false, false, nil),
mkCol("foo", TextColumn, false, false, mkRef("foo", "bar", false)),
true,
},
{
"ref removed",
mkCol("foo", TextColumn, false, false, mkRef("foo", "bar", false)),
mkCol("foo", TextColumn, false, false, nil),
true,
},
{
"ref table changed",
mkCol("foo", TextColumn, false, false, mkRef("foo", "bar", false)),
mkCol("foo", TextColumn, false, false, mkRef("bar", "bar", false)),
true,
},
{
"ref col changed",
mkCol("foo", TextColumn, false, false, mkRef("foo", "bar", false)),
mkCol("foo", TextColumn, false, false, mkRef("foo", "foo", false)),
true,
},
{
"ref col unchanged",
mkCol("foo", TextColumn, false, false, mkRef("foo", "bar", false)),
mkCol("foo", TextColumn, false, false, mkRef("foo", "bar", false)),
false,
},
{
"equal",
mkCol("foo", TextColumn, false, false, nil),
mkCol("foo", TextColumn, false, false, nil),
false,
},
}
for _, c := range cases {
changes := ColumnSchemaDiff("Table", c.old, c.new)
if !c.requiresManualChange {
require.Len(t, changes, 0, c.name)
} else {
require.True(t, len(changes) > 0, c.name)
}
}
} | explode_data.jsonl/19116 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 765
} | [
2830,
3393,
2933,
8632,
21751,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
61828,
11,
501,
1797,
353,
2933,
8632,
198,
197,
197,
41375,
52092,
4072,
1807,
198,
197,
59403,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_TX_BatchInsert(t *testing.T) {
table := createTable()
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
tx, err := db.Begin()
if err != nil {
gtest.Error(err)
}
if _, err := tx.BatchInsert(table, g.List{
{
"id": 2,
"passport": "t",
"password": "25d55ad283aa400af464c76d713c07ad",
"nickname": "T2",
"create_time": gtime.Now().String(),
},
{
"id": 3,
"passport": "t3",
"password": "25d55ad283aa400af464c76d713c07ad",
"nickname": "T3",
"create_time": gtime.Now().String(),
},
}, 10); err != nil {
gtest.Error(err)
}
if err := tx.Commit(); err != nil {
gtest.Error(err)
}
if n, err := db.Table(table).Count(); err != nil {
gtest.Error(err)
} else {
t.Assert(n, 2)
}
})
} | explode_data.jsonl/41307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 432
} | [
2830,
3393,
18819,
1668,
754,
13780,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
1855,
2556,
741,
16867,
5943,
2556,
15761,
692,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
46237,
11,
1848,
1669,
2927,
28467,
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... | 5 |
func TestParseAtlantisURL(t *testing.T) {
cases := []struct {
In string
ExpErr string
ExpURL string
}{
// Valid URLs should work.
{
In: "https://example.com",
ExpURL: "https://example.com",
},
{
In: "http://example.com",
ExpURL: "http://example.com",
},
{
In: "http://example.com/",
ExpURL: "http://example.com",
},
{
In: "http://example.com",
ExpURL: "http://example.com",
},
{
In: "http://example.com:4141",
ExpURL: "http://example.com:4141",
},
{
In: "http://example.com:4141/",
ExpURL: "http://example.com:4141",
},
{
In: "http://example.com/baseurl",
ExpURL: "http://example.com/baseurl",
},
{
In: "http://example.com/baseurl/",
ExpURL: "http://example.com/baseurl",
},
{
In: "http://example.com/baseurl/test",
ExpURL: "http://example.com/baseurl/test",
},
// Must be valid URL.
{
In: "::",
ExpErr: "parse ::: missing protocol scheme",
},
// Must be absolute.
{
In: "/hi",
ExpErr: "http or https must be specified",
},
// Must have http or https scheme..
{
In: "localhost/test",
ExpErr: "http or https must be specified",
},
{
In: "httpl://localhost/test",
ExpErr: "http or https must be specified",
},
}
for _, c := range cases {
t.Run(c.In, func(t *testing.T) {
act, err := server.ParseAtlantisURL(c.In)
if c.ExpErr != "" {
ErrEquals(t, c.ExpErr, err)
} else {
Ok(t, err)
Equals(t, c.ExpURL, act.String())
}
})
}
} | explode_data.jsonl/15319 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 764
} | [
2830,
3393,
14463,
46250,
37866,
3144,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
70167,
257,
914,
198,
197,
197,
8033,
7747,
914,
198,
197,
197,
8033,
3144,
914,
198,
197,
59403,
197,
197,
322,
7818,
35006,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyCallFunctionDef(t *testing.T) {
tc := requireTestCase(t, `def foo$`)
_, err := requireCompletionsOrError(t, tc, EmptyCalls{})
require.Error(t, err, "empty call should not be emitted for function definition")
// should emit for function call within function definition
tc = requireTestCase(t, `import json
def foo():
json.loads$
`)
requireCompletions(t, tc, EmptyCalls{})
} | explode_data.jsonl/56044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
3522,
7220,
5152,
2620,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
1373,
16458,
1155,
11,
1565,
750,
15229,
3,
24183,
197,
6878,
1848,
1669,
1373,
1092,
10819,
908,
2195,
1454,
1155,
11,
17130,
11,
22228,
55292,
37790,
17957... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScannerDisabled(t *testing.T) {
defer leaktest.AfterTest(t)()
const count = 3
ranges := newTestRangeSet(count, t)
q := &testQueue{}
mc := hlc.NewManualClock(123)
clock := hlc.NewClock(mc.UnixNano, time.Nanosecond)
s := newReplicaScanner(makeAmbCtx(), clock, 1*time.Millisecond, 0, 0, ranges)
s.AddQueues(q)
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())
s.Start(stopper)
// Verify queue gets all ranges.
testutils.SucceedsSoon(t, func() error {
if q.count() != count {
return errors.Errorf("expected %d replicas; have %d", count, q.count())
}
if s.scanCount() == 0 {
return errors.Errorf("expected scanner count to increment")
}
return nil
})
lastWaitEnabledCount := s.waitEnabledCount()
// Now, disable the scanner.
s.SetDisabled(true)
testutils.SucceedsSoon(t, func() error {
if s.waitEnabledCount() == lastWaitEnabledCount {
return errors.Errorf("expected scanner to stop when disabled")
}
return nil
})
lastScannerCount := s.scanCount()
// Remove the replicas and verify the scanner still removes them while disabled.
ranges.Visit(func(repl *Replica) bool {
s.RemoveReplica(repl)
return true
})
testutils.SucceedsSoon(t, func() error {
if qc := q.count(); qc != 0 {
return errors.Errorf("expected queue to be empty after replicas removed from scanner; got %d", qc)
}
return nil
})
if sc := s.scanCount(); sc != lastScannerCount {
t.Errorf("expected scanner count to not increment: %d != %d", sc, lastScannerCount)
}
} | explode_data.jsonl/78120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 561
} | [
2830,
3393,
31002,
25907,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
4777,
1760,
284,
220,
18,
198,
7000,
5520,
1669,
501,
2271,
6046,
1649,
11512,
11,
259,
340,
18534,
1669,
609,
1944,
7554,
16094,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCount(t *testing.T) {
catalogStore, err := store.Open("catalog_agg", store.DefaultOptions())
require.NoError(t, err)
defer os.RemoveAll("catalog_agg")
dataStore, err := store.Open("sqldata_agg", store.DefaultOptions())
require.NoError(t, err)
defer os.RemoveAll("sqldata_agg")
engine, err := NewEngine(catalogStore, dataStore, DefaultOptions().WithPrefix(sqlPrefix))
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE DATABASE db1", nil, true)
require.NoError(t, err)
err = engine.UseDatabase("db1")
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE TABLE t1(id INTEGER AUTO_INCREMENT, val1 INTEGER, PRIMARY KEY id)", nil, true)
require.NoError(t, err)
_, err = engine.ExecStmt("CREATE INDEX ON t1(val1)", nil, true)
require.NoError(t, err)
for i := 0; i < 10; i++ {
for j := 0; j < 3; j++ {
_, err = engine.ExecStmt("INSERT INTO t1(val1) VALUES($1)", map[string]interface{}{"param1": j}, true)
require.NoError(t, err)
}
}
r, err := engine.QueryStmt("SELECT COUNT() as c FROM t1", nil, true)
require.NoError(t, err)
row, err := r.Read()
require.NoError(t, err)
require.EqualValues(t, uint64(30), row.Values["(db1.t1.c)"].Value())
err = r.Close()
require.NoError(t, err)
_, err = engine.QueryStmt("SELECT COUNT() as c FROM t1 GROUP BY val1", nil, true)
require.ErrorIs(t, err, ErrLimitedGroupBy)
r, err = engine.QueryStmt("SELECT COUNT() as c FROM t1 GROUP BY val1 ORDER BY val1", nil, true)
require.NoError(t, err)
for j := 0; j < 3; j++ {
row, err = r.Read()
require.NoError(t, err)
require.EqualValues(t, uint64(10), row.Values["(db1.t1.c)"].Value())
}
_, err = r.Read()
require.ErrorIs(t, err, ErrNoMoreRows)
err = r.Close()
require.NoError(t, err)
} | explode_data.jsonl/64077 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 708
} | [
2830,
3393,
2507,
1155,
353,
8840,
836,
8,
341,
1444,
7750,
6093,
11,
1848,
1669,
3553,
12953,
445,
26539,
83534,
497,
3553,
13275,
3798,
2398,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
84427,
445,
26539,
83534,
5130,
8924,
6093,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTryPub(t *testing.T) {
ps := New(1)
defer ps.Shutdown()
ch := ps.Sub("t1")
ps.TryPub("hi", "t1")
ps.TryPub("there", "t1")
<-ch
extraMsg := false
select {
case <-ch:
extraMsg = true
default:
}
if extraMsg {
t.Fatal("Extra message was found in channel")
}
} | explode_data.jsonl/44260 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
21453,
29162,
1155,
353,
8840,
836,
8,
341,
35009,
1669,
1532,
7,
16,
340,
16867,
4726,
10849,
18452,
2822,
23049,
1669,
4726,
12391,
445,
83,
16,
1138,
35009,
19824,
29162,
445,
6023,
497,
330,
83,
16,
1138,
35009,
19824,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPGetMachineInfo(t *testing.T) {
mspec := &cadvisorapi.MachineInfo{
NumCores: 4,
MemoryCapacity: 2048,
}
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
err := json.NewEncoder(w).Encode(mspec)
if err != nil {
t.Fatal(err)
}
}))
defer ts.Close()
hostURL, err := url.Parse(ts.URL)
if err != nil {
t.Fatal(err)
}
parts := strings.Split(hostURL.Host, ":")
port, err := strconv.Atoi(parts[1])
if err != nil {
t.Fatal(err)
}
containerInfoGetter := &HTTPContainerInfoGetter{
Client: http.DefaultClient,
Port: port,
}
received, err := containerInfoGetter.GetMachineInfo(parts[0])
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(received, mspec) {
t.Errorf("received wrong machine spec")
}
} | explode_data.jsonl/53980 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 339
} | [
2830,
3393,
9230,
1949,
21605,
1731,
1155,
353,
8840,
836,
8,
341,
47691,
992,
1669,
609,
34455,
38012,
2068,
1321,
3814,
1731,
515,
197,
197,
4651,
34,
4589,
25,
981,
220,
19,
345,
197,
9209,
4731,
29392,
25,
220,
17,
15,
19,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCertificatesHandler(t *testing.T) {
t.Parallel()
call := func(s signing.Signer) (*signing.PublicCertificates, error) {
r := router.New()
InstallHandlers(r, withSigner(s))
ts := httptest.NewServer(r)
// Note: there are two contexts. One for outter /certificates call
// (this one), and another for /certificates request handler (it is setup
// in the middleware chain above).
ctx := caching.WithEmptyProcessCache(context.Background())
ctx = ModifyConfig(ctx, func(cfg Config) Config {
cfg.AnonymousTransport = func(context.Context) http.RoundTripper {
return http.DefaultTransport
}
return cfg
})
return signing.FetchCertificates(ctx, ts.URL+"/auth/api/v1/server/certificates")
}
Convey("Works", t, func() {
certs, err := call(&phonySigner{})
So(err, ShouldBeNil)
So(len(certs.Certificates), ShouldEqual, 1)
})
Convey("No signer", t, func() {
_, err := call(nil)
So(err, ShouldErrLike, "HTTP code (404)")
})
Convey("Error getting certs", t, func() {
_, err := call(&phonySigner{errors.New("fail")})
So(err, ShouldErrLike, "HTTP code (500)")
})
} | explode_data.jsonl/4597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
97140,
3050,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
67288,
1669,
2915,
1141,
15971,
41152,
261,
8,
4609,
7752,
287,
49139,
97140,
11,
1465,
8,
341,
197,
7000,
1669,
9273,
7121,
741,
197,
197,
24690,
39949,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPushQueue(t *testing.T) {
connection, err := OpenConnection("push", "tcp", "localhost:6379", 1, nil)
assert.NoError(t, err)
queue1, err := connection.OpenQueue("queue1")
assert.NoError(t, err)
queue2, err := connection.OpenQueue("queue2")
assert.NoError(t, err)
queue1.SetPushQueue(queue2)
assert.Equal(t, queue2.(*redisQueue).readyKey, queue1.(*redisQueue).pushKey)
consumer1 := NewTestConsumer("push-cons")
consumer1.AutoAck = false
consumer1.AutoFinish = false
assert.NoError(t, queue1.StartConsuming(10, time.Millisecond))
_, err = queue1.AddConsumer("push-cons", consumer1)
assert.NoError(t, err)
consumer2 := NewTestConsumer("push-cons")
consumer2.AutoAck = false
consumer2.AutoFinish = false
assert.NoError(t, queue2.StartConsuming(10, time.Millisecond))
_, err = queue2.AddConsumer("push-cons", consumer2)
assert.NoError(t, err)
assert.NoError(t, queue1.Publish("d1"))
time.Sleep(2 * time.Millisecond)
count, err := queue1.unackedCount()
assert.NoError(t, err)
assert.Equal(t, int64(1), count)
require.Len(t, consumer1.LastDeliveries, 1)
assert.NoError(t, consumer1.LastDelivery.Push())
time.Sleep(2 * time.Millisecond)
count, err = queue1.unackedCount()
assert.NoError(t, err)
assert.Equal(t, int64(0), count)
count, err = queue2.unackedCount()
assert.NoError(t, err)
assert.Equal(t, int64(1), count)
require.Len(t, consumer2.LastDeliveries, 1)
assert.NoError(t, consumer2.LastDelivery.Push())
time.Sleep(2 * time.Millisecond)
count, err = queue2.rejectedCount()
assert.NoError(t, err)
assert.Equal(t, int64(1), count)
} | explode_data.jsonl/44668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 607
} | [
2830,
3393,
16644,
7554,
1155,
353,
8840,
836,
8,
341,
54590,
11,
1848,
1669,
5264,
4526,
445,
9077,
497,
330,
27161,
497,
330,
8301,
25,
21,
18,
22,
24,
497,
220,
16,
11,
2092,
340,
6948,
35699,
1155,
11,
1848,
340,
46993,
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 TestClientSubscribesTwice(t *testing.T) {
s := pubsub.NewServer()
s.SetLogger(log.TestingLogger())
s.Start()
defer s.Stop()
ctx := context.Background()
q := query.MustParse("tm.events.type='NewBlock'")
subscription1, err := s.Subscribe(ctx, clientID, q)
require.NoError(t, err)
err = s.PublishWithEvents(ctx, "Goblin Queen", map[string][]string{"tm.events.type": {"NewBlock"}})
require.NoError(t, err)
assertReceive(t, "Goblin Queen", subscription1.Out())
subscription2, err := s.Subscribe(ctx, clientID, q)
require.Error(t, err)
require.Nil(t, subscription2)
err = s.PublishWithEvents(ctx, "Spider-Man", map[string][]string{"tm.events.type": {"NewBlock"}})
require.NoError(t, err)
assertReceive(t, "Spider-Man", subscription1.Out())
} | explode_data.jsonl/22058 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
2959,
3136,
11592,
9433,
22816,
558,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
6675,
1966,
7121,
5475,
741,
1903,
4202,
7395,
12531,
8787,
287,
7395,
2398,
1903,
12101,
741,
16867,
274,
30213,
2822,
20985,
1669,
2266,
19047,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.