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 TestParseISORInterval(t *testing.T) {
check := func(input string, exp timeutil.ISORInterval, expEnd time.Time) {
t.Helper()
res, err := timeutil.ParseISORInterval(input)
require.NoError(t, err)
assert.Equal(t, exp, res)
assert.Equal(t, expEnd, res.End())
}
check("R0/2022-01-31T00:00:00Z/2023-01-31T00:00:00Z", timeutil.ISORInterval{
Repeat: 0,
Start: time.Date(2022, 1, 31, 0, 0, 0, 0, time.UTC),
Period: timeutil.ISODuration{TimePart: time.Hour * 24 * 365},
}, time.Date(2023, 1, 31, 0, 0, 0, 0, time.UTC))
check("R1/2022-01-31T00:00:00Z/2024-01-31T00:00:00Z", timeutil.ISORInterval{
Repeat: 1,
Start: time.Date(2022, 1, 31, 0, 0, 0, 0, time.UTC),
Period: timeutil.ISODuration{TimePart: time.Hour * 24 * 365},
}, time.Date(2024, 1, 31, 0, 0, 0, 0, time.UTC))
check("R0/2022-01-31T00:00:00Z/P1Y", timeutil.ISORInterval{
Repeat: 0,
Start: time.Date(2022, 1, 31, 0, 0, 0, 0, time.UTC),
Period: timeutil.ISODuration{Years: 1},
}, time.Date(2023, 1, 31, 0, 0, 0, 0, time.UTC))
check("R1/2022-01-31T00:00:00Z/P1Y", timeutil.ISORInterval{
Repeat: 1,
Start: time.Date(2022, 1, 31, 0, 0, 0, 0, time.UTC),
Period: timeutil.ISODuration{Years: 1},
}, time.Date(2024, 1, 31, 0, 0, 0, 0, time.UTC))
check("R0/P1Y/2023-01-31T00:00:00Z", timeutil.ISORInterval{
Repeat: 0,
Start: time.Date(2022, 1, 31, 0, 0, 0, 0, time.UTC),
Period: timeutil.ISODuration{Years: 1},
}, time.Date(2023, 1, 31, 0, 0, 0, 0, time.UTC))
check("R1/P1Y/2024-01-31T00:00:00Z", timeutil.ISORInterval{
Repeat: 1,
Start: time.Date(2022, 1, 31, 0, 0, 0, 0, time.UTC),
Period: timeutil.ISODuration{Years: 1},
}, time.Date(2024, 1, 31, 0, 0, 0, 0, time.UTC))
} | explode_data.jsonl/49481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 822
} | [
2830,
3393,
14463,
1637,
868,
10256,
1155,
353,
8840,
836,
8,
341,
25157,
1669,
2915,
5384,
914,
11,
1343,
882,
1314,
11230,
868,
10256,
11,
1343,
3727,
882,
16299,
8,
341,
197,
3244,
69282,
2822,
197,
10202,
11,
1848,
1669,
882,
1314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeamsService_IsTeamRepoByID_false(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/organizations/1/team/1/repos/owner/repo", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.WriteHeader(http.StatusNotFound)
})
ctx := context.Background()
repo, resp, err := client.Teams.IsTeamRepoByID(ctx, 1, 1, "owner", "repo")
if err == nil {
t.Errorf("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Teams.IsTeamRepoByID returned status %d, want %d", got, want)
}
if repo != nil {
t.Errorf("Teams.IsTeamRepoByID returned %+v, want nil", repo)
}
} | explode_data.jsonl/4528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
60669,
1860,
31879,
14597,
25243,
60572,
36015,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
69253,
14,
16,
78015,
14,
16,
49505,
14,
8118,
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 TestPlayer_ViewDirectionX(t *testing.T) {
pl := playerWithProperty("m_angEyeAngles[1]", st.PropertyValue{FloatVal: 180})
assert.Equal(t, float32(180), pl.ViewDirectionX())
} | explode_data.jsonl/12193 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 67
} | [
2830,
3393,
4476,
50711,
9268,
55,
1155,
353,
8840,
836,
8,
341,
72213,
1669,
2781,
2354,
3052,
445,
76,
58060,
50058,
46454,
58,
16,
19076,
357,
15727,
1130,
90,
5442,
2208,
25,
220,
16,
23,
15,
8824,
6948,
12808,
1155,
11,
2224,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInsertTimestampArray(t *testing.T) {
t.Parallel()
testWithAndWithoutPreferSimpleProtocol(t, func(t *testing.T, conn *pgx.Conn) {
if results := mustExec(t, conn, "create temporary table foo(spice timestamp[]);"); string(results) != "CREATE TABLE" {
t.Error("Unexpected results from Exec")
}
// Accept parameters
if results := mustExec(t, conn, "insert into foo(spice) values($1)", []time.Time{time.Unix(1419143667, 0), time.Unix(1419143672, 0)}); string(results) != "INSERT 0 1" {
t.Errorf("Unexpected results from Exec: %v", results)
}
})
} | explode_data.jsonl/40022 | {
"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,
13780,
20812,
1857,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
2354,
3036,
26040,
4703,
802,
16374,
20689,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
4534,
353,
3517,
87,
50422,
8,
341,
197,
743,
3059,
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... | 3 |
func TestReadsAcrossEntries(t *testing.T) {
// read half of an entry, read a full entry's worth
if lineSize != int64(len(entries[0])+1) {
t.Fatal("test setup error: entries length doesn't match expected line size")
}
buf := make([]byte, lineSize)
vf := newTestValidationFile(entries)
firstRead := len(buf) / 2
r, err := vf.Read(buf[0:firstRead], 0, fs.WhenceFromCurrent)
if r != firstRead {
t.Fatalf("unexpected read length reading first half of entry, expected %d, got %d",
firstRead, r)
}
if err = compareBuffers(file[:firstRead], buf[:firstRead], 0, t); err != nil {
t.Fatalf("%s", err)
}
r, err = vf.Read(buf[firstRead:], 0, fs.WhenceFromCurrent)
if r != len(buf)-firstRead {
t.Fatalf("unexpected read length reading second half of entry, expecting %d, got %d",
len(buf)-firstRead, r)
}
if err = compareBuffers(file[firstRead:], buf[firstRead:], firstRead, t); err != nil {
t.Fatalf("%s", err)
}
} | explode_data.jsonl/16791 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
4418,
82,
91931,
24533,
1155,
353,
8840,
836,
8,
341,
197,
322,
1349,
4279,
315,
458,
4343,
11,
1349,
264,
2480,
4343,
594,
5802,
271,
743,
1555,
1695,
961,
526,
21,
19,
6901,
72009,
58,
15,
47966,
16,
8,
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... | 6 |
func TestTarFiles(t *testing.T) {
// try without hardlinks
if err := checkNoChanges(1000, false); err != nil {
t.Fatal(err)
}
// try with hardlinks
if err := checkNoChanges(1000, true); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/79249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
62733,
10809,
1155,
353,
8840,
836,
8,
341,
197,
322,
1430,
2041,
2588,
15880,
198,
743,
1848,
1669,
1779,
2753,
11317,
7,
16,
15,
15,
15,
11,
895,
1215,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
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 TestGCSArtifact(t *testing.T) {
a := &GCSArtifact{Key: "my-key", GCSBucket: GCSBucket{Bucket: "my-bucket"}}
assert.True(t, a.HasLocation())
assert.NoError(t, a.SetKey("my-key"))
key, err := a.GetKey()
assert.NoError(t, err)
assert.Equal(t, "my-key", key)
} | explode_data.jsonl/26020 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
38,
6412,
85578,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
609,
38,
6412,
85578,
90,
1592,
25,
330,
2408,
16173,
497,
479,
6412,
36018,
25,
479,
6412,
36018,
90,
36018,
25,
330,
2408,
1455,
11152,
95642,
6948,
32443,
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 TestExpire(t *testing.T) {
db := newDB()
store := New(db, []byte("secret"))
countFn := makeCountHandler("session", store)
r1 := req(countFn, nil)
match(t, r1, 200, "1")
// test still in db but expired
id := r1.Header().Get("X-Session")
s := findSession(db, store, id)
s.ExpiresAt = gorm.NowFunc().Add(-40 * 24 * time.Hour)
db.Save(s)
r2 := req(countFn, parseCookies(r1.Header().Get("Set-Cookie"))["session"])
match(t, r2, 200, "1")
store.Cleanup()
if findSession(db, store, id) != nil {
t.Error("Expected session to be deleted")
}
} | explode_data.jsonl/71331 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
8033,
554,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
501,
3506,
741,
57279,
1669,
1532,
9791,
11,
3056,
3782,
445,
20474,
5455,
18032,
24911,
1669,
1281,
2507,
3050,
445,
5920,
497,
3553,
692,
7000,
16,
1669,
4232,
11512,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractPodsFromHTTP(t *testing.T) {
nodeName := "different-value"
grace := int64(30)
var testCases = []struct {
desc string
pods runtime.Object
expected kubetypes.PodUpdate
}{
{
desc: "Single pod",
pods: &v1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "",
},
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
UID: "111",
Namespace: "mynamespace",
},
Spec: v1.PodSpec{
NodeName: string(nodeName),
Containers: []v1.Container{{Name: "1", Image: "foo", ImagePullPolicy: v1.PullAlways, TerminationMessagePolicy: v1.TerminationMessageReadFile}},
SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName,
},
Status: v1.PodStatus{
Phase: v1.PodPending,
},
},
expected: CreatePodUpdate(kubetypes.SET,
kubetypes.HTTPSource,
&v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "111",
Name: "foo" + "-" + nodeName,
Namespace: "mynamespace",
Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "111"},
SelfLink: getSelfLink("foo-"+nodeName, "mynamespace"),
},
Spec: v1.PodSpec{
NodeName: nodeName,
RestartPolicy: v1.RestartPolicyAlways,
DNSPolicy: v1.DNSClusterFirst,
SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &grace,
SchedulerName: api.DefaultSchedulerName,
Containers: []v1.Container{{
Name: "1",
Image: "foo",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
TerminationMessagePolicy: v1.TerminationMessageReadFile,
}},
},
Status: v1.PodStatus{
Phase: v1.PodPending,
},
}),
},
{
desc: "Multiple pods",
pods: &v1.PodList{
TypeMeta: metav1.TypeMeta{
Kind: "PodList",
APIVersion: "",
},
Items: []v1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
UID: "111",
},
Spec: v1.PodSpec{
NodeName: nodeName,
Containers: []v1.Container{{Name: "1", Image: "foo", ImagePullPolicy: v1.PullAlways, TerminationMessagePolicy: v1.TerminationMessageReadFile}},
SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName,
},
Status: v1.PodStatus{
Phase: v1.PodPending,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
UID: "222",
},
Spec: v1.PodSpec{
NodeName: nodeName,
Containers: []v1.Container{{Name: "2", Image: "bar:bartag", ImagePullPolicy: "", TerminationMessagePolicy: v1.TerminationMessageReadFile}},
SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName,
},
Status: v1.PodStatus{
Phase: v1.PodPending,
},
},
},
},
expected: CreatePodUpdate(kubetypes.SET,
kubetypes.HTTPSource,
&v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "111",
Name: "foo" + "-" + nodeName,
Namespace: "default",
Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "111"},
SelfLink: getSelfLink("foo-"+nodeName, metav1.NamespaceDefault),
},
Spec: v1.PodSpec{
NodeName: nodeName,
RestartPolicy: v1.RestartPolicyAlways,
DNSPolicy: v1.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName,
Containers: []v1.Container{{
Name: "1",
Image: "foo",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "Always",
TerminationMessagePolicy: v1.TerminationMessageReadFile,
}},
},
Status: v1.PodStatus{
Phase: v1.PodPending,
},
},
&v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "222",
Name: "bar" + "-" + nodeName,
Namespace: "default",
Annotations: map[string]string{kubetypes.ConfigHashAnnotationKey: "222"},
SelfLink: getSelfLink("bar-"+nodeName, metav1.NamespaceDefault),
},
Spec: v1.PodSpec{
NodeName: nodeName,
RestartPolicy: v1.RestartPolicyAlways,
DNSPolicy: v1.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName,
Containers: []v1.Container{{
Name: "2",
Image: "bar:bartag",
TerminationMessagePath: "/dev/termination-log",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: v1.TerminationMessageReadFile,
}},
},
Status: v1.PodStatus{
Phase: v1.PodPending,
},
}),
},
}
for _, testCase := range testCases {
var versionedPods runtime.Object
err := testapi.Default.Converter().Convert(&testCase.pods, &versionedPods, nil)
if err != nil {
t.Fatalf("%s: error in versioning the pods: %s", testCase.desc, err)
}
data, err := runtime.Encode(testapi.Default.Codec(), versionedPods)
if err != nil {
t.Fatalf("%s: error in encoding the pod: %v", testCase.desc, err)
}
fakeHandler := utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: string(data),
}
testServer := httptest.NewServer(&fakeHandler)
defer testServer.Close()
ch := make(chan interface{}, 1)
c := sourceURL{testServer.URL, http.Header{}, types.NodeName(nodeName), ch, nil, 0, http.DefaultClient}
if err := c.extractFromURL(); err != nil {
t.Errorf("%s: Unexpected error: %v", testCase.desc, err)
continue
}
update := (<-ch).(kubetypes.PodUpdate)
if !api.Semantic.DeepEqual(testCase.expected, update) {
t.Errorf("%s: Expected: %#v, Got: %#v", testCase.desc, testCase.expected, update)
}
for _, pod := range update.Pods {
// TODO: remove the conversion when validation is performed on versioned objects.
internalPod := &api.Pod{}
if err := v1.Convert_v1_Pod_To_api_Pod(pod, internalPod, nil); err != nil {
t.Fatalf("%s: Cannot convert pod %#v, %#v", testCase.desc, pod, err)
}
if errs := validation.ValidatePod(internalPod); len(errs) != 0 {
t.Errorf("%s: Expected no validation errors on %#v, Got %v", testCase.desc, pod, errs.ToAggregate())
}
}
}
} | explode_data.jsonl/48250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3303
} | [
2830,
3393,
28959,
23527,
82,
3830,
9230,
1155,
353,
8840,
836,
8,
341,
20831,
675,
1669,
330,
63650,
19083,
1837,
90059,
578,
1669,
526,
21,
19,
7,
18,
15,
340,
2405,
1273,
37302,
284,
3056,
1235,
341,
197,
41653,
257,
914,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestInvalidTopLevelObjectType(t *testing.T) {
_, err := loadYAML("1")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Top-level object must be a mapping")
_, err = loadYAML("\"hello\"")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Top-level object must be a mapping")
_, err = loadYAML("[\"hello\"]")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Top-level object must be a mapping")
} | explode_data.jsonl/16380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
7928,
5366,
4449,
49530,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
2795,
56,
31102,
445,
16,
1138,
6948,
6141,
1155,
11,
1848,
340,
6948,
11545,
1155,
11,
1848,
6141,
1507,
330,
5366,
11591,
1633,
1969,
387,
264... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmbedNotice(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
cc.PrepareForTestWithCcDefaultModules,
genrule.PrepareForTestWithGenRuleBuildComponents,
android.MockFS{
"APP_NOTICE": nil,
"GENRULE_NOTICE": nil,
"LIB_NOTICE": nil,
"TOOL_NOTICE": nil,
}.AddToFixture(),
).RunTestWithBp(t, `
android_app {
name: "foo",
srcs: ["a.java"],
static_libs: ["javalib"],
jni_libs: ["libjni"],
notice: "APP_NOTICE",
embed_notices: true,
sdk_version: "current",
}
// No embed_notice flag
android_app {
name: "bar",
srcs: ["a.java"],
jni_libs: ["libjni"],
notice: "APP_NOTICE",
sdk_version: "current",
}
// No NOTICE files
android_app {
name: "baz",
srcs: ["a.java"],
embed_notices: true,
sdk_version: "current",
}
cc_library {
name: "libjni",
system_shared_libs: [],
stl: "none",
notice: "LIB_NOTICE",
sdk_version: "current",
}
java_library {
name: "javalib",
srcs: [
":gen",
],
sdk_version: "current",
}
genrule {
name: "gen",
tools: ["gentool"],
out: ["gen.java"],
notice: "GENRULE_NOTICE",
}
java_binary_host {
name: "gentool",
srcs: ["b.java"],
notice: "TOOL_NOTICE",
}
`)
// foo has NOTICE files to process, and embed_notices is true.
foo := result.ModuleForTests("foo", "android_common")
// verify merge notices rule.
mergeNotices := foo.Rule("mergeNoticesRule")
noticeInputs := mergeNotices.Inputs.Strings()
// TOOL_NOTICE should be excluded as it's a host module.
if len(mergeNotices.Inputs) != 3 {
t.Errorf("number of input notice files: expected = 3, actual = %q", noticeInputs)
}
if !inList("APP_NOTICE", noticeInputs) {
t.Errorf("APP_NOTICE is missing from notice files, %q", noticeInputs)
}
if !inList("LIB_NOTICE", noticeInputs) {
t.Errorf("LIB_NOTICE is missing from notice files, %q", noticeInputs)
}
if !inList("GENRULE_NOTICE", noticeInputs) {
t.Errorf("GENRULE_NOTICE is missing from notice files, %q", noticeInputs)
}
// aapt2 flags should include -A <NOTICE dir> so that its contents are put in the APK's /assets.
res := foo.Output("package-res.apk")
aapt2Flags := res.Args["flags"]
e := "-A out/soong/.intermediates/foo/android_common/NOTICE"
android.AssertStringDoesContain(t, "expected.apkPath", aapt2Flags, e)
// bar has NOTICE files to process, but embed_notices is not set.
bar := result.ModuleForTests("bar", "android_common")
res = bar.Output("package-res.apk")
aapt2Flags = res.Args["flags"]
e = "-A out/soong/.intermediates/bar/android_common/NOTICE"
android.AssertStringDoesNotContain(t, "bar shouldn't have the asset dir flag for NOTICE", aapt2Flags, e)
// baz's embed_notice is true, but it doesn't have any NOTICE files.
baz := result.ModuleForTests("baz", "android_common")
res = baz.Output("package-res.apk")
aapt2Flags = res.Args["flags"]
e = "-A out/soong/.intermediates/baz/android_common/NOTICE"
if strings.Contains(aapt2Flags, e) {
t.Errorf("baz shouldn't have the asset dir flag for NOTICE: %q", e)
}
} | explode_data.jsonl/58505 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1284
} | [
2830,
3393,
25486,
34193,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
2103,
5407,
18930,
4703,
1732,
388,
1006,
197,
197,
50590,
2461,
2271,
2354,
15041,
3675,
28201,
345,
197,
63517,
28770,
3380,
2461,
2271,
2354,
97754,
3675,
28201,
345,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestResourceQuota(t *testing.T) {
cli := &client{}
now := time.Now()
tests := []struct {
name string
handler *mockHandler
output []telegraf.Metric
hasError bool
}{
{
name: "no ressourcequota",
handler: &mockHandler{
responseMap: map[string]interface{}{
"/resourcequotas/": corev1.ResourceQuotaList{},
},
},
output: []telegraf.Metric{},
hasError: false,
},
{
name: "collect resourceqota",
handler: &mockHandler{
responseMap: map[string]interface{}{
"/resourcequotas/": corev1.ResourceQuotaList{
Items: []corev1.ResourceQuota{
{
Status: corev1.ResourceQuotaStatus{
Hard: corev1.ResourceList{
"cpu": resource.MustParse("16"),
"memory": resource.MustParse("125817904Ki"),
"pods": resource.MustParse("110"),
},
Used: corev1.ResourceList{
"cpu": resource.MustParse("10"),
"memory": resource.MustParse("125715504Ki"),
"pods": resource.MustParse("0"),
},
},
ObjectMeta: metav1.ObjectMeta{
Generation: 11232,
Namespace: "ns1",
Name: "rq1",
Labels: map[string]string{
"lab1": "v1",
"lab2": "v2",
},
CreationTimestamp: metav1.Time{Time: now},
},
},
},
},
},
},
output: []telegraf.Metric{
testutil.MustMetric(
resourcequotaMeasurement,
map[string]string{
"resource": "rq1",
"namespace": "ns1",
},
map[string]interface{}{
"hard_cpu_cores_limit": int64(16),
"hard_memory_bytes_limit": int64(1.28837533696e+11),
"hard_pods_limit": int64(110),
"used_cpu_cores": int64(10),
"used_memory_bytes": int64(1.28732676096e+11),
"used_pods": int64(0),
},
time.Unix(0, 0),
),
},
hasError: false,
},
}
for _, v := range tests {
ks := &KubernetesInventory{
client: cli,
}
acc := new(testutil.Accumulator)
for _, quota := range ((v.handler.responseMap["/resourcequotas/"]).(corev1.ResourceQuotaList)).Items {
ks.gatherResourceQuota(quota, acc)
}
err := acc.FirstError()
if v.hasError {
require.Errorf(t, err, "%s failed, should have error", v.name)
continue
}
// No error case
require.NoErrorf(t, err, "%s failed, err: %v", v.name, err)
require.Len(t, acc.Metrics, len(v.output))
testutil.RequireMetricsEqual(t, acc.GetTelegrafMetrics(), v.output, testutil.IgnoreTime())
}
} | explode_data.jsonl/63527 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1317
} | [
2830,
3393,
4783,
2183,
6089,
1155,
353,
8840,
836,
8,
341,
86448,
1669,
609,
2972,
16094,
80922,
1669,
882,
13244,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
53326,
220,
353,
16712,
3050,
198,
197,
21170,
256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQuery(t *testing.T) {
key, value := []byte("hello"), []byte("goodbye")
txHandlerOpt := func(bapp *baseapp.BaseApp) {
legacyRouter := middleware.NewLegacyRouter()
r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
store := ctx.KVStore(capKey1)
store.Set(key, value)
any, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return nil, err
}
return &sdk.Result{
MsgResponses: []*codectypes.Any{any},
}, nil
})
legacyRouter.AddRoute(r)
txHandler := testTxHandler(
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry),
TxDecoder: testTxDecoder(encCfg.Amino),
},
func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
store := ctx.KVStore(capKey1)
store.Set(key, value)
return
},
)
bapp.SetTxHandler(txHandler)
}
app := setupBaseApp(t, txHandlerOpt)
app.InitChain(abci.RequestInitChain{})
// NOTE: "/store/key1" tells us KVStore
// and the final "/key" says to use the data as the
// key in the given KVStore ...
query := abci.RequestQuery{
Path: "/store/key1/key",
Data: key,
}
tx := newTxCounter(0, 0)
// query is empty before we do anything
res := app.Query(query)
require.Equal(t, 0, len(res.Value))
// query is still empty after a CheckTx
_, resTx, err := app.SimCheck(aminoTxEncoder(encCfg.Amino), tx)
require.NoError(t, err)
require.NotNil(t, resTx)
res = app.Query(query)
require.Equal(t, 0, len(res.Value))
// query is still empty after a DeliverTx before we commit
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
_, resTx, err = app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx)
require.NoError(t, err)
require.NotNil(t, resTx)
res = app.Query(query)
require.Equal(t, 0, len(res.Value))
// query returns correct value after Commit
app.Commit()
res = app.Query(query)
require.Equal(t, value, res.Value)
} | explode_data.jsonl/30046 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 847
} | [
2830,
3393,
2859,
1155,
353,
8840,
836,
8,
341,
23634,
11,
897,
1669,
3056,
3782,
445,
14990,
3975,
3056,
3782,
445,
18536,
28374,
5130,
46237,
3050,
21367,
1669,
2915,
1883,
676,
353,
3152,
676,
13018,
2164,
8,
341,
197,
197,
39884,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestErrorWithInvalidReference(t *testing.T) {
b, err := EvalCondition(true, "invalidVariable")
assert.Equal(t, fmt.Errorf("unknown name invalidVariable (1:1)\n | invalidVariable\n | ^"), err)
assert.False(t, b)
} | explode_data.jsonl/51794 | {
"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,
1454,
2354,
7928,
8856,
1155,
353,
8840,
836,
8,
341,
2233,
11,
1848,
1669,
58239,
10547,
3715,
11,
330,
11808,
7827,
1138,
6948,
12808,
1155,
11,
8879,
13080,
445,
16088,
829,
8318,
7827,
320,
16,
25,
16,
10699,
77,
760,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCustomerUsecaseImpl_InsertCustomer(t *testing.T) {
t.Run("Test Normal Case", func(t *testing.T) {
db, mockSql, err := sqlmock.New()
assert.Nil(t, err)
defer db.Close()
mockSql.ExpectBegin()
mockAccoundRepo := new(mocks.CustomerRepoMock)
mockAccoundRepo.On("InsertCustomer", &mockAccount).Return(nil)
u := usecase.CreateCustomerUsecase(mockAccoundRepo)
isSucces := u.InsertCustomer(&mockAccount)
assert.Equal(t, true, isSucces)
})
} | explode_data.jsonl/70251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 192
} | [
2830,
3393,
12792,
52,
5024,
519,
9673,
76417,
12792,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2271,
18437,
11538,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
20939,
11,
7860,
8269,
11,
1848,
1669,
5704,
16712,
7121,
741,
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 TestClientTimeout(t *testing.T) {
// Limit runtime in case of deadlocks
lim := test.TimeOut(time.Second * 20)
defer lim.Stop()
// Check for leaking routines
report := test.CheckRoutines(t)
defer report()
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
clientErr := make(chan error, 1)
ca, _ := dpipe.Pipe()
go func() {
conf := &Config{}
c, err := testClient(ctx, ca, conf, true)
if err == nil {
_ = c.Close()
}
clientErr <- err
}()
// no server!
if err := <-clientErr; err != errHandshakeTimeout {
t.Fatalf("Client error exp(%v) failed(%v)", errHandshakeTimeout, err)
}
} | explode_data.jsonl/40934 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
2959,
7636,
1155,
353,
8840,
836,
8,
341,
197,
322,
28008,
15592,
304,
1142,
315,
5593,
34936,
198,
197,
4659,
1669,
1273,
16299,
2662,
9730,
32435,
353,
220,
17,
15,
340,
16867,
4568,
30213,
2822,
197,
322,
4248,
369,
518... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFlowParse(t *testing.T) {
tnum := -1
var start, end = 0, len(flowParseTestCases)
if tnum >= 0 {
start = tnum
end = tnum + 1
}
// opts := &Options{Plain: false, Reflow: true}
// d := NewDoc("testdoc", "testpath")
// d.Reflow = true
testParse(t, flowParseTestCases, start, end)
} | explode_data.jsonl/76864 | {
"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,
18878,
14463,
1155,
353,
8840,
836,
8,
341,
197,
1517,
372,
1669,
481,
16,
198,
2405,
1191,
11,
835,
284,
220,
15,
11,
2422,
74637,
14463,
2271,
37302,
340,
743,
259,
2413,
2604,
220,
15,
341,
197,
21375,
284,
259,
2413,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewCondition(t *testing.T) {
cond := NewCondition("uuid", "==", "550e8400-e29b-41d4-a716-446655440000")
condStr, _ := json.Marshal(cond)
expected := `["uuid","==","550e8400-e29b-41d4-a716-446655440000"]`
if string(condStr) != expected {
t.Error("condition is not correctly formatted")
}
} | explode_data.jsonl/37849 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
3564,
10547,
1155,
353,
8840,
836,
8,
341,
197,
1297,
1669,
1532,
10547,
445,
17128,
497,
98651,
497,
330,
20,
20,
15,
68,
23,
19,
15,
15,
5655,
17,
24,
65,
12,
19,
16,
67,
19,
7409,
22,
16,
21,
12,
19,
19,
21,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReconcileServiceInstanceWithTerminalProvisionFailure(t *testing.T) {
fakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, fakeosb.FakeClientConfiguration{
ProvisionReaction: &fakeosb.ProvisionReaction{
Error: osb.HTTPStatusCodeError{
StatusCode: http.StatusBadRequest,
ErrorMessage: strPtr("BadRequest"),
Description: strPtr("Your parameters are incorrect!"),
},
},
})
sharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())
sharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())
sharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())
instance := getTestServiceInstanceWithClusterRefs()
if err := reconcileServiceInstance(t, testController, instance); err != nil {
t.Fatalf("unexpected error: %v", err)
}
instance = assertServiceInstanceProvisionInProgressIsTheOnlyCatalogClientAction(t, fakeCatalogClient, instance)
fakeCatalogClient.ClearActions()
fakeKubeClient.ClearActions()
if err := reconcileServiceInstance(t, testController, instance); err != nil {
t.Fatalf("unexpected error: %v", err)
}
brokerActions := fakeClusterServiceBrokerClient.Actions()
assertNumberOfBrokerActions(t, brokerActions, 1)
assertProvision(t, brokerActions[0], &osb.ProvisionRequest{
AcceptsIncomplete: true,
InstanceID: testServiceInstanceGUID,
ServiceID: testClusterServiceClassGUID,
PlanID: testClusterServicePlanGUID,
OrganizationGUID: testClusterID,
SpaceGUID: testNamespaceGUID,
Context: testContext})
// verify one kube action occurred
kubeActions := fakeKubeClient.Actions()
if err := checkKubeClientActions(kubeActions, []kubeClientAction{
{verb: "get", resourceName: "namespaces", checkType: checkGetActionType},
}); err != nil {
t.Fatal(err)
}
actions := fakeCatalogClient.Actions()
assertNumberOfActions(t, actions, 1)
updatedServiceInstance := assertUpdateStatus(t, actions[0], instance)
assertServiceInstanceProvisionRequestFailingErrorNoOrphanMitigation(
t,
updatedServiceInstance,
v1beta1.ServiceInstanceOperationProvision,
errorProvisionCallFailedReason,
"ClusterServiceBrokerReturnedFailure",
instance,
)
events := getRecordedEvents(testController)
message := fmt.Sprintf(
"Error provisioning ServiceInstance of ClusterServiceClass (K8S: %q ExternalName: %q) at ClusterServiceBroker %q: Status: %v; ErrorMessage: %s",
"cscguid", "test-clusterserviceclass", "test-clusterservicebroker", 400, "BadRequest; Description: Your parameters are incorrect!; ResponseError: <nil>",
)
expectedEvents := []string{
warningEventBuilder(errorProvisionCallFailedReason).msg(message).String(),
warningEventBuilder("ClusterServiceBrokerReturnedFailure").msg(message).String(),
}
if err := checkEvents(events, expectedEvents); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/58140 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 980
} | [
2830,
3393,
693,
40446,
457,
1860,
2523,
2354,
47890,
1336,
13013,
17507,
1155,
353,
8840,
836,
8,
341,
1166,
726,
42,
3760,
2959,
11,
12418,
41606,
2959,
11,
12418,
28678,
1860,
65545,
2959,
11,
1273,
2051,
11,
6094,
37891,
388,
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... | 5 |
func TestShardResultRemoveSeries(t *testing.T) {
opts := testResultOptions()
sr := NewShardResult(opts)
inputs := []struct {
id string
tags ident.Tags
series block.DatabaseSeriesBlocks
}{
{"foo", ident.NewTags(ident.StringTag("foo", "foe")), block.NewDatabaseSeriesBlocks(0)},
{"bar", ident.NewTags(ident.StringTag("bar", "baz")), block.NewDatabaseSeriesBlocks(0)},
}
for _, input := range inputs {
sr.AddSeries(ident.StringID(input.id), input.tags, input.series)
}
require.Equal(t, 2, sr.AllSeries().Len())
sr.RemoveSeries(ident.StringID("foo"))
require.Equal(t, 1, sr.AllSeries().Len())
sr.RemoveSeries(ident.StringID("nonexistent"))
require.Equal(t, 1, sr.AllSeries().Len())
} | explode_data.jsonl/4673 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
2016,
567,
2077,
13021,
25544,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
1273,
2077,
3798,
741,
1903,
81,
1669,
1532,
2016,
567,
2077,
30885,
340,
22427,
82,
1669,
3056,
1235,
341,
197,
15710,
257,
914,
198,
197,
3244,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetTids(t *testing.T) {
tids, err := getTids(os.Getpid())
if err != nil {
t.Fatal(err)
}
if len(tids) == 1 {
t.Fatalf("expected multiple threads, got: %+v", tids)
}
} | explode_data.jsonl/33129 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
1949,
51,
3365,
1155,
353,
8840,
836,
8,
341,
3244,
3365,
11,
1848,
1669,
633,
51,
3365,
9638,
2234,
10412,
2398,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
743,
2422,
1155,
3365,
8,
621,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 3 |
func TestMangoClientLoop(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
defer cancel()
sock, err := newSock()
require.NoError(t, err)
serv, err := newSock()
require.NoError(t, err)
err = serv.Listen(testAddr)
require.NoError(t, err)
defer serv.Close()
s := &client{
sock: sock,
addr: testAddr,
}
in := make(chan *transport.Message)
out := make(chan *transport.Message)
ch := s.Loop(ctx, in, out)
msg, err := transport.NewMessage(transport.CmdRequest, "data")
require.NoError(t, err)
data, err := json.Marshal(msg)
require.NoError(t, err)
serv.Send(data)
recvdMsg := <-in
require.Equal(t, msg, recvdMsg)
out <- msg
data, err = serv.Recv()
require.NoError(t, err)
recvdMsg = &transport.Message{}
err = json.Unmarshal(data, recvdMsg)
require.NoError(t, err)
require.Equal(t, msg, recvdMsg)
cancel()
err = <-ch
require.NoError(t, err)
} | explode_data.jsonl/55412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 378
} | [
2830,
3393,
44,
5170,
2959,
14620,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
220,
16,
15,
77053,
71482,
340,
16867,
9121,
2822,
85809,
11,
1848,
1669,
501,
79812,
741,
17957,
35699,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue18066(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
orgEnable := core.PreparedPlanCacheEnabled()
defer core.SetPreparedPlanCache(orgEnable)
core.SetPreparedPlanCache(true)
se, err := session.CreateSession4TestWithOpt(store, &session.Opt{
PreparedPlanCache: kvcache.NewSimpleLRUCache(100, 0.1, math.MaxUint64),
})
require.NoError(t, err)
tk := testkit.NewTestKitWithSession(t, store, se)
tk.RefreshConnectionID()
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
tk.MustExec("prepare stmt from 'select * from t'")
tk.MustQuery("execute stmt").Check(testkit.Rows())
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from `t`'").Check(
testkit.Rows("1 0 0"))
tk.MustQuery("execute stmt").Check(testkit.Rows())
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from `t`'").Check(
testkit.Rows("2 1 1"))
tk.MustExec("prepare stmt from 'select * from t'")
tk.MustQuery("execute stmt").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("select EXEC_COUNT,plan_cache_hits, plan_in_cache from information_schema.statements_summary where digest_text='select * from `t`'").Check(
testkit.Rows("3 1 0"))
} | explode_data.jsonl/5523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 560
} | [
2830,
3393,
42006,
16,
23,
15,
21,
21,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
87625,
11084,
1669,
6200,
28770,
7212,
20485,
8233,
5462,
741,
16867,
6200,
4202,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseBuildTargetFlag(t *testing.T) {
androidArchs := "arm"
iosArchs := "arm,arm64,amd64"
tests := []struct {
in string
wantErr bool
wantOS string
wantArchs string
}{
{"android", false, "android", androidArchs},
{"android,android/arm", false, "android", androidArchs},
{"android/arm", false, "android", "arm"},
{"ios", false, "darwin", iosArchs},
{"ios,ios/arm", false, "darwin", iosArchs},
{"ios/arm", false, "darwin", "arm"},
{"ios/amd64", false, "darwin", "amd64"},
{"", true, "", ""},
{"linux", true, "", ""},
{"android/x86", true, "", ""},
{"android/arm5", true, "", ""},
{"ios/mips", true, "", ""},
{"android,ios", true, "", ""},
{"ios,android", true, "", ""},
}
for _, tc := range tests {
gotOS, gotArchs, err := parseBuildTarget(tc.in)
if tc.wantErr {
if err == nil {
t.Errorf("-target=%q; want error, got (%q, %q, nil)", tc.in, gotOS, gotArchs)
}
continue
}
if err != nil || gotOS != tc.wantOS || strings.Join(gotArchs, ",") != tc.wantArchs {
t.Errorf("-target=%q; want (%v, [%v], nil), got (%q, %q, %v)",
tc.in, tc.wantOS, tc.wantArchs, gotOS, gotArchs, err)
}
}
} | explode_data.jsonl/17104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 518
} | [
2830,
3393,
14463,
11066,
6397,
12135,
1155,
353,
8840,
836,
8,
341,
197,
5954,
18727,
82,
1669,
330,
2178,
698,
197,
3530,
18727,
82,
1669,
330,
2178,
11,
2178,
21,
19,
11,
67913,
21,
19,
1837,
78216,
1669,
3056,
1235,
341,
197,
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... | 7 |
func TestPublishValidatesPackageName(t *testing.T) {
cfg := build.TestConfig()
cfg.PkgName = "INVALIDPACKAGENAME"
defer os.RemoveAll(filepath.Dir(cfg.TempDir))
build.BuildTestPackage(cfg)
depfilePath := filepath.Join(cfg.OutputDir, "depfile.d")
outputManifestPath := filepath.Join(cfg.OutputDir, "package_manifest.json")
packagesListPath := filepath.Join(cfg.OutputDir, "packages.list")
if err := ioutil.WriteFile(packagesListPath, []byte(outputManifestPath+"\n"), 0600); err != nil {
t.Fatal(err)
}
repoDir := t.TempDir()
if err := Run(cfg, []string{"-repo", repoDir, "-depfile", depfilePath, "-lp", "-f", packagesListPath}); err == nil {
t.Fatalf("Expected invalid package name to generate error.")
}
} | explode_data.jsonl/53636 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 262
} | [
2830,
3393,
50145,
4088,
973,
65655,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
1936,
8787,
2648,
741,
50286,
1069,
7351,
675,
284,
330,
46859,
17279,
1890,
67329,
698,
16867,
2643,
84427,
34793,
83757,
28272,
65009,
6184,
1171,
69371,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFreeSpaceTiesBrokenByDetectedTime(t *testing.T) {
manager, fakeRuntime, _ := newRealImageGCManager(ImageGCPolicy{})
fakeRuntime.ImageList = []container.Image{
makeImage(0, 1024),
}
fakeRuntime.AllPodList = []*containertest.FakePod{
{Pod: &container.Pod{
Containers: []*container.Container{
makeContainer(0),
},
}},
}
// Make 1 more recently detected but used at the same time as 0.
require.NoError(t, manager.detectImages(zero))
fakeRuntime.ImageList = []container.Image{
makeImage(0, 1024),
makeImage(1, 2048),
}
require.NoError(t, manager.detectImages(time.Now()))
fakeRuntime.AllPodList = []*containertest.FakePod{}
require.NoError(t, manager.detectImages(time.Now()))
require.Equal(t, manager.imageRecordsLen(), 2)
spaceFreed, err := manager.freeSpace(1024, time.Now())
assert := assert.New(t)
require.NoError(t, err)
assert.EqualValues(2048, spaceFreed)
assert.Len(fakeRuntime.ImageList, 1)
} | explode_data.jsonl/48111 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 352
} | [
2830,
3393,
10940,
9914,
51,
550,
90526,
1359,
17076,
1569,
1462,
1155,
353,
8840,
836,
8,
341,
92272,
11,
12418,
15123,
11,
716,
1669,
501,
12768,
1906,
22863,
2043,
30122,
38,
7123,
8018,
37790,
1166,
726,
15123,
7528,
852,
284,
3056,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_ValidImage(t *testing.T) {
imageNames := map[string]bool{
// error cases
"failed to solve: rpc error: code = Unknown desc = exit code 2": false,
"failed to solve: rpc error: code = Unknown desc = exit status 2": false,
"failed to solve:": false,
"error:": false,
"code =": false,
"-1": false,
"": false,
" ": false,
// "docker-registry:5000/admin/alexellis-sofia-test1-go-world:0.1-374448ba4d75bcf49611525a5b2448d9c3d0bf28": true,
// url (with/without tag)
"docker.io/ofcommunity/someuser/repo-name-function_name": true,
"docker.io/ofcommunity/someuser/repo-name-function_name:latest": true,
"docker.io/ofcommunity/someuser/repo-name-function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
// url with port (with/without tag)
"docker.io:80/ofcommunity/someuser/repo-name-function_name": true,
"docker.io:80/ofcommunity/someuser/repo-name-function_name:latest": true,
"docker.io:80/ofcommunity/someuser/repo-name-function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
// url with ip (with/without tag)
"127.0.0.1/someuser/repo-name-function_name": true,
"127.0.0.1/someuser/repo-name-function_name:latest": true,
"127.0.0.1/someuser/repo-name-function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
// url with ip and port (with/without tag)
"127.0.0.1:5000/someuser/repo-name-function_name": true,
"127.0.0.1:5000/someuser/repo-name-function_name:latest": true,
"127.0.0.1:5000/someuser/repo-name-function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
// docker user specific (with/without tag)
"someuser/repo-name-function_name": true,
"someuser/repo-name-function_name:latest": true,
"someuser/repo-name-function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
// open faas cloud function name (with/without tag)
"repo-name-function_name": true,
"repo-name-function_name:latest": true,
"repo-name-function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
// simple function name (with/without tag)
"function_name": true,
"function_name:latest": true,
"function_name:latest-7f7ec13d12b1397408e54b79686d43e41974bfa0": true,
}
for image, want := range imageNames {
got := validImage(image)
if got != want {
t.Errorf("Validating image %s - want: %v, got: %v", image, want, got)
}
}
} | explode_data.jsonl/11975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1532
} | [
2830,
3393,
97279,
1906,
1155,
353,
8840,
836,
8,
341,
31426,
7980,
1669,
2415,
14032,
96436,
4257,
197,
197,
322,
1465,
5048,
198,
197,
197,
1,
16091,
311,
11625,
25,
35596,
1465,
25,
2038,
284,
21693,
6560,
284,
4869,
2038,
220,
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... | 3 |
func TestResolveMetricArgsUnableToSubstitute(t *testing.T) {
f := newFixture(t)
defer f.Close()
c, _, _ := f.newController(noResyncPeriodFunc)
// Dry-Run or not if the args resolution fails then we should fail the analysis
for _, isDryRun := range [3]bool{false, true, false} {
var dryRunArray []v1alpha1.DryRun
if isDryRun {
dryRunArray = append(dryRunArray, v1alpha1.DryRun{MetricName: "*"})
}
run := &v1alpha1.AnalysisRun{
Spec: v1alpha1.AnalysisRunSpec{
Metrics: []v1alpha1.Metric{{
Name: "rate",
SuccessCondition: "{{args.does-not-exist}}",
Provider: v1alpha1.MetricProvider{
Prometheus: &v1alpha1.PrometheusMetric{
Query: "{{args.metric-name}}",
},
},
}},
DryRun: dryRunArray,
},
}
newRun := c.reconcileAnalysisRun(run)
assert.Equal(t, v1alpha1.AnalysisPhaseError, newRun.Status.Phase)
assert.Equal(t, "Unable to resolve metric arguments: failed to resolve {{args.metric-name}}", newRun.Status.Message)
}
} | explode_data.jsonl/75834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 438
} | [
2830,
3393,
56808,
54310,
4117,
17075,
1249,
3136,
7660,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
10421,
741,
1444,
11,
8358,
716,
1669,
282,
4618,
2051,
39205,
1061,
1721,
23750,
9626,
340,
197,
322,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestParseSimpleExpressions(t *testing.T) {
checkParseExpression(t, "123", "123")
checkParseExpression(t, "abc", "abc")
checkParseExpression(t, "3.14", "3.140000")
} | explode_data.jsonl/33529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
14463,
16374,
40315,
1155,
353,
8840,
836,
8,
341,
25157,
14463,
9595,
1155,
11,
330,
16,
17,
18,
497,
330,
16,
17,
18,
1138,
25157,
14463,
9595,
1155,
11,
330,
13683,
497,
330,
13683,
1138,
25157,
14463,
9595,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestMCP23017DriverReadPort(t *testing.T) {
// read
mcp, adaptor := initTestMCP23017DriverWithStubbedAdaptor(0)
gobottest.Assert(t, mcp.Start(), nil)
port := mcp.getPort("A")
adaptor.i2cReadImpl = func(b []byte) (int, error) {
copy(b, []byte{255})
return 1, nil
}
val, _ := mcp.read(port.IODIR)
gobottest.Assert(t, val, uint8(255))
// read error
mcp, adaptor = initTestMCP23017DriverWithStubbedAdaptor(0)
gobottest.Assert(t, mcp.Start(), nil)
adaptor.i2cReadImpl = func(b []byte) (int, error) {
return len(b), errors.New("read error")
}
val, err := mcp.read(port.IODIR)
gobottest.Assert(t, val, uint8(0))
gobottest.Assert(t, err, errors.New("read error"))
// debug
debug = true
log.SetOutput(ioutil.Discard)
mcp, adaptor = initTestMCP23017DriverWithStubbedAdaptor(0)
gobottest.Assert(t, mcp.Start(), nil)
port = mcp.getPort("A")
adaptor.i2cReadImpl = func(b []byte) (int, error) {
copy(b, []byte{255})
return 1, nil
}
val, _ = mcp.read(port.IODIR)
gobottest.Assert(t, val, uint8(255))
debug = false
log.SetOutput(os.Stdout)
} | explode_data.jsonl/42323 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
44,
7123,
17,
18,
15,
16,
22,
11349,
4418,
7084,
1155,
353,
8840,
836,
8,
341,
197,
322,
1349,
198,
2109,
4672,
11,
91941,
1669,
2930,
2271,
44,
7123,
17,
18,
15,
16,
22,
11349,
2354,
33838,
2721,
2589,
32657,
7,
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 TestDatasources_Vault_UserPassAuth(t *testing.T) {
v := setupDatasourcesVaultTest(t)
v.vc.Logical().Write("secret/foo", map[string]interface{}{"value": "bar"})
defer v.vc.Logical().Delete("secret/foo")
err := v.vc.Sys().EnableAuth("userpass", "userpass", "")
require.NoError(t, err)
err = v.vc.Sys().EnableAuth("userpass2", "userpass", "")
require.NoError(t, err)
defer v.vc.Sys().DisableAuth("userpass")
defer v.vc.Sys().DisableAuth("userpass2")
_, err = v.vc.Logical().Write("auth/userpass/users/dave", map[string]interface{}{
"password": "foo", "ttl": "10s", "policies": "readpol"})
require.NoError(t, err)
_, err = v.vc.Logical().Write("auth/userpass2/users/dave", map[string]interface{}{
"password": "bar", "ttl": "10s", "policies": "readpol"})
require.NoError(t, err)
o, e, err := cmd(t, "-d", "vault=vault:///secret",
"-i", `{{(ds "vault" "foo").value}}`).
withEnv("VAULT_ADDR", "http://"+v.addr).
withEnv("VAULT_AUTH_USERNAME", "dave").
withEnv("VAULT_AUTH_PASSWORD", "foo").
run()
assertSuccess(t, o, e, err, "bar")
userFile := fs.NewFile(t, "test-vault-user", fs.WithContent("dave"))
passFile := fs.NewFile(t, "test-vault-pass", fs.WithContent("foo"))
defer userFile.Remove()
defer passFile.Remove()
o, e, err = cmd(t,
"-d", "vault=vault:///secret",
"-i", `{{(ds "vault" "foo").value}}`).
withEnv("VAULT_ADDR", "http://"+v.addr).
withEnv("VAULT_AUTH_USERNAME_FILE", userFile.Path()).
withEnv("VAULT_AUTH_PASSWORD_FILE", passFile.Path()).
run()
assertSuccess(t, o, e, err, "bar")
o, e, err = cmd(t,
"-d", "vault=vault:///secret",
"-i", `{{(ds "vault" "foo").value}}`).
withEnv("VAULT_ADDR", "http://"+v.addr).
withEnv("VAULT_AUTH_USERNAME", "dave").
withEnv("VAULT_AUTH_PASSWORD", "bar").
withEnv("VAULT_AUTH_USERPASS_MOUNT", "userpass2").
run()
assertSuccess(t, o, e, err, "bar")
} | explode_data.jsonl/57232 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 822
} | [
2830,
3393,
47663,
2360,
2334,
945,
31339,
12187,
5087,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
6505,
47663,
2360,
79177,
2271,
1155,
692,
5195,
3133,
66,
5247,
938,
1005,
7985,
445,
20474,
60555,
497,
2415,
14032,
31344,
6257,
4913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGoveralls(t *testing.T) {
tmp := prepareTest(t)
p := myImportPath()
defer os.RemoveAll(tmp)
runCmd(t, "go", "get", p+"/tester")
runCmd(t, "go", "get", "github.com/axw/gocov/gocov")
b := runCmd(t, "./goveralls", "-package="+p+"/tester", "")
lines := strings.Split(strings.TrimSpace(string(b)), "\n")
s := lines[len(lines)-1]
if s != "Succeeded" {
t.Fatalf("Expected test of tester are succeeded, but failured")
}
} | explode_data.jsonl/4595 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
38,
1975,
5583,
1155,
353,
8840,
836,
8,
341,
20082,
1669,
10549,
2271,
1155,
340,
3223,
1669,
847,
11511,
1820,
741,
16867,
2643,
84427,
10368,
340,
56742,
15613,
1155,
11,
330,
3346,
497,
330,
455,
497,
281,
27569,
73358,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_metricsForwarder_prepareReconcileMetric(t *testing.T) {
defaultGlobalTags := []string{"gtagkey:gtagvalue"}
defaultTags := []string{"tagkey:tagvalue"}
tests := []struct {
name string
reconcileErr error
want float64
want1 []string
wantErr bool
}{
{
name: "lastReconcileErr init value",
reconcileErr: errInitValue,
want: 0.0,
want1: nil,
wantErr: true,
},
{
name: "lastReconcileErr nil",
reconcileErr: nil,
want: 1.0,
want1: []string{"gtagkey:gtagvalue", "tagkey:tagvalue", "reconcile_err:null"},
wantErr: false,
},
{
name: "lastReconcileErr updated and not nil",
reconcileErr: apierrors.NewUnauthorized("Auth error"),
want: 0.0,
want1: []string{"gtagkey:gtagvalue", "tagkey:tagvalue", "reconcile_err:Unauthorized"},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mf := &metricsForwarder{
globalTags: defaultGlobalTags,
tags: defaultTags,
}
got, got1, err := mf.prepareReconcileMetric(tt.reconcileErr)
if (err != nil) != tt.wantErr {
t.Errorf("metricsForwarder.prepareReconcileMetric() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("metricsForwarder.prepareReconcileMetric() got = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got1, tt.want1) {
t.Errorf("metricsForwarder.prepareReconcileMetric() got1 = %v, want %v", got1, tt.want1)
}
})
}
} | explode_data.jsonl/8874 | {
"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,
37686,
25925,
261,
47460,
693,
40446,
457,
54310,
1155,
353,
8840,
836,
8,
341,
11940,
11646,
15930,
1669,
3056,
917,
4913,
70,
4578,
792,
70418,
4578,
957,
16707,
11940,
15930,
1669,
3056,
917,
4913,
4578,
792,
25,
4578,
95... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadonlyModifier(t *testing.T) {
suite := tester.NewParserDumpTestSuite(t)
suite.UsePHP8()
suite.Code = `<?php
class Foo {
readonly string $a;
private readonly string $a;
private string $a;
private readonly $a = 100;
public function __construct(
readonly string $a,
private readonly string $a,
private string $a,
private readonly $a = 100,
) {}
}
`
suite.Expected = `&ast.Root{
Stmts: []ast.Vertex{
&ast.StmtClass{
Name: &ast.Identifier{
Val: []byte("Foo"),
},
Stmts: []ast.Vertex{
&ast.StmtPropertyList{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("readonly"),
},
},
Type: &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{
Val: []byte("string"),
},
},
},
Props: []ast.Vertex{
&ast.StmtProperty{
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
},
},
},
&ast.StmtPropertyList{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("private"),
},
&ast.Identifier{
Val: []byte("readonly"),
},
},
Type: &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{
Val: []byte("string"),
},
},
},
Props: []ast.Vertex{
&ast.StmtProperty{
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
},
},
},
&ast.StmtPropertyList{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("private"),
},
},
Type: &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{
Val: []byte("string"),
},
},
},
Props: []ast.Vertex{
&ast.StmtProperty{
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
},
},
},
&ast.StmtPropertyList{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("private"),
},
&ast.Identifier{
Val: []byte("readonly"),
},
},
Props: []ast.Vertex{
&ast.StmtProperty{
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
Expr: &ast.ScalarLnumber{
Val: []byte("100"),
},
},
},
},
&ast.StmtClassMethod{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("public"),
},
},
Name: &ast.Identifier{
Val: []byte("__construct"),
},
Params: []ast.Vertex{
&ast.Parameter{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("readonly"),
},
},
Type: &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{
Val: []byte("string"),
},
},
},
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
},
&ast.Parameter{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("private"),
},
&ast.Identifier{
Val: []byte("readonly"),
},
},
Type: &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{
Val: []byte("string"),
},
},
},
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
},
&ast.Parameter{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("private"),
},
},
Type: &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{
Val: []byte("string"),
},
},
},
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
},
&ast.Parameter{
Modifiers: []ast.Vertex{
&ast.Identifier{
Val: []byte("private"),
},
&ast.Identifier{
Val: []byte("readonly"),
},
},
Var: &ast.ExprVariable{
Name: &ast.Identifier{
Val: []byte("$a"),
},
},
DefaultValue: &ast.ScalarLnumber{
Val: []byte("100"),
},
},
},
Stmt: &ast.StmtStmtList{
Stmts: []ast.Vertex{},
},
},
},
},
},
},`
suite.Run()
} | explode_data.jsonl/3846 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2615
} | [
2830,
3393,
4418,
3243,
34405,
1155,
353,
8840,
836,
8,
341,
96572,
1669,
37111,
7121,
6570,
51056,
2271,
28000,
1155,
340,
96572,
9046,
15158,
23,
741,
96572,
20274,
284,
1565,
1316,
1208,
198,
1040,
33428,
341,
197,
22569,
914,
400,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNotMatcherSelectsLabelsUnsetSeries(t *testing.T) {
db, delete := openTestDB(t, nil)
defer func() {
testutil.Ok(t, db.Close())
delete()
}()
labelpairs := []labels.Labels{
labels.FromStrings("a", "abcd", "b", "abcde"),
labels.FromStrings("labelname", "labelvalue"),
}
app := db.Appender()
for _, lbls := range labelpairs {
_, err := app.Add(lbls, 0, 1)
testutil.Ok(t, err)
}
testutil.Ok(t, app.Commit())
cases := []struct {
selector labels.Selector
series []labels.Labels
}{{
selector: labels.Selector{
labels.Not(labels.NewEqualMatcher("lname", "lvalue")),
},
series: labelpairs,
}, {
selector: labels.Selector{
labels.NewEqualMatcher("a", "abcd"),
labels.Not(labels.NewEqualMatcher("b", "abcde")),
},
series: []labels.Labels{},
}, {
selector: labels.Selector{
labels.NewEqualMatcher("a", "abcd"),
labels.Not(labels.NewEqualMatcher("b", "abc")),
},
series: []labels.Labels{labelpairs[0]},
}, {
selector: labels.Selector{
labels.Not(labels.NewMustRegexpMatcher("a", "abd.*")),
},
series: labelpairs,
}, {
selector: labels.Selector{
labels.Not(labels.NewMustRegexpMatcher("a", "abc.*")),
},
series: labelpairs[1:],
}, {
selector: labels.Selector{
labels.Not(labels.NewMustRegexpMatcher("c", "abd.*")),
},
series: labelpairs,
}, {
selector: labels.Selector{
labels.Not(labels.NewMustRegexpMatcher("labelname", "labelvalue")),
},
series: labelpairs[:1],
}}
q, err := db.Querier(0, 10)
testutil.Ok(t, err)
defer func() { testutil.Ok(t, q.Close()) }()
for _, c := range cases {
ss, err := q.Select(c.selector...)
testutil.Ok(t, err)
lres, err := expandSeriesSet(ss)
testutil.Ok(t, err)
testutil.Equals(t, c.series, lres)
}
} | explode_data.jsonl/64380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 796
} | [
2830,
3393,
2623,
37554,
3379,
82,
23674,
1806,
746,
25544,
1155,
353,
8840,
836,
8,
341,
20939,
11,
3698,
1669,
1787,
2271,
3506,
1155,
11,
2092,
340,
16867,
2915,
368,
341,
197,
18185,
1314,
54282,
1155,
11,
2927,
10421,
2398,
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 TestUnreadRune(t *testing.T) {
segments := []string{"Hello, world:", "日本語"}
r := NewReader(&StringReader{data: segments})
got := ""
want := strings.Join(segments, "")
// Normal execution.
for {
r1, _, err := r.ReadRune()
if err != nil {
if err != io.EOF {
t.Error("unexpected error on ReadRune:", err)
}
break
}
got += string(r1)
// Put it back and read it again.
if err = r.UnreadRune(); err != nil {
t.Fatal("unexpected error on UnreadRune:", err)
}
r2, _, err := r.ReadRune()
if err != nil {
t.Fatal("unexpected error reading after unreading:", err)
}
if r1 != r2 {
t.Fatalf("incorrect rune after unread: got %c, want %c", r1, r2)
}
}
if got != want {
t.Errorf("got %q, want %q", got, want)
}
} | explode_data.jsonl/22850 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
1806,
878,
49,
2886,
1155,
353,
8840,
836,
8,
341,
197,
56829,
1669,
3056,
917,
4913,
9707,
11,
1879,
12147,
330,
101059,
102819,
16707,
7000,
1669,
1532,
5062,
2099,
703,
5062,
90,
691,
25,
20632,
3518,
3174,
354,
1669,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestNacksTracker(t *testing.T) {
nmc := newNackMockedConsumer()
nacks := newNegativeAcksTracker(nmc, testNackDelay)
nacks.Add(&messageID{
ledgerID: 1,
entryID: 1,
batchIdx: 1,
})
nacks.Add(&messageID{
ledgerID: 2,
entryID: 2,
batchIdx: 1,
})
msgIds := make([]messageID, 0)
for id := range nmc.Wait() {
msgIds = append(msgIds, id)
}
msgIds = sortMessageIds(msgIds)
assert.Equal(t, 2, len(msgIds))
assert.Equal(t, int64(1), msgIds[0].ledgerID)
assert.Equal(t, int64(1), msgIds[0].entryID)
assert.Equal(t, int64(2), msgIds[1].ledgerID)
assert.Equal(t, int64(2), msgIds[1].entryID)
nacks.Close()
} | explode_data.jsonl/23022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
45,
7821,
31133,
1155,
353,
8840,
836,
8,
341,
9038,
12887,
1669,
501,
45,
473,
11571,
291,
29968,
741,
9038,
7821,
1669,
501,
38489,
32,
14553,
31133,
1445,
12887,
11,
1273,
45,
473,
20039,
692,
9038,
7821,
1904,
2099,
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 TestPacketMPLSInMPLS(t *testing.T) {
p := gopacket.NewPacket(testPacketMPLSInMPLS, LinkTypeEthernet, testDecodeOptions)
if p.ErrorLayer() != nil {
t.Error("Failed to decode packet:", p.ErrorLayer().Error())
}
checkLayers(p, []gopacket.LayerType{
LayerTypeEthernet,
LayerTypeMPLS,
LayerTypeMPLS,
LayerTypeIPv4,
LayerTypeICMPv4,
gopacket.LayerTypePayload}, t)
} | explode_data.jsonl/42266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
16679,
44,
2916,
50,
641,
44,
2916,
50,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
342,
453,
5709,
7121,
16679,
8623,
16679,
44,
2916,
50,
641,
44,
2916,
50,
11,
5948,
929,
98006,
11,
1273,
32564,
3798,
340,
743,
281,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCreateTableEscaped(t *testing.T) {
testCases := []struct {
input string
output string
}{{
input: "create table `a`(`id` int, primary key(`id`))",
output: "create table a (\n" +
"\tid int,\n" +
"\tprimary key (id)\n" +
")",
}, {
input: "create table `insert`(`update` int, primary key(`delete`))",
output: "create table `insert` (\n" +
"\t`update` int,\n" +
"\tprimary key (`delete`)\n" +
")",
}}
for _, tcase := range testCases {
tree, err := ParseStrictDDL(tcase.input)
if err != nil {
t.Errorf("input: %s, err: %v", tcase.input, err)
continue
}
if got, want := String(tree.(*CreateTable)), tcase.output; got != want {
t.Errorf("Parse(%s):\n%s, want\n%s", tcase.input, got, want)
}
}
} | explode_data.jsonl/27190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
4021,
2556,
36121,
10185,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
22427,
220,
914,
198,
197,
21170,
914,
198,
197,
15170,
515,
197,
22427,
25,
330,
3182,
1965,
1565,
64,
63,
5809,
307,
63,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCollector(t *testing.T) {
tests := []struct {
name string
d device
metrics []string
}{
{
name: "no tuners",
d: &testDevice{
model: "hdhomerun_test",
},
metrics: []string{
`hdhomerun_device_info{model="hdhomerun_test"} 1`,
},
},
{
name: "not tuned",
d: &testDevice{
model: "hdhomerun_test",
tuners: []testTuner{{
index: 0,
debug: &hdhomerun.TunerDebug{
Tuner: &hdhomerun.TunerStatus{
Channel: "none",
Lock: "none",
},
Device: &hdhomerun.DeviceStatus{},
CableCARD: &hdhomerun.CableCARDStatus{},
TransportStream: &hdhomerun.TransportStreamStatus{},
Network: &hdhomerun.NetworkStatus{},
},
}},
},
metrics: []string{
`hdhomerun_cablecard_bytes_per_second 0`,
`hdhomerun_cablecard_overflow 0`,
`hdhomerun_cablecard_resync 0`,
`hdhomerun_device_info{model="hdhomerun_test"} 1`,
`hdhomerun_network_errors{tuner="0"} 0`,
`hdhomerun_network_packets_per_second{tuner="0"} 0`,
`hdhomerun_tuner_info{channel="none",lock="none",tuner="0"} 1`,
`hdhomerun_tuner_signal_strength_ratio{tuner="0"} 0`,
`hdhomerun_tuner_signal_to_noise_ratio{tuner="0"} 0`,
`hdhomerun_tuner_symbol_error_ratio{tuner="0"} 0`,
},
},
{
name: "tuned",
d: &testDevice{
model: "hdhomerun_test",
tuners: []testTuner{
{
index: 0,
debug: &hdhomerun.TunerDebug{
Tuner: &hdhomerun.TunerStatus{
Channel: "qam:381000000",
Lock: "qam256:381000000",
SignalStrength: 100,
SignalToNoiseQuality: 100,
SymbolErrorQuality: 100,
},
Device: &hdhomerun.DeviceStatus{
BitsPerSecond: 38809216,
Resync: 1,
Overflow: 1,
},
CableCARD: &hdhomerun.CableCARDStatus{
BitsPerSecond: 38810720,
Resync: 1,
Overflow: 1,
},
TransportStream: &hdhomerun.TransportStreamStatus{
BitsPerSecond: 2534240,
TransportErrors: 1,
CRCErrors: 1,
},
Network: &hdhomerun.NetworkStatus{
PacketsPerSecond: 241,
Errors: 1,
Stop: hdhomerun.StopReasonNotStopped,
},
},
},
{
index: 1,
debug: &hdhomerun.TunerDebug{
Tuner: &hdhomerun.TunerStatus{
Channel: "none",
Lock: "none",
},
Device: &hdhomerun.DeviceStatus{},
CableCARD: &hdhomerun.CableCARDStatus{},
TransportStream: &hdhomerun.TransportStreamStatus{},
Network: &hdhomerun.NetworkStatus{},
},
},
},
},
metrics: []string{
`hdhomerun_cablecard_bytes_per_second 4.85134e+06`,
`hdhomerun_cablecard_overflow 1`,
`hdhomerun_cablecard_resync 1`,
`hdhomerun_device_info{model="hdhomerun_test"} 1`,
`hdhomerun_network_errors{tuner="0"} 1`,
`hdhomerun_network_errors{tuner="1"} 0`,
`hdhomerun_network_packets_per_second{tuner="0"} 241`,
`hdhomerun_network_packets_per_second{tuner="1"} 0`,
`hdhomerun_tuner_info{channel="qam:381000000",lock="qam256:381000000",tuner="0"} 1`,
`hdhomerun_tuner_info{channel="none",lock="none",tuner="1"} 1`,
`hdhomerun_tuner_signal_strength_ratio{tuner="0"} 1`,
`hdhomerun_tuner_signal_strength_ratio{tuner="1"} 0`,
`hdhomerun_tuner_signal_to_noise_ratio{tuner="0"} 1`,
`hdhomerun_tuner_signal_to_noise_ratio{tuner="1"} 0`,
`hdhomerun_tuner_symbol_error_ratio{tuner="0"} 1`,
`hdhomerun_tuner_symbol_error_ratio{tuner="1"} 0`,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
body := testCollector(t, tt.d)
s := bufio.NewScanner(bytes.NewReader(body))
for s.Scan() {
// Skip metric HELP and TYPE lines.
text := s.Text()
if strings.HasPrefix(text, "#") {
continue
}
var found bool
for _, m := range tt.metrics {
if text == m {
found = true
break
}
}
if !found {
t.Log(string(body))
t.Fatalf("metric string not matched in whitelist: %s", text)
}
}
if err := s.Err(); err != nil {
t.Fatalf("failed to scan metrics: %v", err)
}
})
}
} | explode_data.jsonl/72233 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2314
} | [
2830,
3393,
53694,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
2698,
981,
3671,
198,
197,
2109,
13468,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
2152,
11460,
388,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgCreateGroupSigner(t *testing.T) {
_, _, myAddr := testdata.KeyTestPubAddr()
assert.Equal(t, []sdk.AccAddress{myAddr}, MsgCreateGroupRequest{Admin: myAddr.String()}.GetSigners())
} | explode_data.jsonl/82399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
6611,
4021,
2808,
7264,
261,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
847,
13986,
1669,
1273,
691,
9610,
2271,
29162,
13986,
741,
6948,
12808,
1155,
11,
3056,
51295,
77538,
4286,
90,
2408,
13986,
2137,
24205,
4021,
280... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfig(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
cfg := &Config{DialTimeout: time.Second, OpTimeout: time.Second}
etcdCfg, err := ConfigToClient(cfg)
Expect(err).ToNot(HaveOccurred())
Expect(etcdCfg).NotTo(BeNil())
Expect(etcdCfg.OpTimeout).To(BeEquivalentTo(time.Second))
Expect(etcdCfg.DialTimeout).To(BeEquivalentTo(time.Second))
Expect(etcdCfg.TLS).To(BeNil())
} | explode_data.jsonl/29439 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
2648,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6505,
2271,
1155,
340,
16867,
5635,
31853,
37496,
2271,
2822,
50286,
1669,
609,
2648,
90,
35,
530,
7636,
25,
882,
32435,
11,
10672,
7636,
25,
882,
32435,
532,
197,
295,
4385... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCiid_Contains(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
fields string
args args
want bool
}{
{
name: "correct",
fields: "MsA/1.1/xxx%22s(msC/1.4%5555s+msD/2.2%23234s)",
args: args{
s: "MsA/1.1",
},
want: true,
},
{
name: "correct",
fields: "MsA/1.1/xxx%22s(msC/1.4%5555s+msD/2.2%23234s)",
args: args{
s: "msC",
},
want: true,
},
{
name: "correct",
fields: "MsA/1.1/xxx%22s(msC/1.4%5555s+msD/2.2%23234s)",
args: args{
s: "msC/1.4",
},
want: true,
},
{
name: "correct",
fields: "MsA/1.1/xxx%22s(msC/1.4%5555s+msD/2.2%23234s)",
args: args{
s: "msC/1.3",
},
want: false,
},
{
name: "correct",
fields: "MsA/1.1/xxx%22s(msC/1.4%5555s+msD/2.2%23234s)",
args: args{
s: "msD/1.4",
},
want: false,
},
{
name: "correct",
fields: "MsA/1.1/xxx%22s(msC/1.4%5555s+msD/2.2%23234s)",
args: args{
s: "msD/2.2",
},
want: true,
},
{
name: "empty",
fields: "msA/1.1/dev-1234%22s",
args: args{
s: "",
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := NewStdCiid(tt.fields)
if got := m.Contains(tt.args.s); got != tt.want {
t.Errorf("Ciid.Contains() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/64800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 831
} | [
2830,
3393,
34,
54483,
62,
23805,
1155,
353,
8840,
836,
8,
1476,
13158,
2827,
2036,
341,
197,
1903,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
55276,
914,
198,
197,
31215,
256,
2827,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBuildManagerIdentifier(t *testing.T) {
tests := []struct {
managedFieldsEntry string
expected string
}{
{
managedFieldsEntry: `
apiVersion: v1
fieldsV1:
f:apiVersion: {}
manager: foo
operation: Update
time: "2001-02-03T04:05:06Z"
`,
expected: "{\"manager\":\"foo\",\"operation\":\"Update\",\"apiVersion\":\"v1\"}",
},
{
managedFieldsEntry: `
apiVersion: v1
fieldsV1:
f:apiVersion: {}
manager: foo
operation: Apply
time: "2001-02-03T04:05:06Z"
`,
expected: "{\"manager\":\"foo\",\"operation\":\"Apply\"}",
},
}
for _, test := range tests {
t.Run(test.managedFieldsEntry, func(t *testing.T) {
var unmarshaled metav1.ManagedFieldsEntry
if err := yaml.Unmarshal([]byte(test.managedFieldsEntry), &unmarshaled); err != nil {
t.Fatalf("did not expect yaml unmarshalling error but got: %v", err)
}
decoded, err := BuildManagerIdentifier(&unmarshaled)
if err != nil {
t.Fatalf("did not expect decoding error but got: %v", err)
}
if !reflect.DeepEqual(decoded, test.expected) {
t.Fatalf("expected:\n%v\nbut got:\n%v", test.expected, decoded)
}
})
}
} | explode_data.jsonl/68835 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 466
} | [
2830,
3393,
11066,
2043,
8714,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
25270,
8941,
5874,
914,
198,
197,
42400,
1843,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
25270,
8941,
5874,
25,
22074,
2068,
563... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}
for _, invalidParam := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderDecenterAds, json.RawMessage(invalidParam)); err == nil {
t.Errorf("Schema allowed unexpected params: %s", invalidParam)
}
}
} | explode_data.jsonl/57182 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
7928,
4870,
1155,
353,
8840,
836,
8,
341,
197,
16112,
11,
1848,
1669,
1787,
3342,
65,
9927,
7121,
65452,
1107,
4870,
14256,
36800,
1978,
3470,
307,
1107,
12,
3519,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
94... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreatePostSendOutOfChannelMentions(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Client := th.Client
WebSocketClient, err := th.CreateWebSocketClient()
require.Nil(t, err)
WebSocketClient.Listen()
inChannelUser := th.CreateUser()
th.LinkUserToTeam(inChannelUser, th.BasicTeam)
th.App.AddUserToChannel(inChannelUser, th.BasicChannel)
post1 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "@" + inChannelUser.Username}
_, resp := Client.CreatePost(post1)
CheckNoError(t, resp)
CheckCreatedStatus(t, resp)
timeout := time.After(300 * time.Millisecond)
waiting := true
for waiting {
select {
case event := <-WebSocketClient.EventChannel:
require.NotEqual(t, model.WEBSOCKET_EVENT_EPHEMERAL_MESSAGE, event.EventType(), "should not have ephemeral message event")
case <-timeout:
waiting = false
}
}
outOfChannelUser := th.CreateUser()
th.LinkUserToTeam(outOfChannelUser, th.BasicTeam)
post2 := &model.Post{ChannelId: th.BasicChannel.Id, Message: "@" + outOfChannelUser.Username}
_, resp = Client.CreatePost(post2)
CheckNoError(t, resp)
CheckCreatedStatus(t, resp)
timeout = time.After(300 * time.Millisecond)
waiting = true
for waiting {
select {
case event := <-WebSocketClient.EventChannel:
if event.EventType() != model.WEBSOCKET_EVENT_EPHEMERAL_MESSAGE {
// Ignore any other events
continue
}
wpost := model.PostFromJson(strings.NewReader(event.GetData()["post"].(string)))
acm, ok := wpost.GetProp(model.PROPS_ADD_CHANNEL_MEMBER).(map[string]interface{})
require.True(t, ok, "should have received ephemeral post with 'add_channel_member' in props")
require.True(t, acm["post_id"] != nil, "should not be nil")
require.True(t, acm["user_ids"] != nil, "should not be nil")
require.True(t, acm["usernames"] != nil, "should not be nil")
waiting = false
case <-timeout:
require.FailNow(t, "timed out waiting for ephemeral message event")
}
}
} | explode_data.jsonl/5242 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 731
} | [
2830,
3393,
4021,
4133,
11505,
31731,
9629,
44,
63701,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
197,
61238,
2959,
11,
1848,
1669,
270,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestNewFailApplicationEvent(t *testing.T) {
tests := []struct {
name string
appID, errorMsg string
wantID, wantErrorMsg string
wantEvent events.ApplicationEventType
}{
{TestCreateName, "testAppId001", "test error msg", "testAppId001", "test error msg", events.FailApplication},
}
for _, tt := range tests {
instance := NewFailApplicationEvent(tt.appID, tt.errorMsg)
t.Run(tt.name, func(t *testing.T) {
if instance.applicationID != tt.wantID || instance.errorMessage != tt.wantErrorMsg || instance.event != tt.wantEvent {
t.Errorf("want %s %s %s, got %s %s %s",
tt.wantID, tt.wantErrorMsg, tt.wantEvent,
instance.applicationID, instance.errorMessage, tt.wantEvent)
}
})
}
} | explode_data.jsonl/9790 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
3564,
19524,
4988,
1556,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
28236,
915,
11,
52247,
414,
914,
198,
197,
50780,
915,
11,
1366,
89035,
914,
198,
197,
50780,
1556,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileHeadOperation(t *testing.T) {
tcs := []struct {
want string
values url.Values
}{
// https://github.com/elastic/apm/blob/main/specs/agents/tracing-instrumentation-azure.md#determining-operations-3
{
want: "GetProperties",
values: url.Values{},
},
{
want: "GetProperties",
values: url.Values{"restype": []string{"share"}},
},
{
want: "GetMetadata",
values: url.Values{"comp": []string{"metadata"}},
},
{
want: "GetAcl",
values: url.Values{"comp": []string{"acl"}},
},
}
q := new(fileRPC)
for _, tc := range tcs {
assert.Equal(t, tc.want, q.headOperation(tc.values))
}
} | explode_data.jsonl/35220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
1703,
12346,
8432,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
50780,
256,
914,
198,
197,
45939,
2515,
35145,
198,
197,
59403,
197,
197,
322,
3703,
1110,
5204,
905,
14,
61964,
24670,
76,
34827,
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 TestRole(t *testing.T) {
for _, envCmd := range []cli.Command{
*createRoleCommand(),
*listRoleCommand(),
*getRoleCommand(),
*deleteRoleCommand(),
*updateRoleCommand(),
} {
assert.Equal(t, envCmd.Category, "Roles")
assert.NotEmpty(t, envCmd.Name)
assert.NotEmpty(t, envCmd.Usage)
}
} | explode_data.jsonl/82591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
9030,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
6105,
15613,
1669,
2088,
3056,
19521,
12714,
515,
197,
197,
9,
3182,
9030,
4062,
3148,
197,
197,
9,
1607,
9030,
4062,
3148,
197,
197,
9,
455,
9030,
4062,
3148,
197,
197,
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... | 2 |
func TestRelationOne2(t *testing.T) {
RunWithSchema(t, func(t *testing.T) {
initDatas(t)
moment := &UserMoment{}
err := Model(moment).Relation("Moments", func(b *Builder) {
b.Limit(2)
}).Where("id = ?", 5).Get()
b, _ := json.MarshalIndent(moment, "", " ")
fmt.Println(string(b), err)
if err != nil {
t.Fatal(err)
}
})
} | explode_data.jsonl/26856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
33790,
3966,
17,
1155,
353,
8840,
836,
8,
341,
197,
51918,
8632,
1155,
11,
2915,
1155,
353,
8840,
836,
8,
341,
197,
28248,
47663,
1155,
340,
197,
2109,
12913,
1669,
609,
1474,
83817,
16094,
197,
9859,
1669,
4903,
79390,
56... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContainsOperationTransfer(t *testing.T) {
script := `0500bca06501145a936d7abbaae28579dd36609f910f9b50de972f147bee835ff211327677c453d5f19b693e70a361ab53c1087472616e7366657267b6155db85e53298f01e0280cc2f21a0f40c4e808f10400e1f505147e548ecd2a87dd58731e6171752b1aa11494c62f147bee835ff211327677c453d5f19b693e70a361ab53c1087472616e7366657267b6155db85e53298f01e0280cc2f21a0f40c4e808f10500dc5c240214c10704464fade3197739536450ec9531a1f24a37147bee835ff211327677c453d5f19b693e70a361ab53c1087472616e7366657267b6155db85e53298f01e0280cc2f21a0f40c4e808f166b2263911344b5b15`
p := smartcontract.NewParserWithScript(script)
contains := p.ContainsOperation("transfer")
log.Printf("%v", contains)
if contains == false {
t.Fail()
}
} | explode_data.jsonl/28987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 356
} | [
2830,
3393,
23805,
8432,
21970,
1155,
353,
8840,
836,
8,
341,
86956,
1669,
1565,
15,
20,
15,
15,
65,
924,
15,
21,
20,
15,
16,
16,
19,
20,
64,
24,
18,
21,
67,
22,
370,
4645,
5918,
17,
23,
20,
22,
24,
631,
18,
21,
21,
15,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDelete(t *testing.T) {
memDB := db.NewMemDB()
tree, err := NewMutableTree(memDB, 0)
require.NoError(t, err)
tree.set([]byte("k1"), []byte("Fred"))
hash, version, err := tree.SaveVersion()
require.NoError(t, err)
_, _, err = tree.SaveVersion()
require.NoError(t, err)
require.NoError(t, tree.DeleteVersion(version))
k1Value, _, _ := tree.GetVersionedWithProof([]byte("k1"), version)
require.Nil(t, k1Value)
key := tree.ndb.rootKey(version)
err = memDB.Set(key, hash)
require.NoError(t, err)
tree.versions[version] = true
k1Value, _, err = tree.GetVersionedWithProof([]byte("k1"), version)
require.Nil(t, err)
require.Equal(t, 0, bytes.Compare([]byte("Fred"), k1Value))
} | explode_data.jsonl/23772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
6435,
1155,
353,
8840,
836,
8,
341,
14145,
3506,
1669,
2927,
7121,
18816,
3506,
741,
51968,
11,
1848,
1669,
1532,
11217,
6533,
39908,
3506,
11,
220,
15,
340,
17957,
35699,
1155,
11,
1848,
692,
51968,
980,
10556,
3782,
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 TestScanWhitespace(t *testing.T) {
var buf bytes.Buffer
var ws uint64
// start at 1, NUL character is not allowed
for ch := byte(1); ch < ' '; ch++ {
buf.WriteByte(ch)
ws |= 1 << ch
}
const orig = 'x'
buf.WriteByte(orig)
s := new(Scanner).Init(&buf)
s.Mode = 0
s.Whitespace = ws
tok := s.Scan()
if tok != orig {
t.Errorf("tok = %s, want %s", TokenString(tok), TokenString(orig))
}
} | explode_data.jsonl/56534 | {
"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,
26570,
73804,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
5820,
22622,
198,
2405,
17624,
2622,
21,
19,
198,
197,
322,
1191,
518,
220,
16,
11,
451,
1094,
3668,
374,
537,
5420,
198,
2023,
521,
1669,
4922,
7,
16,
1215,
521,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConsulUpdateGetSvcDetailErr(t *testing.T) {
err := errors.New("asonteuh")
testConsulGetClustersCase{nil, err, nil}.run(t)
testConsulGetClustersCase{}.run(t)
} | explode_data.jsonl/71884 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
15220,
360,
4289,
1949,
92766,
10649,
7747,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
5975,
7121,
445,
300,
52277,
12540,
1138,
18185,
15220,
360,
1949,
94992,
4207,
90,
8385,
11,
1848,
11,
2092,
7810,
6108,
1155,
340,
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 |
func Test_WatchTable_BasicAddWorks(t *testing.T) {
ts, err := ptypes.TimestampProto(someWatchTime)
assert.Nil(t, err)
watchRec := &typed.KubeWatchResult{Kind: someKind, WatchType: typed.KubeWatchResult_ADD, Timestamp: ts, Payload: somePodPayload}
results := helper_runWatchTableProcessingOnInputs(t, []*typed.KubeWatchResult{watchRec}, false)
assert.Equal(t, 1, len(results))
actualkey := results[0].Key
actualVal := results[0].Value
assert.Equal(t, expectedKey, actualkey)
assert.Equal(t, someKind, actualVal.Kind)
assertex.ProtoEqual(t, ts, actualVal.Timestamp)
assert.Equal(t, somePodPayload, actualVal.Payload)
assert.Equal(t, typed.KubeWatchResult_ADD, actualVal.WatchType)
} | explode_data.jsonl/38951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 255
} | [
2830,
3393,
2763,
754,
2556,
1668,
5971,
2212,
37683,
1155,
353,
8840,
836,
8,
341,
57441,
11,
1848,
1669,
281,
9242,
49024,
31549,
1141,
635,
14247,
1462,
340,
6948,
59678,
1155,
11,
1848,
340,
6692,
754,
3820,
1669,
609,
44181,
11352,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserAgent(t *testing.T) {
s := fakeServer()
cancelInformer := test.StartInformer(s.projInformer)
defer cancelInformer()
port, err := test.GetFreePort()
assert.NoError(t, err)
metricsPort, err := test.GetFreePort()
assert.NoError(t, err)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go s.Run(ctx, port, metricsPort)
defer func() { time.Sleep(3 * time.Second) }()
err = test.WaitForPortListen(fmt.Sprintf("127.0.0.1:%d", port), 10*time.Second)
assert.NoError(t, err)
type testData struct {
userAgent string
errorMsg string
}
currentVersionBytes, err := ioutil.ReadFile("../VERSION")
assert.NoError(t, err)
currentVersion := strings.TrimSpace(string(currentVersionBytes))
var tests = []testData{
{
// Reject out-of-date user-agent
userAgent: fmt.Sprintf("%s/0.10.0", common.ArgoCDUserAgentName),
errorMsg: "unsatisfied client version constraint",
},
{
// Accept up-to-date user-agent
userAgent: fmt.Sprintf("%s/%s", common.ArgoCDUserAgentName, currentVersion),
},
{
// Accept up-to-date pre-release user-agent
userAgent: fmt.Sprintf("%s/%s-rc1", common.ArgoCDUserAgentName, currentVersion),
},
{
// Reject legacy client
// NOTE: after we update the grpc-go client past 1.15.0, this test will break and should be deleted
userAgent: " ", // need a space here since the apiclient will set the default user-agent if empty
errorMsg: "unsatisfied client version constraint",
},
{
// Permit custom clients
userAgent: "foo/1.2.3",
},
}
for _, test := range tests {
opts := apiclient.ClientOptions{
ServerAddr: fmt.Sprintf("localhost:%d", port),
PlainText: true,
UserAgent: test.userAgent,
}
clnt, err := apiclient.NewClient(&opts)
assert.NoError(t, err)
conn, appClnt := clnt.NewApplicationClientOrDie()
_, err = appClnt.List(ctx, &applicationpkg.ApplicationQuery{})
if test.errorMsg != "" {
assert.Error(t, err)
assert.Regexp(t, test.errorMsg, err.Error())
} else {
assert.NoError(t, err)
}
_ = conn.Close()
}
} | explode_data.jsonl/38041 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 808
} | [
2830,
3393,
1474,
16810,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
12418,
5475,
741,
84441,
641,
34527,
1669,
1273,
12101,
641,
34527,
1141,
82177,
641,
34527,
340,
16867,
9121,
641,
34527,
741,
52257,
11,
1848,
1669,
1273,
2234,
10940,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcilableDiff(t *testing.T) {
var oldFiles []ign3types.File
nOldFiles := uint(10)
for i := uint(0); i < nOldFiles; i++ {
oldFiles = append(oldFiles, newTestIgnitionFile(uint(i)))
}
oldConfig := newMachineConfigFromFiles(oldFiles)
newConfig := newMachineConfigFromFiles(append(oldFiles, newTestIgnitionFile(nOldFiles+1)))
diff, err := reconcilable(oldConfig, newConfig)
checkReconcilableResults(t, "add file", err)
assert.Equal(t, diff.osUpdate, false)
assert.Equal(t, diff.passwd, false)
assert.Equal(t, diff.units, false)
assert.Equal(t, diff.files, true)
newConfig = newMachineConfigFromFiles(nil)
diff, err = reconcilable(oldConfig, newConfig)
checkReconcilableResults(t, "remove all files", err)
assert.Equal(t, diff.osUpdate, false)
assert.Equal(t, diff.passwd, false)
assert.Equal(t, diff.units, false)
assert.Equal(t, diff.files, true)
newConfig = newMachineConfigFromFiles(oldFiles)
newConfig.Spec.OSImageURL = "example.com/machine-os-content:new"
diff, err = reconcilable(oldConfig, newConfig)
checkReconcilableResults(t, "os update", err)
assert.Equal(t, diff.osUpdate, true)
assert.Equal(t, diff.passwd, false)
assert.Equal(t, diff.units, false)
assert.Equal(t, diff.files, false)
} | explode_data.jsonl/28208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 456
} | [
2830,
3393,
693,
40446,
321,
480,
21751,
1155,
353,
8840,
836,
8,
341,
2405,
2310,
10809,
3056,
622,
18,
9242,
8576,
198,
9038,
18284,
10809,
1669,
2622,
7,
16,
15,
340,
2023,
600,
1669,
2622,
7,
15,
1215,
600,
366,
308,
18284,
1080... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCancelExchangeOrder(t *testing.T) {
// Arrange
h.SetDefaults()
TestSetup(t)
if !isRealOrderTestEnabled() {
t.Skip()
}
currencyPair := pair.NewCurrencyPair(symbol.LTC, symbol.BTC)
var orderCancellation = exchange.OrderCancellation{
OrderID: "1",
WalletAddress: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB",
AccountID: "1",
CurrencyPair: currencyPair,
}
// Act
err := h.CancelOrder(orderCancellation)
// Assert
if err != nil {
t.Errorf("Could not cancel order: %s", err)
}
} | explode_data.jsonl/9488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
9269,
31564,
4431,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
9598,
4202,
16273,
741,
73866,
21821,
1155,
692,
743,
753,
285,
12768,
4431,
2271,
5462,
368,
341,
197,
3244,
57776,
741,
197,
630,
1444,
5088,
12443,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpaceOrg(t *testing.T) {
Convey("Find space org", t, func() {
setup(MockRoute{"GET", "/v2/org/foobar", orgPayload, "", 200, "", nil}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
space := &Space{
Guid: "123",
Name: "test space",
OrgURL: "/v2/org/foobar",
c: client,
}
org, err := space.Org()
So(err, ShouldBeNil)
So(org.Name, ShouldEqual, "test-org")
So(org.Guid, ShouldEqual, "da0dba14-6064-4f7a-b15a-ff9e677e49b2")
})
} | explode_data.jsonl/59985 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
9914,
42437,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
9885,
3550,
1240,
497,
259,
11,
2915,
368,
341,
197,
84571,
66436,
4899,
4913,
3806,
497,
3521,
85,
17,
41361,
14,
50267,
497,
1240,
29683,
11,
7342,
220,
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 TestPercentageGrowth__OnSuccess(t *testing.T) {
// test checks if the linear growth follows the arithmetic sequence starting
// at s, growing by r for n steps
test := func(s int, r float64, n int) {
g := &tester.PercentageGrowth{Increase: r}
a := s
for i := 1; i < n; i++ {
a = g.OnSuccess(a)
expected := int(float64(s) * math.Pow((100+r)/100., float64(i)))
// We're reounding every result to int so it may not be equal
assert.InDelta(t, expected, a, float64(s)*r/100.)
}
}
test(10, 100, 100)
test(2, 200, 10)
test(100, 100, 10)
} | explode_data.jsonl/66514 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
36167,
38,
19089,
563,
1925,
7188,
1155,
353,
8840,
836,
8,
341,
197,
322,
1273,
12341,
421,
279,
13482,
6513,
11017,
279,
34784,
8500,
5916,
198,
197,
322,
518,
274,
11,
7826,
553,
435,
369,
308,
7354,
198,
18185,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNamedChanCloseIssue790(t *testing.T) {
gopClTest(t, `
type XChan chan int
func foo(ch XChan) {
close(ch)
}
`, `package main
type XChan chan int
func foo(ch XChan) {
close(ch)
}
`)
} | explode_data.jsonl/73580 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
15810,
46019,
7925,
42006,
22,
24,
15,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
1313,
1599,
46019,
26023,
526,
271,
2830,
15229,
7520,
1599,
46019,
8,
341,
27873,
7520,
340,
532,
7808,
1565,
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 |
func TestListConfig(t *testing.T) {
baseConfig := &config.Config{
Global: &config.ContextConfig{
DefaultRepo: "global-repository",
},
ContextConfigs: []*config.ContextConfig{
{
Kubecontext: "test-context",
DefaultRepo: "context-local-repository",
},
},
}
c, _ := yaml.Marshal(*baseConfig)
cfg, teardown := testutil.TempFile(t, "config", c)
defer teardown()
type testListCase struct {
description string
kubectx string
expectedOutput []string
}
var tests = []testListCase{
{
description: "list for test-context",
kubectx: "test-context",
expectedOutput: []string{"default-repo: context-local-repository"},
},
{
description: "list all",
expectedOutput: []string{
"global:",
"default-repo: global-repository",
"kube-context: test-context",
"default-repo: context-local-repository",
},
},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
args := []string{"config", "list", "-c", cfg}
if test.kubectx != "" {
args = append(args, "-k", test.kubectx)
} else {
args = append(args, "--all")
}
cmd := exec.Command("skaffold", args...)
rawOut, err := util.RunCmdOut(cmd)
if err != nil {
t.Error(err)
}
out := string(rawOut)
for _, output := range test.expectedOutput {
if !strings.Contains(out, output) {
t.Errorf("expected output %s not found in output: %s", output, out)
}
}
})
}
} | explode_data.jsonl/6178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 636
} | [
2830,
3393,
852,
2648,
1155,
353,
8840,
836,
8,
341,
24195,
2648,
1669,
609,
1676,
10753,
515,
197,
59003,
25,
609,
1676,
9328,
2648,
515,
298,
91084,
25243,
25,
330,
9752,
5504,
3099,
756,
197,
197,
1583,
197,
70871,
84905,
25,
29838... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReturnsPolicyErrorWhenForbidden(t *testing.T) {
defer leaktest.Check(t)()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
source := kt.NewFakeControllerSource()
defer source.Shutdown()
source.Add(testutil.NewPodWithRole("ns", "name", "192.168.0.1", "Running", "running_role"))
podCache := k8s.NewPodCache(sts.DefaultResolver("arn:account:"), source, time.Second, defaultBuffer)
podCache.Run(ctx)
server := &KiamServer{pods: podCache, assumePolicy: &forbidPolicy{}, arnResolver: sts.DefaultResolver("prefix")}
_, err := server.GetPodCredentials(ctx, &pb.GetPodCredentialsRequest{Ip: "192.168.0.1"})
if err != ErrPolicyForbidden {
t.Error("unexpected error:", err)
}
} | explode_data.jsonl/43095 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 255
} | [
2830,
3393,
16446,
13825,
1454,
4498,
69115,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
10600,
1155,
8,
2822,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
47418,
1669,
18541,
7121,
52317,
2051,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEtcdSDGetKey(t *testing.T) {
t.Parallel()
tables := []struct {
serverType string
serverID string
ret string
}{
{"type1", "id1", "servers/type1/id1"},
{"t", "1", "servers/t/1"},
}
for _, table := range tables {
t.Run(table.ret, func(t *testing.T) {
assert.Equal(t, table.ret, getKey(table.serverID, table.serverType))
})
}
} | explode_data.jsonl/61560 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
31860,
4385,
5491,
1949,
1592,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
26481,
82,
1669,
3056,
1235,
341,
197,
41057,
929,
914,
198,
197,
41057,
915,
256,
914,
198,
197,
11262,
286,
914,
198,
197,
59403,
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 TestFileNumChunks(t *testing.T) {
tests := []struct {
size uint64
pieceSize uint64
piecesPerChunk int
expNumChunks uint64
}{
{100, 10, 1, 10}, // evenly divides
{100, 10, 2, 5}, // evenly divides
{101, 10, 1, 11}, // padded
{101, 10, 2, 6}, // padded
{10, 100, 1, 1}, // larger piece than file
{0, 10, 1, 1}, // 0-length
}
for _, test := range tests {
rsc, _ := NewRSCode(test.piecesPerChunk, 1) // can't use 0
f := &file{size: test.size, erasureCode: rsc, pieceSize: test.pieceSize}
if f.numChunks() != test.expNumChunks {
t.Errorf("Test %v: expected %v, got %v", test, test.expNumChunks, f.numChunks())
}
}
} | explode_data.jsonl/68226 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
1703,
4651,
89681,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
13832,
1843,
2622,
21,
19,
198,
197,
3223,
9108,
1695,
414,
2622,
21,
19,
198,
197,
3223,
29765,
3889,
28304,
526,
198,
197,
48558,
4651,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSquash(t *testing.T) {
r := require.New(t)
table := []struct {
name string
files MigrationFileList
returnError bool
deletedFiles []string
remainingFiles []string
upFilename string
upContent string
downFilename string
downContent string
}{
{
name: "successfully squashes files all files",
files: MigrationFileList{
MigrationFile{Timestamp: 1, Up: "mig_1_up.sql", Down: "mig_1_down.sql"},
MigrationFile{Timestamp: 2, Up: "mig_2_up.sql", Down: "mig_2_down.sql"},
MigrationFile{Timestamp: 3, Up: "mig_3_up.sql", Down: "mig_3_down.sql"},
},
deletedFiles: []string{"mig_1_up.sql", "mig_2_up.sql", "mig_3_up.sql", "mig_1_down.sql", "mig_2_down.sql", "mig_3_down.sql"},
remainingFiles: []string{"mig_3_squashed_up.sql", "mig_3_squashed_down.sql"},
upFilename: "mig_3_squashed_up.sql",
upContent: "\n-- migration 1 UP\nup mig 1\n\n-- migration 2 UP\nup mig 2\n\n-- migration 3 UP\nup mig 3\n",
downFilename: "mig_3_squashed_down.sql",
downContent: "\n-- migration 3 DOWN\ndown mig 3\n\n-- migration 2 DOWN\ndown mig 2\n\n-- migration 1 DOWN\ndown mig 1\n",
},
{
name: "successfully squashes first two files",
files: MigrationFileList{
MigrationFile{Timestamp: 1, Up: "mig_1_up.sql", Down: "mig_1_down.sql"},
MigrationFile{Timestamp: 2, Up: "mig_2_up.sql", Down: "mig_2_down.sql"},
},
deletedFiles: []string{"mig_1_up.sql", "mig_2_up.sql", "mig_1_down.sql", "mig_2_down.sql"},
remainingFiles: []string{"mig_2_squashed_up.sql", "mig_2_squashed_down.sql", "mig_3_up.sql", "mig_3_down.sql"},
upFilename: "mig_2_squashed_up.sql",
upContent: "\n-- migration 1 UP\nup mig 1\n\n-- migration 2 UP\nup mig 2\n",
downFilename: "mig_2_squashed_down.sql",
downContent: "\n-- migration 2 DOWN\ndown mig 2\n\n-- migration 1 DOWN\ndown mig 1\n",
},
{
name: "returns error",
files: MigrationFileList{},
deletedFiles: []string{},
remainingFiles: []string{"mig_1_up.sql", "mig_2_up.sql", "mig_3_up.sql", "mig_1_down.sql", "mig_2_down.sql", "mig_3_down.sql"},
returnError: true,
},
}
for _, test := range table {
t.Run(test.name, func(t *testing.T) {
fs := afero.NewMemMapFs()
fsystem := &ImplFilesystem{Fs: fs}
afero.WriteFile(fs, "mig_1_up.sql", []byte("up mig 1"), 0666)
afero.WriteFile(fs, "mig_1_down.sql", []byte("down mig 1"), 0666)
afero.WriteFile(fs, "mig_2_up.sql", []byte("up mig 2"), 0666)
afero.WriteFile(fs, "mig_2_down.sql", []byte("down mig 2"), 0666)
afero.WriteFile(fs, "mig_3_up.sql", []byte("up mig 3"), 0666)
afero.WriteFile(fs, "mig_3_down.sql", []byte("down mig 3"), 0666)
afero.WriteFile(fs, configFileName, []byte(validContent), 0666)
err := fsystem.Squash(test.files)
for _, f := range test.deletedFiles {
exists, _ := afero.Exists(fs, f)
r.False(exists)
}
for _, f := range test.remainingFiles {
exists, _ := afero.Exists(fs, f)
r.True(exists)
}
if test.upFilename != "" {
content, _ := afero.ReadFile(fs, test.upFilename)
r.Equal(string(content), test.upContent)
}
if test.downFilename != "" {
content, _ := afero.ReadFile(fs, test.downFilename)
r.Equal(string(content), test.downContent)
}
if test.returnError {
r.Error(err)
} else {
r.NoError(err)
}
})
}
} | explode_data.jsonl/81672 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1600
} | [
2830,
3393,
50,
446,
988,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1373,
7121,
1155,
340,
26481,
1669,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
74075,
688,
21248,
1703,
852,
198,
197,
853,
1454,
262,
1807,
198,
197,
197,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestBinlogDB(t *testing.T) {
db, mock, err := sqlmock.New()
require.Nil(t, err)
ctx := context.Background()
cases := []struct {
doDB string
ignoreDB string
schemas map[string]struct{}
state State
caseSensitive bool
}{
// doDB
{
doDB: "do",
schemas: map[string]struct{}{
"do": {},
},
state: StateSuccess,
},
{
doDB: "do",
schemas: map[string]struct{}{
"do": {},
"do2": {},
},
state: StateFailure,
},
{
doDB: "do",
schemas: map[string]struct{}{
"do2": {},
},
state: StateFailure,
},
{
doDB: "do,do2",
schemas: map[string]struct{}{
"do2": {},
},
state: StateSuccess,
},
// ignoreDB
{
ignoreDB: "ignore",
schemas: map[string]struct{}{
"do": {},
"ignore": {},
},
state: StateFailure,
},
{
ignoreDB: "ignore",
schemas: map[string]struct{}{
"do": {},
"do2": {},
},
state: StateSuccess,
},
{
ignoreDB: "ignore,ignore2",
schemas: map[string]struct{}{
"do": {},
"ignore2": {},
},
state: StateFailure,
},
{
ignoreDB: "ignore,ignore2",
schemas: map[string]struct{}{
"ignore3": {},
},
state: StateSuccess,
},
// case sensitive
{
caseSensitive: true,
doDB: "Do",
schemas: map[string]struct{}{
"do": {},
},
state: StateFailure,
},
{
caseSensitive: false,
doDB: "Do",
schemas: map[string]struct{}{
"do": {},
},
state: StateSuccess,
},
}
for _, cs := range cases {
binlogDBChecker := NewBinlogDBChecker(db, &dbutil.DBConfig{}, cs.schemas, cs.caseSensitive)
versionRow := sqlmock.NewRows([]string{"Variable_name", "Value"}).AddRow("version", "mysql")
masterStatusRow := sqlmock.NewRows([]string{"File", "Position", "Binlog_Do_DB", "Binlog_Ignore_DB", "Executed_Gtid_Set"}).
AddRow("", 0, cs.doDB, cs.ignoreDB, "")
mock.ExpectQuery("SHOW GLOBAL VARIABLES LIKE 'version'").WillReturnRows(versionRow)
mock.ExpectQuery("SHOW MASTER STATUS").WillReturnRows(masterStatusRow)
r := binlogDBChecker.Check(ctx)
require.Nil(t, mock.ExpectationsWereMet())
require.Equal(t, cs.state, r.State)
}
} | explode_data.jsonl/46930 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1096
} | [
2830,
3393,
28794,
839,
3506,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
1848,
1669,
5704,
16712,
7121,
741,
17957,
59678,
1155,
11,
1848,
340,
20985,
1669,
2266,
19047,
2822,
1444,
2264,
1669,
3056,
1235,
341,
197,
19935,
3506,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInterOrgExternalEndpointDisclosure(t *testing.T) {
t.Parallel()
cs := &cryptoService{}
adapter := new(gossipAdapterMock)
pkiID1 := common.PKIidType("withExternalEndpoint")
pkiID2 := common.PKIidType("noExternalEndpoint")
pkiID3 := common.PKIidType("pkiIDinOrg2")
adapter.On("Lookup", pkiID1).Return(&discovery.NetworkMember{Endpoint: "localhost:5000"})
adapter.On("Lookup", pkiID2).Return(&discovery.NetworkMember{})
adapter.On("Lookup", pkiID3).Return(&discovery.NetworkMember{})
adapter.On("GetOrgOfPeer", pkiID1).Return(orgInChannelA)
adapter.On("GetOrgOfPeer", pkiID2).Return(orgInChannelA)
adapter.On("GetOrgOfPeer", pkiID3).Return(api.OrgIdentityType("ORG2"))
adapter.On("Gossip", mock.Anything)
adapter.On("Forward", mock.Anything)
adapter.On("DeMultiplex", mock.Anything)
configureAdapter(adapter)
jcm := &joinChanMsg{
members2AnchorPeers: map[string][]api.AnchorPeer{
string(orgInChannelA): {},
"ORG2": {},
},
}
gc := NewGossipChannel(pkiIDInOrg1, orgInChannelA, cs, channelA, adapter, jcm, disabledMetrics)
gc.HandleMessage(&receivedMsg{PKIID: pkiID1, msg: createStateInfoMsg(0, pkiID1, channelA)})
gc.HandleMessage(&receivedMsg{PKIID: pkiID2, msg: createStateInfoMsg(0, pkiID2, channelA)})
gc.HandleMessage(&receivedMsg{PKIID: pkiID2, msg: createStateInfoMsg(0, pkiID3, channelA)})
sentMessages := make(chan *proto.GossipMessage, 10)
// Check that we only return StateInfo messages of peers with external endpoints
// to peers of other orgs
sMsg, _ := (&proto.GossipMessage{
Tag: proto.GossipMessage_CHAN_OR_ORG,
Content: &proto.GossipMessage_StateInfoPullReq{
StateInfoPullReq: &proto.StateInfoPullRequest{
Channel_MAC: GenerateMAC(pkiID3, channelA),
},
},
}).NoopSign()
snapshotReq := &receivedMsg{
PKIID: pkiID3,
msg: sMsg,
}
snapshotReq.On("Respond", mock.Anything).Run(func(args mock.Arguments) {
sentMessages <- args.Get(0).(*proto.GossipMessage)
})
go gc.HandleMessage(snapshotReq)
select {
case <-time.After(time.Second):
assert.Fail(t, "Should have responded to this StateInfoSnapshot, but didn't")
case msg := <-sentMessages:
elements := msg.GetStateSnapshot().Elements
assert.Len(t, elements, 2)
m1, _ := elements[0].ToGossipMessage()
m2, _ := elements[1].ToGossipMessage()
pkiIDs := [][]byte{m1.GetStateInfo().PkiId, m2.GetStateInfo().PkiId}
assert.Contains(t, pkiIDs, []byte(pkiID1))
assert.Contains(t, pkiIDs, []byte(pkiID3))
}
// Check that we return all StateInfo messages to peers in our organization, regardless
// if the peers from foreign organizations have external endpoints or not
sMsg, _ = (&proto.GossipMessage{
Tag: proto.GossipMessage_CHAN_OR_ORG,
Content: &proto.GossipMessage_StateInfoPullReq{
StateInfoPullReq: &proto.StateInfoPullRequest{
Channel_MAC: GenerateMAC(pkiID2, channelA),
},
},
}).NoopSign()
snapshotReq = &receivedMsg{
PKIID: pkiID2,
msg: sMsg,
}
snapshotReq.On("Respond", mock.Anything).Run(func(args mock.Arguments) {
sentMessages <- args.Get(0).(*proto.GossipMessage)
})
go gc.HandleMessage(snapshotReq)
select {
case <-time.After(time.Second):
assert.Fail(t, "Should have responded to this StateInfoSnapshot, but didn't")
case msg := <-sentMessages:
elements := msg.GetStateSnapshot().Elements
assert.Len(t, elements, 3)
m1, _ := elements[0].ToGossipMessage()
m2, _ := elements[1].ToGossipMessage()
m3, _ := elements[2].ToGossipMessage()
pkiIDs := [][]byte{m1.GetStateInfo().PkiId, m2.GetStateInfo().PkiId, m3.GetStateInfo().PkiId}
assert.Contains(t, pkiIDs, []byte(pkiID1))
assert.Contains(t, pkiIDs, []byte(pkiID2))
assert.Contains(t, pkiIDs, []byte(pkiID3))
}
} | explode_data.jsonl/66326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1482
} | [
2830,
3393,
3306,
42437,
25913,
27380,
91065,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
71899,
1669,
609,
35772,
1860,
16094,
197,
19731,
1669,
501,
3268,
41473,
5940,
11571,
340,
3223,
6642,
915,
16,
1669,
4185,
1069,
80971,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOutputsRedeeming(t *testing.T) {
p := NewPersist()
ctx := context.Background()
tm := time.Now().UTC().Truncate(1 * time.Second)
v := &OutputsRedeeming{}
v.ID = "id1"
v.RedeemedAt = tm
v.RedeemingTransactionID = "rtxid"
v.Amount = 100
v.OutputIndex = 1
v.Intx = "intx1"
v.AssetID = "aid1"
v.ChainID = "cid1"
v.CreatedAt = tm
stream := health.NewStream()
rawDBConn, err := dbr.Open(TestDB, TestDSN, stream)
if err != nil {
t.Fatal("db fail", err)
}
_, _ = rawDBConn.NewSession(stream).DeleteFrom(TableOutputsRedeeming).Exec()
err = p.InsertOutputsRedeeming(ctx, rawDBConn.NewSession(stream), v, true)
if err != nil {
t.Fatal("insert fail", err)
}
fv, err := p.QueryOutputsRedeeming(ctx, rawDBConn.NewSession(stream), v)
if err != nil {
t.Fatal("query fail", err)
}
if !reflect.DeepEqual(*v, *fv) {
t.Fatal("compare fail")
}
v.RedeemingTransactionID = "rtxid1"
v.Amount = 102
v.OutputIndex = 3
v.Intx = "intx2"
v.AssetID = "aid2"
v.ChainID = "cid2"
err = p.InsertOutputsRedeeming(ctx, rawDBConn.NewSession(stream), v, true)
if err != nil {
t.Fatal("insert fail", err)
}
fv, err = p.QueryOutputsRedeeming(ctx, rawDBConn.NewSession(stream), v)
if err != nil {
t.Fatal("query fail", err)
}
if fv.Intx != "intx2" {
t.Fatal("compare fail")
}
if !reflect.DeepEqual(*v, *fv) {
t.Fatal("compare fail")
}
} | explode_data.jsonl/12925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 619
} | [
2830,
3393,
61438,
6033,
68,
73814,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1532,
61267,
741,
20985,
1669,
2266,
19047,
741,
3244,
76,
1669,
882,
13244,
1005,
21183,
1005,
1282,
26900,
7,
16,
353,
882,
32435,
692,
5195,
1669,
609,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestFetchTradablePairs(t *testing.T) {
t.Parallel()
_, err := b.FetchTradablePairs(context.Background(), asset.Spot)
if err != nil {
t.Error("Binance FetchTradablePairs(asset asets.AssetType) error", err)
}
_, err = b.FetchTradablePairs(context.Background(), asset.CoinMarginedFutures)
if err != nil {
t.Error(err)
}
_, err = b.FetchTradablePairs(context.Background(), asset.USDTMarginedFutures)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76642 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
20714,
42834,
480,
54228,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
78506,
42834,
480,
54228,
5378,
19047,
1507,
9329,
808,
19099,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
445,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestContainerStatsCollection(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockDockerClient := mock_dockerapi.NewMockDockerClient(ctrl)
dockerID := "container1"
ctx, cancel := context.WithCancel(context.TODO())
statChan := make(chan *docker.Stats)
mockDockerClient.EXPECT().Stats(dockerID, ctx).Return(statChan, nil)
go func() {
for _, stat := range statsData {
// doing this with json makes me sad, but is the easiest way to
// deal with the docker.Stats.MemoryStats inner struct
jsonStat := fmt.Sprintf(`
{
"memory_stats": {"usage":%d, "privateworkingset":%d},
"cpu_stats":{
"cpu_usage":{
"percpu_usage":[%d],
"total_usage":%d
}
}
}`, stat.memBytes, stat.memBytes, stat.cpuTime, stat.cpuTime)
dockerStat := &docker.Stats{}
json.Unmarshal([]byte(jsonStat), dockerStat)
dockerStat.Read = stat.timestamp
statChan <- dockerStat
}
}()
container := &StatsContainer{
containerMetadata: &ContainerMetadata{
DockerID: dockerID,
},
ctx: ctx,
cancel: cancel,
client: mockDockerClient,
}
container.StartStatsCollection()
time.Sleep(checkPointSleep)
container.StopStatsCollection()
cpuStatsSet, err := container.statsQueue.GetCPUStatsSet()
if err != nil {
t.Fatal("Error gettting cpu stats set:", err)
}
if *cpuStatsSet.Min == math.MaxFloat64 || math.IsNaN(*cpuStatsSet.Min) {
t.Error("Min value incorrectly set: ", *cpuStatsSet.Min)
}
if *cpuStatsSet.Max == -math.MaxFloat64 || math.IsNaN(*cpuStatsSet.Max) {
t.Error("Max value incorrectly set: ", *cpuStatsSet.Max)
}
if *cpuStatsSet.SampleCount == 0 {
t.Error("Samplecount is 0")
}
if *cpuStatsSet.Sum == 0 {
t.Error("Sum value incorrectly set: ", *cpuStatsSet.Sum)
}
memStatsSet, err := container.statsQueue.GetMemoryStatsSet()
if err != nil {
t.Error("Error gettting cpu stats set:", err)
}
if *memStatsSet.Min == math.MaxFloat64 {
t.Error("Min value incorrectly set: ", *memStatsSet.Min)
}
if *memStatsSet.Max == 0 {
t.Error("Max value incorrectly set: ", *memStatsSet.Max)
}
if *memStatsSet.SampleCount == 0 {
t.Error("Samplecount is 0")
}
if *memStatsSet.Sum == 0 {
t.Error("Sum value incorrectly set: ", *memStatsSet.Sum)
}
} | explode_data.jsonl/22611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 876
} | [
2830,
3393,
4502,
16635,
6482,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
741,
77333,
35,
13659,
2959,
1669,
7860,
814,
13659,
2068,
7121,
11571,
35,
13659,
2959,
62100,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestServicedCLI_CmdServiceList_one(t *testing.T) {
serviceID := "test-service-1"
expected, err := DefaultServiceAPITest.GetService(serviceID)
if err != nil {
t.Fatal(err)
}
var actual service.Service
output := pipe(InitServiceAPITest, "serviced", "service", "list", serviceID)
if err := json.Unmarshal(output, &actual); err != nil {
t.Fatalf("error unmarshaling resource: %s", err)
}
// Did you remember to update Service.Equals?
if !actual.Equals(expected) {
t.Fatalf("\ngot:\n%+v\nwant:\n%+v", actual, expected)
}
} | explode_data.jsonl/18996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
39159,
7572,
63959,
98253,
1860,
852,
11667,
1155,
353,
8840,
836,
8,
341,
52934,
915,
1669,
330,
1944,
23461,
12,
16,
1837,
42400,
11,
1848,
1669,
7899,
1860,
2537,
952,
477,
81342,
21656,
915,
340,
743,
1848,
961,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCollection_CreateIndexes(t *testing.T) {
ast := require.New(t)
cli := initClient("test")
defer cli.Close(context.Background())
defer cli.DropCollection(context.Background())
var expireS int32 = 100
unique := []string{"id1"}
indexOpts := officialOpts.Index()
indexOpts.SetUnique(true).SetExpireAfterSeconds(expireS)
ast.NoError(cli.CreateOneIndex(context.Background(), options.IndexModel{Key: unique, IndexOptions: indexOpts}))
ast.NoError(cli.CreateIndexes(context.Background(), []options.IndexModel{{Key: []string{"id2", "id3"}},
{Key: []string{"id4", "-id5"}}}))
// same index,error
ast.Error(cli.CreateOneIndex(context.Background(), options.IndexModel{Key: unique}))
// check if unique indexs is working
var err error
doc := bson.M{
"id1": 1,
}
_, err = cli.InsertOne(context.Background(), doc)
ast.NoError(err)
_, err = cli.InsertOne(context.Background(), doc)
ast.Equal(true, IsDup(err))
} | explode_data.jsonl/18369 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 335
} | [
2830,
3393,
6482,
34325,
62229,
1155,
353,
8840,
836,
8,
341,
88836,
1669,
1373,
7121,
1155,
340,
86448,
1669,
2930,
2959,
445,
1944,
1138,
16867,
21348,
10421,
5378,
19047,
2398,
16867,
21348,
21688,
6482,
5378,
19047,
12367,
2405,
32563,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJetStreamInterfaces(t *testing.T) {
s := RunBasicJetStreamServer()
defer s.Shutdown()
if config := s.JetStreamConfig(); config != nil {
defer os.RemoveAll(config.StoreDir)
}
nc, err := nats.Connect(s.ClientURL())
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
defer nc.Close()
var js nats.JetStream
var jsm nats.JetStreamManager
var jsctx nats.JetStreamContext
// JetStream that can publish/subscribe but cannot manage streams.
js, err = nc.JetStream()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
js.Publish("foo", []byte("hello"))
// JetStream context that can manage streams/consumers but cannot produce messages.
jsm, err = nc.JetStream()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
jsm.AddStream(&nats.StreamConfig{Name: "FOO"})
// JetStream context that can both manage streams/consumers
// as well as publish/subscribe.
jsctx, err = nc.JetStream()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
jsctx.AddStream(&nats.StreamConfig{Name: "BAR"})
jsctx.Publish("bar", []byte("hello world"))
publishMsg := func(js nats.JetStream, payload []byte) {
js.Publish("foo", payload)
}
publishMsg(js, []byte("hello world"))
} | explode_data.jsonl/29169 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 450
} | [
2830,
3393,
35641,
3027,
41066,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
6452,
15944,
35641,
3027,
5475,
741,
16867,
274,
10849,
18452,
2822,
743,
2193,
1669,
274,
3503,
295,
3027,
2648,
2129,
2193,
961,
2092,
341,
197,
16867,
2643,
84... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppendInstalledIngresses(t *testing.T) {
os.Setenv(common.KoEnvKey, "testdata/kodata")
defer os.Unsetenv(common.KoEnvKey)
tests := []struct {
name string
instance servingv1alpha1.KnativeServing
expected bool
expectedResourcesNum int
}{{
name: "Available installed ingresses",
instance: servingv1alpha1.KnativeServing{
Spec: servingv1alpha1.KnativeServingSpec{},
Status: servingv1alpha1.KnativeServingStatus{
Version: "0.18.1",
},
},
expected: true,
expectedResourcesNum: numberIngressResource,
}, {
name: "Available installed ingresses for missing status.version",
instance: servingv1alpha1.KnativeServing{
Spec: servingv1alpha1.KnativeServingSpec{
CommonSpec: servingv1alpha1.CommonSpec{
Version: "0.18.1",
},
},
Status: servingv1alpha1.KnativeServingStatus{},
},
expected: true,
expectedResourcesNum: numberIngressResource,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
manifest, _ := mf.ManifestFrom(mf.Slice{})
err := AppendInstalledIngresses(context.TODO(), &manifest, &tt.instance)
util.AssertEqual(t, err == nil, tt.expected)
util.AssertEqual(t, len(manifest.Resources()), tt.expectedResourcesNum)
})
}
} | explode_data.jsonl/15437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 550
} | [
2830,
3393,
23877,
60800,
641,
2483,
288,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
57802,
11352,
78,
14359,
1592,
11,
330,
92425,
14109,
56169,
1138,
16867,
2643,
10616,
746,
3160,
57802,
11352,
78,
14359,
1592,
692,
78216,
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 TestRetryWaitBackoffTime(t *testing.T) {
t.Parallel()
r := New(
WithBackoff(&longBackoff{}),
)
ctx, cancel := context.WithCancel(context.Background())
go func() {
time.Sleep(100 * time.Millisecond)
cancel()
}()
err := r.waitBackoffTime(ctx, 1)
assert.True(t, errors.Is(err, context.Canceled))
} | explode_data.jsonl/82064 | {
"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,
51560,
14190,
3707,
1847,
1462,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
7000,
1669,
1532,
1006,
197,
197,
2354,
3707,
1847,
2099,
4825,
3707,
1847,
6257,
1326,
197,
692,
20985,
11,
9121,
1669,
2266,
26124,
926... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEth_GetTransactionReceipt_ContractDeployment(t *testing.T) {
hash, _ := deployTestContract(t)
time.Sleep(time.Second * 5)
param := []string{hash.String()}
rpcRes := call(t, "eth_getTransactionReceipt", param)
receipt := make(map[string]interface{})
err := json.Unmarshal(rpcRes.Result, &receipt)
require.NoError(t, err)
require.Equal(t, "0x1", receipt["status"].(string))
require.NotEqual(t, common.Address{}.String(), receipt["contractAddress"].(string))
require.NotNil(t, receipt["logs"])
} | explode_data.jsonl/856 | {
"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,
65390,
13614,
8070,
67461,
15100,
2144,
75286,
1155,
353,
8840,
836,
8,
341,
50333,
11,
716,
1669,
10517,
2271,
14067,
1155,
692,
21957,
31586,
9730,
32435,
353,
220,
20,
692,
36037,
1669,
3056,
917,
90,
8296,
6431,
23509,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReceiveBufferAutoTuning(t *testing.T) {
const mtu = 1500
const mss = mtu - header.IPv4MinimumSize - header.TCPMinimumSize
c := context.New(t, mtu)
defer c.Cleanup()
// Enable Auto-tuning.
stk := c.Stack()
// Set lower limits for auto-tuning tests. This is required because the
// test stops the worker which can cause packets to be dropped because
// the segment queue holding unprocessed packets is limited to 500.
const receiveBufferSize = 80 << 10 // 80KB.
const maxReceiveBufferSize = receiveBufferSize * 10
if err := stk.SetTransportProtocolOption(tcp.ProtocolNumber, tcp.ReceiveBufferSizeOption{1, receiveBufferSize, maxReceiveBufferSize}); err != nil {
t.Fatalf("SetTransportProtocolOption failed: %v", err)
}
// Enable auto-tuning.
if err := stk.SetTransportProtocolOption(tcp.ProtocolNumber, tcpip.ModerateReceiveBufferOption(true)); err != nil {
t.Fatalf("SetTransportProtocolOption failed: %v", err)
}
// Change the expected window scale to match the value needed for the
// maximum buffer size used by stack.
c.WindowScale = uint8(tcp.FindWndScale(maxReceiveBufferSize))
rawEP := c.CreateConnectedWithOptions(header.TCPSynOptions{TS: true, WS: 4})
wantRcvWnd := receiveBufferSize
scaleRcvWnd := func(rcvWnd int) uint16 {
return uint16(rcvWnd >> uint16(c.WindowScale))
}
// Allocate a large array to send to the endpoint.
b := make([]byte, receiveBufferSize*48)
// In every iteration we will send double the number of bytes sent in
// the previous iteration and read the same from the app. The received
// window should grow by at least 2x of bytes read by the app in every
// RTT.
offset := 0
payloadSize := receiveBufferSize / 8
worker := (c.EP).(interface {
StopWork()
ResumeWork()
})
tsVal := rawEP.TSVal
// We are going to do our own computation of what the moderated receive
// buffer should be based on sent/copied data per RTT and verify that
// the advertised window by the stack matches our calculations.
prevCopied := 0
done := false
latency := 1 * time.Millisecond
for i := 0; !done; i++ {
tsVal++
// Stop the worker goroutine.
worker.StopWork()
start := offset
end := offset + payloadSize
totalSent := 0
packetsSent := 0
for ; start < end; start += mss {
rawEP.SendPacketWithTS(b[start:start+mss], tsVal)
totalSent += mss
packetsSent++
}
// Resume it so that it only sees the packets once all of them
// are waiting to be read.
worker.ResumeWork()
// Give 1ms for the worker to process the packets.
time.Sleep(1 * time.Millisecond)
// Verify that the advertised window on the ACK is reduced by
// the total bytes sent.
expectedWnd := wantRcvWnd - totalSent
if packetsSent > 100 {
for i := 0; i < (packetsSent / 100); i++ {
_ = c.GetPacket()
}
}
rawEP.VerifyACKRcvWnd(scaleRcvWnd(expectedWnd))
// Now read all the data from the endpoint and invoke the
// moderation API to allow for receive buffer auto-tuning
// to happen before we measure the new window.
totalCopied := 0
for {
b, _, err := c.EP.Read(nil)
if err == tcpip.ErrWouldBlock {
break
}
totalCopied += len(b)
}
// Invoke the moderation API. This is required for auto-tuning
// to happen. This method is normally expected to be invoked
// from a higher layer than tcpip.Endpoint. So we simulate
// copying to user-space by invoking it explicitly here.
c.EP.ModerateRecvBuf(totalCopied)
// Now send a keep-alive packet to trigger an ACK so that we can
// measure the new window.
rawEP.NextSeqNum--
rawEP.SendPacketWithTS(nil, tsVal)
rawEP.NextSeqNum++
if i == 0 {
// In the first iteration the receiver based RTT is not
// yet known as a result the moderation code should not
// increase the advertised window.
rawEP.VerifyACKRcvWnd(scaleRcvWnd(wantRcvWnd))
prevCopied = totalCopied
} else {
rttCopied := totalCopied
if i == 1 {
// The moderation code accumulates copied bytes till
// RTT is established. So add in the bytes sent in
// the first iteration to the total bytes for this
// RTT.
rttCopied += prevCopied
// Now reset it to the initial value used by the
// auto tuning logic.
prevCopied = tcp.InitialCwnd * mss * 2
}
newWnd := rttCopied<<1 + 16*mss
grow := (newWnd * (rttCopied - prevCopied)) / prevCopied
newWnd += (grow << 1)
if newWnd > maxReceiveBufferSize {
newWnd = maxReceiveBufferSize
done = true
}
rawEP.VerifyACKRcvWnd(scaleRcvWnd(newWnd))
wantRcvWnd = newWnd
prevCopied = rttCopied
// Increase the latency after first two iterations to
// establish a low RTT value in the receiver since it
// only tracks the lowest value. This ensures that when
// ModerateRcvBuf is called the elapsed time is always >
// rtt. Without this the test is flaky due to delays due
// to scheduling/wakeup etc.
latency += 50 * time.Millisecond
}
time.Sleep(latency)
offset += payloadSize
payloadSize *= 2
}
} | explode_data.jsonl/22341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1752
} | [
2830,
3393,
14742,
4095,
13253,
51,
37202,
1155,
353,
8840,
836,
8,
341,
4777,
11965,
84,
284,
220,
16,
20,
15,
15,
198,
4777,
296,
778,
284,
11965,
84,
481,
4247,
46917,
85,
19,
28695,
1695,
481,
4247,
836,
7123,
28695,
1695,
271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetProductDetail(t *testing.T) {
t.Log("Test catalogrepository product detail")
catalogRepo := NewCatalogRepository(db)
product, err := catalogRepo.GetProductDetail(context.TODO(), "604497558ffcad558eb8e1f4")
assert.Nil(t, err)
assert.Equal(t, product.Name, "Salad Cesar")
} | explode_data.jsonl/58788 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
1949,
4816,
10649,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
445,
2271,
16403,
23319,
1985,
7716,
5130,
1444,
7750,
25243,
1669,
1532,
41606,
4624,
9791,
692,
69288,
11,
1848,
1669,
16403,
25243,
2234,
4816,
10649,
5378,
90988... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSetTLPArtifact(t *testing.T) {
art, err := NewArtifact("file", "./testData/thehive.txt")
if err != nil {
t.Errorf("unexpected error: %s", err.Error())
}
if art.TLP != Amber {
t.Errorf("expected TLP to be %d, but found %d", Amber, art.TLP)
}
art.SetTLP(Red)
if art.TLP != Red {
t.Errorf("expected TLP to be %d, but found %d", Red, art.TLP)
}
err = art.SetTLP(10)
if err != nil && err.Error() != "tlp provided is not a valid value" {
t.Errorf("expected tlp provided is not a valid value as error, but none was found")
}
} | explode_data.jsonl/29242 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
1649,
13470,
8041,
3342,
20754,
1155,
353,
8840,
836,
8,
341,
197,
471,
11,
1848,
1669,
1532,
85578,
445,
1192,
497,
5924,
1944,
1043,
51257,
88568,
3909,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
53859,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAwsAccS3IamMount_WithCluster(t *testing.T) {
if _, ok := os.LookupEnv("CLOUD_ENV"); !ok {
t.Skip("Acceptance tests skipped unless env 'CLOUD_ENV' is set")
}
config := qa.EnvironmentTemplate(t, `
resource "databricks_instance_profile" "this" {
instance_profile_arn = "{env.TEST_EC2_INSTANCE_PROFILE}"
skip_validation = false
}
resource "databricks_cluster" "this" {
cluster_name = "ready-{var.RANDOM}"
instance_pool_id = "{var.POOL}"
spark_version = "{var.SPARK}"
autotermination_minutes = 10
num_workers = 1
aws_attributes {
instance_profile_arn = databricks_instance_profile.this.id
}
}
resource "databricks_aws_s3_mount" "mount" {
cluster_id = databricks_cluster.this.id
mount_name = "{var.RANDOM}"
s3_bucket_name = "{env.TEST_S3_BUCKET}"
}`, map[string]string{
"POOL": compute.CommonInstancePoolID(),
"SPARK": compute.CommonRuntimeVersion(),
})
acceptance.AccTest(t, resource.TestCase{
Steps: []resource.TestStep{
{
Config: config,
Check: mountResourceCheck("databricks_aws_s3_mount.mount",
func(client *common.DatabricksClient, mp MountPoint) error {
source, err := mp.Source()
assert.NoError(t, err)
assert.Equal(t, fmt.Sprintf("s3a://%s",
qa.FirstKeyValue(t, config, "s3_bucket_name")), source)
return nil
}),
},
},
})
} | explode_data.jsonl/42599 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 595
} | [
2830,
3393,
47359,
14603,
50,
18,
40,
309,
16284,
62,
2354,
28678,
1155,
353,
8840,
836,
8,
341,
743,
8358,
5394,
1669,
2643,
79261,
14359,
445,
34,
47645,
22027,
5038,
753,
562,
341,
197,
3244,
57776,
445,
16646,
681,
7032,
35157,
72... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiTable(t *testing.T) {
_, err := decode(`
schema "hi" {
}
table "users" {
schema = schema.hi
column "id" {
type = int
unsigned = true
null = false
default = 123
}
}
table "accounts" {
schema = schema.hi
column "id" {
type = varchar(255)
}
index "name" {
unique = true
}
}
`)
require.NoError(t, err)
} | explode_data.jsonl/81314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
20358,
2556,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
16895,
61528,
17349,
330,
6023,
1,
1476,
630,
2005,
330,
4218,
1,
341,
1903,
3416,
284,
10802,
860,
72,
198,
51661,
330,
307,
1,
341,
197,
13158,
284,
526... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateJobs_SingleJobThatExists_ChangesJob(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
job1 := addTestJobWithClientId(t, r, "queue1", "my-job-1")
newSchedName := "custom"
results, err := r.UpdateJobs([]string{job1.Id}, func(jobs []*api.Job) {
assert.Equal(t, 1, len(jobs))
jobs[0].PodSpec.SchedulerName = newSchedName
})
if err != nil {
t.Fatalf("expected no error but got: %s", err)
}
assert.Equal(t, 1, len(results))
assert.Nil(t, results[0].Error)
assert.Equal(t, job1.Id, results[0].JobId)
reloadedJobs, err := r.GetExistingJobsByIds([]string{job1.Id})
assert.Nil(t, err)
assert.Equal(t, 1, len(reloadedJobs))
assert.Equal(t, newSchedName, reloadedJobs[0].PodSpec.SchedulerName)
assert.Equal(t, results[0].Job, reloadedJobs[0])
})
} | explode_data.jsonl/32069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
4289,
40667,
1098,
2173,
12245,
4792,
15575,
27588,
5520,
12245,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
68577,
16,
1669,
912,
2271,
12245,
2354,
94116,
1155,
11,
435,
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 TestDeleteSimple(t *testing.T) {
numSamples := int64(10)
cases := []struct {
intervals Intervals
remaint []int64
}{
{
intervals: Intervals{{0, 3}},
remaint: []int64{4, 5, 6, 7, 8, 9},
},
{
intervals: Intervals{{1, 3}},
remaint: []int64{0, 4, 5, 6, 7, 8, 9},
},
{
intervals: Intervals{{1, 3}, {4, 7}},
remaint: []int64{0, 8, 9},
},
{
intervals: Intervals{{1, 3}, {4, 700}},
remaint: []int64{0},
},
{ // This case is to ensure that labels and symbols are deleted.
intervals: Intervals{{0, 9}},
remaint: []int64{},
},
}
Outer:
for _, c := range cases {
db, delete := openTestDB(t, nil)
defer func() {
testutil.Ok(t, db.Close())
delete()
}()
app := db.Appender()
smpls := make([]float64, numSamples)
for i := int64(0); i < numSamples; i++ {
smpls[i] = rand.Float64()
app.Add(labels.Labels{{Name: "a", Value: "b"}}, i, smpls[i])
}
testutil.Ok(t, app.Commit())
// TODO(gouthamve): Reset the tombstones somehow.
// Delete the ranges.
for _, r := range c.intervals {
testutil.Ok(t, db.Delete(r.Mint, r.Maxt, labels.NewEqualMatcher("a", "b")))
}
// Compare the result.
q, err := db.Querier(0, numSamples)
testutil.Ok(t, err)
res, err := q.Select(labels.NewEqualMatcher("a", "b"))
testutil.Ok(t, err)
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
for _, ts := range c.remaint {
expSamples = append(expSamples, sample{ts, smpls[ts]})
}
expss := newMockSeriesSet([]Series{
newSeries(map[string]string{"a": "b"}, expSamples),
})
lns, err := q.LabelNames()
testutil.Ok(t, err)
lvs, err := q.LabelValues("a")
testutil.Ok(t, err)
if len(expSamples) == 0 {
testutil.Equals(t, 0, len(lns))
testutil.Equals(t, 0, len(lvs))
testutil.Assert(t, res.Next() == false, "")
continue
} else {
testutil.Equals(t, 1, len(lns))
testutil.Equals(t, 1, len(lvs))
testutil.Equals(t, "a", lns[0])
testutil.Equals(t, "b", lvs[0])
}
for {
eok, rok := expss.Next(), res.Next()
testutil.Equals(t, eok, rok)
if !eok {
continue Outer
}
sexp := expss.At()
sres := res.At()
testutil.Equals(t, sexp.Labels(), sres.Labels())
smplExp, errExp := expandSeriesIterator(sexp.Iterator())
smplRes, errRes := expandSeriesIterator(sres.Iterator())
testutil.Equals(t, errExp, errRes)
testutil.Equals(t, smplExp, smplRes)
}
}
} | explode_data.jsonl/64364 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1153
} | [
2830,
3393,
6435,
16374,
1155,
353,
8840,
836,
8,
341,
22431,
39571,
1669,
526,
21,
19,
7,
16,
15,
692,
1444,
2264,
1669,
3056,
1235,
341,
197,
2084,
42198,
1333,
42198,
198,
197,
197,
1826,
1641,
256,
3056,
396,
21,
19,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHTTPFetcher_ErrorMessage(t *testing.T) {
data := adapterResponse{
ErrorMessage: null.StringFrom("could not hit data fetcher"),
}
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusTooManyRequests)
require.NoError(t, json.NewEncoder(w).Encode(data))
})
server := httptest.NewServer(handler)
defer server.Close()
feedURL, err := url.ParseRequestURI(server.URL)
require.NoError(t, err)
fetcher := newHTTPFetcher(defaultHTTPTimeout, ethUSDPairing, feedURL, 32768)
price, err := fetcher.Fetch(context.Background(), emptyMeta)
assert.Error(t, err)
assert.Equal(t, decimal.NewFromInt(0).String(), price.String())
assert.Contains(t, err.Error(), "could not hit data fetcher")
} | explode_data.jsonl/26497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
9230,
97492,
62,
21349,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
12956,
2582,
515,
197,
197,
21349,
25,
845,
6431,
3830,
445,
28077,
537,
4201,
821,
7807,
261,
4461,
197,
630,
53326,
1669,
1758,
89164,
18552,
3622,
1758,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDSNParser(t *testing.T) {
for i, tst := range testDSNs {
cfg, err := ParseDSN(tst.in)
if err != nil {
t.Error(err.Error())
}
// pointer not static
cfg.tls = nil
if !reflect.DeepEqual(cfg, tst.out) {
t.Errorf("%d. ParseDSN(%q) mismatch:\ngot %+v\nwant %+v", i, tst.in, cfg, tst.out)
}
}
} | explode_data.jsonl/70841 | {
"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,
5936,
45,
6570,
1155,
353,
8840,
836,
8,
972,
2023,
600,
11,
71707,
1669,
2088,
1273,
5936,
47360,
972,
197,
50286,
11,
1848,
1669,
14775,
5936,
45,
1155,
267,
1858,
1218,
197,
743,
1848,
961,
2092,
972,
298,
3244,
6141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewClient(t *testing.T) {
t.Parallel()
// set required flags
Flags.Endpoint = "http://127.0.0.1:4001"
// instantiate client
_, err := NewClient()
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/82072 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
3564,
2959,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
738,
2567,
8042,
198,
197,
9195,
90409,
284,
330,
1254,
1110,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
19,
15,
15,
16,
1837,
197,
322,
40902... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLiterals(t *testing.T) {
testStr := `<?
$var = "one";
$var = 2;
$var = true;
$var = null;`
p := NewParser()
p.disableScoping = true
a, _ := p.Parse("test.php", testStr)
if len(a.Nodes) != 4 {
t.Fatalf("Literals did not correctly parse")
}
tree := []ast.Node{
ast.ExprStmt{Expr: ast.AssignmentExpr{
Assignee: ast.NewVariable("var"),
Value: &ast.Literal{Type: ast.String, Value: `"one"`},
Operator: "=",
}},
ast.ExprStmt{Expr: ast.AssignmentExpr{
Assignee: ast.NewVariable("var"),
Value: &ast.Literal{Type: ast.Float, Value: "2"},
Operator: "=",
}},
ast.ExprStmt{Expr: ast.AssignmentExpr{
Assignee: ast.NewVariable("var"),
Value: &ast.Literal{Type: ast.Boolean, Value: "true"},
Operator: "=",
}},
ast.ExprStmt{Expr: ast.AssignmentExpr{
Assignee: ast.NewVariable("var"),
Value: &ast.Literal{Type: ast.Null, Value: "null"},
Operator: "=",
}},
}
if !reflect.DeepEqual(a.Nodes, tree) {
fmt.Printf("Found: %+v\n", a)
fmt.Printf("Expected: %+v\n", tree)
t.Fatalf("Literals did not correctly parse")
}
} | explode_data.jsonl/28448 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 518
} | [
2830,
3393,
43,
37802,
1155,
353,
8840,
836,
8,
341,
18185,
2580,
1669,
1565,
53075,
220,
400,
947,
284,
330,
603,
876,
220,
400,
947,
284,
220,
17,
280,
220,
400,
947,
284,
830,
280,
220,
400,
947,
284,
845,
26,
3989,
3223,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCreateSubDirsExist(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
pool, testRepo := setupObjectPool(t)
err := pool.Create(ctx, testRepo)
require.NoError(t, err)
require.NoError(t, pool.Remove(ctx))
// Recreate pool so the subdirs exist already
err = pool.Create(ctx, testRepo)
require.NoError(t, err)
} | explode_data.jsonl/44267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
4021,
3136,
97384,
25613,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
1273,
18764,
9328,
741,
16867,
9121,
2822,
85273,
11,
1273,
25243,
1669,
6505,
1190,
10551,
1155,
692,
9859,
1669,
7314,
7251,
7502,
11,
1273,
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 TestCumSum(t *testing.T) {
t.Parallel()
s := []float64{3, 4, 1, 7, 5}
receiver := make([]float64, len(s))
result := CumSum(receiver, s)
truth := []float64{3, 7, 8, 15, 20}
areSlicesEqual(t, truth, receiver, "Wrong cumsum mutated with new receiver")
areSlicesEqual(t, truth, result, "Wrong cumsum returned with new receiver")
CumSum(receiver, s)
areSlicesEqual(t, truth, receiver, "Wrong cumsum returned with reused receiver")
// Test that it panics
if !Panics(func() { CumSum(make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Did not panic with length mismatch")
}
// Test empty CumSum
emptyReceiver := make([]float64, 0)
truth = []float64{}
CumSum(emptyReceiver, emptyReceiver)
areSlicesEqual(t, truth, emptyReceiver, "Wrong cumsum returned with empty receiver")
} | explode_data.jsonl/1214 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 303
} | [
2830,
3393,
85805,
9190,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
1669,
3056,
3649,
21,
19,
90,
18,
11,
220,
19,
11,
220,
16,
11,
220,
22,
11,
220,
20,
532,
17200,
12862,
1669,
1281,
10556,
3649,
21,
19,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateImageNameAndGroup(t *testing.T) {
tests := []struct {
name string
image ImageReference
expectedErr error
}{
{
name: "valid run",
image: ImageReference{
Name: "rhel9000",
ResourceGroup: "club",
},
expectedErr: nil,
},
{
name: "invalid: image name is missing",
image: ImageReference{
ResourceGroup: "club",
},
expectedErr: errors.New(`imageName needs to be specified when imageResourceGroup is provided`),
},
{
name: "invalid: image resource group is missing",
image: ImageReference{
Name: "rhel9000",
},
expectedErr: errors.New(`imageResourceGroup needs to be specified when imageName is provided`),
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
cs := getK8sDefaultContainerService(true)
cs.Properties.AgentPoolProfiles = []*AgentPoolProfile{
{
Name: "agentpool",
VMSize: "Standard_D2_v2",
Count: 1,
AvailabilityProfile: AvailabilitySet,
ImageRef: &test.image,
},
}
gotErr := cs.Properties.validateAgentPoolProfiles(true)
if !helpers.EqualError(gotErr, test.expectedErr) {
t.Logf("scenario %q", test.name)
t.Errorf("expected error: %v, got: %v", test.expectedErr, gotErr)
}
})
}
} | explode_data.jsonl/17879 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 616
} | [
2830,
3393,
17926,
1906,
675,
3036,
2808,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
31426,
981,
4654,
8856,
198,
197,
42400,
7747,
1465,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBasicAuthDecode(t *testing.T) {
_, _, err := BasicAuthDecode("?")
assert.Equal(t, "illegal base64 data at input byte 0", err.Error())
user, pass, err := BasicAuthDecode("Zm9vOmJhcg==")
assert.NoError(t, err)
assert.Equal(t, "foo", user)
assert.Equal(t, "bar", pass)
} | explode_data.jsonl/14311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
15944,
5087,
32564,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
1848,
1669,
14625,
5087,
32564,
66689,
1138,
6948,
12808,
1155,
11,
330,
75998,
2331,
21,
19,
821,
518,
1946,
4922,
220,
15,
497,
1848,
6141,
12367,
19060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilePoolNoErrorOnAlreadyDeleted(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping test on windows (cannot delete in-use file)")
}
dir, err := ioutil.TempDir("", "fastzip-filepool")
require.NoError(t, err)
fp, err := New(dir, 16, -1)
require.NoError(t, err)
for range fp.files {
f := fp.Get()
_, err := f.Write([]byte("foobar"))
assert.NoError(t, err)
fp.Put(f)
}
err = os.RemoveAll(dir)
require.NoError(t, err)
assert.NoError(t, fp.Close())
} | explode_data.jsonl/60249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
1703,
10551,
2753,
1454,
1925,
38370,
26039,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
445,
85945,
1273,
389,
11030,
320,
33260,
3698,
304,
24673,
1034,
19107,
197,
630... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommentDeleteBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
commenterHex := "temp-commenter-hex"
commentHex, _ := commentNew(commenterHex, "example.com", "/path.html", "root", "**foo**", "approved", time.Now().UTC())
commentNew(commenterHex, "example.com", "/path.html", commentHex, "**bar**", "approved", time.Now().UTC())
if err := commentDelete(commentHex, commenterHex); err != nil {
t.Errorf("unexpected error deleting comment: %v", err)
return
}
c, _, _ := commentList(commenterHex, "example.com", "/path.html", false)
if len(c) != 0 {
t.Errorf("expected no comments found %d comments", len(c))
return
}
} | explode_data.jsonl/12232 | {
"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,
10677,
6435,
33603,
1211,
1155,
353,
8840,
836,
8,
341,
63052,
2271,
74945,
1155,
11,
6505,
2271,
14359,
12367,
96268,
261,
20335,
1669,
330,
3888,
45666,
261,
2832,
327,
698,
96268,
20335,
11,
716,
1669,
3980,
3564,
39327,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAWSGetFreeDeviceNumberOnErr(t *testing.T) {
ctrl, _, mockEC2 := setup(t)
defer ctrl.Finish()
// test error handling
mockEC2.EXPECT().DescribeInstances(gomock.Any()).Return(nil, errors.New("Error on DescribeInstances"))
ins := &EC2InstanceMetadataCache{ec2SVC: mockEC2}
_, err := ins.awsGetFreeDeviceNumber()
assert.Error(t, err)
} | explode_data.jsonl/19288 | {
"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,
36136,
1949,
10940,
6985,
2833,
1925,
7747,
1155,
353,
8840,
836,
8,
341,
84381,
11,
8358,
7860,
7498,
17,
1669,
6505,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
322,
1273,
1465,
11589,
198,
77333,
7498,
17,
22402,
7285... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClient_SetLogConfig(t *testing.T) {
t.Parallel()
app := startNewApplication(t)
client, _ := app.NewClientAndRenderer()
logLevel := "warn"
set := flag.NewFlagSet("loglevel", 0)
set.String("level", logLevel, "")
c := cli.NewContext(nil, set, nil)
err := client.SetLogLevel(c)
require.NoError(t, err)
assert.Equal(t, logLevel, app.Config.LogLevel().String())
sqlEnabled := true
set = flag.NewFlagSet("logsql", 0)
set.Bool("enable", sqlEnabled, "")
c = cli.NewContext(nil, set, nil)
err = client.SetLogSQL(c)
assert.NoError(t, err)
assert.Equal(t, sqlEnabled, app.Config.LogSQL())
sqlEnabled = false
set = flag.NewFlagSet("logsql", 0)
set.Bool("disable", true, "")
c = cli.NewContext(nil, set, nil)
err = client.SetLogSQL(c)
assert.NoError(t, err)
assert.Equal(t, sqlEnabled, app.Config.LogSQL())
} | explode_data.jsonl/5278 | {
"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,
2959,
14812,
2201,
2648,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
28236,
1669,
1191,
3564,
4988,
1155,
340,
25291,
11,
716,
1669,
906,
7121,
2959,
3036,
11541,
2822,
6725,
4449,
1669,
330,
33481,
698,
8196,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestList(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
resourceID := "/subscriptions/subscriptionID/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines"
armClient := mockarmclient.NewMockInterface(ctrl)
vmList := []compute.VirtualMachine{getTestVM("vm1"), getTestVM("vm1"), getTestVM("vm1")}
responseBody, err := json.Marshal(compute.VirtualMachineListResult{Value: &vmList})
assert.NoError(t, err)
armClient.EXPECT().GetResource(gomock.Any(), resourceID, "").Return(
&http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader(responseBody)),
}, nil).Times(1)
armClient.EXPECT().CloseResponse(gomock.Any(), gomock.Any()).Times(1)
vmClient := getTestVMClient(armClient)
result, rerr := vmClient.List(context.TODO(), "rg")
assert.Nil(t, rerr)
assert.Equal(t, 3, len(result))
} | explode_data.jsonl/16686 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
852,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
50346,
915,
1669,
3521,
72560,
14,
34404,
915,
53100,
22173,
14,
1984,
82543,
10270,
3929,
89237,
5457,
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 TestRemoveSecrets(t *testing.T) {
ctx := context.Background()
assertRewrite(t, RemoveSecrets{
Context: ctx,
Source: "https://example.com/secrets/1",
}, `
exo = "0.1"
`, `
exo = "0.1"
`)
assertRewrite(t, RemoveSecrets{
Context: ctx,
Source: "https://example.com/secrets/1",
}, `
exo = "0.1"
environment {
secrets {
source = "https://example.com/secrets/1"
}
}
`, `
exo = "0.1"
`)
assertRewrite(t, RemoveSecrets{
Context: ctx,
Source: "https://example.com/secrets/1",
}, `
exo = "0.1"
environment {
secrets {
source = "https://example.com/secrets/1"
}
secrets {
source = "https://example.com/secrets/2"
}
}
`, `
exo = "0.1"
environment {
secrets {
source = "https://example.com/secrets/2"
}
}
`)
} | explode_data.jsonl/52939 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
13021,
19773,
82,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
6948,
58465,
1247,
1155,
11,
10783,
19773,
82,
515,
197,
70871,
25,
5635,
345,
197,
197,
3608,
25,
220,
330,
2428,
1110,
8687,
905,
59587,
5271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSnapshotsMatch(t *testing.T) {
files, err := ioutil.ReadDir("testdata")
assert.NoError(t, err)
us := os.Getenv("UPDATE_SNAPSHOTS")
updateSnapshots := strings.ToLower(us) == "true"
for _, f := range files {
if !strings.HasSuffix(f.Name(), ".json") {
continue
}
inputFile := fmt.Sprintf("testdata/%s", f.Name())
snapshotFile := fmt.Sprintf("%s~snapshot", inputFile)
CompareSnapshot(t, inputFile, snapshotFile, updateSnapshots)
}
} | explode_data.jsonl/52372 | {
"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,
61871,
27634,
8331,
1155,
353,
8840,
836,
8,
341,
74075,
11,
1848,
1669,
43144,
6503,
6184,
445,
92425,
1138,
6948,
35699,
1155,
11,
1848,
340,
70175,
1669,
2643,
64883,
445,
9239,
47260,
2537,
8590,
46213,
1138,
27175,
61871,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDependencyOutputSkipOutputsWithMockOutput(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, TEST_FIXTURE_GET_OUTPUT)
tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_GET_OUTPUT)
rootPath := filepath.Join(tmpEnvPath, TEST_FIXTURE_GET_OUTPUT, "mock-outputs")
dependent3Path := filepath.Join(rootPath, "dependent3")
showStdout := bytes.Buffer{}
showStderr := bytes.Buffer{}
err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", dependent3Path), &showStdout, &showStderr)
assert.NoError(t, err)
logBufferContentsLineByLine(t, showStdout, "show stdout")
logBufferContentsLineByLine(t, showStderr, "show stderr")
// verify expected output when mocks are used: The answer is 0
stdout := bytes.Buffer{}
stderr := bytes.Buffer{}
require.NoError(
t,
runTerragruntCommand(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", dependent3Path), &stdout, &stderr),
)
outputs := map[string]TerraformOutput{}
require.NoError(t, json.Unmarshal([]byte(stdout.String()), &outputs))
assert.Equal(t, outputs["truth"].Value, "The answer is 0")
// Now apply-all so that the dependency is applied, and verify it still uses the mock output
err = runTerragruntCommand(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath), &showStdout, &showStderr)
assert.NoError(t, err)
logBufferContentsLineByLine(t, showStdout, "show stdout")
logBufferContentsLineByLine(t, showStderr, "show stderr")
// verify expected output when mocks are used: The answer is 0
stdout = bytes.Buffer{}
stderr = bytes.Buffer{}
require.NoError(
t,
runTerragruntCommand(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", dependent3Path), &stdout, &stderr),
)
outputs = map[string]TerraformOutput{}
require.NoError(t, json.Unmarshal([]byte(stdout.String()), &outputs))
assert.Equal(t, outputs["truth"].Value, "The answer is 0")
} | explode_data.jsonl/10132 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 777
} | [
2830,
3393,
36387,
5097,
35134,
5097,
16056,
11571,
5097,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1444,
60639,
51,
13886,
627,
13682,
1155,
11,
13602,
42635,
41486,
12702,
23981,
340,
20082,
14359,
1820,
1669,
2975,
12723,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.