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 TestProcessNewView(t *testing.T) {
smr, err := MakeSmr(t)
if err != nil {
t.Error("TestProcessNewView MakeSmr error", err)
return
}
err = smr.ProcessNewView(1005, "dpzuVdosQrF2kmzumhVeFQZa1aYcdgFpN", "dpzuVdosQrF2kmzumhVeFQZa1aYcdgFpN")
if err != nil {
t.Error("TestProcessNewView error", err)
}
} | explode_data.jsonl/33022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
7423,
3564,
851,
1155,
353,
8840,
836,
8,
341,
1903,
20946,
11,
1848,
1669,
7405,
10673,
81,
1155,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
445,
2271,
7423,
3564,
851,
7405,
10673,
81,
1465,
497,
1848,
340,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCheckOrder(t *testing.T) {
RegisterFailHandler(test.FailedHandler(t))
err := revenue.CheckOrder(logger.NewEmptyLogger(), context.TODO(), "dev", "259")
Expect(err).To(BeNil())
err = revenue.CheckOrder(logger.NewEmptyLogger(), context.TODO(), "dev", "62235c6c8ed20c2774179f40")
Expect(err).To(BeNil())
err = revenue.CheckOrder(logger.NewEmptyLogger(), context.TODO(), "dev", "62229b6c957a5b919f8360fb")
Expect(err).To(BeNil())
} | explode_data.jsonl/9626 | {
"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,
3973,
4431,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
8623,
991,
5687,
3050,
1155,
4390,
9859,
1669,
12957,
10600,
4431,
37833,
7121,
3522,
7395,
1507,
2266,
90988,
1507,
330,
3583,
497,
330,
17,
20,
24,
1138,
35911,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConsumeEventData(t *testing.T) {
tests := []struct {
name string
resourceLogs pdata.Logs
reqTestFunc func(t *testing.T, r *http.Request)
httpResponseCode int
numDroppedLogRecords int
wantErr bool
}{
{
name: "happy_path",
resourceLogs: makeSampleResourceLogs(),
reqTestFunc: nil,
httpResponseCode: http.StatusAccepted,
},
{
name: "no_event_attribute",
resourceLogs: func() pdata.Logs {
out := makeSampleResourceLogs()
out.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).Logs().At(0).Attributes().Delete("com.splunk.signalfx.event_category")
return out
}(),
reqTestFunc: nil,
numDroppedLogRecords: 1,
httpResponseCode: http.StatusAccepted,
},
{
name: "nonconvertible_log_attrs",
resourceLogs: func() pdata.Logs {
out := makeSampleResourceLogs()
attrs := out.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).Logs().At(0).Attributes()
mapAttr := pdata.NewAttributeValueMap()
attrs.Insert("map", mapAttr)
propsAttrs, _ := attrs.Get("com.splunk.signalfx.event_properties")
propsAttrs.MapVal().Insert("map", mapAttr)
return out
}(),
reqTestFunc: nil,
// The log does go through, just without that prop
numDroppedLogRecords: 0,
httpResponseCode: http.StatusAccepted,
},
{
name: "response_forbidden",
resourceLogs: makeSampleResourceLogs(),
reqTestFunc: nil,
httpResponseCode: http.StatusForbidden,
numDroppedLogRecords: 1,
wantErr: true,
},
{
name: "large_batch",
resourceLogs: generateLargeEventBatch(),
reqTestFunc: nil,
httpResponseCode: http.StatusAccepted,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "test", r.Header.Get("test_header_"))
if tt.reqTestFunc != nil {
tt.reqTestFunc(t, r)
}
w.WriteHeader(tt.httpResponseCode)
}))
defer server.Close()
serverURL, err := url.Parse(server.URL)
assert.NoError(t, err)
eventClient := &sfxEventClient{
sfxClientBase: sfxClientBase{
ingestURL: serverURL,
headers: map[string]string{"test_header_": "test"},
client: &http.Client{
Timeout: 1 * time.Second,
},
zippers: newGzipPool(),
},
logger: zap.NewNop(),
}
numDroppedLogRecords, err := eventClient.pushLogsData(context.Background(), tt.resourceLogs)
assert.Equal(t, tt.numDroppedLogRecords, numDroppedLogRecords)
if tt.wantErr {
assert.Error(t, err)
return
}
assert.NoError(t, err)
})
}
} | explode_data.jsonl/61018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1289
} | [
2830,
3393,
1109,
31323,
65874,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
50346,
51053,
260,
70311,
5247,
82,
198,
197,
24395,
2271,
9626,
688,
2915,
1155,
353,
8840,
836,
11,
435,
353... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSquote(t *testing.T) {
tpl := `{{squote "a" "b" "c"}}`
if err := runt(tpl, `'a' 'b' 'c'`); err != nil {
t.Error(err)
}
tpl = `{{squote 1 2 3 }}`
if err := runt(tpl, `'1' '2' '3'`); err != nil {
t.Error(err)
}
} | explode_data.jsonl/63873 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
50,
2949,
1155,
353,
8840,
836,
8,
341,
3244,
500,
1669,
1565,
2979,
82,
2949,
330,
64,
1,
330,
65,
1,
330,
66,
30975,
3989,
743,
1848,
1669,
1598,
83,
1155,
500,
11,
72911,
64,
6,
364,
65,
6,
364,
66,
6,
63,
1215,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientUnsupportedCipher(t *testing.T) {
config := &ClientConfig{
User: "testuser",
Auth: []AuthMethod{
PublicKeys(),
},
Config: Config{
Ciphers: []string{"aes128-cbc"}, // not currently supported
},
}
if err := tryAuth(t, config); err == nil {
t.Errorf("expected no ciphers in common")
}
} | explode_data.jsonl/6941 | {
"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,
2959,
41884,
79460,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
609,
2959,
2648,
515,
197,
31672,
25,
330,
1944,
872,
756,
197,
197,
5087,
25,
3056,
5087,
3523,
515,
298,
73146,
8850,
3148,
197,
197,
1583,
197,
66156,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_scsi_RescanSCSIHostByHCTL(t *testing.T) {
type args struct {
ctx context.Context
addr HCTL
}
ctx := context.Background()
defaultArgs := args{ctx: ctx, addr: getValidHCTL()}
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mocks := mh.MockHelper{
Ctrl: ctrl,
OSOpenFileCallPath: fmt.Sprintf(
"/sys/class/scsi_host/host%s/scan", defaultArgs.addr.Host),
FileWriteStringCallData: fmt.Sprintf("%s %s %s", defaultArgs.addr.Channel,
defaultArgs.addr.Target, defaultArgs.addr.Lun),
}
tests := []struct {
name string
fields scsiFields
stateSetter func(fields scsiFields)
args args
wantErr bool
}{
{
name: "open file error",
fields: getDefaultSCSIFields(ctrl),
stateSetter: func(fields scsiFields) {
mocks.OSOpenFileCallErr(fields.os)
},
args: defaultArgs,
wantErr: true,
},
{
name: "write to file error",
fields: getDefaultSCSIFields(ctrl),
stateSetter: func(fields scsiFields) {
_, fileMock := mocks.OSOpenFileCallOK(fields.os)
mocks.FileWriteStringErr(fileMock)
},
args: defaultArgs,
wantErr: true,
},
{
name: "file close error",
fields: getDefaultSCSIFields(ctrl),
stateSetter: func(fields scsiFields) {
_, fileMock := mocks.OSOpenFileCallOK(fields.os)
mocks.FileWriteStringOK(fileMock)
mocks.FileCloseErr(fileMock)
},
args: defaultArgs,
wantErr: true,
},
{
name: "rescan without error",
fields: getDefaultSCSIFields(ctrl),
stateSetter: func(fields scsiFields) {
_, fileMock := mocks.OSOpenFileCallOK(fields.os)
mocks.FileWriteStringOK(fileMock)
mocks.FileCloseOK(fileMock)
},
args: defaultArgs,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &Scsi{
fileReader: tt.fields.fileReader,
filePath: tt.fields.filePath,
os: tt.fields.os,
osexec: tt.fields.osexec,
singleCall: tt.fields.singleCall,
}
tt.stateSetter(tt.fields)
if err := s.RescanSCSIHostByHCTL(tt.args.ctx, tt.args.addr); (err != nil) != tt.wantErr {
t.Errorf("RescanSCSIHostByHCTL() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
} | explode_data.jsonl/65979 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1043
} | [
2830,
3393,
643,
63229,
92815,
4814,
3540,
13817,
9296,
1359,
39,
23871,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
20985,
220,
2266,
9328,
198,
197,
53183,
472,
23871,
198,
197,
630,
20985,
1669,
2266,
19047,
2822,
1194... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractUtcTime(t *testing.T) {
s := uint32(0xD6EE7BD8)
f := uint32(0x8DC714FC)
got := extractUtcTime(s, f)
want := time.Unix(0, 1396964696553818999).UTC()
if want != got {
t.Errorf("TestUtcTime(), want=%v, got=%v, nanos=%d", want, got, got.UnixNano())
}
} | explode_data.jsonl/53127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
28959,
97768,
1462,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
2622,
18,
17,
7,
15,
15764,
21,
7099,
22,
9548,
23,
340,
1166,
1669,
2622,
18,
17,
7,
15,
87,
23,
5626,
22,
16,
19,
6754,
340,
3174,
354,
1669,
8649,
9776... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncodeDecodeTag(t *testing.T) {
v := Tag{}
var buf bytes.Buffer
msgp.Encode(&buf, &v)
m := v.Msgsize()
if buf.Len() > m {
t.Log("WARNING: TestEncodeDecodeTag Msgsize() is inaccurate")
}
vn := Tag{}
err := msgp.Decode(&buf, &vn)
if err != nil {
t.Error(err)
}
buf.Reset()
msgp.Encode(&buf, &v)
err = msgp.NewReader(&buf).Skip()
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/14250 | {
"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,
32535,
32564,
5668,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
12353,
16094,
2405,
6607,
5820,
22622,
198,
21169,
79,
50217,
2099,
5909,
11,
609,
85,
692,
2109,
1669,
348,
30365,
2141,
741,
743,
6607,
65819,
368,
861,
296,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestActivityService_ListWatched_authenticatedUser(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/user/subscriptions", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"page": "2",
})
fmt.Fprint(w, `[{"id":1}]`)
})
ctx := context.Background()
watched, _, err := client.Activity.ListWatched(ctx, "", &ListOptions{Page: 2})
if err != nil {
t.Errorf("Activity.ListWatched returned error: %v", err)
}
want := []*Repository{{ID: Int64(1)}}
if !reflect.DeepEqual(watched, want) {
t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want)
}
const methodName = "ListWatched"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Activity.ListWatched(ctx, "\n", &ListOptions{Page: 2})
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Activity.ListWatched(ctx, "", &ListOptions{Page: 2})
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
} | explode_data.jsonl/50048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
4052,
1860,
27104,
14247,
291,
64913,
1474,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
872,
37885,
29966,
497,
2915,
3622,
1758,
37508,
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 TestMsgBurnNFTGetSignersMethod(t *testing.T) {
newMsgBurnNFT := types.NewMsgBurnNFT(address.String(), id, denom)
signers := newMsgBurnNFT.GetSigners()
require.Equal(t, 1, len(signers))
require.Equal(t, address.String(), signers[0].String())
} | explode_data.jsonl/28180 | {
"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,
6611,
66213,
45,
3994,
1949,
7264,
388,
3523,
1155,
353,
8840,
836,
8,
341,
8638,
6611,
66213,
45,
3994,
1669,
4494,
7121,
6611,
66213,
45,
3994,
15434,
6431,
1507,
877,
11,
49744,
340,
69054,
388,
1669,
501,
6611,
66213,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_VirtualNetworks_Spec_PropertiesARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip of VirtualNetworks_Spec_PropertiesARM via JSON returns original",
prop.ForAll(RunJSONSerializationTestForVirtualNetworksSpecPropertiesARM, VirtualNetworksSpecPropertiesARMGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
} | explode_data.jsonl/2898 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
2334,
2901,
12320,
82,
1098,
992,
1088,
9249,
17911,
62,
4498,
77521,
78967,
98054,
2848,
4756,
2121,
2993,
1155,
353,
8840,
836,
8,
341,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
220,
16,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBranchRecoveryState(t *testing.T) {
const recoveryWindow = 10
recoverySteps := []Stepper{
// First, check that expanding our horizon returns exactly the
// recovery window (10).
InitialDelta{},
// Expected horizon: 10.
// Report finding the 2nd addr, this should cause our horizon
// to expand by 2.
ReportFound{1},
CheckDelta{2},
// Expected horizon: 12.
// Sanity check that expanding again reports zero delta, as
// nothing has changed.
CheckDelta{0},
// Now, report finding the 6th addr, which should expand our
// horizon to 16 with a detla of 4.
ReportFound{5},
CheckDelta{4},
// Expected horizon: 16.
// Sanity check that expanding again reports zero delta, as
// nothing has changed.
CheckDelta{0},
// Report finding child index 5 again, nothing should change.
ReportFound{5},
CheckDelta{0},
// Report finding a lower index that what was last found,
// nothing should change.
ReportFound{4},
CheckDelta{0},
// Moving on, report finding the 11th addr, which should extend
// our horizon to 21.
ReportFound{10},
CheckDelta{5},
// Expected horizon: 21.
// Before testing the lookahead expansion when encountering
// invalid child keys, check that we are correctly starting with
// no invalid keys.
CheckNumInvalid{0},
// Now that the window has been expanded, simulate deriving
// invalid keys in range of addrs that are being derived for the
// first time. The horizon will be incremented by one, as the
// recovery manager is expected to try and derive at least the
// next address.
MarkInvalid{17},
CheckNumInvalid{1},
CheckDelta{0},
// Expected horizon: 22.
// Check that deriving a second invalid key shows both invalid
// indexes currently within the horizon.
MarkInvalid{18},
CheckNumInvalid{2},
CheckDelta{0},
// Expected horizon: 23.
// Lastly, report finding the addr immediately after our two
// invalid keys. This should return our number of invalid keys
// within the horizon back to 0.
ReportFound{19},
CheckNumInvalid{0},
// As the 20-th key was just marked found, our horizon will need
// to expand to 30. With the horizon at 23, the delta returned
// should be 7.
CheckDelta{7},
CheckDelta{0},
// Expected horizon: 30.
}
brs := wallet.NewBranchRecoveryState(recoveryWindow)
harness := &Harness{
t: t,
brs: brs,
recoveryWindow: recoveryWindow,
}
for i, step := range recoverySteps {
step.Apply(i, harness)
}
} | explode_data.jsonl/6671 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 818
} | [
2830,
3393,
18197,
693,
7449,
1397,
1155,
353,
8840,
836,
8,
1476,
4777,
13351,
4267,
284,
220,
16,
15,
271,
17200,
7449,
33951,
1669,
3056,
20903,
6922,
515,
197,
197,
322,
5512,
11,
1779,
429,
23175,
1039,
34074,
4675,
6896,
279,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLocalDockerCompose(t *testing.T) {
path := "./testresources/docker-compose-simple.yml"
identifier := strings.ToLower(uuid.New().String())
compose := NewLocalDockerCompose([]string{path}, identifier, WithLogger(TestLogger(t)))
destroyFn := func() {
err := compose.Down()
checkIfError(t, err)
}
defer destroyFn()
err := compose.
WithCommand([]string{"up", "-d"}).
Invoke()
checkIfError(t, err)
} | explode_data.jsonl/43625 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
7319,
35,
13659,
70492,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
5924,
1944,
12745,
61764,
65070,
65957,
33936,
1837,
197,
15909,
1669,
9069,
29983,
41458,
7121,
1005,
703,
12367,
32810,
2900,
1669,
1532,
7319,
35,
13659,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLevelDBReceiptsFilterByIDsAndFromTo(t *testing.T) {
assert := assert.New(t)
conf := &LevelDBReceiptStoreConf{
Path: path.Join(tmpdir, "test3"),
}
r, err := newLevelDBReceipts(conf)
defer r.store.Close()
now := time.Now()
var receivedAt int64
receivedAt = int64(now.UnixNano() / int64(time.Millisecond))
receipt1 := make(map[string]interface{})
receipt1["_id"] = "r1"
receipt1["prop1"] = "value1"
receipt1["receivedAt"] = receivedAt
receipt1["from"] = "addr1"
receipt1["to"] = "addr2"
err = r.AddReceipt("r1", &receipt1)
receipt2 := make(map[string]interface{})
receipt2["_id"] = "r2"
receipt2["prop1"] = "value2"
receipt2["receivedAt"] = receivedAt
receipt2["from"] = "addr1.1"
receipt2["to"] = "addr2"
err = r.AddReceipt("r2", &receipt2)
receipt3 := make(map[string]interface{})
receipt3["_id"] = "r3"
receipt3["prop1"] = "value3"
receipt3["receivedAt"] = receivedAt
receipt3["from"] = "addr1"
err = r.AddReceipt("r3", &receipt3)
results, err := r.GetReceipts(1, 3, []string{"r1", "r2"}, 0, "addr1", "addr2", "")
assert.NoError(err)
assert.Equal(1, len(*results))
assert.Equal("value1", (*results)[0]["prop1"])
} | explode_data.jsonl/21455 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 522
} | [
2830,
3393,
4449,
3506,
67461,
82,
5632,
1359,
30466,
3036,
3830,
1249,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
67850,
1669,
609,
4449,
3506,
67461,
6093,
15578,
515,
197,
69640,
25,
1815,
22363,
10368,
3741,
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 TestWriteOnMultipleCachedTable(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists ct1, ct2")
tk.MustExec("create table ct1 (id int, c int)")
tk.MustExec("create table ct2 (id int, c int)")
tk.MustExec("alter table ct1 cache")
tk.MustExec("alter table ct2 cache")
tk.MustQuery("select * from ct1").Check(testkit.Rows())
tk.MustQuery("select * from ct2").Check(testkit.Rows())
lastReadFromCache := func(tk *testkit.TestKit) bool {
return tk.Session().GetSessionVars().StmtCtx.ReadFromTableCache
}
cached := false
for i := 0; i < 50; i++ {
tk.MustQuery("select * from ct1")
if lastReadFromCache(tk) {
cached = true
break
}
time.Sleep(100 * time.Millisecond)
}
require.True(t, cached)
tk.MustExec("begin")
tk.MustExec("insert into ct1 values (3, 4)")
tk.MustExec("insert into ct2 values (5, 6)")
tk.MustExec("commit")
tk.MustQuery("select * from ct1").Check(testkit.Rows("3 4"))
tk.MustQuery("select * from ct2").Check(testkit.Rows("5 6"))
// cleanup
tk.MustExec("alter table ct1 nocache")
tk.MustExec("alter table ct2 nocache")
} | explode_data.jsonl/5715 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 480
} | [
2830,
3393,
7985,
1925,
32089,
70293,
2556,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntegration_HttpRequestWithHeaders(t *testing.T) {
config, cfgCleanup := cltest.NewConfig(t)
defer cfgCleanup()
config.Set("ADMIN_CREDENTIALS_FILE", "")
config.Set("ETH_HEAD_TRACKER_MAX_BUFFER_SIZE", 99)
rpcClient, gethClient, sub, assertMocksCalled := cltest.NewEthMocks(t)
defer assertMocksCalled()
chchNewHeads := make(chan chan<- *models.Head, 1)
app, appCleanup := cltest.NewApplicationWithConfigAndKey(t, config,
eth.NewClientWith(rpcClient, gethClient),
)
defer appCleanup()
tickerHeaders := http.Header{
"Key1": []string{"value"},
"Key2": []string{"value", "value"},
}
tickerResponse := `{"high": "10744.00", "last": "10583.75", "timestamp": "1512156162", "bid": "10555.13", "vwap": "10097.98", "volume": "17861.33960013", "low": "9370.11", "ask": "10583.00", "open": "9927.29"}`
mockServer, assertCalled := cltest.NewHTTPMockServer(t, http.StatusOK, "GET", tickerResponse,
func(header http.Header, _ string) {
for key, values := range tickerHeaders {
assert.Equal(t, values, header[key])
}
})
defer assertCalled()
confirmed := int64(23456)
safe := confirmed + int64(config.MinRequiredOutgoingConfirmations())
inLongestChain := safe - int64(config.GasUpdaterBlockDelay())
rpcClient.On("EthSubscribe", mock.Anything, mock.Anything, "newHeads").
Run(func(args mock.Arguments) { chchNewHeads <- args.Get(1).(chan<- *models.Head) }).
Return(sub, nil)
rpcClient.On("CallContext", mock.Anything, mock.Anything, "eth_getBlockByNumber", mock.Anything, false).
Run(func(args mock.Arguments) {
head := args.Get(1).(**models.Head)
*head = cltest.Head(inLongestChain)
}).
Return(nil)
gethClient.On("ChainID", mock.Anything).Return(config.ChainID(), nil)
gethClient.On("PendingNonceAt", mock.Anything, mock.Anything).Maybe().Return(uint64(0), nil)
gethClient.On("BalanceAt", mock.Anything, mock.Anything, mock.Anything).Maybe().Return(oneETH.ToInt(), nil)
gethClient.On("SendTransaction", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
tx, ok := args.Get(1).(*types.Transaction)
require.True(t, ok)
rpcClient.On("BatchCallContext", mock.Anything, mock.MatchedBy(func(b []rpc.BatchElem) bool {
return len(b) == 1 && cltest.BatchElemMatchesHash(b[0], tx.Hash())
})).Return(nil).Run(func(args mock.Arguments) {
elems := args.Get(1).([]rpc.BatchElem)
elems[0].Result = &bulletprooftxmanager.Receipt{TxHash: tx.Hash(), BlockNumber: big.NewInt(confirmed), BlockHash: cltest.NewHash()}
})
}).
Return(nil).Once()
sub.On("Err").Return(nil)
sub.On("Unsubscribe").Return(nil).Maybe()
assert.NoError(t, app.StartAndConnect())
newHeads := <-chchNewHeads
j := cltest.CreateHelloWorldJobViaWeb(t, app, mockServer.URL)
jr := cltest.WaitForJobRunToPendOutgoingConfirmations(t, app.Store, cltest.CreateJobRunViaWeb(t, app, j))
app.EthBroadcaster.Trigger()
cltest.WaitForEthTxAttemptCount(t, app.Store, 1)
// Do the thing
newHeads <- cltest.Head(safe)
cltest.WaitForJobRunToComplete(t, app.Store, jr)
} | explode_data.jsonl/75889 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1181
} | [
2830,
3393,
52464,
2039,
1209,
1900,
2354,
10574,
1155,
353,
8840,
836,
8,
341,
25873,
11,
13286,
67335,
1669,
1185,
1944,
7121,
2648,
1155,
340,
16867,
13286,
67335,
741,
25873,
4202,
445,
34697,
920,
81509,
50,
8087,
497,
14676,
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 TestMain(t *testing.T) {
conn, err := voltdbclient.OpenTLSConn("127.0.0.1", voltdbclient.ClientConfig{"foo.pem", false})
assert.NotNil(t, err)
assert.Nil(t, conn)
conn, err = voltdbclient.OpenTLSConn("127.0.0.1", voltdbclient.ClientConfig{"foo.pem", true})
assert.Nil(t, err)
assert.NotNil(t, conn)
var params []driver.Value
for _, s := range []interface{}{"PAUSE_CHECK", int32(0)} {
params = append(params, s)
}
vr, err := conn.Query("@Statistics", params)
assert.Nil(t, err)
assert.NotNil(t, vr)
pretty.Print(vr)
} | explode_data.jsonl/19352 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
6202,
1155,
353,
8840,
836,
8,
1476,
32917,
11,
1848,
1669,
4400,
1296,
65,
2972,
12953,
45439,
9701,
445,
16,
17,
22,
13,
15,
13,
15,
13,
16,
497,
4400,
1296,
65,
2972,
11716,
2648,
4913,
7975,
49373,
497,
895,
3518,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventDelTxList(t *testing.T) {
q, mem := initEnv(0)
defer q.Close()
defer mem.Close()
// add tx
hashes, err := add4TxHash(mem.client)
if err != nil {
t.Error("add tx error", err.Error())
return
}
hashBytes := [][]byte{[]byte(hashes[0]), []byte(hashes[1])}
msg := mem.client.NewMessage("mempool", types.EventDelTxList, &types.TxHashList{Count: 2, Hashes: hashBytes})
mem.client.Send(msg, true)
_, err = mem.client.Wait(msg)
if err != nil {
t.Error(err)
return
}
if mem.Size() != 2 {
t.Error("TestEventDelTxList failed")
}
} | explode_data.jsonl/16820 | {
"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,
1556,
16532,
31584,
852,
1155,
353,
8840,
836,
8,
341,
18534,
11,
1833,
1669,
2930,
14359,
7,
15,
340,
16867,
2804,
10421,
741,
16867,
1833,
10421,
2822,
197,
322,
912,
9854,
198,
50333,
288,
11,
1848,
1669,
912,
19,
31584... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRejectSNIWithTrailingDot(t *testing.T) {
testClientHelloFailure(t, testConfig, &clientHelloMsg{
vers: VersionTLS12,
random: make([]byte, 32),
serverName: "foo.com.",
}, "unexpected message")
} | explode_data.jsonl/36312 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
78413,
50,
14912,
2354,
1282,
14277,
34207,
1155,
353,
8840,
836,
8,
341,
18185,
2959,
9707,
17507,
1155,
11,
1273,
2648,
11,
609,
2972,
9707,
6611,
515,
197,
197,
3004,
25,
981,
6079,
45439,
16,
17,
345,
197,
83628,
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 TestConfigMapReconcileFieldMissingField(t *testing.T) {
desired := &v1.ConfigMap{
Data: map[string]string{
"a1": "a1Value",
},
}
existing := &v1.ConfigMap{
Data: map[string]string{
"a2": "a2Value",
},
}
update := ConfigMapReconcileField(desired, existing, "a1")
if !update {
t.Fatal("when field is missing, reconciler reported no update needed")
}
a1Value, ok := existing.Data["a1"]
if !ok {
t.Fatal("existing does not have a1 data")
}
if a1Value != "a1Value" {
t.Fatalf("existing data not expected. Expected: 'a1Value', got: %s", a1Value)
}
} | explode_data.jsonl/35904 | {
"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,
2648,
2227,
693,
40446,
457,
1877,
25080,
1877,
1155,
353,
8840,
836,
8,
341,
52912,
2690,
1669,
609,
85,
16,
10753,
2227,
515,
197,
40927,
25,
2415,
14032,
30953,
515,
298,
197,
56693,
16,
788,
330,
64,
16,
1130,
756,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestToReplicaSet(t *testing.T) {
cases := []struct {
replicaSet *apps.ReplicaSet
podInfo *common.PodInfo
expected ReplicaSet
}{
{
&apps.ReplicaSet{ObjectMeta: metaV1.ObjectMeta{Name: "replica-set"}},
&common.PodInfo{Running: 1, Warnings: []common.Event{}},
ReplicaSet{
ObjectMeta: api.ObjectMeta{Name: "replica-set"},
TypeMeta: api.TypeMeta{Kind: api.ResourceKindReplicaSet},
Pods: common.PodInfo{Running: 1, Warnings: []common.Event{}},
},
},
}
for _, c := range cases {
actual := ToReplicaSet(c.replicaSet, c.podInfo)
if !reflect.DeepEqual(actual, c.expected) {
t.Errorf("ToReplicaSet(%#v, %#v) == \ngot %#v, \nexpected %#v", c.replicaSet,
c.podInfo, actual, c.expected)
}
}
} | explode_data.jsonl/52269 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
1249,
18327,
15317,
1649,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
73731,
15317,
1649,
353,
27635,
2817,
79,
15317,
1649,
198,
197,
3223,
347,
1731,
262,
353,
5464,
88823,
1731,
198,
197,
42400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDB_BatchTime(t *testing.T) {
db := MustOpenDB()
defer db.MustClose()
if err := db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("widgets"))
return err
}); err != nil {
t.Fatal(err)
}
const size = 1
// buffered so we never leak goroutines
ch := make(chan error, size)
put := func(i int) {
ch <- db.Batch(func(tx *bolt.Tx) error {
return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{})
})
}
db.MaxBatchSize = 1000
db.MaxBatchDelay = 0
go put(1)
// Batch must trigger by time alone.
// Check all responses to make sure there's no error.
for i := 0; i < size; i++ {
if err := <-ch; err != nil {
t.Fatal(err)
}
}
// Ensure data is correct.
if err := db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("widgets"))
for i := 1; i <= size; i++ {
if v := b.Get(u64tob(uint64(i))); v == nil {
t.Errorf("key not found: %d", i)
}
}
return nil
}); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/27493 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 431
} | [
2830,
3393,
3506,
1668,
754,
1462,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
15465,
5002,
3506,
741,
16867,
2927,
50463,
7925,
741,
743,
1848,
1669,
2927,
16689,
18552,
27301,
353,
52433,
81362,
8,
1465,
341,
197,
197,
6878,
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 TestScrapeLoopCache(t *testing.T) {
s := teststorage.New(t)
defer s.Close()
sapp, err := s.Appender()
if err != nil {
t.Error(err)
}
appender := &collectResultAppender{next: sapp}
var (
signal = make(chan struct{})
scraper = &testScraper{}
app = func() storage.Appender { return appender }
)
defer close(signal)
ctx, cancel := context.WithCancel(context.Background())
sl := newScrapeLoop(ctx,
scraper,
nil, nil,
nopMutator,
nopMutator,
app,
nil,
0,
true,
)
numScrapes := 0
scraper.scrapeFunc = func(ctx context.Context, w io.Writer) error {
if numScrapes == 1 || numScrapes == 2 {
if _, ok := sl.cache.series["metric_a"]; !ok {
t.Errorf("metric_a missing from cache after scrape %d", numScrapes)
}
if _, ok := sl.cache.series["metric_b"]; !ok {
t.Errorf("metric_b missing from cache after scrape %d", numScrapes)
}
} else if numScrapes == 3 {
if _, ok := sl.cache.series["metric_a"]; !ok {
t.Errorf("metric_a missing from cache after scrape %d", numScrapes)
}
if _, ok := sl.cache.series["metric_b"]; ok {
t.Errorf("metric_b present in cache after scrape %d", numScrapes)
}
}
numScrapes++
if numScrapes == 1 {
w.Write([]byte("metric_a 42\nmetric_b 43\n"))
return nil
} else if numScrapes == 3 {
w.Write([]byte("metric_a 44\n"))
return nil
} else if numScrapes == 4 {
cancel()
}
return fmt.Errorf("scrape failed")
}
go func() {
sl.run(10*time.Millisecond, time.Hour, nil)
signal <- struct{}{}
}()
select {
case <-signal:
case <-time.After(5 * time.Second):
t.Fatalf("Scrape wasn't stopped.")
}
// 1 successfully scraped sample, 1 stale marker after first fail, 5 report samples for
// each scrape successful or not.
if len(appender.result) != 26 {
t.Fatalf("Appended samples not as expected. Wanted: %d samples Got: %d", 26, len(appender.result))
}
} | explode_data.jsonl/56125 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 803
} | [
2830,
3393,
3326,
19842,
14620,
8233,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1273,
16172,
7121,
1155,
340,
16867,
274,
10421,
2822,
1903,
676,
11,
1848,
1669,
274,
5105,
1659,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidLedger(t *testing.T) {
templates, err := testutils.LoadTemplates("test-data-alltemplates.yaml")
if err != nil || len(templates) < 1 {
t.Errorf("cannot load test templates! %v", err)
return
}
ld := NewJSONLedger("foobar")
summaries := ld.Summarize(templates)
expected := []Summary{}
checkSummaries(t, summaries, expected)
} | explode_data.jsonl/45681 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
7928,
60850,
1389,
1155,
353,
8840,
836,
8,
341,
197,
15463,
11,
1848,
1669,
1273,
6031,
13969,
51195,
445,
1944,
13945,
22346,
15463,
33406,
1138,
743,
1848,
961,
2092,
1369,
2422,
7,
15463,
8,
366,
220,
16,
341,
197,
324... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDifferentStores(t *testing.T) {
testutil.FilterSpeed(t, testutil.Slow)
logger, cleanup := testutil.Logger(t)
defer cleanup()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mn := mocknet.New(ctx)
rdvp, err := mn.GenPeer()
require.NoError(t, err, "failed to generate mocked peer")
defer rdvp.Close()
_, cleanrdvp := ipfsutil.TestingRDVP(ctx, t, rdvp)
defer cleanrdvp()
ipfsOpts := &ipfsutil.TestingAPIOpts{
Logger: logger,
Mocknet: mn,
RDVPeer: rdvp.Peerstore().PeerInfo(rdvp.ID()),
}
pathBase, err := ioutil.TempDir("", "odb_manyaddstest")
if err != nil {
t.Fatal(err)
}
require.NoError(t, mn.ConnectAllButSelf())
var baseDS datastore.Batching
baseDS, err = badger.NewDatastore(pathBase, nil)
require.NoError(t, err)
defer baseDS.Close()
baseDS = sync_ds.MutexWrap(baseDS)
defer baseDS.Close()
api1, cleanup := ipfsutil.TestingCoreAPIUsingMockNet(ctx, t, ipfsOpts)
defer cleanup()
odb1 := newTestOrbitDB(ctx, t, logger, api1, datastoreutil.NewNamespacedDatastore(baseDS, datastore.NewKey("peer1")))
defer odb1.Close()
api2, cleanup := ipfsutil.TestingCoreAPIUsingMockNet(ctx, t, ipfsOpts)
defer cleanup()
odb2 := newTestOrbitDB(ctx, t, logger, api2, datastoreutil.NewNamespacedDatastore(baseDS, datastore.NewKey("peer2")))
defer odb2.Close()
err = mn.LinkAll()
require.NoError(t, err)
err = mn.ConnectAllButSelf()
require.NoError(t, err)
gA, _, err := NewGroupMultiMember()
require.NoError(t, err)
gB, _, err := NewGroupMultiMember()
require.NoError(t, err)
assert.NotEqual(t, gA.PublicKey, gB.PublicKey)
g1a, err := odb1.openGroup(ctx, gA, nil)
require.NoError(t, err)
g2a, err := odb2.openGroup(ctx, gA, nil)
require.NoError(t, err)
g1b, err := odb1.openGroup(ctx, gB, nil)
require.NoError(t, err)
g2b, err := odb2.openGroup(ctx, gB, nil)
require.NoError(t, err)
require.NoError(t, ActivateGroupContext(ctx, g1a, nil))
require.NoError(t, ActivateGroupContext(ctx, g2a, nil))
require.NoError(t, ActivateGroupContext(ctx, g1b, nil))
require.NoError(t, ActivateGroupContext(ctx, g2b, nil))
assert.Equal(t, g1a.MetadataStore().Address().String(), g2a.MetadataStore().Address().String())
assert.Equal(t, g1b.MetadataStore().Address().String(), g2b.MetadataStore().Address().String())
assert.NotEqual(t, g1a.MetadataStore().Address().String(), g1a.MessageStore().Address().String())
assert.NotEqual(t, g1a.MetadataStore().Address().String(), g1b.MetadataStore().Address().String())
authorized1, err := g1a.MetadataStore().AccessController().GetAuthorizedByRole("write")
require.NoError(t, err)
authorized2, err := g1a.MetadataStore().AccessController().GetAuthorizedByRole("write")
require.NoError(t, err)
assert.Equal(t, strings.Join(authorized1, ","), strings.Join(authorized2, ","))
pk1, err := g1a.MetadataStore().Identity().GetPublicKey()
require.NoError(t, err)
pk2, err := g2a.MetadataStore().Identity().GetPublicKey()
require.NoError(t, err)
require.True(t, pk1.Equals(pk2))
rawPK, err := pk1.Raw()
require.NoError(t, err)
require.Equal(t, hex.EncodeToString(rawPK), authorized1[0])
_, err = g1a.MetadataStore().SendAppMetadata(ctx, []byte("From 1 - 1"), nil)
require.NoError(t, err)
_, err = g2a.MetadataStore().SendAppMetadata(ctx, []byte("From 2 - 1"), nil)
require.NoError(t, err)
_, err = g1b.MetadataStore().SendAppMetadata(ctx, []byte("From 1 - 2"), nil)
require.NoError(t, err)
_, err = g2b.MetadataStore().SendAppMetadata(ctx, []byte("From 2 - 2"), nil)
require.NoError(t, err)
_, err = g1b.MetadataStore().SendAppMetadata(ctx, []byte("From 1 - 3"), nil)
require.NoError(t, err)
_, err = g2b.MetadataStore().SendAppMetadata(ctx, []byte("From 2 - 3"), nil)
require.NoError(t, err)
time.Sleep(time.Millisecond * 250)
evt1, err := g1a.MetadataStore().ListEvents(ctx, nil, nil, false)
require.NoError(t, err)
ops1 := testFilterAppMetadata(t, evt1)
evt2, err := g2a.MetadataStore().ListEvents(ctx, nil, nil, false)
require.NoError(t, err)
ops2 := testFilterAppMetadata(t, evt2)
evt3, err := g1b.MetadataStore().ListEvents(ctx, nil, nil, false)
require.NoError(t, err)
ops3 := testFilterAppMetadata(t, evt3)
evt4, err := g2b.MetadataStore().ListEvents(ctx, nil, nil, false)
require.NoError(t, err)
ops4 := testFilterAppMetadata(t, evt4)
assert.Equal(t, 2, len(ops1))
assert.Equal(t, 2, len(ops2))
assert.Equal(t, 4, len(ops3))
assert.Equal(t, 4, len(ops4))
} | explode_data.jsonl/53415 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1797
} | [
2830,
3393,
69123,
69026,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
31696,
11056,
1155,
11,
1273,
1314,
808,
10303,
340,
17060,
11,
21290,
1669,
1273,
1314,
12750,
1155,
340,
16867,
21290,
741,
20985,
11,
9121,
1669,
2266,
26124,
9269,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepareWithSnapshot(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
safePointName := "tikv_gc_safe_point"
safePointValue := "20060102-15:04:05 -0700"
safePointComment := "All versions after safe point can be accessed. (DO NOT EDIT)"
updateSafePoint := fmt.Sprintf(`INSERT INTO mysql.tidb VALUES ('%[1]s', '%[2]s', '%[3]s')
ON DUPLICATE KEY
UPDATE variable_value = '%[2]s', comment = '%[3]s'`, safePointName, safePointValue, safePointComment)
tk.MustExec(updateSafePoint)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(id int primary key, v int)")
tk.MustExec("insert into t select 1, 2")
tk.MustExec("begin")
ts := tk.MustQuery("select @@tidb_current_ts").Rows()[0][0].(string)
tk.MustExec("commit")
tk.MustExec("update t set v = 3 where id = 1")
tk.MustExec("prepare s1 from 'select * from t where id = 1';")
tk.MustExec("prepare s2 from 'select * from t';")
tk.MustExec("set @@tidb_snapshot = " + ts)
tk.MustQuery("execute s1").Check(testkit.Rows("1 2"))
tk.MustQuery("execute s2").Check(testkit.Rows("1 2"))
} | explode_data.jsonl/5507 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 440
} | [
2830,
3393,
50590,
2354,
15009,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
1903,
5645,
2609,
675,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerUnpublishVolume(t *testing.T) {
d, err := NewFakeDriver(t)
d.cloud = &azure.Cloud{}
if err != nil {
t.Fatalf("Error getting driver: %v", err)
}
tests := []struct {
desc string
req *csi.ControllerUnpublishVolumeRequest
expectedErr error
}{
{
desc: "Volume ID missing",
req: &csi.ControllerUnpublishVolumeRequest{},
expectedErr: status.Error(codes.InvalidArgument, "Volume ID not provided"),
},
{
desc: "Node ID missing",
req: &csi.ControllerUnpublishVolumeRequest{
VolumeId: "vol_1",
},
expectedErr: status.Error(codes.InvalidArgument, "Node ID not provided"),
},
{
desc: "DiskName error",
req: &csi.ControllerUnpublishVolumeRequest{
VolumeId: "vol_1",
NodeId: "unit-test-node",
},
expectedErr: fmt.Errorf("could not get disk name from vol_1, correct format: (?i).*/subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/disks/(.+)"),
},
}
for _, test := range tests {
_, err := d.ControllerUnpublishVolume(context.Background(), test.req)
if !reflect.DeepEqual(err, test.expectedErr) {
t.Errorf("desc: %s\n actualErr: (%v), expectedErr: (%v)", test.desc, err, test.expectedErr)
}
}
} | explode_data.jsonl/59385 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 508
} | [
2830,
3393,
2051,
1806,
27502,
18902,
1155,
353,
8840,
836,
8,
341,
2698,
11,
1848,
1669,
1532,
52317,
11349,
1155,
340,
2698,
16935,
284,
609,
39495,
94492,
16094,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1454,
3709,
5579,
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... | 4 |
func TestStep_Validate(t *testing.T) {
type TestCase struct {
data Step
expected error
actual error
}
var testdata []TestCase
name := []string{"", "test1", "test2", "test3", "test4", "test5", "aaaaaaaaaaaaaaaaaaaaaa", "123ABCabc", "$%&#@"}
typeD := []enums.STEP_TYPE{"DEPLOY", "DEPLOY", "BUILD", "", "sss", "BUILD", "BUILD", "BUILD", "BUILD"}
trigger := []enums.TRIGGER{"AUTO", "", "ssss", "MANUAL", "AUTO", "AUTO", "AUTO", "AUTO", "AUTO"}
params := []map[enums.PARAMS]string{{"type": "sss", "env": "12223"}, {"type": "sss", "env": "12223"}, {"type": "sss", "env": "12223"}, {"type": "sss", "env": "12223"}, {"type": "sss", "env": "12223"}, {"type": "", "env": "12223"}, {"type": "abc", "env": "12223"}, {"type": "abc", "env": "12223"}, {"type": "abc", "env": "12223"}}
expec := []error{errors.New("step name is required"), errors.New("step trigger is required"), errors.New("step trigger is invalid"), errors.New("step type is required"), errors.New("step type is invalid"), errors.New("step params is missing"), errors.New("step name length cannot be more than 16 character"), errors.New("step name can only contain lower case characters or digits"), errors.New("step name can only contain lower case characters or digits")}
for i := 0; i < 9; i++ {
testcase := TestCase{
data: Step{
Name: name[i],
Type: typeD[i],
Trigger: trigger[i],
Params: params[i],
Next: nil,
Descriptors: nil,
},
expected: expec[i],
}
testdata = append(testdata, testcase)
}
for i := 0; i < 9; i++ {
testdata[i].actual = testdata[i].data.Validate()
if !reflect.DeepEqual(testdata[i].expected, testdata[i].actual) {
fmt.Println(testdata[i].actual)
assert.ElementsMatch(t, testdata[i].expected, testdata[i].actual)
}
}
} | explode_data.jsonl/6695 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 713
} | [
2830,
3393,
8304,
62,
17926,
1155,
353,
8840,
836,
8,
341,
13158,
30573,
2036,
341,
197,
8924,
257,
14822,
198,
197,
42400,
1465,
198,
197,
88814,
256,
1465,
198,
197,
630,
2405,
1273,
691,
3056,
16458,
198,
11609,
1669,
3056,
917,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSpotOrderFills(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys required but not set, skipping test")
}
_, err := c.GetSpotOrderFills("1912131427156307968")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/42931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
1949,
47049,
4431,
37,
3305,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
7082,
6894,
2567,
714,
537,
738,
11,
42659,
1273,
1138,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMergeRequestList_hyperlinks(t *testing.T) {
noHyperlinkCells := [][]string{
{"!6", "MergeRequest one", "(master) ← (test1)"},
{"!7", "MergeRequest two", "(master) ← (test2)"},
}
hyperlinkCells := [][]string{
{makeHyperlink("!6", "http://gitlab.com/OWNER/REPO/merge_requests/6"), "MergeRequest one", "(master) ← (test1)"},
{makeHyperlink("!7", "http://gitlab.com/OWNER/REPO/merge_requests/7"), "MergeRequest two", "(master) ← (test2)"},
}
type hyperlinkTest struct {
forceHyperlinksEnv string
displayHyperlinksConfig string
isTTY bool
expectedCells [][]string
}
tests := []hyperlinkTest{
// FORCE_HYPERLINKS causes hyperlinks to be output, whether or not we're talking to a TTY
{forceHyperlinksEnv: "1", isTTY: true, expectedCells: hyperlinkCells},
{forceHyperlinksEnv: "1", isTTY: false, expectedCells: hyperlinkCells},
// empty/missing display_hyperlinks in config defaults to *not* outputting hyperlinks
{displayHyperlinksConfig: "", isTTY: true, expectedCells: noHyperlinkCells},
{displayHyperlinksConfig: "", isTTY: false, expectedCells: noHyperlinkCells},
// display_hyperlinks: false in config prevents outputting hyperlinks
{displayHyperlinksConfig: "false", isTTY: true, expectedCells: noHyperlinkCells},
{displayHyperlinksConfig: "false", isTTY: false, expectedCells: noHyperlinkCells},
// display_hyperlinks: true in config only outputs hyperlinks if we're talking to a TTY
{displayHyperlinksConfig: "true", isTTY: true, expectedCells: hyperlinkCells},
{displayHyperlinksConfig: "true", isTTY: false, expectedCells: noHyperlinkCells},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
fakeHTTP := httpmock.New()
defer fakeHTTP.Verify(t)
fakeHTTP.RegisterResponder("GET", "/projects/OWNER/REPO/merge_requests",
httpmock.NewStringResponse(200, `
[
{
"state" : "opened",
"description" : "a description here",
"project_id" : 1,
"updated_at" : "2016-01-04T15:31:51.081Z",
"id" : 76,
"title" : "MergeRequest one",
"created_at" : "2016-01-04T15:31:51.081Z",
"iid" : 6,
"labels" : ["foo", "bar"],
"target_branch": "master",
"source_branch": "test1",
"web_url": "http://gitlab.com/OWNER/REPO/merge_requests/6"
},
{
"state" : "opened",
"description" : "description two here",
"project_id" : 1,
"updated_at" : "2016-01-04T15:31:51.081Z",
"id" : 77,
"title" : "MergeRequest two",
"created_at" : "2016-01-04T15:31:51.081Z",
"iid" : 7,
"target_branch": "master",
"source_branch": "test2",
"labels" : ["fooz", "baz"],
"web_url": "http://gitlab.com/OWNER/REPO/merge_requests/7"
}
]
`))
doHyperlinks := "never"
if test.forceHyperlinksEnv == "1" {
doHyperlinks = "always"
} else if test.displayHyperlinksConfig == "true" {
doHyperlinks = "auto"
}
output, err := runCommand(fakeHTTP, test.isTTY, "", nil, doHyperlinks)
if err != nil {
t.Errorf("error running command `mr list`: %v", err)
}
out := output.String()
lines := strings.Split(strings.TrimRight(out, "\n"), "\n")
// first two lines have the header and some separating whitespace, so skip those
for lineNum, line := range lines[2:] {
gotCells := strings.Split(line, "\t")
expectedCells := test.expectedCells[lineNum]
assert.Equal(t, len(expectedCells), len(gotCells))
for cellNum, gotCell := range gotCells {
expectedCell := expectedCells[cellNum]
assert.Equal(t, expectedCell, strings.Trim(gotCell, " "))
}
}
})
}
} | explode_data.jsonl/48221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1446
} | [
2830,
3393,
52096,
1900,
852,
93416,
15880,
1155,
353,
8840,
836,
8,
341,
72104,
73946,
2080,
20857,
1669,
52931,
917,
515,
197,
197,
4913,
0,
21,
497,
330,
52096,
1900,
825,
497,
11993,
13629,
8,
47464,
320,
1944,
16,
96773,
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... | 6 |
func TestModifyConfig_empty(t *testing.T) {
e, err := newSchemaGenerator(&gen.Graph{
Config: &gen.Config{
Package: "example.com",
},
})
require.NoError(t, err)
e.relaySpec = false
cfg, err := e.genModels()
require.NoError(t, err)
expected := map[string]string{}
require.Equal(t, expected, cfg)
} | explode_data.jsonl/63032 | {
"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,
44427,
2648,
15124,
1155,
353,
8840,
836,
8,
341,
7727,
11,
1848,
1669,
501,
8632,
12561,
2099,
4370,
40237,
515,
197,
66156,
25,
609,
4370,
10753,
515,
298,
10025,
1434,
25,
330,
8687,
905,
756,
197,
197,
1583,
197,
3518,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTrie_Visit(t *testing.T) {
trie := NewTrie()
data := []testData{
{"Pepa", 0, success},
{"Pepa Zdepa", 1, success},
{"Pepa Kuchar", 2, success},
{"Honza", 3, success},
{"Jenik", 4, success},
}
for _, v := range data {
t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
}
}
if err := trie.Visit(func(prefix Prefix, item Item) error {
name := data[item.(int)].key
t.Logf("VISITING prefix=%q, item=%v", prefix, item)
if !strings.HasPrefix(string(prefix), name) {
t.Errorf("Unexpected prefix encountered, %q not a prefix of %q", prefix, name)
}
return nil
}); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/2363 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 347
} | [
2830,
3393,
51,
7231,
2334,
285,
275,
1155,
353,
8840,
836,
8,
341,
197,
8927,
1669,
1532,
51,
7231,
2822,
8924,
1669,
3056,
1944,
1043,
515,
197,
197,
4913,
47,
747,
64,
497,
220,
15,
11,
2393,
1583,
197,
197,
4913,
47,
747,
64,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParserTMText(t *testing.T) {
assertTextAndMarker(t, "foo${1:bar}}", "foobar}", &text{}, &placeholder{}, &text{})
assertTextAndMarker(t, "foo${1:bar}${2:foo}}", "foobarfoo}", &text{}, &placeholder{}, &placeholder{}, &text{})
assertTextAndMarker(t, "foo${1:bar\\}${2:foo}}", "foobar}foo", &text{}, &placeholder{})
parse := *newSnippetParser().parse("foo${1:bar\\}${2:foo}}", false, false)
ph := *parse[1].(*placeholder)
children := *ph._children
assertEqual(t, ph.index, 1)
assertMarkerTypes(t, children[0], &text{})
assertEqual(t, children[0].String(), "bar}")
assertMarkerTypes(t, children[1], &placeholder{})
assertEqual(t, children[1].String(), "foo")
} | explode_data.jsonl/60274 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
6570,
22034,
1178,
1155,
353,
8840,
836,
8,
341,
6948,
1178,
3036,
20613,
1155,
11,
330,
7975,
2365,
16,
25,
2257,
3417,
497,
330,
50267,
9545,
609,
1318,
22655,
609,
12384,
22655,
609,
1318,
37790,
6948,
1178,
3036,
20613,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemove(t *testing.T) {
s := NewScope()
items := []ScopeItem{
{550, 250}, {900, 600}, {10, 80}, {100, 400},
}
size := uint64(0)
for _, v := range items {
s.Insert(v.Address, v.Size)
size += v.Size
}
//删除元素的开始
s.Remove(900, 200)
s.Remove(10, 20)
s.Remove(550, 50)
s.Remove(100, 1)
shouldItems := []ScopeItem{
{30, 60}, {101, 399}, {600, 200}, {1100, 400},
}
should(t, s, shouldItems, 1059)
//删除掉元素
s.Remove(101, 399)
shouldItems = append(shouldItems[:1], shouldItems[2:]...)
should(t, s, shouldItems, 660)
s.Remove(500, 700)
shouldItems = []ScopeItem{{30, 60}, {1200, 300}}
should(t, s, shouldItems, 360)
s.Remove(500, 1000)
shouldItems = []ScopeItem{{30, 60}}
should(t, s, shouldItems, 60)
s.Remove(80, 10)
shouldItems = []ScopeItem{{30, 50}}
should(t, s, shouldItems, 50)
s.Remove(40, 10)
shouldItems = []ScopeItem{{30, 10}, {50, 30}}
should(t, s, shouldItems, 40)
} | explode_data.jsonl/17763 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
13021,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1532,
10803,
741,
46413,
1669,
3056,
10803,
1234,
515,
197,
197,
90,
20,
20,
15,
11,
220,
17,
20,
15,
2137,
314,
24,
15,
15,
11,
220,
21,
15,
15,
2137,
314,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDriverCreate(t *testing.T) {
denyAllDevmapper()
denyAllSyscall()
defer denyAllSyscall()
defer denyAllDevmapper()
calls := make(Set)
mockAllDevmapper(calls)
sysMount = func(source, target, fstype string, flags uintptr, data string) (err error) {
calls["sysMount"] = true
// FIXME: compare the exact source and target strings (inodes + devname)
if expectedSource := "/dev/mapper/docker-"; !strings.HasPrefix(source, expectedSource) {
t.Fatalf("Wrong syscall call\nExpected: Mount(%v)\nReceived: Mount(%v)\n", expectedSource, source)
}
if expectedTarget := "/tmp/docker-test-devmapper-"; !strings.HasPrefix(target, expectedTarget) {
t.Fatalf("Wrong syscall call\nExpected: Mount(%v)\nReceived: Mount(%v)\n", expectedTarget, target)
}
if expectedFstype := "ext4"; fstype != expectedFstype {
t.Fatalf("Wrong syscall call\nExpected: Mount(%v)\nReceived: Mount(%v)\n", expectedFstype, fstype)
}
if expectedFlags := uintptr(3236757504); flags != expectedFlags {
t.Fatalf("Wrong syscall call\nExpected: Mount(%v)\nReceived: Mount(%v)\n", expectedFlags, flags)
}
return nil
}
Mounted = func(mnt string) (bool, error) {
calls["Mounted"] = true
if !strings.HasPrefix(mnt, "/tmp/docker-test-devmapper-") || !strings.HasSuffix(mnt, "/mnt/1") {
t.Fatalf("Wrong mounted call\nExpected: Mounted(%v)\nReceived: Mounted(%v)\n", "/tmp/docker-test-devmapper-.../mnt/1", mnt)
}
return false, nil
}
sysSyscall = func(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
calls["sysSyscall"] = true
if trap != sysSysIoctl {
t.Fatalf("Unexpected syscall. Expecting SYS_IOCTL, received: %d", trap)
}
switch a2 {
case LoopSetFd:
calls["ioctl.loopsetfd"] = true
case LoopCtlGetFree:
calls["ioctl.loopctlgetfree"] = true
case LoopGetStatus64:
calls["ioctl.loopgetstatus"] = true
case LoopSetStatus64:
calls["ioctl.loopsetstatus"] = true
case LoopClrFd:
calls["ioctl.loopclrfd"] = true
case LoopSetCapacity:
calls["ioctl.loopsetcapacity"] = true
case BlkGetSize64:
calls["ioctl.blkgetsize"] = true
default:
t.Fatalf("Unexpected IOCTL. Received %d", a2)
}
return 0, 0, 0
}
func() {
d := newDriver(t)
calls.Assert(t,
"DmSetDevDir",
"DmLogWithErrnoInit",
"DmTaskSetName",
"DmTaskRun",
"DmTaskGetInfo",
"execRun",
"DmTaskCreate",
"DmTaskSetTarget",
"DmTaskSetCookie",
"DmUdevWait",
"DmTaskSetSector",
"DmTaskSetMessage",
"DmTaskSetAddNode",
"sysSyscall",
"ioctl.blkgetsize",
"ioctl.loopsetfd",
"ioctl.loopsetstatus",
"?ioctl.loopctlgetfree",
)
if err := d.Create("1", ""); err != nil {
t.Fatal(err)
}
calls.Assert(t,
"DmTaskCreate",
"DmTaskGetInfo",
"sysMount",
"DmTaskRun",
"DmTaskSetTarget",
"DmTaskSetSector",
"DmTaskSetCookie",
"DmUdevWait",
"DmTaskSetName",
"DmTaskSetMessage",
"DmTaskSetAddNode",
)
}()
runtime.GC()
calls.Assert(t,
"DmTaskDestroy",
)
} | explode_data.jsonl/45478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1333
} | [
2830,
3393,
11349,
4021,
1155,
353,
8840,
836,
8,
341,
2698,
32395,
2403,
1912,
7338,
3106,
741,
2698,
32395,
2403,
32792,
6659,
741,
16867,
23101,
2403,
32792,
6659,
741,
16867,
23101,
2403,
1912,
7338,
3106,
2822,
1444,
5583,
1669,
1281... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOperatorInitDryRun(t *testing.T) {
tests := []struct {
operatorNamespace string
watchedNamespaces string
}{
{
// default nss
operatorNamespace: "",
watchedNamespaces: "",
},
{
operatorNamespace: "test",
watchedNamespaces: "test1",
},
{
operatorNamespace: "",
watchedNamespaces: "test4, test5",
},
}
kubeClients = MockKubernetesClients
for _, test := range tests {
t.Run("", func(t *testing.T) {
args := []string{"operator", "init", "--dry-run"}
if test.operatorNamespace != "" {
args = append(args, "--operatorNamespace", test.operatorNamespace)
}
if test.watchedNamespaces != "" {
args = append(args, "--watchedNamespaces", test.watchedNamespaces)
}
rootCmd := GetRootCmd(args)
err := rootCmd.Execute()
assert.NoError(t, err)
readActions := map[string]bool{
"get": true,
"list": true,
"watch": true,
}
actions := extendedClient.Kube().(*fake.Clientset).Actions()
for _, action := range actions {
if v := readActions[action.GetVerb()]; !v {
t.Fatalf("unexpected action: %+v, expected %s", action.GetVerb(), "get")
}
}
})
}
} | explode_data.jsonl/67549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 491
} | [
2830,
3393,
18461,
3803,
85215,
6727,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
83041,
22699,
914,
198,
197,
6692,
34244,
7980,
27338,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
322,
1638,
308,
778,
198,
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... | 5 |
func TestMapProxy_Values(t *testing.T) {
var expecteds []string = make([]string, 10)
var ret []string = make([]string, 10)
for i := 0; i < 10; i++ {
mp.Put(strconv.Itoa(i), strconv.Itoa(i))
expecteds[i] = strconv.Itoa(i)
}
values, _ := mp.Values()
for j := 0; j < 10; j++ {
ret[j] = values[j].(string)
}
sort.Strings(ret)
if len(values) != len(expecteds) || !reflect.DeepEqual(ret, expecteds) {
t.Fatalf("map Values failed")
}
} | explode_data.jsonl/57018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
2227,
16219,
62,
6227,
1155,
353,
8840,
836,
8,
341,
2405,
3601,
82,
3056,
917,
284,
1281,
10556,
917,
11,
220,
16,
15,
340,
2405,
2112,
3056,
917,
284,
1281,
10556,
917,
11,
220,
16,
15,
340,
2023,
600,
1669,
220,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestMultiCloser(t *testing.T) {
c := New(context.TODO(), logrus.NewEntry(logrus.StandardLogger()), outErrCmdString[0], outErrCmdString[1:]...)
m, err := c.StdoutStderrPipe()
if err != nil {
t.Fatal(err)
}
if err := c.Cmd.Start(); err != nil {
t.Fatal(err)
}
bs, err := ioutil.ReadAll(m.stdout)
if err != nil {
t.Fatal(err)
}
if e := "out"; e != string(bytes.TrimSpace(bs)) {
t.Errorf("got: %s wanted: %s", string(bs), e)
}
bs, err = ioutil.ReadAll(m.stderr)
if err != nil {
t.Fatal(err)
}
if e := "error"; e != string(bytes.TrimSpace(bs)) {
t.Errorf("got: %s wanted: %s", string(bs), e)
}
} | explode_data.jsonl/60294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
20358,
51236,
799,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
5378,
90988,
1507,
1487,
20341,
7121,
5874,
12531,
20341,
53615,
7395,
11858,
700,
7747,
15613,
703,
58,
15,
1125,
700,
7747,
15613,
703,
58,
16,
28283,
3121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetBlockImages(t *testing.T) {
mockServer := NewMockHttpServer(200, SuccessGetBlockImagesContent)
defer mockServer.Close()
mockHttpClient := NewMockHttpClient(mockServer.URL)
client := NewRookNetworkRestClient(mockServer.URL, mockHttpClient)
getBlockImagesResponse, err := client.GetBlockImages()
assert.Nil(t, err)
assert.Equal(t, 2, len(getBlockImagesResponse))
expectedImage := model.BlockImage{
Name: "myimage2",
PoolName: "rbd2",
Size: 10485761,
}
var actualImage *model.BlockImage
for i := range getBlockImagesResponse {
if getBlockImagesResponse[i].Name == expectedImage.Name {
actualImage = &(getBlockImagesResponse[i])
break
}
}
assert.NotNil(t, actualImage)
assert.Equal(t, expectedImage, *actualImage)
} | explode_data.jsonl/27842 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
1949,
4713,
14228,
1155,
353,
8840,
836,
8,
341,
77333,
5475,
1669,
1532,
11571,
2905,
5475,
7,
17,
15,
15,
11,
13047,
1949,
4713,
14228,
2762,
340,
16867,
7860,
5475,
10421,
741,
77333,
26316,
1669,
1532,
11571,
26316,
3038... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteImageWithMultipleTags(t *testing.T) {
manager, fakeDocker := newTestDockerManager()
fakeDocker.Image = &dockertypes.ImageInspect{ID: "1111", RepoTags: []string{"foo", "bar"}}
manager.RemoveImage(kubecontainer.ImageSpec{Image: "1111"})
fakeDocker.AssertCallDetails(NewCalledDetail("inspect_image", nil),
NewCalledDetail("remove_image", []interface{}{"foo", dockertypes.ImageRemoveOptions{PruneChildren: true}}),
NewCalledDetail("remove_image", []interface{}{"bar", dockertypes.ImageRemoveOptions{PruneChildren: true}}))
} | explode_data.jsonl/31156 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
6435,
1906,
2354,
32089,
15930,
1155,
353,
8840,
836,
8,
341,
92272,
11,
12418,
35,
13659,
1669,
501,
2271,
35,
13659,
2043,
741,
1166,
726,
35,
13659,
7528,
284,
609,
77055,
529,
1804,
7528,
58533,
90,
915,
25,
330,
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 TestServerOkV2(t *testing.T) {
apm, teardown, err := setupServer(t, nil, nil)
require.NoError(t, err)
defer teardown()
baseUrl, client := apm.client(false)
req := makeTransactionV2Request(t, baseUrl)
req.Header.Add("Content-Type", "application/x-ndjson")
res, err := client.Do(req)
assert.NoError(t, err)
assert.Equal(t, http.StatusAccepted, res.StatusCode, body(t, res))
} | explode_data.jsonl/4936 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
5475,
11578,
53,
17,
1155,
353,
8840,
836,
8,
341,
69898,
76,
11,
49304,
11,
1848,
1669,
6505,
5475,
1155,
11,
2092,
11,
2092,
340,
17957,
35699,
1155,
11,
1848,
340,
16867,
49304,
2822,
24195,
2864,
11,
2943,
1669,
1443,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRound(t *testing.T) {
var tests = map[time.Duration]time.Duration{
// 599.935µs -> 560µs
559935 * time.Nanosecond: 560 * time.Microsecond,
// 1.55ms -> 2ms
1550 * time.Microsecond: 2 * time.Millisecond,
// 1.5555s -> 1.556s
1555500 * time.Microsecond: 1556 * time.Millisecond,
// 1m2.0035s -> 1m2.004s
62003500 * time.Microsecond: 62004 * time.Millisecond,
}
for dur, expected := range tests {
rounded := roundDuration(dur)
if rounded != expected {
t.Errorf("Expected %v, Got %v", expected, rounded)
}
}
} | explode_data.jsonl/29034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 237
} | [
2830,
3393,
27497,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
2415,
58,
1678,
33795,
60,
1678,
33795,
515,
197,
197,
322,
220,
20,
24,
24,
13,
24,
18,
20,
73048,
82,
1464,
220,
20,
21,
15,
73048,
82,
198,
197,
197,
20,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServerCreate(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc(testlib.CloudServerURL("/servers"), func(w http.ResponseWriter, r *http.Request) {
require.Equal(t, http.MethodPost, r.Method)
var scr *ServerCreateRequest
payload := []*ServerCreateRequest{scr}
require.NoError(t, json.NewDecoder(r.Body).Decode(&payload))
assert.Equal(t, "sapd123", payload[0].Name)
assert.Equal(t, "image", payload[0].OS.Type)
assert.Equal(t, "2c_2g", payload[0].FlavorName)
assert.Equal(t, "HDD", payload[0].RootDisk.Type)
assert.Equal(t, 40, payload[0].RootDisk.Size)
resp := `
{
"task_id": [
"71b9caeb-1df3-4a60-8741-fdea426fed4c"
]
}
`
_, _ = fmt.Fprint(w, resp)
})
scr := &ServerCreateRequest{
Name: "sapd123",
FlavorName: "2c_2g",
SSHKey: "sapd1",
Password: true,
RootDisk: &ServerDisk{40, "HDD"},
Type: "premium",
AvailabilityZone: "HN1",
OS: &ServerOS{"cbf5f34b-751b-42a5-830f-6b2324f61d5a", "image"},
}
task, err := client.Server.Create(ctx, scr)
require.NoError(t, err)
assert.Equal(t, "71b9caeb-1df3-4a60-8741-fdea426fed4c", task.Task[0])
} | explode_data.jsonl/35471 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 585
} | [
2830,
3393,
5475,
4021,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
741,
2109,
2200,
63623,
8623,
2740,
94492,
5475,
3144,
4283,
67696,
3975,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
17957,
12808,
1155... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestYAML(t *testing.T) {
viper.SetConfigName("docker-compose")
viper.AddConfigPath("../etcd/")
err := viper.ReadInConfig()
assert.NoError(t, err)
assert.Equal(t, []string{"12379:2379", "12380:2380"}, viper.GetStringSlice("services.etcd1.ports"))
} | explode_data.jsonl/67327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
56,
31102,
1155,
353,
8840,
836,
8,
341,
5195,
12858,
4202,
2648,
675,
445,
28648,
65070,
1138,
5195,
12858,
1904,
2648,
1820,
17409,
295,
4385,
14,
5130,
9859,
1669,
95132,
6503,
641,
2648,
741,
6948,
35699,
1155,
11,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_parser(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("Bitbucket parser", func() {
g.It("Should ignore unsupported hook", func() {
buf := bytes.NewBufferString(fixtures.HookPush)
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, "issue:created")
r, b, err := parseHook(req)
g.Assert(r == nil).IsTrue()
g.Assert(b == nil).IsTrue()
g.Assert(err == nil).IsTrue()
})
g.Describe("Given a pull request hook payload", func() {
g.It("Should return err when malformed", func() {
buf := bytes.NewBufferString("[]")
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, hookPullCreated)
_, _, err := parseHook(req)
g.Assert(err != nil).IsTrue()
})
g.It("Should return nil if not open", func() {
buf := bytes.NewBufferString(fixtures.HookMerged)
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, hookPullCreated)
r, b, err := parseHook(req)
g.Assert(r == nil).IsTrue()
g.Assert(b == nil).IsTrue()
g.Assert(err == nil).IsTrue()
})
g.It("Should return pull request details", func() {
buf := bytes.NewBufferString(fixtures.HookPull)
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, hookPullCreated)
r, b, err := parseHook(req)
g.Assert(err == nil).IsTrue()
g.Assert(r.FullName).Equal("user_name/repo_name")
g.Assert(b.Commit).Equal("ce5965ddd289")
})
})
g.Describe("Given a push hook payload", func() {
g.It("Should return err when malformed", func() {
buf := bytes.NewBufferString("[]")
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, hookPush)
_, _, err := parseHook(req)
g.Assert(err != nil).IsTrue()
})
g.It("Should return nil if missing commit sha", func() {
buf := bytes.NewBufferString(fixtures.HookPushEmptyHash)
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, hookPush)
r, b, err := parseHook(req)
g.Assert(r == nil).IsTrue()
g.Assert(b == nil).IsTrue()
g.Assert(err == nil).IsTrue()
})
g.It("Should return push details", func() {
buf := bytes.NewBufferString(fixtures.HookPush)
req, _ := http.NewRequest("POST", "/hook", buf)
req.Header = http.Header{}
req.Header.Set(hookEvent, hookPush)
r, b, err := parseHook(req)
g.Assert(err == nil).IsTrue()
g.Assert(r.FullName).Equal("user_name/repo_name")
g.Assert(b.Commit).Equal("709d658dc5b6d6afcd46049c2f332ee3f515a67d")
})
})
})
} | explode_data.jsonl/73849 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1199
} | [
2830,
3393,
18517,
1155,
353,
8840,
836,
8,
1476,
3174,
1669,
342,
47061,
1224,
47061,
1155,
340,
3174,
23548,
3114,
445,
8344,
30410,
6729,
497,
2915,
368,
1476,
197,
3174,
27528,
445,
14996,
10034,
40409,
9704,
497,
2915,
368,
341,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOptConfig(t *testing.T) {
assert := assert.New(t)
cfg := Config{
DefaultHeaders: map[string]string{"X-Debug": "debug-value"},
CookieName: "FOOBAR",
}
var app App
assert.Nil(OptConfig(cfg)(&app))
assert.Equal("FOOBAR", app.Auth.CookieDefaults.Name)
assert.NotEmpty(app.BaseHeaders)
assert.Equal([]string{"debug-value"}, app.BaseHeaders["X-Debug"])
assert.Equal([]string{PackageName}, app.BaseHeaders[webutil.HeaderServer])
} | explode_data.jsonl/7705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
21367,
2648,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
50286,
1669,
5532,
515,
197,
91084,
10574,
25,
2415,
14032,
30953,
4913,
55,
12,
7939,
788,
330,
8349,
19083,
7115,
197,
6258,
9619,
675,
25,
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 TestLinuxVersions(t *testing.T) {
for _, version := range common.GetAllSupportedKubernetesVersions(false, false) {
cs := getK8sDefaultContainerService(false)
cs.Properties.OrchestratorProfile.OrchestratorVersion = version
if err := cs.Validate(false); err != nil {
t.Errorf(
"should not error on valid Linux version: %v", err,
)
}
sv, _ := semver.Make(version)
cs = getK8sDefaultContainerService(false)
cs.Properties.OrchestratorProfile.OrchestratorRelease = fmt.Sprintf("%d.%d", sv.Major, sv.Minor)
if err := cs.Validate(false); err != nil {
t.Errorf(
"should not error on valid Linux version: %v", err,
)
}
}
cs := getK8sDefaultContainerService(false)
cs.Properties.OrchestratorProfile.OrchestratorRelease = "1.4"
if err := cs.Validate(false); err == nil {
t.Errorf(
"should error on invalid Linux version",
)
}
cs = getK8sDefaultContainerService(false)
cs.Properties.OrchestratorProfile.OrchestratorVersion = "1.4.0"
if err := cs.Validate(false); err == nil {
t.Errorf(
"should error on invalid Linux version",
)
}
} | explode_data.jsonl/17878 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
46324,
69015,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
2319,
1669,
2088,
4185,
45732,
34636,
42,
29827,
69015,
3576,
11,
895,
8,
341,
197,
71899,
1669,
633,
42,
23,
82,
3675,
4502,
1860,
3576,
340,
197,
71899,
15945,
9044... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMakeDefaultConfig(t *testing.T) {
var translateConfig = NewTranslationConfig()
if translateConfig != &DefaultLocaleConfig {
t.Errorf("%v=%v default config for translation instance is not equal", translateConfig, &DefaultLocaleConfig)
}
} | explode_data.jsonl/81778 | {
"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,
8078,
3675,
2648,
1155,
353,
8840,
836,
8,
341,
2405,
14683,
2648,
284,
1532,
24412,
2648,
2822,
743,
14683,
2648,
961,
609,
3675,
19231,
2648,
341,
197,
3244,
13080,
4430,
85,
7846,
85,
1638,
2193,
369,
14468,
2867,
374,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRealClockTimer(t *testing.T) {
c := Clock{}
d := time.Millisecond
tmr := c.NewTimer(d)
if _, fired := testutil.TryRead(tmr.C(), time.Second); !fired {
t.Fatalf("Timer did not fire after %v, wanted it to fire", time.Second)
}
if tmr.Stop() {
<-tmr.C()
}
tmr.Reset(time.Second)
} | explode_data.jsonl/25154 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
12768,
26104,
10105,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
26142,
16094,
2698,
1669,
882,
71482,
198,
3244,
20946,
1669,
272,
7121,
10105,
1500,
340,
743,
8358,
13895,
1669,
1273,
1314,
19824,
4418,
1155,
20946,
727,
1507,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSource(t *testing.T) {
scope := NewReferenceScope(TestTx)
for _, v := range sourceTests {
result, err := Source(context.Background(), scope, v.Expr)
if err != nil {
if len(v.Error) < 1 {
t.Errorf("%s: unexpected error %q", v.Name, err)
} else if err.Error() != v.Error {
t.Errorf("%s: error %q, want error %q", v.Name, err.Error(), v.Error)
}
continue
}
if 0 < len(v.Error) {
t.Errorf("%s: no error, want error %q", v.Name, v.Error)
continue
}
if !reflect.DeepEqual(result, v.Result) {
t.Errorf("%s: result = %q, want %q", v.Name, result, v.Result)
}
}
} | explode_data.jsonl/50840 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
3608,
1155,
353,
8840,
836,
8,
341,
66836,
1669,
1532,
8856,
10803,
31159,
31584,
692,
2023,
8358,
348,
1669,
2088,
2530,
18200,
341,
197,
9559,
11,
1848,
1669,
8748,
5378,
19047,
1507,
6891,
11,
348,
93267,
340,
197,
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... | 7 |
func TestIsDefault(t *testing.T) {
validate := New()
type Inner struct {
String string `validate:"isdefault"`
}
type Test struct {
String string `validate:"isdefault"`
Inner *Inner `validate:"isdefault"`
}
var tt Test
errs := validate.Struct(tt)
Equal(t, errs, nil)
tt.Inner = &Inner{String: ""}
errs = validate.Struct(tt)
NotEqual(t, errs, nil)
fe := errs.(ValidationErrors)[0]
Equal(t, fe.Field(), "Inner")
Equal(t, fe.Namespace(), "Test.Inner")
Equal(t, fe.Tag(), "isdefault")
validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
if name == "-" {
return ""
}
return name
})
type Inner2 struct {
String string `validate:"isdefault"`
}
type Test2 struct {
Inner Inner2 `validate:"isdefault" json:"inner"`
}
var t2 Test2
errs = validate.Struct(t2)
Equal(t, errs, nil)
t2.Inner.String = "Changed"
errs = validate.Struct(t2)
NotEqual(t, errs, nil)
fe = errs.(ValidationErrors)[0]
Equal(t, fe.Field(), "inner")
Equal(t, fe.Namespace(), "Test2.inner")
Equal(t, fe.Tag(), "isdefault")
} | explode_data.jsonl/77355 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 469
} | [
2830,
3393,
3872,
3675,
1155,
353,
8840,
836,
8,
341,
197,
7067,
1669,
1532,
2822,
13158,
36356,
2036,
341,
197,
4980,
914,
1565,
7067,
2974,
285,
2258,
8805,
197,
532,
13158,
3393,
2036,
341,
197,
4980,
914,
1565,
7067,
2974,
285,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestHideCaddyfile(t *testing.T) {
ctx := newContext(&caddy.Instance{Storage: make(map[interface{}]interface{})}).(*httpContext)
ctx.saveConfig("test", &SiteConfig{
Root: Root,
originCaddyfile: "Testfile",
})
err := hideCaddyfile(ctx)
if err != nil {
t.Fatalf("Failed to hide Caddyfile, got: %v", err)
return
}
if len(ctx.siteConfigs[0].HiddenFiles) == 0 {
t.Fatal("Failed to add Caddyfile to HiddenFiles.")
return
}
for _, file := range ctx.siteConfigs[0].HiddenFiles {
if file == "/Testfile" {
return
}
}
t.Fatal("Caddyfile missing from HiddenFiles")
} | explode_data.jsonl/26466 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
21692,
34,
22478,
1192,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
501,
1972,
2099,
66,
22478,
12688,
90,
5793,
25,
1281,
9147,
58,
4970,
78134,
4970,
28875,
16630,
4071,
1254,
1972,
340,
20985,
5681,
2648,
445,
1944,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestReplace(t *testing.T) {
v, _ := replace("aab", "a", "b")
assert.Equal(t, "bbb", v)
v, _ = replace("11a11", 1, 2)
assert.Equal(t, "22a22", v)
v, _ = replace(12345, 1, 2)
assert.Equal(t, "22345", v)
_, e := replace(tstNoStringer{}, "a", "b")
assert.NotNil(t, e, "tstNoStringer isn't trimmable")
_, e = replace("a", tstNoStringer{}, "b")
assert.NotNil(t, e, "tstNoStringer cannot be converted to string")
_, e = replace("a", "b", tstNoStringer{})
assert.NotNil(t, e, "tstNoStringer cannot be converted to string")
} | explode_data.jsonl/9241 | {
"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,
23107,
1155,
353,
8840,
836,
8,
341,
5195,
11,
716,
1669,
8290,
445,
88607,
497,
330,
64,
497,
330,
65,
1138,
6948,
12808,
1155,
11,
330,
53151,
497,
348,
340,
5195,
11,
716,
284,
8290,
445,
16,
16,
64,
16,
16,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParsesEnvInnerFails(t *testing.T) {
defer os.Clearenv()
type config struct {
Foo struct {
Number int `env:"NUMBER"`
}
}
os.Setenv("NUMBER", "not-a-number")
var cfg = config{}
assert.EqualError(t, Parse(&cfg), "env: parse error on field \"Number\" of type \"int\": strconv.ParseInt: parsing \"not-a-number\": invalid syntax")
} | explode_data.jsonl/78753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
47,
1561,
288,
14359,
31597,
37,
6209,
1155,
353,
8840,
836,
8,
341,
16867,
2643,
727,
273,
9151,
85,
741,
13158,
2193,
2036,
341,
197,
12727,
2624,
2036,
341,
298,
197,
2833,
526,
1565,
3160,
2974,
51639,
8805,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewElasticsearchCRWhenNodeSelectorIsDefined(t *testing.T) {
expSelector := map[string]string{
"foo": "bar",
}
cluster := &logging.ClusterLogging{
Spec: logging.ClusterLoggingSpec{
LogStore: &logging.LogStoreSpec{
Type: "elasticsearch",
ElasticsearchSpec: logging.ElasticsearchSpec{
NodeSelector: expSelector,
},
},
},
}
cr := &ClusterLoggingRequest{
Cluster: cluster,
}
existing := &elasticsearch.Elasticsearch{}
elasticsearchCR := cr.newElasticsearchCR("test-app-name", existing)
if !reflect.DeepEqual(elasticsearchCR.Spec.Spec.NodeSelector, expSelector) {
t.Errorf("Exp. the nodeSelector to be %q but was %q", expSelector, elasticsearchCR.Spec.Spec.NodeSelector)
}
} | explode_data.jsonl/72369 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 281
} | [
2830,
3393,
3564,
36,
51179,
1836,
8973,
4498,
1955,
5877,
3872,
29361,
1155,
353,
8840,
836,
8,
341,
48558,
5877,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
7975,
788,
330,
2257,
756,
197,
532,
197,
18855,
1669,
609,
25263,
72883,
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 TestImporter_Add_Closed(t *testing.T) {
tree, err := NewMutableTree(db.NewMemDB(), 0)
require.NoError(t, err)
importer, err := tree.Import(1)
require.NoError(t, err)
importer.Close()
err = importer.Add(&ExportNode{Key: []byte("key"), Value: []byte("value"), Version: 1, Height: 0})
require.Error(t, err)
require.Equal(t, ErrNoImport, err)
} | explode_data.jsonl/25879 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
77289,
21346,
920,
9259,
1155,
353,
8840,
836,
8,
341,
51968,
11,
1848,
1669,
1532,
11217,
6533,
9791,
7121,
18816,
3506,
1507,
220,
15,
340,
17957,
35699,
1155,
11,
1848,
340,
21918,
261,
11,
1848,
1669,
4916,
67275,
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... | 1 |
func TestParseNotification(t *testing.T) {
tests := []struct {
notif *Notification
comment string
}{
{
notif: nil,
comment: "I have nothing to do with a notification",
},
{
notif: nil,
comment: " [NOTIF] Line can't start with space",
},
{
notif: nil,
comment: "[NOTIF SOMETHING] Notif name can't have space",
},
{
notif: &Notification{Name: "NOTIF"},
comment: "[NOTIF]",
},
{
notif: nil,
comment: "Notif must be at the very beginning:\n[NOTIF]\nAnd something else...",
},
{
notif: &Notification{Name: "NOTIF", Arguments: "Valid notification"},
comment: "[NOTIF] Valid notification",
},
{
notif: &Notification{Name: "NOTIF", Arguments: "Multiple Lines"},
comment: "[NOTIF] Multiple Lines \nAnd something else...",
},
{
notif: &Notification{Name: "NOTIF", Arguments: "Notif name is upper-cased"},
comment: "[notif] Notif name is upper-cased",
},
{
notif: &Notification{Name: "NOTIF", Arguments: "Arguments is trimmed"},
comment: "[notif] Arguments is trimmed ",
},
}
for _, test := range tests {
actualNotif := ParseNotification(&github.IssueComment{Body: &test.comment})
if !reflect.DeepEqual(actualNotif, test.notif) {
t.Error(actualNotif, "doesn't match expected notif:", test.notif)
}
}
} | explode_data.jsonl/10275 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 548
} | [
2830,
3393,
14463,
11196,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
85046,
256,
353,
11196,
198,
197,
96268,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
85046,
25,
256,
2092,
345,
298,
96268,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDuplicateDomain(t *testing.T) {
expectConfigPanic(
t,
func() {
files := loadFile("basic_config.yaml")
files = append(files, loadFile("duplicate_domain.yaml")...)
config.NewRateLimitConfigImpl(files, stats.NewStore(stats.NewNullSink(), false))
},
"duplicate_domain.yaml: duplicate domain 'test-domain' in config file")
} | explode_data.jsonl/41131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
53979,
13636,
1155,
353,
8840,
836,
8,
341,
24952,
2648,
47,
31270,
1006,
197,
3244,
345,
197,
29244,
368,
341,
298,
74075,
1669,
2795,
1703,
445,
22342,
5332,
33406,
1138,
298,
74075,
284,
8737,
32544,
11,
2795,
1703,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStringOrByteArray(t *testing.T) {
for _, testCase := range testCases {
result := stringOrByteArray(testCase.input)
if result != testCase.output {
t.Errorf("[Test Failed] Expeced: %s, Returned: %s", testCase.output, result)
}
}
} | explode_data.jsonl/74097 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
703,
2195,
18394,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
54452,
1669,
2088,
1273,
37302,
341,
197,
9559,
1669,
914,
2195,
18394,
8623,
4207,
10046,
340,
197,
743,
1102,
961,
54452,
13413,
341,
298,
3244,
13080,
10937,
227... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServer_StreamBlocks_ContextCanceled(t *testing.T) {
db, _ := dbTest.SetupDB(t)
ctx := context.Background()
chainService := &chainMock.ChainService{}
ctx, cancel := context.WithCancel(ctx)
server := &Server{
Ctx: ctx,
BlockNotifier: chainService.BlockNotifier(),
HeadFetcher: chainService,
BeaconDB: db,
}
exitRoutine := make(chan bool)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockStream := mock.NewMockBeaconChain_StreamBlocksServer(ctrl)
mockStream.EXPECT().Context().Return(ctx)
go func(tt *testing.T) {
assert.ErrorContains(tt, "Context canceled", server.StreamBlocks(&ptypes.Empty{}, mockStream))
<-exitRoutine
}(t)
cancel()
exitRoutine <- true
} | explode_data.jsonl/36482 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
5475,
80631,
29804,
71994,
63263,
1155,
353,
8840,
836,
8,
341,
20939,
11,
716,
1669,
2927,
2271,
39820,
3506,
1155,
340,
20985,
1669,
2266,
19047,
2822,
197,
8819,
1860,
1669,
609,
8819,
11571,
98269,
1860,
16094,
20985,
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 TestAdvertise(t *testing.T) {
s2 := zktest.New()
z, ch, _ := s2.Connect()
z2, ch2, _ := s2.Connect()
zkConnFunc := ZkConnCreatorFunc(func() (ZkConn, <-chan zk.Event, error) {
zkp, err := zkplus.NewBuilder().PathPrefix("/test").Connector(&zkplus.StaticConnector{C: z, Ch: ch}).Build()
return zkp, zkp.EventChan(), err
})
zkConnFunc2 := ZkConnCreatorFunc(func() (ZkConn, <-chan zk.Event, error) {
zkp, err := zkplus.NewBuilder().PathPrefix("/test").Connector(&zkplus.StaticConnector{C: z2, Ch: ch2}).Build()
return zkp, zkp.EventChan(), err
})
testAdvertise(t, zkConnFunc, zkConnFunc2)
} | explode_data.jsonl/46869 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
2589,
67787,
1155,
353,
8840,
836,
8,
341,
1903,
17,
1669,
94528,
1944,
7121,
741,
20832,
11,
521,
11,
716,
1669,
274,
17,
43851,
741,
20832,
17,
11,
521,
17,
11,
716,
1669,
274,
17,
43851,
741,
20832,
74,
9701,
9626,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContainsTransfer(t *testing.T) {
p := smartcontract.NewParserWithScript("05007f3e3602146b55668bb616336a5c6d2da6a035e4eb856f88c41445fc40a091bd0de5e5408e3dbf6b023919a6f7d953c1087472616e7366657267c5cc1cb5392019e2cc4e6d6b5ea54c8d4b6d11acf166605efb0156b867db")
contains := p.ContainsOperation("transfer")
log.Printf("%v", contains)
if contains == false {
t.Fail()
}
} | explode_data.jsonl/28986 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
23805,
21970,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
7785,
20257,
7121,
6570,
2354,
5910,
445,
15,
20,
15,
15,
22,
69,
18,
68,
18,
21,
15,
17,
16,
19,
21,
65,
20,
20,
21,
21,
23,
6066,
21,
16,
21,
18,
18,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCloudProviderNoRateLimit(t *testing.T) {
fnh := &testutil.FakeNodeHandler{
Existing: []*v1.Node{
{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{
Type: v1.NodeReady,
Status: v1.ConditionUnknown,
LastHeartbeatTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
LastTransitionTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
},
},
},
},
},
Clientset: fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{*testutil.NewPod("pod0", "node0"), *testutil.NewPod("pod1", "node0")}}),
DeleteWaitChan: make(chan struct{}),
}
nodeController, _ := newNodeLifecycleControllerFromClient(
nil,
fnh,
10*time.Minute,
testRateLimiterQPS,
testRateLimiterQPS,
testLargeClusterThreshold,
testUnhealthyThreshold,
testNodeMonitorGracePeriod,
testNodeStartupGracePeriod,
testNodeMonitorPeriod,
false)
nodeController.cloud = &fakecloud.FakeCloud{}
nodeController.now = func() metav1.Time { return metav1.Date(2016, 1, 1, 12, 0, 0, 0, time.UTC) }
nodeController.recorder = testutil.NewFakeRecorder()
nodeController.nodeExistsInCloudProvider = func(nodeName types.NodeName) (bool, error) {
return false, nil
}
nodeController.nodeShutdownInCloudProvider = func(ctx context.Context, node *v1.Node) (bool, error) {
return false, nil
}
// monitorNodeHealth should allow this node to be immediately deleted
if err := nodeController.syncNodeStore(fnh); err != nil {
t.Errorf("unexpected error: %v", err)
}
if err := nodeController.monitorNodeHealth(); err != nil {
t.Errorf("unexpected error: %v", err)
}
select {
case <-fnh.DeleteWaitChan:
case <-time.After(wait.ForeverTestTimeout):
t.Errorf("Timed out waiting %v for node to be deleted", wait.ForeverTestTimeout)
}
if len(fnh.DeletedNodes) != 1 || fnh.DeletedNodes[0].Name != "node0" {
t.Errorf("Node was not deleted")
}
if nodeOnQueue := nodeController.zonePodEvictor[""].Remove("node0"); nodeOnQueue {
t.Errorf("Node was queued for eviction. Should have been immediately deleted.")
}
} | explode_data.jsonl/9613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 923
} | [
2830,
3393,
16055,
5179,
2753,
11564,
16527,
1155,
353,
8840,
836,
8,
341,
1166,
16719,
1669,
609,
1944,
1314,
991,
726,
1955,
3050,
515,
197,
197,
53067,
25,
29838,
85,
16,
21714,
515,
298,
197,
515,
571,
23816,
12175,
25,
77520,
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 TestParsesEnvInnerNil(t *testing.T) {
os.Setenv("innervar", "someinnervalue")
defer os.Clearenv()
cfg := ParentStruct{}
assert.NoError(t, Parse(&cfg))
} | explode_data.jsonl/78754 | {
"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,
47,
1561,
288,
14359,
31597,
19064,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
445,
6130,
648,
277,
497,
330,
14689,
6130,
648,
540,
1138,
16867,
2643,
727,
273,
9151,
85,
741,
50286,
1669,
17022,
9422,
16094,
6948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSTSClient_AssumeRole(t *testing.T) {
client := NewTestClient()
roleArn := os.Getenv("RoleArn")
req := AssumeRoleRequest{
RoleArn: roleArn,
RoleSessionName: fmt.Sprintf("commander-role-%d", time.Now().Unix()),
DurationSeconds: 3600,
}
response, err := client.AssumeRole(req)
if err != nil {
t.Fatalf("%++v", err)
} else {
t.Logf("Response=%++v", response)
}
} | explode_data.jsonl/71435 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
80725,
2959,
62222,
3885,
9030,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
1532,
2271,
2959,
2822,
197,
5778,
58331,
1669,
2643,
64883,
445,
9030,
58331,
5130,
24395,
1669,
62197,
9030,
1900,
515,
197,
197,
9030,
58331,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestJobManagerSubmitJob(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mockMaster := lib.NewMockMasterImpl("", "submit-job-test")
mockMaster.On("InitImpl", mock.Anything).Return(nil)
mockMaster.MasterClient().On(
"ScheduleTask", mock.Anything, mock.Anything, mock.Anything).Return(
&pb.ScheduleTaskResponse{}, errors.ErrClusterResourceNotEnough.FastGenByArgs(),
)
mgr := &JobManagerImplV2{
BaseMaster: mockMaster.DefaultBaseMaster,
JobFsm: NewJobFsm(),
clocker: clock.New(),
uuidGen: uuid.NewGenerator(),
frameMetaClient: mockMaster.GetFrameMetaClient(),
masterMetaClient: metadata.NewMasterMetadataClient(metadata.JobManagerUUID, mockMaster.GetFrameMetaClient()),
jobStatusChangeMu: ctxmu.New(),
notifier: notifier.NewNotifier[resManager.JobStatusChangeEvent](),
}
// set master impl to JobManagerImplV2
mockMaster.Impl = mgr
err := mockMaster.Init(ctx)
require.Nil(t, err)
req := &pb.SubmitJobRequest{
Tp: pb.JobType_CVSDemo,
Config: []byte("{\"srcHost\":\"0.0.0.0:1234\", \"dstHost\":\"0.0.0.0:1234\", \"srcDir\":\"data\", \"dstDir\":\"data1\"}"),
}
resp := mgr.SubmitJob(ctx, req)
require.Nil(t, resp.Err)
err = mockMaster.Poll(ctx)
require.NoError(t, err)
require.Eventually(t, func() bool {
return mgr.JobFsm.JobCount(pb.QueryJobResponse_online) == 0 &&
mgr.JobFsm.JobCount(pb.QueryJobResponse_dispatched) == 1 &&
mgr.JobFsm.JobCount(pb.QueryJobResponse_pending) == 0
}, time.Second*2, time.Millisecond*20)
queryResp := mgr.QueryJob(ctx, &pb.QueryJobRequest{JobId: resp.JobIdStr})
require.Nil(t, queryResp.Err)
require.Equal(t, pb.QueryJobResponse_dispatched, queryResp.Status)
} | explode_data.jsonl/29353 | {
"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,
12245,
2043,
8890,
12245,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
77333,
18041,
1669,
3051,
7121,
11571,
18041,
9673,
19814,
330,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMakeUserActiveAndInactive(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
// first inactivate the user
th.CheckCommand(t, "user", "deactivate", th.BasicUser.Email)
// activate the inactive user
th.CheckCommand(t, "user", "activate", th.BasicUser.Email)
} | explode_data.jsonl/57420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
8078,
1474,
5728,
3036,
72214,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
197,
322,
1156,
304,
16856,
279,
1196,
198,
70479,
10600,
4062,
1155,
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 TestAltKeyring_UnsafeExportPrivKeyHex(t *testing.T) {
keyring, err := New(t.Name(), BackendTest, t.TempDir(), nil)
require.NoError(t, err)
uid := theID
_, _, err = keyring.NewMnemonic(uid, English, sdk.FullFundraiserPath, hd.Secp256k1)
require.NoError(t, err)
unsafeKeyring := NewUnsafe(keyring)
privKey, err := unsafeKeyring.UnsafeExportPrivKeyHex(uid)
require.NoError(t, err)
require.Equal(t, 64, len(privKey))
_, err = hex.DecodeString(privKey)
require.NoError(t, err)
// test error on non existing key
_, err = unsafeKeyring.UnsafeExportPrivKeyHex("non-existing")
require.Error(t, err)
} | explode_data.jsonl/73466 | {
"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,
26017,
1592,
12640,
40687,
18675,
16894,
32124,
1592,
20335,
1155,
353,
8840,
836,
8,
341,
23634,
12640,
11,
1848,
1669,
1532,
1155,
2967,
1507,
55260,
2271,
11,
259,
65009,
6184,
1507,
2092,
340,
17957,
35699,
1155,
11,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSpeciateEvolveMerge(t *testing.T) {
var (
rng = newRand()
testCases = []struct {
pop Population
speciator Speciator
model Model
err error
}{
{
pop: Population{
ID: "42",
RNG: rng,
Individuals: Individuals{
Individual{Fitness: 0},
Individual{Fitness: 1},
Individual{Fitness: 2},
Individual{Fitness: 3},
Individual{Fitness: 4},
},
},
speciator: SpecFitnessInterval{3},
model: ModIdentity{},
err: nil,
},
{
pop: Population{
ID: "42",
RNG: rng,
Individuals: Individuals{
Individual{Fitness: 0},
Individual{Fitness: 1},
Individual{Fitness: 2},
},
},
speciator: SpecFitnessInterval{4},
model: ModIdentity{},
err: errors.New("Invalid speciator"),
},
{
pop: Population{
ID: "42",
RNG: rng,
Individuals: Individuals{
Individual{Fitness: 0},
Individual{Fitness: 1},
Individual{Fitness: 2},
Individual{Fitness: 3},
Individual{Fitness: 4},
},
},
speciator: SpecFitnessInterval{3},
model: ModGenerational{
Selector: SelTournament{6},
MutRate: 0.5,
},
err: errors.New("Invalid model"),
},
}
)
for i, tc := range testCases {
t.Run(fmt.Sprintf("TC %d", i), func(t *testing.T) {
var err = tc.pop.speciateEvolveMerge(tc.speciator, tc.model)
if (err == nil) != (tc.err == nil) {
t.Errorf("Wrong error in test case number %d", i)
}
// If there is no error check the Individuals are ordered as they were
// initially
if err == nil {
for j, indi := range tc.pop.Individuals {
if indi.Fitness != float64(j) {
t.Errorf("Wrong result in test case number %d", i)
}
}
}
})
}
} | explode_data.jsonl/82084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 901
} | [
2830,
3393,
8327,
6493,
34112,
3948,
52096,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
7000,
968,
981,
284,
501,
56124,
741,
197,
18185,
37302,
284,
3056,
1235,
341,
298,
74813,
981,
39529,
198,
298,
98100,
36122,
10956,
36122,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_list_buildPart(t *testing.T) {
l := &List{}
p := NewPartition("p1122", "1122", "test1122")
expect := "PARTITION p1122 VALUES IN (1122) COMMENT = 'test1122'"
result, err := l.buildPart(p)
if err != nil {
t.Fatal("error build part.", err.Error())
}
if diff := cmp.Diff(result, expect); diff != "" {
t.Fatalf("error invalid result:%s", diff)
}
} | explode_data.jsonl/77604 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
2019,
20801,
5800,
1155,
353,
8840,
836,
8,
341,
8810,
1669,
609,
852,
31483,
3223,
1669,
1532,
49978,
445,
79,
16,
16,
17,
17,
497,
330,
16,
16,
17,
17,
497,
330,
1944,
16,
16,
17,
17,
1138,
24952,
1669,
330,
33490,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSQLValue2Validation(t *testing.T) {
validate := New()
validate.RegisterCustomTypeFunc(ValidateValuerType, valuer{}, (*driver.Valuer)(nil), sql.NullString{}, sql.NullInt64{}, sql.NullBool{}, sql.NullFloat64{})
validate.RegisterCustomTypeFunc(ValidateCustomType, MadeUpCustomType{})
validate.RegisterCustomTypeFunc(OverrideIntTypeForSomeReason, 1)
val := valuer{
Name: "",
}
errs := validate.Var(val, "required")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "required")
val.Name = "Valid Name"
errs = validate.VarCtx(context.Background(), val, "required")
Equal(t, errs, nil)
val.Name = "errorme"
PanicMatches(t, func() { _ = validate.Var(val, "required") }, "SQL Driver Valuer error: some kind of error")
myVal := valuer{
Name: "",
}
errs = validate.Var(myVal, "required")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "required")
cust := MadeUpCustomType{
FirstName: "Joey",
LastName: "Bloggs",
}
c := CustomMadeUpStruct{MadeUp: cust, OverriddenInt: 2}
errs = validate.Struct(c)
Equal(t, errs, nil)
c.MadeUp.FirstName = ""
c.OverriddenInt = 1
errs = validate.Struct(c)
NotEqual(t, errs, nil)
Equal(t, len(errs.(ValidationErrors)), 2)
AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "CustomMadeUpStruct.MadeUp", "MadeUp", "MadeUp", "required")
AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "OverriddenInt", "gt")
} | explode_data.jsonl/77233 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 570
} | [
2830,
3393,
6688,
1130,
17,
13799,
1155,
353,
8840,
836,
8,
1476,
197,
7067,
1669,
1532,
741,
197,
7067,
19983,
10268,
929,
9626,
7,
17926,
2208,
8801,
929,
11,
1044,
8801,
22655,
4609,
12521,
77819,
8801,
2376,
8385,
701,
5704,
23979,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsPrecertificate(t *testing.T) {
tests := []struct {
desc string
certPEM string
want bool
}{
{
desc: "certificate",
certPEM: pemCertificate,
want: false,
},
{
desc: "precertificate",
certPEM: pemPrecertificate,
want: true,
},
{
desc: "nil",
certPEM: "",
want: false,
},
}
for _, test := range tests {
var cert *Certificate
if test.certPEM != "" {
var err error
cert, err = certificateFromPEM(test.certPEM)
if err != nil {
t.Errorf("%s: error parsing certificate: %s", test.desc, err)
continue
}
}
if got := cert.IsPrecertificate(); got != test.want {
t.Errorf("%s: c.IsPrecertificate() = %t, want %t", test.desc, got, test.want)
}
}
} | explode_data.jsonl/67991 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
3872,
68833,
20962,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
262,
914,
198,
197,
1444,
529,
1740,
44,
914,
198,
197,
50780,
262,
1807,
198,
197,
59403,
197,
197,
515,
298,
41653,
25,
262,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestContains(t *testing.T) {
tests := []struct {
enclosing, contained string
contains bool
}{
// A region contains itself.
{"US", "US", true},
{"001", "001", true},
// Direct containment.
{"001", "002", true},
{"039", "XK", true},
{"150", "XK", true},
{"EU", "AT", true},
{"QO", "AQ", true},
// Indirect containemnt.
{"001", "US", true},
{"001", "419", true},
{"001", "013", true},
// No containment.
{"US", "001", false},
{"155", "EU", false},
}
for i, tt := range tests {
r := MustParseRegion(tt.enclosing)
con := MustParseRegion(tt.contained)
if got := r.Contains(con); got != tt.contains {
t.Errorf("%d: %s.Contains(%s) was %v; want %v", i, tt.enclosing, tt.contained, got, tt.contains)
}
}
} | explode_data.jsonl/15841 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
23805,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
954,
17831,
11,
12985,
914,
198,
197,
197,
13372,
1797,
1807,
198,
197,
59403,
197,
197,
322,
362,
5537,
5610,
5086,
624,
197,
197,
4913,
2034,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSample1(t *testing.T) {
points := [][]int{{2, 1}, {2, 2}, {3, 3}}
angle := 90
loc := []int{1, 1}
expect := 3
runSample(t, points, angle, loc, expect)
} | explode_data.jsonl/9007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
17571,
16,
1155,
353,
8840,
836,
8,
341,
67499,
1669,
52931,
396,
2979,
17,
11,
220,
16,
2137,
314,
17,
11,
220,
17,
2137,
314,
18,
11,
220,
18,
11248,
82341,
1669,
220,
24,
15,
198,
71128,
1669,
3056,
396,
90,
16,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeduplicate(t *testing.T) {
testCases := []struct {
src []string
expect []string
}{
{
src: []string{"a", "b", "c", "d", "e", "f"},
expect: []string{"a", "b", "c", "d", "e", "f"},
},
{
src: []string{"a", "b", "c", "b", "e", "f"},
expect: []string{"a", "b", "c", "e", "f"},
},
{
src: []string{"a", "a", "b", "b", "c", "b"},
expect: []string{"a", "b", "c"},
},
}
for _, testCase := range testCases {
get := deduplicate(testCase.src)
if !reflect.DeepEqual(get, testCase.expect) {
t.Errorf("expect: %v, get: %v", testCase.expect, get)
}
}
} | explode_data.jsonl/67860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
35,
291,
14070,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41144,
262,
3056,
917,
198,
197,
24952,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
41144,
25,
262,
3056,
917,
4913,
64,
497,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetEnvAsFloat64OrFallback(t *testing.T) {
const expected = 1.0
assert := assert.New(t)
key := "FLOCKER_SET_VAR"
os.Setenv(key, "1.0")
returnVal, _ := GetEnvAsFloat64OrFallback(key, 2.0)
assert.Equal(expected, returnVal)
key = "FLOCKER_UNSET_VAR"
returnVal, _ = GetEnvAsFloat64OrFallback(key, 1.0)
assert.Equal(expected, returnVal)
} | explode_data.jsonl/36782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
1949,
14359,
2121,
5442,
21,
19,
2195,
87206,
1155,
353,
8840,
836,
8,
341,
4777,
3601,
284,
220,
16,
13,
15,
271,
6948,
1669,
2060,
7121,
1155,
692,
23634,
1669,
330,
37,
8044,
640,
8481,
25750,
698,
25078,
4202,
3160,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetClientAccessInfoFailure(t *testing.T) {
clientFunc := func(client RookRestClient) (interface{}, error) {
return client.GetClientAccessInfo()
}
verifyFunc := func(resp interface{}, err error) {
assert.NotNil(t, err)
assert.Equal(t, model.ClientAccessInfo{}, resp.(model.ClientAccessInfo))
}
ClientFailureHelperWithVerification(t, clientFunc, verifyFunc)
} | explode_data.jsonl/27857 | {
"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,
1949,
2959,
6054,
1731,
17507,
1155,
353,
8840,
836,
8,
341,
25291,
9626,
1669,
2915,
12805,
431,
1941,
12416,
2959,
8,
320,
4970,
22655,
1465,
8,
341,
197,
853,
2943,
2234,
2959,
6054,
1731,
741,
197,
532,
93587,
9626,
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 TestKeySend(t *testing.T) {
t.Run("enabled", func(t *testing.T) {
testKeySend(t, true)
})
t.Run("disabled", func(t *testing.T) {
testKeySend(t, false)
})
} | explode_data.jsonl/59115 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
1592,
11505,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
15868,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
18185,
1592,
11505,
1155,
11,
830,
340,
197,
3518,
3244,
16708,
445,
11978,
497,
2915,
1155,
353,
8840,
836,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientDoJSONResponseIsNotJSON(t *testing.T) {
client := newClient()
client.HTTPClient = &http.Client{Transport: httpx.FakeTransport{
Resp: &http.Response{
StatusCode: 200,
Body: httpx.FakeBody{
Err: io.EOF,
},
},
}}
err := client.DoJSON(&http.Request{URL: &url.URL{Scheme: "https", Host: "x.org"}}, nil)
if err == nil || err.Error() != "unexpected end of JSON input" {
t.Fatal("not the error we expected")
}
} | explode_data.jsonl/60971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
2959,
5404,
5370,
2582,
3872,
2623,
5370,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
2959,
741,
25291,
27358,
2959,
284,
609,
1254,
11716,
90,
27560,
25,
1758,
87,
991,
726,
27560,
515,
197,
197,
36555,
25,
609,
1254,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_MemoryStore_Del(t *testing.T) {
m := NewMemoryStore()
m.Open()
pm := newPublishMsg(QOS_ONE, "/a/b/c", []byte{0xBE, 0xEF, 0xED})
pm.setMsgId(17)
key := obound_mid2key(pm.MsgId())
m.Put(key, pm)
if len(m.messages) != 1 {
t.Fatalf("message not in store")
}
m.Del(key)
if len(m.messages) != 1 {
t.Fatalf("message still exists after deletion")
}
} | explode_data.jsonl/37297 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
1245,
4731,
6093,
1557,
301,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
10642,
6093,
741,
2109,
12953,
2822,
86511,
1669,
501,
50145,
6611,
6253,
3126,
34727,
11,
3521,
64,
3470,
2899,
497,
3056,
3782,
90,
15,
85449,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOpenIdImplicitFlowRejectsTokenWithoutPrivileges(t *testing.T) {
clockTime := time.Date(2021, 12, 1, 0, 0, 0, 0, time.UTC)
util.Clock = util.ClockMock{Time: clockTime}
cfg := config.NewConfig()
cfg.LoginToken.SigningKey = "kiali67890123456"
cfg.LoginToken.ExpirationSeconds = 1
config.Set(cfg)
// No namespaces should result in auth failure
k8s := kubetest.NewK8SClientMock()
k8s.On("GetProjects", "").Return([]osproject_v1.Project{}, nil)
stateHash := sha256.Sum224([]byte(fmt.Sprintf("%s+%s+%s", "nonceString", clockTime.UTC().Format("060102150405"), config.GetSigningKey())))
requestBody := strings.NewReader(fmt.Sprintf("id_token=%s&state=%x-%s", openIdTestToken, stateHash, clockTime.UTC().Format("060102150405")))
request := httptest.NewRequest(http.MethodPost, "/api/authenticate", requestBody)
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
request.AddCookie(&http.Cookie{
Name: OpenIdNonceCookieName,
Value: "nonceString",
})
controller := NewOpenIdAuthController(CookieSessionPersistor{}, func(authInfo *api.AuthInfo) (*business.Layer, error) {
if authInfo.Token != openIdTestToken {
return nil, errors.New("unexpected token")
}
return business.NewWithBackends(k8s, nil, nil), nil
})
rr := httptest.NewRecorder()
sData, err := controller.Authenticate(request, rr)
assert.NotNil(t, err)
assert.IsType(t, &AuthenticationFailureError{}, err)
assert.Equal(t, 401, err.(*AuthenticationFailureError).HttpStatus)
assert.Contains(t, err.Error(), "RBAC")
assert.Nil(t, sData)
// nonce cookie cleanup
response := rr.Result()
assert.Len(t, response.Cookies(), 1)
assert.Equal(t, OpenIdNonceCookieName, response.Cookies()[0].Name)
assert.True(t, clockTime.After(response.Cookies()[0].Expires))
} | explode_data.jsonl/72703 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 661
} | [
2830,
3393,
5002,
764,
59558,
18878,
78413,
82,
3323,
26040,
32124,
70838,
1155,
353,
8840,
836,
8,
341,
84165,
1462,
1669,
882,
8518,
7,
17,
15,
17,
16,
11,
220,
16,
17,
11,
220,
16,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNoHandlers(t *testing.T) {
s := NewServer(nil, nil)
conn, err := net.ListenUDP("udp", &net.UDPAddr{})
if err != nil {
panic(err)
}
go s.Serve(conn)
c, err := NewClient(localSystem(conn))
if err != nil {
panic(err)
}
_, err = c.Send("test", "octet")
if err == nil {
t.Errorf("error expected")
}
_, err = c.Receive("test", "octet")
if err == nil {
t.Errorf("error expected")
}
} | explode_data.jsonl/17558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
2753,
39949,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1532,
5475,
27907,
11,
2092,
692,
32917,
11,
1848,
1669,
4179,
68334,
41648,
445,
31101,
497,
609,
4711,
13,
41648,
13986,
37790,
743,
1848,
961,
2092,
341,
197,
30764,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetStats(t *testing.T) {
ms := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter,
r *http.Request) {
if r.RequestURI == "/state" {
_, _ = w.Write([]byte(stateTestData))
return
}
if r.RequestURI == "/stats.json" {
_, _ = w.Write([]byte(statsTestData))
return
}
if strings.HasPrefix(r.RequestURI, "/find/1/tags?query=test") {
_, _ = w.Write([]byte(tagsTestData))
return
}
}))
defer ms.Close()
sc, err := NewSnowthClient(false, ms.URL)
if err != nil {
t.Fatal("Unable to create snowth client", err)
}
u, err := url.Parse(ms.URL)
if err != nil {
t.Fatal("Invalid test URL")
}
node := &SnowthNode{url: u}
res, err := sc.GetStats(node)
if err != nil {
t.Fatal(err)
}
exp := "bb6f7162-4828-11df-bab8-6bac200dcc2a"
if res.Identity() != exp {
t.Errorf("Expected identity: %v, got: %v", exp, res.Identity())
}
exp = "0.1.1570000000"
if res.SemVer() != exp {
t.Errorf("Expected version: %v, got: %v", exp, res.SemVer())
}
exp = "294cbd39999c2270964029691e8bc5e231a867d525ccba62181dc8988ff218dc"
if res.CurrentTopology() != exp {
t.Errorf("Expected current: %v, got: %v", exp, res.CurrentTopology())
}
exp = "-"
if res.NextTopology() != exp {
t.Errorf("Expected next: %v, got: %v", exp, res.NextTopology())
}
} | explode_data.jsonl/9005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 583
} | [
2830,
3393,
1949,
16635,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
345,
197,
7000,
353,
1254,
9659,
8,
341,
197,
743,
435,
9659,
10301,
621,
3521,
2454,
1,
341,
298,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestIdentifySystem(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
conn, err := pgconn.Connect(ctx, os.Getenv("PGLOGREPL_TEST_CONN_STRING"))
require.NoError(t, err)
defer closeConn(t, conn)
sysident, err := pglogrepl.IdentifySystem(ctx, conn)
require.NoError(t, err)
assert.Greater(t, len(sysident.SystemID), 0)
assert.True(t, sysident.Timeline > 0)
assert.True(t, sysident.XLogPos > 0)
assert.Greater(t, len(sysident.DBName), 0)
} | explode_data.jsonl/45902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
28301,
1437,
2320,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
882,
32435,
9,
20,
340,
16867,
9121,
2822,
32917,
11,
1848,
1669,
17495,
5148,
43851,
7502,
11,
2643,
64883,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_LoginPage__should_set_returnto_cookie_correctly(t *testing.T) {
setup := setupTest(t, nil)
defer setup.ctrl.Finish()
mockRenderPageCall(setup)
testReq := httptest.NewRequest(http.MethodGet, "/?returnto=testurl", nil)
setup.testCtx.Request = testReq
setup.router.LoginPage(setup.testCtx)
assert.True(t, strings.Contains(setup.w.HeaderMap["Set-Cookie"][0], returnToCookie+"=testurl"))
} | explode_data.jsonl/32960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
79232,
2665,
563,
5445,
2602,
12511,
983,
38663,
31550,
398,
1155,
353,
8840,
836,
8,
341,
84571,
1669,
6505,
2271,
1155,
11,
2092,
340,
16867,
6505,
57078,
991,
18176,
2822,
77333,
6750,
2665,
7220,
14171,
454,
692,
18185,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIngesterFlushWithChunksStorage(t *testing.T) {
s, err := e2e.NewScenario(networkName)
require.NoError(t, err)
defer s.Close()
// Start dependencies.
dynamo := e2edb.NewDynamoDB()
consul := e2edb.NewConsul()
require.NoError(t, s.StartAndWaitReady(dynamo, consul))
// Start Cortex components.
require.NoError(t, writeFileToSharedDir(s, cortexSchemaConfigFile, []byte(cortexSchemaConfigYaml)))
tableManager := e2ecortex.NewTableManager("table-manager", ChunksStorageFlags, "")
ingester := e2ecortex.NewIngester("ingester", consul.NetworkHTTPEndpoint(), mergeFlags(ChunksStorageFlags, map[string]string{
"-ingester.max-transfer-retries": "0",
}), "")
querier := e2ecortex.NewQuerier("querier", consul.NetworkHTTPEndpoint(), ChunksStorageFlags, "")
distributor := e2ecortex.NewDistributor("distributor", consul.NetworkHTTPEndpoint(), ChunksStorageFlags, "")
require.NoError(t, s.StartAndWaitReady(distributor, querier, ingester, tableManager))
// Wait until the first table-manager sync has completed, so that we're
// sure the tables have been created.
require.NoError(t, tableManager.WaitSumMetrics(e2e.Greater(0), "cortex_table_manager_sync_success_timestamp_seconds"))
// Wait until both the distributor and querier have updated the ring.
require.NoError(t, distributor.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
require.NoError(t, querier.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
c, err := e2ecortex.NewClient(distributor.HTTPEndpoint(), querier.HTTPEndpoint(), "", "", "user-1")
require.NoError(t, err)
// Push some series to Cortex.
now := time.Now()
series1, expectedVector1 := generateSeries("series_1", now)
series2, expectedVector2 := generateSeries("series_2", now)
for _, series := range [][]prompb.TimeSeries{series1, series2} {
res, err := c.Push(series)
require.NoError(t, err)
require.Equal(t, 200, res.StatusCode)
}
// Ensure ingester metrics are tracked correctly.
require.NoError(t, ingester.WaitSumMetrics(e2e.Equals(2), "cortex_ingester_chunks_created_total"))
// Query the series.
result, err := c.Query("series_1", now)
require.NoError(t, err)
require.Equal(t, model.ValVector, result.Type())
assert.Equal(t, expectedVector1, result.(model.Vector))
result, err = c.Query("series_2", now)
require.NoError(t, err)
require.Equal(t, model.ValVector, result.Type())
assert.Equal(t, expectedVector2, result.(model.Vector))
// Ensure no service-specific metrics prefix is used by the wrong service.
assertServiceMetricsPrefixes(t, Ingester, ingester)
// Stop ingester-1, so that it will flush all chunks to the storage. This function will return
// once the ingester-1 is successfully stopped, which means the flushing is completed.
require.NoError(t, s.Stop(ingester))
// Ensure chunks have been uploaded to the storage (DynamoDB).
dynamoURL := "dynamodb://u:p@" + dynamo.Endpoint(8000)
dynamoClient, err := newDynamoClient(dynamoURL)
require.NoError(t, err)
// We have pushed 2 series, so we do expect 2 chunks.
period := now.Unix() / (168 * 3600)
indexTable := fmt.Sprintf("cortex_%d", period)
chunksTable := fmt.Sprintf("cortex_chunks_%d", period)
out, err := dynamoClient.Scan(&dynamodb.ScanInput{TableName: aws.String(indexTable)})
require.NoError(t, err)
assert.Equal(t, int64(2*2), *out.Count)
out, err = dynamoClient.Scan(&dynamodb.ScanInput{TableName: aws.String(chunksTable)})
require.NoError(t, err)
assert.Equal(t, int64(2), *out.Count)
// Ensure no service-specific metrics prefix is used by the wrong service.
assertServiceMetricsPrefixes(t, Distributor, distributor)
assertServiceMetricsPrefixes(t, Querier, querier)
assertServiceMetricsPrefixes(t, TableManager, tableManager)
} | explode_data.jsonl/70431 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1302
} | [
2830,
3393,
25416,
5191,
46874,
2354,
89681,
5793,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
384,
17,
68,
7121,
54031,
46542,
675,
340,
17957,
35699,
1155,
11,
1848,
340,
16867,
274,
10421,
2822,
197,
322,
5145,
19543,
624,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLogsPathMatcher_InvalidSource3(t *testing.T) {
cfgLogsPath := "/var/log/containers/"
source := "/var/log/containers/pod_ns_container_01234567.log"
expectedResult := ""
executeTest(t, cfgLogsPath, source, expectedResult)
} | explode_data.jsonl/34416 | {
"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,
51053,
1820,
37554,
62,
7928,
3608,
18,
1155,
353,
8840,
836,
8,
341,
50286,
51053,
1820,
1669,
3521,
947,
19413,
14,
39399,
29555,
47418,
1669,
3521,
947,
19413,
14,
39399,
4322,
347,
34728,
15847,
62,
15,
16,
17,
18,
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 TestJoinPredicatePushDown(t *testing.T) {
var (
input []string
output []struct {
Left string
Right string
}
)
planSuiteUnexportedData.GetTestCases(t, &input, &output)
s := createPlannerSuite()
ctx := context.Background()
for i, ca := range input {
comment := fmt.Sprintf("for %s", ca)
stmt, err := s.p.ParseOneStmt(ca, "", "")
require.NoError(t, err, comment)
p, _, err := BuildLogicalPlanForTest(ctx, s.ctx, stmt, s.is)
require.NoError(t, err, comment)
p, err = logicalOptimize(context.TODO(), flagPredicatePushDown|flagDecorrelate|flagPrunColumns|flagPrunColumnsAgain, p.(LogicalPlan))
require.NoError(t, err, comment)
proj, ok := p.(*LogicalProjection)
require.True(t, ok, comment)
join, ok := proj.children[0].(*LogicalJoin)
require.True(t, ok, comment)
leftPlan, ok := join.children[0].(*DataSource)
require.True(t, ok, comment)
rightPlan, ok := join.children[1].(*DataSource)
require.True(t, ok, comment)
leftCond := fmt.Sprintf("%s", leftPlan.pushedDownConds)
rightCond := fmt.Sprintf("%s", rightPlan.pushedDownConds)
testdata.OnRecord(func() {
output[i].Left, output[i].Right = leftCond, rightCond
})
require.Equal(t, output[i].Left, leftCond, comment)
require.Equal(t, output[i].Right, rightCond, comment)
}
} | explode_data.jsonl/50202 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 516
} | [
2830,
3393,
12292,
36329,
16644,
4454,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
22427,
220,
3056,
917,
198,
197,
21170,
3056,
1235,
341,
298,
197,
5415,
220,
914,
198,
298,
197,
5979,
914,
198,
197,
197,
532,
197,
340,
197,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetRequest(t *testing.T) {
api := BaseFeature{}
api.SetBaseUrl("https://jsonplaceholder.typicode.com")
err := api.CreatePathRequest(http.MethodGet, "/todos/{id}")
require.NoError(t, err)
id := "1"
err = api.SetsRequestPathParameterTo("id", id)
require.NoError(t, err)
err = api.ExecuteTheRequest()
require.NoError(t, err)
err = api.AssertResponseCode(http.StatusOK)
assert.NoError(t, err)
res, err := json_matcher.Read(api.Response.Body, ".id")
require.NoError(t, err)
assert.Equal(t, id, res)
} | explode_data.jsonl/81225 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
1949,
1900,
1155,
353,
8840,
836,
8,
341,
54299,
1669,
5351,
13859,
16094,
54299,
4202,
71587,
445,
2428,
1110,
2236,
12384,
49286,
13634,
905,
5130,
9859,
1669,
6330,
7251,
1820,
1900,
19886,
20798,
1949,
11,
3521,
49188,
938... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVersionMatchesTag(t *testing.T) {
tag := os.Getenv("TRAVIS_TAG")
if tag == "" {
t.SkipNow()
}
// We expect a tag of the form vX.Y.Z. If that's not the case,
// we need someone to have a look. So fail if first letter is not
// a `v`
if tag[0] != 'v' {
t.Fatalf("Expect tag to start with `v`, tag is: %s", tag)
}
// Strip the `v` from the tag for the version comparison.
if Version != tag[1:] {
t.Fatalf("Version (%s) does not match tag (%s)", Version, tag[1:])
}
} | explode_data.jsonl/44905 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
5637,
42470,
5668,
1155,
353,
8840,
836,
8,
341,
60439,
1669,
2643,
64883,
445,
2378,
98716,
16592,
1138,
743,
4772,
621,
1591,
341,
197,
3244,
57776,
7039,
741,
197,
532,
197,
322,
1205,
1720,
264,
4772,
315,
279,
1352,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFreeENIRetry(t *testing.T) {
ctrl, _, mockEC2 := setup(t)
defer ctrl.Finish()
attachmentID := eniAttachID
attachment := &ec2.NetworkInterfaceAttachment{AttachmentId: &attachmentID}
result := &ec2.DescribeNetworkInterfacesOutput{
NetworkInterfaces: []*ec2.NetworkInterface{{Attachment: attachment}}}
mockEC2.EXPECT().DescribeNetworkInterfaces(gomock.Any()).Return(result, nil)
// retry 2 times
mockEC2.EXPECT().DetachNetworkInterface(gomock.Any()).Return(nil, nil)
mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, errors.New("testing retrying delete"))
mockEC2.EXPECT().DeleteNetworkInterface(gomock.Any()).Return(nil, nil)
ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2}
err := ins.FreeENI("test-eni")
assert.NoError(t, err)
} | explode_data.jsonl/19295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
10940,
953,
2801,
15149,
1155,
353,
8840,
836,
8,
341,
84381,
11,
8358,
7860,
7498,
17,
1669,
6505,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
21981,
915,
1669,
662,
72,
30485,
915,
198,
197,
21981,
1669,
609,
757,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDispatchMetricsShouldDistributeMetrics(t *testing.T) {
t.Parallel()
r := rand.New(rand.NewSource(time.Now().UnixNano()))
n := r.Intn(5) + 1
factory := newTestFactory()
// use a sync channel (perWorkerBufferSize = 0) to force the workers to process events before the context is cancelled
h := NewBackendHandler(nil, 0, n, 0, factory)
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
var wgFinish wait.Group
wgFinish.StartWithContext(ctx, h.Run)
numMetrics := r.Intn(1000) + n*10
var wg sync.WaitGroup
wg.Add(numMetrics)
for i := 0; i < numMetrics; i++ {
m := &gostatsd.Metric{
Type: gostatsd.COUNTER,
Name: fmt.Sprintf("counter.metric.%d", r.Int63()),
Tags: nil,
Value: r.Float64(),
}
go func() {
defer wg.Done()
h.DispatchMetrics(ctx, []*gostatsd.Metric{m})
}()
}
wg.Wait() // Wait for all metrics to be dispatched
cancelFunc() // After all metrics have been dispatched, we signal dispatcher to shut down
wgFinish.Wait() // Wait for dispatcher to shutdown
receiveInvocations := getTotalInvocations(factory.receiveInvocations)
assert.Equal(t, numMetrics, receiveInvocations)
for agrNum, count := range factory.receiveInvocations {
if count == 0 {
t.Errorf("aggregator %d was never invoked", agrNum)
} else {
t.Logf("aggregator %d was invoked %d time(s)", agrNum, count)
}
}
} | explode_data.jsonl/35887 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 541
} | [
2830,
3393,
11283,
27328,
14996,
35,
80133,
27328,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
7000,
1669,
10382,
7121,
37595,
7121,
3608,
9730,
13244,
1005,
55832,
83819,
12145,
9038,
1669,
435,
7371,
77,
7,
20,
8,
488,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTemplate(t *testing.T) {
tpl, err := template.ParseFiles("./sql.tpl")
if err != nil {
t.Fatal(err)
}
s := tpl.Templates()
for _, v := range s {
t.Log(v.Name())
}
var param = TestTable{Id: 1, UserName: "user", Password: "pw"}
t.Run("select", func(t *testing.T) {
tpl = tpl.Lookup("selectTestTable")
if tpl == nil {
t.Fatal("not found")
}
err = tpl.Execute(os.Stdout, param)
if err != nil {
t.Fatal(err)
}
})
t.Run("insert", func(t *testing.T) {
tpl = tpl.Lookup("insertTestTable")
if tpl == nil {
t.Fatal("not found")
}
err = tpl.Execute(os.Stdout, param)
if err != nil {
t.Fatal(err)
}
})
t.Run("update", func(t *testing.T) {
tpl = tpl.Lookup("updateTestTable")
if tpl == nil {
t.Fatal("not found")
}
err = tpl.Execute(os.Stdout, param)
if err != nil {
t.Fatal(err)
}
})
t.Run("delete", func(t *testing.T) {
tpl = tpl.Lookup("deleteTestTable")
if tpl == nil {
t.Fatal("not found")
}
err = tpl.Execute(os.Stdout, param)
if err != nil {
t.Fatal(err)
}
})
} | explode_data.jsonl/60505 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 523
} | [
2830,
3393,
7275,
1155,
353,
8840,
836,
8,
341,
3244,
500,
11,
1848,
1669,
3811,
8937,
10809,
13988,
3544,
34066,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
1903,
1669,
60979,
836,
76793,
741,
2023,
8358,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPointBls12377G2Identity(t *testing.T) {
bls12377G2 := BLS12377G2()
sc := bls12377G2.Point.Identity()
require.True(t, sc.IsIdentity())
require.Equal(t, sc.ToAffineCompressed(), []byte{0xc0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0})
} | explode_data.jsonl/15764 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 471
} | [
2830,
3393,
2609,
33,
4730,
16,
17,
18,
22,
22,
38,
17,
18558,
1155,
353,
8840,
836,
8,
341,
96421,
82,
16,
17,
18,
22,
22,
38,
17,
1669,
425,
7268,
16,
17,
18,
22,
22,
38,
17,
741,
29928,
1669,
1501,
82,
16,
17,
18,
22,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVaultSource(t *testing.T) {
const (
addr = "127.0.0.1:58421"
rootToken = "token"
certPath = "secret/fabio/cert"
)
// start a vault server
vault, client := vaultServer(t, addr, rootToken)
defer vault.Process.Kill()
// create a cert and store it in vault
certPEM, keyPEM := makePEM("localhost", time.Minute)
data := map[string]interface{}{"cert": string(certPEM), "key": string(keyPEM)}
if _, err := client.Logical().Write(certPath+"/localhost", data); err != nil {
t.Fatalf("logical.Write failed: %s", err)
}
newBool := func(b bool) *bool { return &b }
// run tests
tests := []struct {
desc string
wrapTTL string
req *vaultapi.TokenCreateRequest
}{
{
desc: "renewable token",
req: &vaultapi.TokenCreateRequest{Lease: "1m", TTL: "1m", Policies: []string{"fabio"}},
},
{
desc: "non-renewable token",
req: &vaultapi.TokenCreateRequest{Lease: "1m", TTL: "1m", Renewable: newBool(false), Policies: []string{"fabio"}},
},
{
desc: "renewable orphan token",
req: &vaultapi.TokenCreateRequest{Lease: "1m", TTL: "1m", NoParent: true, Policies: []string{"fabio"}},
},
{
desc: "non-renewable orphan token",
req: &vaultapi.TokenCreateRequest{Lease: "1m", TTL: "1m", NoParent: true, Renewable: newBool(false), Policies: []string{"fabio"}},
},
{
desc: "renewable wrapped token",
wrapTTL: "10s",
req: &vaultapi.TokenCreateRequest{Lease: "1m", TTL: "1m", Policies: []string{"fabio"}},
},
{
desc: "non-renewable wrapped token",
wrapTTL: "10s",
req: &vaultapi.TokenCreateRequest{Lease: "1m", TTL: "1m", Renewable: newBool(false), Policies: []string{"fabio"}},
},
}
pool := makeCertPool(certPEM)
timeout := 50 * time.Millisecond
for _, tt := range tests {
t.Log("Test vault source with", tt.desc)
src := &VaultSource{
Addr: "http://" + addr,
CertPath: certPath,
vaultToken: makeToken(t, client, tt.wrapTTL, tt.req),
}
testSource(t, src, pool, timeout)
}
} | explode_data.jsonl/24947 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 851
} | [
2830,
3393,
79177,
3608,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
53183,
414,
284,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
20,
23,
19,
17,
16,
698,
197,
33698,
3323,
284,
330,
5839,
698,
197,
1444,
529,
1820,
220,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_rulesAreEqual(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
a *netlink.Rule
b *netlink.Rule
equal bool
}{
"both nil": {
equal: true,
},
"first nil": {
b: &netlink.Rule{},
},
"second nil": {
a: &netlink.Rule{},
},
"both not nil": {
a: &netlink.Rule{},
b: &netlink.Rule{},
equal: true,
},
"both equal": {
a: &netlink.Rule{
Src: &net.IPNet{
IP: net.IPv4(1, 1, 1, 1),
Mask: net.IPv4Mask(255, 255, 255, 0),
},
Priority: 100,
Table: 101,
},
b: &netlink.Rule{
Src: &net.IPNet{
IP: net.IPv4(1, 1, 1, 1),
Mask: net.IPv4Mask(255, 255, 255, 0),
},
Priority: 100,
Table: 101,
},
equal: true,
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
equal := rulesAreEqual(testCase.a, testCase.b)
assert.Equal(t, testCase.equal, equal)
})
}
} | explode_data.jsonl/25734 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 524
} | [
2830,
3393,
21407,
11526,
2993,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
11323,
257,
353,
4711,
2080,
63961,
198,
197,
2233,
257,
353,
4711,
2080,
63961,
198,
197,
7727,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerUpdateEventWithNoController(t *testing.T) {
c, tc := makeController("v1", "Pod")
c.Update(simplePod("unit", "test"))
validateNotSent(t, tc, sourcesv1beta1.ApiServerSourceUpdateRefEventType)
} | explode_data.jsonl/39265 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
2051,
4289,
1556,
2354,
2753,
2051,
1155,
353,
8840,
836,
8,
341,
1444,
11,
17130,
1669,
1281,
2051,
445,
85,
16,
497,
330,
23527,
1138,
1444,
16689,
1141,
6456,
23527,
445,
3843,
497,
330,
1944,
5455,
197,
7067,
2623,
313... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEngineBatchCommit(t *testing.T) {
defer leaktest.AfterTest(t)()
numWrites := 10000
key := mvccKey("a")
finalVal := []byte(strconv.Itoa(numWrites - 1))
runWithAllEngines(func(e Engine, t *testing.T) {
// Start a concurrent read operation in a busy loop.
readsBegun := make(chan struct{})
readsDone := make(chan error)
writesDone := make(chan struct{})
go func() {
readsDone <- func() error {
readsBegunAlias := readsBegun
for {
select {
case <-writesDone:
return nil
default:
val, err := e.Get(key)
if err != nil {
return err
}
if val != nil && !bytes.Equal(val, finalVal) {
return errors.Errorf("key value should be empty or %q; got %q", string(finalVal), string(val))
}
if readsBegunAlias != nil {
close(readsBegunAlias)
readsBegunAlias = nil
}
}
}
}()
}()
// Wait until we've succeeded with first read.
<-readsBegun
// Create key/values and put them in a batch to engine.
batch := e.NewBatch()
defer batch.Close()
for i := 0; i < numWrites; i++ {
if err := batch.Put(key, []byte(strconv.Itoa(i))); err != nil {
t.Fatal(err)
}
}
if err := batch.Commit(false /* sync */); err != nil {
t.Fatal(err)
}
close(writesDone)
if err := <-readsDone; err != nil {
t.Fatal(err)
}
}, t)
} | explode_data.jsonl/38106 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 608
} | [
2830,
3393,
4571,
21074,
33441,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
22431,
93638,
1669,
220,
16,
15,
15,
15,
15,
198,
23634,
1669,
23164,
638,
1592,
445,
64,
1138,
14213,
2208,
1669,
3056,
3782... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestE(t *testing.T) {
for _, ut := range eTests {
if newE := e(ut.p.Rank, ut.in, defaultOptions); newE != ut.out {
t.Errorf("TestE() = %+v, want %+v.", newE, ut.out)
}
}
} | explode_data.jsonl/22941 | {
"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,
36,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
8621,
1669,
2088,
384,
18200,
341,
394,
421,
501,
36,
1669,
384,
7,
332,
556,
2013,
1180,
11,
8621,
1858,
11,
1638,
3798,
1215,
501,
36,
961,
8621,
2532,
341,
298,
3244,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestErrorReturnsCondition(t *testing.T) {
s := stanza.Error{Condition: "leprosy"}
if string(s.Condition) != s.Error() {
t.Errorf("Expected stanza error to return condition `leprosy` but got %s", s.Error())
}
s = stanza.Error{Condition: "nope", Text: map[string]string{
"": "Text",
}}
if string(s.Condition) != s.Error() {
t.Errorf("Expected stanza error to return text `Text` but got %s", s.Error())
}
} | explode_data.jsonl/33541 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
1454,
16446,
10547,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
95436,
6141,
90,
10547,
25,
330,
273,
776,
22860,
16707,
743,
914,
1141,
75134,
8,
961,
274,
6141,
368,
341,
197,
3244,
13080,
445,
18896,
95436,
1465,
311,
470... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.