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 TestNullArray(t *testing.T) {
n, _ := get(`{"data":null}`, "data").Interface()
if n != nil {
t.Fatalf("expected '%v', got '%v'", nil, n)
}
n = get(`{}`, "data")
if reflect.DeepEqual(n, nil) {
t.Fatalf("expected '%v', got '%v'", nil, n)
}
n = get(`{"data":[]}`, "data")
if reflect.DeepEqual(n, &ast.Node{}) {
t.Fatalf("expected '%v', got '%v'", nil, n)
}
arr, _ := get(`{"data":[null]}`, "data").Array()
n = len(arr)
if n != 1 {
t.Fatalf("expected '%v', got '%v'", 1, n)
}
} | explode_data.jsonl/62356 | {
"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,
3280,
1857,
1155,
353,
8840,
836,
8,
341,
262,
308,
11,
716,
1669,
633,
5809,
4913,
691,
788,
2921,
28350,
330,
691,
1827,
5051,
741,
262,
421,
308,
961,
2092,
341,
286,
259,
30762,
445,
7325,
7677,
85,
516,
2684,
7677,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPostingsForMatcher(t *testing.T) {
cases := []struct {
matcher *labels.Matcher
hasError bool
}{
{
// Equal label matcher will just return.
matcher: labels.MustNewMatcher(labels.MatchEqual, "test", "test"),
hasError: false,
},
{
// Regex matcher which doesn't have '|' will call Labelvalues()
matcher: labels.MustNewMatcher(labels.MatchRegexp, "test", ".*"),
hasError: true,
},
{
matcher: labels.MustNewMatcher(labels.MatchRegexp, "test", "a|b"),
hasError: false,
},
{
// Test case for double quoted regex matcher
matcher: labels.MustNewMatcher(labels.MatchRegexp, "test", "^(?:a|b)$"),
hasError: true,
},
}
for _, tc := range cases {
ir := &mockMatcherIndex{}
_, err := postingsForMatcher(ir, tc.matcher)
if tc.hasError {
testutil.NotOk(t, err)
} else {
testutil.Ok(t, err)
}
}
} | explode_data.jsonl/50271 | {
"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,
4133,
819,
2461,
37554,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
2109,
28058,
220,
353,
16873,
76452,
198,
197,
63255,
1454,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
322,
38474,
2383,
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... | 3 |
func TestSimpleMetaFactoryUpdate(t *testing.T) {
factory := SimpleMetaFactory{VersionField: "V", KindField: "K"}
obj := struct {
V string
K string
}{"1", "2"}
// must pass a pointer
if err := factory.Update("test", "other", obj); err == nil {
t.Errorf("unexpected non-error")
}
if obj.V != "1" || obj.K != "2" {
t.Errorf("unexpected update: %v", obj)
}
// updates
if err := factory.Update("test", "other", &obj); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if obj.V != "test" || obj.K != "other" {
t.Errorf("unexpected update: %v", obj)
}
} | explode_data.jsonl/34479 | {
"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,
16374,
12175,
4153,
4289,
1155,
353,
8840,
836,
8,
341,
1166,
2919,
1669,
8993,
12175,
4153,
90,
5637,
1877,
25,
330,
53,
497,
16840,
1877,
25,
330,
42,
63159,
22671,
1669,
2036,
341,
197,
17446,
914,
198,
197,
39340,
914,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSearch(t *testing.T) {
tests := []struct {
vector []float64
want SearchResult
}{
{[]float64{1, 0, 0, 0, 0, 0}, SearchResult{1, 0}},
{[]float64{0, 1, 0, 0, 0, 0}, SearchResult{2, 0}},
{[]float64{0, 0, 1, 0, 0, 0}, SearchResult{3, 0}},
{[]float64{0, 0, 0, 1, 0, 0}, SearchResult{4, 0}},
{[]float64{0, 0, 0, 0, 1, 0}, SearchResult{5, 0}},
{[]float64{1, 1, 0, 0, 0, 0}, SearchResult{6, 0}},
}
ngt := New(index).Open()
defer ngt.Close()
if errs := ngt.GetErrors(); len(errs) > 0 {
t.Errorf("Unexpected error: TestSearch(%v)", errs)
}
for _, tt := range tests {
result, err := ngt.Search(tt.vector, 1, DefaultEpsilon)
if err != nil {
t.Errorf("Unexpected error: TestSearch(%v)", err)
}
if result[0].ID != tt.want.ID || result[0].Distance != tt.want.Distance {
t.Errorf("TestSearch(%v): %v, wanted: %v", tt.vector, result, tt.want)
}
}
} | explode_data.jsonl/31019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 413
} | [
2830,
3393,
5890,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
20365,
3056,
3649,
21,
19,
198,
197,
50780,
256,
96597,
198,
197,
59403,
197,
197,
90,
1294,
3649,
21,
19,
90,
16,
11,
220,
15,
11,
220,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestUnknownRevision(t *testing.T) {
testenv.NeedsGo1Point(t, 14)
const unknown = `
-- go.mod --
module mod.com
require (
example.com v1.2.2
)
-- main.go --
package main
import "example.com/blah"
func main() {
var x = blah.Name
}
`
// Start from a bad state/bad IWL, and confirm that we recover.
t.Run("bad", func(t *testing.T) {
runModfileTest(t, unknown, proxy, func(t *testing.T, env *Env) {
env.OpenFile("go.mod")
env.Await(
env.DiagnosticAtRegexp("go.mod", "example.com v1.2.2"),
)
env.RegexpReplace("go.mod", "v1.2.2", "v1.2.3")
env.Editor.SaveBufferWithoutActions(env.Ctx, "go.mod") // go.mod changes must be on disk
env.Await(
env.DiagnosticAtRegexp("main.go", "x = "),
)
})
})
const known = `
-- go.mod --
module mod.com
require (
example.com v1.2.3
)
-- main.go --
package main
import "example.com/blah"
func main() {
var x = blah.Name
}
`
// Start from a good state, transform to a bad state, and confirm that we
// still recover.
t.Run("good", func(t *testing.T) {
runModfileTest(t, known, proxy, func(t *testing.T, env *Env) {
env.OpenFile("go.mod")
env.Await(
env.DiagnosticAtRegexp("main.go", "x = "),
)
env.RegexpReplace("go.mod", "v1.2.3", "v1.2.2")
env.Editor.SaveBufferWithoutActions(env.Ctx, "go.mod") // go.mod changes must be on disk
env.Await(
env.DiagnosticAtRegexp("go.mod", "example.com v1.2.2"),
)
env.RegexpReplace("go.mod", "v1.2.2", "v1.2.3")
env.Editor.SaveBufferWithoutActions(env.Ctx, "go.mod") // go.mod changes must be on disk
env.Await(
env.DiagnosticAtRegexp("main.go", "x = "),
)
})
})
} | explode_data.jsonl/3745 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 746
} | [
2830,
3393,
13790,
33602,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
2067,
68,
6767,
10850,
16,
2609,
1155,
11,
220,
16,
19,
692,
4777,
9788,
284,
22074,
313,
728,
10929,
39514,
4352,
1463,
905,
271,
4310,
2399,
8122,
1516,
905,
348,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObjectDifficultName(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionWithContainer(t)
defer rollback()
const name = `hello? sausage/êé/Hello, 世界/ " ' @ < > & ?/`
err := c.ObjectPutString(ctx, CONTAINER, name, CONTENTS, "")
if err != nil {
t.Fatal(err)
}
defer func() {
err = c.ObjectDelete(ctx, CONTAINER, name)
if err != nil {
t.Fatal(err)
}
}()
objects, err := c.ObjectNamesAll(ctx, CONTAINER, nil)
if err != nil {
t.Error(err)
}
found := false
for _, object := range objects {
if object == name {
found = true
break
}
}
if !found {
t.Errorf("Couldn't find %q in listing %q", name, objects)
}
} | explode_data.jsonl/12717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 283
} | [
2830,
3393,
1190,
21751,
3866,
675,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
2354,
4502,
1155,
340,
16867,
60414,
741,
4777,
829,
284,
1565,
14990,
30,
58886,
14,
5498,
963,
14,
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 TestMiddleware(t *testing.T) {
cookies := sessions.NewCookieStore([]byte("my-secret"))
mockServer := newMockIndieAuthServer(t)
// Create a server that use the lib
s, err := New(cookies, mockServer.Me)
if err != nil {
panic(err)
}
m := s.Middleware()
mux := http.NewServeMux()
mux.HandleFunc("/indieauth-redirect", s.RedirectHandler)
mux.Handle("/", m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t.Logf("hello")
w.Write([]byte("hello"))
})))
server := httptest.NewServer(mux)
// Setup a client with cookies support
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
if err != nil {
log.Fatal(err)
}
client := &http.Client{
Jar: jar,
}
resp, err := client.Get(server.URL)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
t.Errorf("expected 200, got %d", resp.StatusCode)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
if string(data) != "hello" {
t.Errorf("bad response, expected \"hello\", got \"%s\"", data)
}
if mockServer.authCall != 1 {
t.Errorf("the authorization endpoint wasn't called")
}
if mockServer.verifCall != 1 {
t.Errorf("code was not verified")
}
} | explode_data.jsonl/7019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
24684,
1155,
353,
8840,
836,
8,
341,
197,
44317,
1669,
15704,
7121,
20616,
6093,
10556,
3782,
445,
2408,
68892,
28075,
77333,
5475,
1669,
501,
11571,
1425,
645,
5087,
5475,
1155,
692,
197,
322,
4230,
264,
3538,
429,
990,
279... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandleDefaultNamespace(t *testing.T) {
testcases := []struct {
name string
given map[plugins.ConfigMapID][]ConfigMapUpdate
expected map[plugins.ConfigMapID][]ConfigMapUpdate
}{
{
name: "nil map",
given: nil,
expected: map[plugins.ConfigMapID][]ConfigMapUpdate{},
},
{
name: "empty map",
given: map[plugins.ConfigMapID][]ConfigMapUpdate{},
expected: map[plugins.ConfigMapID][]ConfigMapUpdate{},
},
{
name: "no empty string as namespace",
given: map[plugins.ConfigMapID][]ConfigMapUpdate{
{Name: "some-config", Namespace: "ns1", Cluster: "build01"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "other-config", Namespace: "default", Cluster: "default"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
{Key: "bar.yaml", Filename: "config/bar.yaml"},
},
},
expected: map[plugins.ConfigMapID][]ConfigMapUpdate{
{Name: "some-config", Namespace: "ns1", Cluster: "build01"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "other-config", Namespace: "default", Cluster: "default"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
{Key: "bar.yaml", Filename: "config/bar.yaml"},
},
},
},
{
name: "some empty string as namespace",
given: map[plugins.ConfigMapID][]ConfigMapUpdate{
{Name: "some-config", Namespace: "ns1", Cluster: "build01"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "other-config", Cluster: "default"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
{Key: "bar.yaml", Filename: "config/bar.yaml"},
},
},
expected: map[plugins.ConfigMapID][]ConfigMapUpdate{
{Name: "some-config", Namespace: "ns1", Cluster: "build01"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "other-config", Namespace: "default", Cluster: "default"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
{Key: "bar.yaml", Filename: "config/bar.yaml"},
},
},
},
{
name: "some empty string as namespace with potential conflicting id",
given: map[plugins.ConfigMapID][]ConfigMapUpdate{
{Name: "some-config", Namespace: "ns1", Cluster: "build01"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "multikey-config", Cluster: "default"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "multikey-config", Namespace: "default", Cluster: "default"}: {
{Key: "bar.yaml", Filename: "config/bar.yaml"},
},
},
expected: map[plugins.ConfigMapID][]ConfigMapUpdate{
{Name: "some-config", Namespace: "ns1", Cluster: "build01"}: {
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
{Name: "multikey-config", Namespace: "default", Cluster: "default"}: {
{Key: "bar.yaml", Filename: "config/bar.yaml"},
{Key: "foo.yaml", Filename: "config/foo.yaml"},
},
},
},
}
for _, tc := range testcases {
actual := handleDefaultNamespace(tc.given, defaultNamespace)
if !equality.Semantic.DeepEqual(tc.expected, actual) {
t.Errorf("%s: incorrect changes: %v", tc.name, diff.ObjectReflectDiff(tc.expected, actual))
}
}
} | explode_data.jsonl/45259 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1385
} | [
2830,
3393,
6999,
3675,
22699,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
3174,
2071,
262,
2415,
58,
18716,
10753,
2227,
915,
45725,
2648,
2227,
4289,
198,
197,
42400,
2415,
58,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWatchPods(t *testing.T) {
fakeWatch := watch.NewFake()
client := &fake.Clientset{}
client.AddWatchReactor("*", core.DefaultWatchReactor(fakeWatch, nil))
manager := NewReplicaSetController(client, controller.NoResyncPeriodFunc, BurstReplicas, 0)
manager.podStoreSynced = alwaysReady
// Put one ReplicaSet and one pod into the controller's stores
labelMap := map[string]string{"foo": "bar"}
testRSSpec := newReplicaSet(1, labelMap)
manager.rsStore.Store.Add(testRSSpec)
received := make(chan string)
// The pod update sent through the fakeWatcher should figure out the managing ReplicaSet and
// send it into the syncHandler.
manager.syncHandler = func(key string) error {
obj, exists, err := manager.rsStore.Store.GetByKey(key)
if !exists || err != nil {
t.Errorf("Expected to find replica set under key %v", key)
}
rsSpec := obj.(*extensions.ReplicaSet)
if !api.Semantic.DeepDerivative(rsSpec, testRSSpec) {
t.Errorf("\nExpected %#v,\nbut got %#v", testRSSpec, rsSpec)
}
close(received)
return nil
}
// Start only the pod watcher and the workqueue, send a watch event,
// and make sure it hits the sync method for the right ReplicaSet.
stopCh := make(chan struct{})
defer close(stopCh)
go manager.podController.Run(stopCh)
go wait.Until(manager.worker, 10*time.Millisecond, stopCh)
pods := newPodList(nil, 1, api.PodRunning, labelMap, testRSSpec, "pod")
testPod := pods.Items[0]
testPod.Status.Phase = api.PodFailed
fakeWatch.Add(&testPod)
select {
case <-received:
case <-time.After(wait.ForeverTestTimeout):
t.Errorf("Expected 1 call but got 0")
}
} | explode_data.jsonl/10048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 565
} | [
2830,
3393,
14247,
23527,
82,
1155,
353,
8840,
836,
8,
341,
1166,
726,
14247,
1669,
3736,
7121,
52317,
741,
25291,
1669,
609,
30570,
11716,
746,
16094,
25291,
1904,
14247,
693,
5621,
29592,
497,
6200,
13275,
14247,
693,
5621,
74138,
14247... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRest_UpdateWithRestrictedWords(t *testing.T) {
ts, _, teardown := startupT(t)
defer teardown()
c1 := store.Comment{Text: "What the quack is that?", ParentID: "p1",
Locator: store.Locator{SiteID: "remark42", URL: "https://radio-t.com/blah1"}}
id := addComment(t, c1, ts)
client := http.Client{}
req, err := http.NewRequest(http.MethodPut, ts.URL+"/api/v1/comment/"+id+"?site=remark42&url=https://radio-t.com/blah1",
strings.NewReader(`{"text":"What the duck is that?", "summary":"my edit"}`))
assert.NoError(t, err)
req.Header.Add("X-JWT", devToken)
b, err := client.Do(req)
assert.NoError(t, err)
body, err := ioutil.ReadAll(b.Body)
assert.NoError(t, err)
c := R.JSON{}
err = json.Unmarshal(body, &c)
assert.NoError(t, err)
assert.Equal(t, 400, b.StatusCode, string(body))
assert.Equal(t, "comment contains restricted words", c["error"])
assert.Equal(t, "invalid comment", c["details"])
} | explode_data.jsonl/37397 | {
"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,
12416,
47393,
2354,
86405,
23489,
1155,
353,
8840,
836,
8,
341,
57441,
11,
8358,
49304,
1669,
20567,
51,
1155,
340,
16867,
49304,
2822,
1444,
16,
1669,
3553,
56730,
90,
1178,
25,
330,
3838,
279,
922,
473,
374,
429,
31011,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRejectModelSpecMissing(t *testing.T) {
g := gomega.NewGomegaWithT(t)
kfsvc := makeTestKFService()
kfsvc.Spec.Default.Predictor.Tensorflow = nil
g.Expect(kfsvc.ValidateCreate()).Should(gomega.MatchError(ExactlyOnePredictorViolatedError))
} | explode_data.jsonl/7097 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
78413,
1712,
8327,
25080,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
340,
16463,
69,
58094,
1669,
1281,
2271,
65008,
1860,
741,
16463,
69,
58094,
36473,
13275,
1069,
8861,
269,
442... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTabContainer_Hidden_AsChild(t *testing.T) {
c1 := widget.NewLabel("Tab 1 content")
c2 := widget.NewLabel("Tab 2 content\nTab 2 content\nTab 2 content")
ti1 := container.NewTabItem("Tab 1", c1)
ti2 := container.NewTabItem("Tab 2", c2)
tabs := container.NewAppTabs(ti1, ti2)
tabs.Refresh()
assert.True(t, c1.Visible())
assert.False(t, c2.Visible())
tabs.SelectTabIndex(1)
assert.False(t, c1.Visible())
assert.True(t, c2.Visible())
} | explode_data.jsonl/32313 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
8582,
4502,
2039,
2854,
62741,
3652,
1155,
353,
8840,
836,
8,
341,
1444,
16,
1669,
9086,
7121,
2476,
445,
8582,
220,
16,
2213,
1138,
1444,
17,
1669,
9086,
7121,
2476,
445,
8582,
220,
17,
2213,
1699,
8582,
220,
17,
2213,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerragruntGenerateBlockDisableSignature(t *testing.T) {
t.Parallel()
generateTestCase := filepath.Join(TEST_FIXTURE_CODEGEN_PATH, "generate-block", "disable-signature")
cleanupTerraformFolder(t, generateTestCase)
cleanupTerragruntFolder(t, generateTestCase)
runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", generateTestCase))
// Now check the outputs to make sure they are as expected
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", generateTestCase), &stdout, &stderr),
)
outputs := map[string]TerraformOutput{}
require.NoError(t, json.Unmarshal([]byte(stdout.String()), &outputs))
assert.Equal(t, outputs["text"].Value, "Hello, World!")
} | explode_data.jsonl/10164 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
51402,
68305,
3850,
31115,
4713,
25479,
25088,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3174,
13220,
16458,
1669,
26054,
22363,
50320,
42635,
41486,
10020,
11085,
7944,
11,
330,
19366,
9425,
497,
330,
18015,
27953,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSourceMap(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/Users/user/project/src/entry.js": `
import {bar} from './bar'
function foo() { bar() }
foo()
`,
"/Users/user/project/src/bar.js": `
export function bar() { throw new Error('test') }
`,
},
entryPaths: []string{"/Users/user/project/src/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
SourceMap: config.SourceMapLinkedWithComment,
AbsOutputFile: "/Users/user/project/out.js",
},
})
} | explode_data.jsonl/38489 | {
"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,
3608,
2227,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
7137,
11739,
40118,
13437,
14,
4085,
2857,
788,
22074,
571,
21918,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMfsStress(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, rt := setupRoot(ctx, t)
numroutines := 10
errs := make(chan error)
for i := 0; i < numroutines; i++ {
go testActor(rt, 50, errs)
}
for i := 0; i < numroutines; i++ {
err := <-errs
if err != nil {
t.Fatal(err)
}
}
} | explode_data.jsonl/35820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
44,
3848,
623,
673,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
741,
197,
6878,
16677,
1669,
6505,
8439,
7502,
11,
259,
692,
22431,
81,
28628,
1669,
220,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestReconcileWithWhenExpressionsWithParameters(t *testing.T) {
names.TestingSeed()
prName := "test-pipeline-run"
ps := []*v1beta1.Pipeline{{
ObjectMeta: baseObjectMeta("test-pipeline", "foo"),
Spec: v1beta1.PipelineSpec{
Params: []v1beta1.ParamSpec{{
Name: "run",
Type: v1beta1.ParamTypeString,
}},
Tasks: []v1beta1.PipelineTask{
{
Name: "hello-world-1",
TaskRef: &v1beta1.TaskRef{Name: "hello-world-1"},
WhenExpressions: []v1beta1.WhenExpression{
{
Input: "foo",
Operator: selection.NotIn,
Values: []string{"bar"},
},
{
Input: "$(params.run)",
Operator: selection.In,
Values: []string{"yes"},
},
},
},
{
Name: "hello-world-2",
TaskRef: &v1beta1.TaskRef{Name: "hello-world-2"},
WhenExpressions: []v1beta1.WhenExpression{{
Input: "$(params.run)",
Operator: selection.NotIn,
Values: []string{"yes"},
}},
},
},
},
}}
prs := []*v1beta1.PipelineRun{{
ObjectMeta: metav1.ObjectMeta{
Name: prName,
Namespace: "foo",
Annotations: map[string]string{"PipelineRunAnnotation": "PipelineRunValue"},
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{Name: "test-pipeline"},
ServiceAccountName: "test-sa",
Params: []v1beta1.Param{{
Name: "run",
Value: *v1beta1.NewArrayOrString("yes"),
}},
},
}}
ts := []*v1beta1.Task{
{ObjectMeta: baseObjectMeta("hello-world-1", "foo")},
{ObjectMeta: baseObjectMeta("hello-world-2", "foo")},
}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
wantEvents := []string{
"Normal Started",
"Normal Running Tasks Completed: 0 \\(Failed: 0, Cancelled 0\\), Incomplete: 1, Skipped: 1",
}
pipelineRun, clients := prt.reconcileRun("foo", prName, wantEvents, false)
// Check that the expected TaskRun was created
actual, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{
LabelSelector: "tekton.dev/pipelineTask=hello-world-1,tekton.dev/pipelineRun=test-pipeline-run",
Limit: 1,
})
if err != nil {
t.Fatalf("Failure to list TaskRun's %s", err)
}
if len(actual.Items) != 1 {
t.Fatalf("Expected 1 TaskRun got %d", len(actual.Items))
}
expectedTaskRunName := "test-pipeline-run-hello-world-1-9l9zj"
expectedTaskRunObjectMeta := taskRunObjectMeta(expectedTaskRunName, "foo", "test-pipeline-run", "test-pipeline", "hello-world-1", false)
expectedTaskRunObjectMeta.Annotations["PipelineRunAnnotation"] = "PipelineRunValue"
expectedTaskRun := &v1beta1.TaskRun{
ObjectMeta: expectedTaskRunObjectMeta,
Spec: v1beta1.TaskRunSpec{
TaskRef: &v1beta1.TaskRef{Name: "hello-world-1"},
ServiceAccountName: "test-sa",
Resources: &v1beta1.TaskRunResources{},
Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute},
},
}
actualTaskRun := actual.Items[0]
if d := cmp.Diff(&actualTaskRun, expectedTaskRun, ignoreResourceVersion); d != "" {
t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRunName, diff.PrintWantGot(d))
}
actualWhenExpressionsInTaskRun := pipelineRun.Status.PipelineRunStatusFields.TaskRuns[expectedTaskRunName].WhenExpressions
expectedWhenExpressionsInTaskRun := []v1beta1.WhenExpression{{
Input: "foo",
Operator: "notin",
Values: []string{"bar"},
}, {
Input: "yes",
Operator: "in",
Values: []string{"yes"},
}}
if d := cmp.Diff(expectedWhenExpressionsInTaskRun, actualWhenExpressionsInTaskRun); d != "" {
t.Errorf("expected to see When Expressions %v created. Diff %s", expectedTaskRunName, diff.PrintWantGot(d))
}
actualSkippedTasks := pipelineRun.Status.SkippedTasks
expectedSkippedTasks := []v1beta1.SkippedTask{{
Name: "hello-world-2",
WhenExpressions: v1beta1.WhenExpressions{{
Input: "yes",
Operator: "notin",
Values: []string{"yes"},
}},
}}
if d := cmp.Diff(actualSkippedTasks, expectedSkippedTasks); d != "" {
t.Errorf("expected to find Skipped Tasks %v. Diff %s", expectedSkippedTasks, diff.PrintWantGot(d))
}
skippedTasks := []string{"hello-world-2"}
for _, skippedTask := range skippedTasks {
labelSelector := fmt.Sprintf("tekton.dev/pipelineTask=%s,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs", skippedTask)
actualSkippedTask, err := clients.Pipeline.TektonV1beta1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{
LabelSelector: labelSelector,
Limit: 1,
})
if err != nil {
t.Fatalf("Failure to list TaskRun's %s", err)
}
if len(actualSkippedTask.Items) != 0 {
t.Fatalf("Expected 0 TaskRuns got %d", len(actualSkippedTask.Items))
}
}
} | explode_data.jsonl/68287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2079
} | [
2830,
3393,
693,
40446,
457,
2354,
4498,
40315,
2354,
9706,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
741,
25653,
675,
1669,
330,
1944,
2268,
8790,
22973,
698,
35009,
1669,
29838,
85,
16,
19127,
16,
1069,
8790,
90,
515,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestUniqueTermFilter(t *testing.T) {
var tests = []struct {
input analysis.TokenStream
// expected indices of input which should be included in the output. We
// use indices instead of another TokenStream, since position/start/end
// should be preserved.
expectedIndices []int
}{
{
input: tokenStream(),
expectedIndices: []int{},
},
{
input: tokenStream("a"),
expectedIndices: []int{0},
},
{
input: tokenStream("each", "term", "in", "this", "sentence", "is", "unique"),
expectedIndices: []int{0, 1, 2, 3, 4, 5, 6},
},
{
input: tokenStream("Lui", "è", "alto", "e", "lei", "è", "bassa"),
expectedIndices: []int{0, 1, 2, 3, 4, 6},
},
{
input: tokenStream("a", "a", "A", "a", "a", "A"),
expectedIndices: []int{0, 2},
},
}
uniqueTermFilter := NewUniqueTermFilter()
for _, test := range tests {
expected := subStream(test.input, test.expectedIndices)
actual := uniqueTermFilter.Filter(test.input)
if !reflect.DeepEqual(actual, expected) {
t.Errorf("expected %s \n\n got %s", expected, actual)
}
}
} | explode_data.jsonl/48870 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 476
} | [
2830,
3393,
22811,
17249,
5632,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
22427,
6358,
32277,
3027,
198,
197,
197,
322,
3601,
14937,
315,
1946,
892,
1265,
387,
5230,
304,
279,
2550,
13,
1205,
198,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_getVersionFromKubectlOutput(t *testing.T) {
ver := getVersionFromKubectlOutput(`{
"serverVersion": {
"major": "1",
"minor": "8",
"gitVersion": "v1.8.0"
}
}`)
if ver.BaseVersion() != "1.8" {
t.Fatalf("Expected 1.8 got %s", ver.BaseVersion())
}
ver = getVersionFromKubectlOutput("Something completely different")
if ver.BaseVersion() != defaultKubeVersion {
t.Fatalf("Expected %s got %s", defaultKubeVersion, ver.BaseVersion())
}
} | explode_data.jsonl/60198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
3062,
5637,
3830,
42,
53380,
5097,
1155,
353,
8840,
836,
8,
341,
197,
423,
1669,
97245,
3830,
42,
53380,
5097,
5809,
515,
220,
330,
4030,
5637,
788,
341,
262,
330,
36505,
788,
330,
16,
756,
262,
330,
45670,
788,
330,
23,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCfg_FilePath(t *testing.T) {
gtest.Case(t, func() {
c := gcfg.New("config.yml")
path := c.FilePath("tmp")
gtest.Assert(path, "")
path = c.FilePath("tmp")
gtest.Assert(path, "")
})
} | explode_data.jsonl/24455 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
42467,
34061,
1820,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
519,
1155,
11,
2915,
368,
341,
197,
1444,
1669,
342,
14072,
7121,
445,
1676,
33936,
1138,
197,
26781,
1669,
272,
8576,
1820,
445,
5173,
1138,
197,
3174,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewRequestWithContext(t *testing.T) {
opts := Options{
BaseURL: apiURL,
Headers: Headers{
"some": "header",
"other": "value",
},
}
client, err := New(opts)
require.NoError(t, err, "create client error")
type testKeyCtx struct{}
contextValue := "context-value"
ctx := context.WithValue(context.Background(), testKeyCtx{}, contextValue)
t.Run("throws if url parsing throw", func(t *testing.T) {
req, err := client.NewRequestWithContext(context.Background(), http.MethodGet, "\t", nil)
require.True(t, strings.Contains(err.Error(), "invalid control character in URL"))
require.Nil(t, req, "req is not nil")
})
t.Run("throws if baseURL and urlStr are absolute", func(t *testing.T) {
req, err := client.NewRequestWithContext(context.Background(), http.MethodGet, "http://example.org", nil)
require.EqualError(t, err, "baseURL and urlStr cannot be both absolute")
require.Nil(t, req, "req is not nil")
})
t.Run("correctly create request path", func(t *testing.T) {
req, err := client.NewRequestWithContext(ctx, http.MethodGet, "my-resource", nil)
require.NoError(t, err, "new request not errors")
require.Exactly(t, "https://base-url:8080/api/url/my-resource", req.URL.String())
require.Exactly(t, req.Header.Get("Content-Type"), "")
v := req.Context().Value(testKeyCtx{})
require.Exactly(t, contextValue, v, "context is not correct")
})
t.Run("correctly create request path with query params", func(t *testing.T) {
req, err := client.NewRequestWithContext(ctx, http.MethodGet, "my-resource?query=params", nil)
require.NoError(t, err, "new request not errors")
require.Exactly(t, "https://base-url:8080/api/url/my-resource?query=params", req.URL.String())
})
t.Run("correctly set request body", func(t *testing.T) {
var data = map[string]interface{}{
"some": "json format",
"foo": "bar",
"that": float64(3),
}
req, err := client.NewRequestWithContext(ctx, http.MethodPost, "my-resource", data)
require.NoError(t, err, "request error")
var reqBody map[string]interface{}
err = json.NewDecoder(req.Body).Decode(&reqBody)
require.NoError(t, err, "json marshal error")
require.Exactly(t, data, reqBody, "wrong request body")
require.Exactly(t, req.Header.Get("Content-Type"), "application/json")
v := req.Context().Value(testKeyCtx{})
require.Exactly(t, contextValue, v, "context is not correct")
})
t.Run("correctly set request body without base path", func(t *testing.T) {
var data = map[string]interface{}{
"some": "json format",
"foo": "bar",
"that": float64(3),
}
opts := Options{
Headers: Headers{
"some": "header",
"other": "value",
},
}
client, err := New(opts)
require.NoError(t, err, "create client error")
req, err := client.NewRequestWithContext(ctx, http.MethodPost, "https://local-server/my-resource", data)
require.NoError(t, err, "request error")
var reqBody map[string]interface{}
err = json.NewDecoder(req.Body).Decode(&reqBody)
require.NoError(t, err, "json marshal error")
require.Exactly(t, data, reqBody, "wrong request body")
require.Exactly(t, req.Header.Get("Content-Type"), "application/json")
v := req.Context().Value(testKeyCtx{})
require.Exactly(t, contextValue, v, "context is not correct")
})
t.Run("correctly add default headers to the request", func(t *testing.T) {
req, err := client.NewRequestWithContext(ctx, http.MethodPost, "my-resource", nil)
require.NoError(t, err, "request error")
require.Exactly(t, req.Header.Get("some"), "header")
require.Exactly(t, req.Header.Get("other"), "value")
})
t.Run("content-type header is overwritten to json if body passed", func(t *testing.T) {
var data = map[string]interface{}{
"some": "json format",
"foo": "bar",
"that": float64(3),
}
opts := Options{
BaseURL: apiURL,
Headers: Headers{
"Content-Type": "not-a-json",
},
}
client, err := New(opts)
require.NoError(t, err, "create client error")
req, err := client.NewRequestWithContext(ctx, http.MethodPost, "my-resource", data)
require.NoError(t, err, "request error")
require.Exactly(t, req.Header.Get("Content-Type"), "application/json")
})
} | explode_data.jsonl/66011 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1547
} | [
2830,
3393,
3564,
1900,
91101,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
14566,
515,
197,
66732,
3144,
25,
6330,
3144,
345,
197,
197,
10574,
25,
21426,
515,
298,
197,
1,
14689,
788,
220,
330,
2708,
756,
298,
197,
1,
1575,
788,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateStackTypechecking(t *testing.T) {
tcs := []struct {
name string
code []byte
err error
}{
{
name: "call i32",
code: []byte{
operators.Call, 0,
operators.Drop,
},
err: nil,
},
{
name: "call bad index",
code: []byte{
operators.Call, 100,
},
err: wasm.InvalidFunctionIndexError(100),
},
{
name: "call i32 unbalanced",
code: []byte{
operators.Call, 0,
},
err: UnbalancedStackErr(wasm.ValueTypeI32),
},
{
name: "parameterized call",
code: []byte{
operators.I32Const, 1,
operators.I32Const, 2,
operators.Call, 1,
operators.Drop,
},
err: nil,
},
{
name: "parameterized call type mismatch",
code: []byte{
operators.F32Const, 0, 0, 0, 0,
operators.I32Const, 2,
operators.Call, 1,
operators.Drop,
},
err: InvalidTypeError{wasm.ValueTypeI32, wasm.ValueTypeF32},
},
{
name: "call indirect",
code: []byte{
operators.I32Const, 0,
operators.CallIndirect, 0, 0,
operators.Drop,
},
err: nil,
},
{
name: "call indirect invalid selector type",
code: []byte{
operators.F32Const, 0, 0, 0, 0,
operators.CallIndirect, 0, 0,
operators.Drop,
},
err: InvalidTypeError{wasm.ValueTypeI32, wasm.ValueTypeF32},
},
{
name: "call indirect non-zero table index",
code: []byte{
operators.I32Const, 0,
operators.CallIndirect, 0, 1,
operators.Drop,
},
err: InvalidTableIndexError{"table", 1},
},
{
name: "call indirect i32 unbalanced",
code: []byte{
operators.I32Const, 0,
operators.CallIndirect, 0, 0,
},
err: UnbalancedStackErr(wasm.ValueTypeI32),
},
{
name: "call indirect parameters",
code: []byte{
operators.I32Const, 1,
operators.I32Const, 2,
operators.I32Const, 0,
operators.CallIndirect, 1, 0,
operators.Drop,
},
err: nil,
},
{
name: "call indirect parameters underflow",
code: []byte{
operators.I32Const, 1,
operators.I32Const, 0,
operators.CallIndirect, 1, 0,
operators.Drop,
},
err: ErrStackUnderflow,
},
{
name: "call indirect parameters mismatch",
code: []byte{
operators.I32Const, 1,
operators.I64Const, 2,
operators.I32Const, 0,
operators.CallIndirect, 1, 0,
operators.Drop,
},
err: InvalidTypeError{wasm.ValueTypeI32, wasm.ValueTypeI64},
},
{
name: "call indirect parameters return mismatch",
code: []byte{
operators.I32Const, 8,
operators.I32Const, 1,
operators.I32Const, 2,
operators.I32Const, 0,
operators.CallIndirect, 1, 0,
operators.I32Add,
operators.Drop,
},
err: InvalidTypeError{wasm.ValueTypeI32, wasm.ValueTypeF32},
},
}
for i := range tcs {
tc := tcs[i]
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
mod := wasm.Module{
FunctionIndexSpace: []wasm.Function{
{ // Function at index 0 returns an i32.
Sig: &wasm.FunctionSig{
Form: 0x60,
ParamTypes: nil, // No parameters
ReturnTypes: []wasm.ValueType{wasm.ValueTypeI32},
},
},
{ // Function at index 1 returns an f32, consuming 2 i32's.
Sig: &wasm.FunctionSig{
Form: 0x60,
ParamTypes: []wasm.ValueType{wasm.ValueTypeI32, wasm.ValueTypeI32},
ReturnTypes: []wasm.ValueType{wasm.ValueTypeF32},
},
},
},
Table: &wasm.SectionTables{
Entries: []wasm.Table{
{ElementType: wasm.ElemTypeAnyFunc},
{ElementType: wasm.ElemTypeAnyFunc},
},
},
}
mod.Types = &wasm.SectionTypes{
Entries: []wasm.FunctionSig{
*mod.FunctionIndexSpace[0].Sig,
*mod.FunctionIndexSpace[1].Sig,
},
}
sig := wasm.FunctionSig{Form: 0x60 /* Must always be 0x60 */}
fn := wasm.FunctionBody{Module: &mod, Code: tc.code}
_, err := verifyBody(&sig, &fn, &mod)
if err != tc.err {
t.Fatalf("verify returned '%v', want '%v'", err, tc.err)
}
})
}
} | explode_data.jsonl/16568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1929
} | [
2830,
3393,
17926,
4336,
929,
57854,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
43343,
3056,
3782,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
6659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddByIndex(t *testing.T) {
dll, err := generateBaseDLL(5)
if err != nil {
t.Error(err)
}
val := "index-2-inserted"
err = dll.AddByIndex(val, 2)
if err != nil {
t.Error(err)
}
if dll.head.next.next.data != val {
t.Errorf("The item with data '%s' was should be added by index 2, got %s", val, dll.head.next.next.data)
}
} | explode_data.jsonl/59813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
2212,
1359,
1552,
1155,
353,
8840,
836,
8,
341,
2698,
654,
11,
1848,
1669,
6923,
3978,
64187,
7,
20,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
532,
19302,
1669,
330,
1252,
12,
17,
74550,
291,
698,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStartReqLogger(t *testing.T) {
tests := map[string]struct {
isErr bool
request reconcile.Request
}{
"Test Positive-1": {
request: reconcile.Request{
NamespacedName: types.NamespacedName{
Name: "default",
},
},
isErr: false,
},
}
for name, mock := range tests {
t.Run(name, func(t *testing.T) {
req := startReqLogger(mock.request)
if mock.isErr && req != nil {
t.Fatalf("Test %q failed: expected error not to be nil", name)
}
if !mock.isErr && req == nil {
t.Fatalf("Test %q failed: expected error to be nil", name)
}
})
}
} | explode_data.jsonl/32134 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
3479,
27234,
7395,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
19907,
7747,
256,
1807,
198,
197,
23555,
63408,
9659,
198,
197,
59403,
197,
197,
1,
2271,
43903,
12,
16,
788,
341,
298,
23555,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_AddTwoPodsToVolume_Positive(t *testing.T) {
// Arrange
volumePluginMgr, plugin := volumetesting.GetTestVolumePluginMgr(t)
asw := NewActualStateOfWorld("mynode" /* nodeName */, volumePluginMgr)
devicePath := "fake/device/path"
pod1 := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod1",
UID: "pod1uid",
},
Spec: v1.PodSpec{
Volumes: []v1.Volume{
{
Name: "volume-name-1",
VolumeSource: v1.VolumeSource{
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
PDName: "fake-device1",
},
},
},
},
},
}
pod2 := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "pod2",
UID: "pod2uid",
},
Spec: v1.PodSpec{
Volumes: []v1.Volume{
{
Name: "volume-name-2",
VolumeSource: v1.VolumeSource{
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
PDName: "fake-device1",
},
},
},
},
},
}
volumeSpec1 := &volume.Spec{Volume: &pod1.Spec.Volumes[0]}
volumeSpec2 := &volume.Spec{Volume: &pod2.Spec.Volumes[0]}
generatedVolumeName1, err := util.GetUniqueVolumeNameFromSpec(
plugin, volumeSpec1)
require.NoError(t, err)
generatedVolumeName2, err := util.GetUniqueVolumeNameFromSpec(
plugin, volumeSpec2)
require.NoError(t, err)
if generatedVolumeName1 != generatedVolumeName2 {
t.Fatalf(
"Unique volume names should be the same. unique volume name 1: <%q> unique volume name 2: <%q>, spec1 %v, spec2 %v",
generatedVolumeName1,
generatedVolumeName2, volumeSpec1, volumeSpec2)
}
err = asw.MarkVolumeAsAttached(generatedVolumeName1, volumeSpec1, "" /* nodeName */, devicePath)
if err != nil {
t.Fatalf("MarkVolumeAsAttached failed. Expected: <no error> Actual: <%v>", err)
}
podName1 := util.GetUniquePodName(pod1)
mounter1, err := plugin.NewMounter(volumeSpec1, pod1, volume.VolumeOptions{})
if err != nil {
t.Fatalf("NewMounter failed. Expected: <no error> Actual: <%v>", err)
}
mapper1, err := plugin.NewBlockVolumeMapper(volumeSpec1, pod1, volume.VolumeOptions{})
if err != nil {
t.Fatalf("NewBlockVolumeMapper failed. Expected: <no error> Actual: <%v>", err)
}
err = asw.AddPodToVolume(
podName1, pod1.UID, generatedVolumeName1, mounter1, mapper1, volumeSpec1.Name(), "" /* volumeGidValue */, volumeSpec1)
if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
}
podName2 := util.GetUniquePodName(pod2)
mounter2, err := plugin.NewMounter(volumeSpec2, pod2, volume.VolumeOptions{})
if err != nil {
t.Fatalf("NewMounter failed. Expected: <no error> Actual: <%v>", err)
}
mapper2, err := plugin.NewBlockVolumeMapper(volumeSpec2, pod2, volume.VolumeOptions{})
if err != nil {
t.Fatalf("NewBlockVolumeMapper failed. Expected: <no error> Actual: <%v>", err)
}
err = asw.AddPodToVolume(
podName2, pod2.UID, generatedVolumeName1, mounter2, mapper2, volumeSpec2.Name(), "" /* volumeGidValue */, volumeSpec2)
if err != nil {
t.Fatalf("AddPodToVolume failed. Expected: <no error> Actual: <%v>", err)
}
verifyVolumeExistsAsw(t, generatedVolumeName1, true /* shouldExist */, asw)
verifyVolumeDoesntExistInUnmountedVolumes(t, generatedVolumeName1, asw)
verifyVolumeDoesntExistInGloballyMountedVolumes(t, generatedVolumeName1, asw)
verifyPodExistsInVolumeAsw(t, podName1, generatedVolumeName1, "fake/device/path" /* expectedDevicePath */, asw)
verifyVolumeExistsWithSpecNameInVolumeAsw(t, podName1, volumeSpec1.Name(), asw)
verifyPodExistsInVolumeAsw(t, podName2, generatedVolumeName2, "fake/device/path" /* expectedDevicePath */, asw)
verifyVolumeExistsWithSpecNameInVolumeAsw(t, podName2, volumeSpec2.Name(), asw)
verifyVolumeSpecNameInVolumeAsw(t, podName1, []*volume.Spec{volumeSpec1}, asw)
verifyVolumeSpecNameInVolumeAsw(t, podName2, []*volume.Spec{volumeSpec2}, asw)
} | explode_data.jsonl/28881 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1519
} | [
2830,
3393,
21346,
11613,
23527,
82,
1249,
18902,
44246,
3404,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
5195,
4661,
11546,
25567,
11,
9006,
1669,
62820,
57824,
287,
2234,
2271,
18902,
11546,
25567,
1155,
340,
60451,
86,
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... | 9 |
func TestDomainDelete(t *testing.T) {
args := testutil.Args
scenarios := []testutil.TestScenario{
{
Args: args("domain delete --service-id 123 --version 1"),
WantError: "error parsing arguments: required flag --name not provided",
},
{
Args: args("domain delete --service-id 123 --version 1 --name www.test.com --autoclone"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
CloneVersionFn: testutil.CloneVersionResult(4),
DeleteDomainFn: deleteDomainError,
},
WantError: errTest.Error(),
},
{
Args: args("domain delete --service-id 123 --version 1 --name www.test.com --autoclone"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
CloneVersionFn: testutil.CloneVersionResult(4),
DeleteDomainFn: deleteDomainOK,
},
WantOutput: "Deleted domain www.test.com (service 123 version 4)",
},
}
for _, testcase := range scenarios {
t.Run(testcase.Name, func(t *testing.T) {
var stdout bytes.Buffer
opts := testutil.NewRunOpts(testcase.Args, &stdout)
opts.APIClient = mock.APIClient(testcase.API)
err := app.Run(opts)
testutil.AssertErrorContains(t, err, testcase.WantError)
testutil.AssertStringContains(t, stdout.String(), testcase.WantOutput)
})
}
} | explode_data.jsonl/17443 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 491
} | [
2830,
3393,
13636,
6435,
1155,
353,
8840,
836,
8,
341,
31215,
1669,
1273,
1314,
51015,
198,
29928,
60494,
1669,
3056,
1944,
1314,
8787,
54031,
515,
197,
197,
515,
298,
197,
4117,
25,
414,
2827,
445,
12204,
3698,
1177,
7936,
12897,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLeaderStartReplication(t *testing.T) {
s := newTestMemoryStorage(withPeers(1, 2, 3))
r := newTestRaft(1, 10, 1, s)
r.becomeCandidate()
r.becomeLeader()
commitNoopEntry(r, s)
li := r.raftLog.lastIndex()
ents := []pb.Entry{{Data: []byte("some data")}}
r.Step(pb.Message{From: 1, To: 1, Type: pb.MsgProp, Entries: ents})
if g := r.raftLog.lastIndex(); g != li+1 {
t.Errorf("lastIndex = %d, want %d", g, li+1)
}
if g := r.raftLog.committed; g != li {
t.Errorf("committed = %d, want %d", g, li)
}
msgs := r.readMessages()
sort.Sort(messageSlice(msgs))
wents := []pb.Entry{{Index: li + 1, Term: 1, Data: []byte("some data")}}
wmsgs := []pb.Message{
{From: 1, To: 2, Term: 1, Type: pb.MsgApp, Index: li, LogTerm: 1, Entries: wents, Commit: li},
{From: 1, To: 3, Term: 1, Type: pb.MsgApp, Index: li, LogTerm: 1, Entries: wents, Commit: li},
}
if !reflect.DeepEqual(msgs, wmsgs) {
t.Errorf("msgs = %+v, want %+v", msgs, wmsgs)
}
if g := r.raftLog.unstableEntries(); !reflect.DeepEqual(g, wents) {
t.Errorf("ents = %+v, want %+v", g, wents)
}
} | explode_data.jsonl/47055 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
52621,
3479,
18327,
1693,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
2271,
10642,
5793,
16980,
10197,
388,
7,
16,
11,
220,
17,
11,
220,
18,
1171,
7000,
1669,
501,
2271,
55535,
723,
7,
16,
11,
220,
16,
15,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestWhereStr(t *testing.T) {
v := &Value{data: []string{string("hello"), string("hello"), string("hello"), string("hello"), string("hello"), string("hello")}}
selected := v.WhereStr(func(i int, val string) bool {
return i%2 == 0
}).MustStrSlice()
assert.Equal(t, 3, len(selected))
} | explode_data.jsonl/23412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
9064,
2580,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
3056,
917,
90,
917,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
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... | 1 |
func TestBitBufferBytes1(t *testing.T) {
bb := NewBitBuffer()
s := byte(0b_0101_1001)
bb.WriteByte(s)
// fmt.Println(bb)
ss, err := bb.ReadByte()
if ss != s || err != nil {
fmt.Printf("From %08b ==> %08b\n", s, ss)
t.Fatal(err, bb)
}
} | explode_data.jsonl/49146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
8344,
4095,
7078,
16,
1155,
353,
8840,
836,
8,
1476,
2233,
65,
1669,
1532,
8344,
4095,
741,
1903,
1669,
4922,
7,
15,
65,
62,
15,
16,
15,
16,
62,
16,
15,
15,
16,
340,
2233,
65,
98026,
1141,
340,
197,
322,
8879,
12419,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGitCommandMergeStatusFiles(t *testing.T) {
type scenario struct {
testName string
oldFiles []*File
newFiles []*File
test func([]*File)
}
scenarios := []scenario{
{
"Old file and new file are the same",
[]*File{},
[]*File{
{
Name: "new_file.txt",
},
},
func(files []*File) {
expected := []*File{
{
Name: "new_file.txt",
},
}
assert.Len(t, files, 1)
assert.EqualValues(t, expected, files)
},
},
{
"Several files to merge, with some identical",
[]*File{
{
Name: "new_file1.txt",
},
{
Name: "new_file2.txt",
},
{
Name: "new_file3.txt",
},
},
[]*File{
{
Name: "new_file4.txt",
},
{
Name: "new_file5.txt",
},
{
Name: "new_file1.txt",
},
},
func(files []*File) {
expected := []*File{
{
Name: "new_file1.txt",
},
{
Name: "new_file4.txt",
},
{
Name: "new_file5.txt",
},
}
assert.Len(t, files, 3)
assert.EqualValues(t, expected, files)
},
},
}
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
gitCmd := newDummyGitCommand()
s.test(gitCmd.MergeStatusFiles(s.oldFiles, s.newFiles))
})
}
} | explode_data.jsonl/38360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 697
} | [
2830,
3393,
46562,
4062,
52096,
2522,
10809,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
18185,
675,
914,
198,
197,
61828,
10809,
29838,
1703,
198,
197,
8638,
10809,
29838,
1703,
198,
197,
18185,
257,
2915,
85288,
1703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOperatorInit(t *testing.T) {
goldenFilepath := filepath.Join(operatorRootDir, "cmd/mesh/testdata/operator/output/operator-init.yaml")
rootArgs := &rootArgs{}
oiArgs := &operatorInitArgs{
common: operatorCommonArgs{
hub: "foo.io/istio",
tag: "1.2.3",
operatorNamespace: "operator-test-namespace",
watchedNamespaces: "istio-test-namespace1,istio-test-namespace2",
manifestsPath: string(snapshotCharts),
},
}
l := clog.NewConsoleLogger(os.Stdout, os.Stderr, installerScope)
_, gotYAML, err := renderOperatorManifest(rootArgs, &oiArgs.common)
if err != nil {
l.LogAndFatal(err)
}
if refreshGoldenFiles() {
t.Logf("Refreshing golden file for %s", goldenFilepath)
if err := os.WriteFile(goldenFilepath, []byte(gotYAML), 0o644); err != nil {
t.Error(err)
}
}
wantYAML, err := readFile(goldenFilepath)
if err != nil {
t.Fatal(err)
}
if diff := util.YAMLDiff(wantYAML, gotYAML); diff != "" {
t.Fatalf("diff: %s", diff)
}
} | explode_data.jsonl/67548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 440
} | [
2830,
3393,
18461,
3803,
1155,
353,
8840,
836,
8,
341,
3174,
813,
268,
1703,
2343,
1669,
26054,
22363,
79091,
8439,
6184,
11,
330,
8710,
3183,
4288,
12697,
691,
68341,
47016,
68341,
54773,
33406,
1138,
33698,
4117,
1669,
609,
2888,
4117,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestMapPinFlags(t *testing.T) {
tmp := testutils.TempBPFFS(t)
spec := &MapSpec{
Name: "map",
Type: Array,
KeySize: 4,
ValueSize: 4,
MaxEntries: 1,
Pinning: PinByName,
}
m, err := NewMapWithOptions(spec, MapOptions{
PinPath: tmp,
})
qt.Assert(t, err, qt.IsNil)
m.Close()
_, err = NewMapWithOptions(spec, MapOptions{
PinPath: tmp,
LoadPinOptions: LoadPinOptions{
Flags: math.MaxUint32,
},
})
if !errors.Is(err, unix.EINVAL) {
t.Fatal("Invalid flags should trigger EINVAL:", err)
}
} | explode_data.jsonl/21659 | {
"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,
2227,
19861,
9195,
1155,
353,
8840,
836,
8,
341,
20082,
1669,
1273,
6031,
65009,
26095,
1748,
50,
1155,
692,
98100,
1669,
609,
2227,
8327,
515,
197,
21297,
25,
981,
330,
2186,
756,
197,
27725,
25,
981,
2910,
345,
197,
5524... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidate_required(t *testing.T) {
assert := assert.New(t)
type User struct {
FirstName string `validate:"required"`
LastName *string `validate:"required"`
}
assert.EqualError(
v.Validate(User{}, valis.EachFields(tagrule.Validate)),
"(required) .LastName is required",
)
assert.NoError(
v.Validate(&User{
LastName: henge.ToStringPtr("Tanaka"),
}, valis.EachFields(tagrule.Validate)),
)
} | explode_data.jsonl/17249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
17926,
18743,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
13158,
2657,
2036,
341,
197,
197,
26584,
914,
220,
1565,
7067,
2974,
6279,
8805,
197,
197,
27920,
220,
353,
917,
1565,
7067,
2974,
6279,
8805,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestViper(t *testing.T) {
viper.SetConfigName("config") // name of config file, Does not include extension
viper.AddConfigPath("/etc/appname/") // path to look for the config file in
viper.AddConfigPath("$HOME/.appname") // call multiple times to add many search paths
viper.AddConfigPath(".") // optionally look for config in the working directory
err := viper.ReadInConfig() // Find and read the config file
assert.NoError(t, err)
assert.Equal(t, "TOML Example", viper.GetString("title"))
assert.Equal(t, "192.168.1.1", viper.GetString("database.server"))
assert.Equal(t, []int{8000, 8001, 8002}, viper.GetIntSlice("database.ports"))
assert.Equal(t, "10.0.0.1", viper.GetString("servers.alpha.ip"))
assert.Equal(t, []interface{}{[]interface{}{"gamma", "delta"}, []interface{}{int64(1), int64(2)}}, viper.Get("clients.data"))
} | explode_data.jsonl/67326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
53,
12858,
1155,
353,
8840,
836,
8,
341,
5195,
12858,
4202,
2648,
675,
445,
1676,
899,
260,
442,
829,
315,
2193,
1034,
11,
12553,
537,
2924,
8894,
198,
5195,
12858,
1904,
2648,
1820,
4283,
12107,
10640,
606,
97112,
220,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoConcurrentCallbacks(t *testing.T) {
const timeout = 2 * time.Second
type Callback struct {
Index int
Func dnode.Function
}
k := newXhrKite("callback", "0.0.1")
k.Config.DisableAuthentication = true
k.HandleFunc("call", func(r *Request) (interface{}, error) {
if r.Args == nil {
return nil, errors.New("empty argument")
}
var arg Callback
if err := r.Args.One().Unmarshal(&arg); err != nil {
return nil, err
}
if !arg.Func.IsValid() {
return nil, errors.New("invalid argument")
}
if err := arg.Func.Call(arg.Index); err != nil {
return nil, err
}
return true, nil
})
go k.Run()
<-k.ServerReadyNotify()
defer k.Close()
url := fmt.Sprintf("http://127.0.0.1:%d/kite", k.Port())
c := k.NewClient(url)
defer c.Close()
// The TestNoConcurrentCallbacks asserts ConcurrentCallbacks
// are disabled by default for each new client.
//
// When callbacks are executed concurrently, the order
// of indices received on the channel is random,
// thus making this test to fail.
//
// c.ConcurrentCallbacks = true
if err := c.DialTimeout(timeout); err != nil {
t.Errorf("DialTimeout(%q)=%s", url, err)
}
indices := make(chan int, 50)
callback := dnode.Callback(func(arg *dnode.Partial) {
var index int
if err := arg.One().Unmarshal(&index); err != nil {
t.Logf("failed to unmarshal: %s", err)
}
time.Sleep(time.Duration(rand.Int31n(100)) * time.Millisecond)
indices <- index
})
for i := 0; i < cap(indices); i++ {
arg := &Callback{
Index: i + 1,
Func: callback,
}
if _, err := c.TellWithTimeout("call", timeout, arg); err != nil {
t.Fatalf("%d: TellWithTimeout()=%s", i, err)
}
}
var n, lastIndex int
for {
if n == cap(indices) {
// All indices were read.
break
}
select {
case <-time.After(timeout):
t.Fatalf("reading indices has timed out after %s (n=%d)", timeout, n)
case index := <-indices:
if index == 0 {
t.Fatalf("invalid index=%d (n=%d)", index, n)
}
if index <= lastIndex {
t.Fatalf("expected to receive indices in ascending order; received %d, last index %d (n=%d)", index, lastIndex, n)
}
lastIndex = index
n++
}
}
} | explode_data.jsonl/68246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 877
} | [
2830,
3393,
2753,
1109,
3231,
44461,
1155,
353,
8840,
836,
8,
341,
4777,
9632,
284,
220,
17,
353,
882,
32435,
271,
13158,
22668,
2036,
341,
197,
197,
1552,
526,
198,
197,
197,
9626,
220,
294,
3509,
30547,
198,
197,
630,
16463,
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 TestReplaceDomainsConfig_Panic(t *testing.T) {
assert := assertlib.New(t)
globalConfig := viper.New()
globalConfig.Set("domains", []int{1, 2})
application := &Application{Config: viper.New()}
assert.Panics(func() {
application.ReplaceDomainsConfig(globalConfig)
})
} | explode_data.jsonl/61950 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
23107,
74713,
2648,
1088,
31270,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
2740,
7121,
1155,
340,
18842,
2648,
1669,
95132,
7121,
741,
18842,
2648,
4202,
445,
59621,
497,
3056,
396,
90,
16,
11,
220,
17,
3518,
197,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadSnapshotChunk(t *testing.T) {
app, teardown := setupBaseAppWithSnapshots(t, 2, 5)
defer teardown()
testcases := map[string]struct {
height uint64
format uint32
chunk uint32
expectEmpty bool
}{
"Existing snapshot": {2, 1, 1, false},
"Missing height": {100, 1, 1, true},
"Missing format": {2, 2, 1, true},
"Missing chunk": {2, 1, 9, true},
"Zero height": {0, 1, 1, true},
"Zero format": {2, 0, 1, true},
"Zero chunk": {2, 1, 0, false},
}
for name, tc := range testcases {
tc := tc
t.Run(name, func(t *testing.T) {
resp := app.LoadSnapshotChunk(abci.RequestLoadSnapshotChunk{
Height: tc.height,
Format: tc.format,
Chunk: tc.chunk,
})
if tc.expectEmpty {
assert.Equal(t, abci.ResponseLoadSnapshotChunk{}, resp)
return
}
assert.NotEmpty(t, resp.Chunk)
})
}
} | explode_data.jsonl/30051 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
5879,
15009,
28304,
1155,
353,
8840,
836,
8,
341,
28236,
11,
49304,
1669,
6505,
3978,
2164,
2354,
61871,
27634,
1155,
11,
220,
17,
11,
220,
20,
340,
16867,
49304,
2822,
18185,
23910,
1669,
2415,
14032,
60,
1235,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSyncNetwork(t *testing.T) {
accounts := make([]model.Account, 0)
if err := model.QueryAll(map[string]interface{}{}, &accounts, ""); err != nil {
t.Log("query account,", err)
return
}
for _, account := range accounts {
err := service.RefreshAccount(&service.SimpleTask{
ProviderName: account.Provider,
AccountKey: account.AccountKey,
})
if err != nil {
t.Log(account.AccountKey, err)
continue
}
}
} | explode_data.jsonl/72647 | {
"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,
12154,
12320,
1155,
353,
8840,
836,
8,
341,
197,
26206,
1669,
1281,
10556,
2528,
30877,
11,
220,
15,
340,
743,
1848,
1669,
1614,
15685,
2403,
9147,
14032,
31344,
6257,
22655,
609,
26206,
11,
93754,
1848,
961,
2092,
341,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRestartRemoved(t *testing.T) {
defer testutil.AfterTest(t)
// 1. start single-member cluster
c := NewCluster(t, 1)
for _, m := range c.Members {
m.ServerConfig.StrictReconfigCheck = true
}
c.Launch(t)
defer c.Terminate(t)
// 2. add a new member
c.AddMember(t)
c.WaitLeader(t)
oldm := c.Members[0]
oldm.keepDataDirTerminate = true
// 3. remove first member, shut down without deleting data
if err := c.removeMember(t, uint64(c.Members[0].s.ID())); err != nil {
t.Fatalf("expected to remove member, got error %v", err)
}
c.WaitLeader(t)
// 4. restart first member with 'initial-cluster-state=new'
// wrong config, expects exit within ReqTimeout
oldm.ServerConfig.NewCluster = false
if err := oldm.Restart(t); err != nil {
t.Fatalf("unexpected ForceRestart error: %v", err)
}
defer func() {
oldm.Close()
os.RemoveAll(oldm.ServerConfig.DataDir)
}()
select {
case <-oldm.s.StopNotify():
case <-time.After(time.Minute):
t.Fatalf("removed member didn't exit within %v", time.Minute)
}
} | explode_data.jsonl/16306 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
59354,
42642,
1155,
353,
8840,
836,
8,
341,
16867,
1273,
1314,
36892,
2271,
1155,
692,
197,
322,
220,
16,
13,
1191,
3175,
43550,
10652,
198,
1444,
1669,
1532,
28678,
1155,
11,
220,
16,
340,
2023,
8358,
296,
1669,
2088,
272... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransport_RoundTrip(t *testing.T) {
if os.Getenv("KAFKA_ADDR") == "" {
t.Skip("set KAFKA_ADDR to run TestTransport_RoundTrip")
return
}
addrs := strings.Split(os.Getenv("KAFKA_ADDR"), ",")
tracer := mocktracer.New()
factory, cleanup := provideWriterFactory(factoryIn{
Tracer: tracer,
In: di.In{},
Conf: config.MapAdapter{"kafka.writer": map[string]WriterConfig{
"default": {
Brokers: addrs,
Topic: "Test",
},
}},
Logger: log.NewNopLogger(),
}, func(name string, writer *kafka.Writer) {})
defer cleanup()
def, _ := factory.Make("default")
span, ctx := opentracing.StartSpanFromContextWithTracer(context.Background(), tracer, "test")
def.WriteMessages(ctx, kafka.Message{Value: []byte(`foo`)})
assert.Len(t, tracer.FinishedSpans(), 1)
span.Finish()
} | explode_data.jsonl/70625 | {
"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,
27560,
2568,
795,
56352,
1155,
353,
8840,
836,
8,
341,
743,
2643,
64883,
445,
42,
8276,
26444,
16058,
899,
621,
1591,
341,
197,
3244,
57776,
445,
746,
730,
8276,
26444,
16058,
311,
1598,
3393,
27560,
2568,
795,
56352,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Web_ServeHTTP(t *testing.T) {
Convey("Serve HTTP requests", t, func() {
result := ""
m := New()
m.Use(func(c *Context) {
result += "foo"
c.Next()
result += "ban"
})
m.Use(func(c *Context) {
result += "bar"
c.Next()
result += "baz"
})
m.Get("/", func() {})
m.Action(func(res http.ResponseWriter, req *http.Request) {
result += "bat"
res.WriteHeader(http.StatusBadRequest)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(result, ShouldEqual, "foobarbatbazban")
So(resp.Code, ShouldEqual, http.StatusBadRequest)
})
} | explode_data.jsonl/44976 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
62,
5981,
1098,
5852,
9230,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
60421,
10130,
7388,
497,
259,
11,
2915,
368,
341,
197,
9559,
1669,
8389,
197,
2109,
1669,
1532,
741,
197,
2109,
9046,
18552,
1337,
353,
1972,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFallback(t *testing.T) {
cfg := v2.TLSConfig{
Status: true,
CertChain: "invalid_certificate",
PrivateKey: "invalid_key",
Fallback: true,
}
filterChains := []v2.FilterChain{
{
TLS: cfg,
},
}
lc := &v2.Listener{}
lc.FilterChains = filterChains
serverMgr, err := NewTLSServerContextManager(lc, nil, log.StartLogger)
if err != nil {
t.Errorf("create context manager failed %v", err)
return
}
if serverMgr.Enabled() {
t.Error("tls maanger is not fallabck")
return
}
clientMgr, err := NewTLSClientContextManager(&cfg, nil)
if err != nil {
t.Errorf("create client context manager failed %v", err)
return
}
if clientMgr.Enabled() {
t.Error("tls maanger is not fallabck")
return
}
} | explode_data.jsonl/1525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 306
} | [
2830,
3393,
87206,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
348,
17,
836,
7268,
2648,
515,
197,
58321,
25,
257,
830,
345,
197,
6258,
529,
18837,
25,
220,
330,
11808,
63047,
756,
197,
197,
75981,
25,
330,
11808,
3097,
756,
197,
127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccCirconusCheckConsul_service(t *testing.T) {
checkName := fmt.Sprintf("Terraform test: consul.service.consul mode=service check - %s", acctest.RandString(5))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDestroyCirconusCheckBundle,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccCirconusCheckConsulConfigV1HealthServiceFmt, checkName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("circonus_check.consul_server", "active", "true"),
resource.TestMatchResourceAttr("circonus_check.consul_server", "check_id", regexp.MustCompile(config.CheckCIDRegex)),
resource.TestCheckResourceAttr("circonus_check.consul_server", "collector.#", "1"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "collector.2084916526.id", "/broker/2110"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.#", "1"),
// resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.ca_chain", ""),
// resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.certificate_file", ""),
// resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.ciphers", ""),
// resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.key_file", ""),
resource.TestCheckNoResourceAttr("circonus_check.consul_server", "consul.0.headers"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.http_addr", "http://consul.service.consul"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.service", "consul"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.service_blacklist.#", "3"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.service_blacklist.0", "bad"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.service_blacklist.1", "hombre"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "consul.0.service_blacklist.2", "service"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "name", checkName),
resource.TestCheckResourceAttr("circonus_check.consul_server", "notes", ""),
resource.TestCheckResourceAttr("circonus_check.consul_server", "period", "60s"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.#", "2"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3333874791.active", "true"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3333874791.name", "KnownLeader"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3333874791.tags.#", "2"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3333874791.tags.1401442048", "lifecycle:unittest"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3333874791.tags.2058715988", "source:consul"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3333874791.type", "text"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.active", "true"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.name", "LastContact"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.tags.#", "2"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.tags.1401442048", "lifecycle:unittest"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.tags.2058715988", "source:consul"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.type", "numeric"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "metric.3148913305.unit", "seconds"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "tags.#", "2"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "tags.1401442048", "lifecycle:unittest"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "tags.2058715988", "source:consul"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "target", "consul.service.consul"),
resource.TestCheckResourceAttr("circonus_check.consul_server", "type", "consul"),
),
},
},
})
} | explode_data.jsonl/28950 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1726
} | [
2830,
3393,
14603,
34,
88276,
355,
3973,
15220,
360,
12267,
1155,
353,
8840,
836,
8,
341,
25157,
675,
1669,
8879,
17305,
445,
51,
13886,
627,
1273,
25,
74189,
5736,
63201,
360,
3856,
28,
7936,
1779,
481,
1018,
82,
497,
1613,
67880,
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... | 1 |
func TestVersion(t *testing.T) {
// skip the test if the VERSION environment variable has not been set
if version.Version == "" {
t.SkipNow()
}
cleanup, _, _, port := InitializeTestLCD(t, 1, []sdk.AccAddress{}, true)
defer cleanup()
// node info
res, body := Request(t, port, "GET", "/version", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
reg, err := regexp.Compile(`\d+\.\d+\.\d+.*`)
require.Nil(t, err)
match := reg.MatchString(body)
require.True(t, match, body, body)
// node info
res, body = Request(t, port, "GET", "/node_version", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
reg, err = regexp.Compile(`\d+\.\d+\.\d+.*`)
require.Nil(t, err)
match = reg.MatchString(body)
require.True(t, match, body)
} | explode_data.jsonl/25397 | {
"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,
5637,
1155,
353,
8840,
836,
8,
341,
197,
322,
10706,
279,
1273,
421,
279,
33792,
4573,
3890,
702,
537,
1012,
738,
198,
743,
2319,
35842,
621,
1591,
341,
197,
3244,
57776,
7039,
741,
197,
630,
1444,
60639,
11,
8358,
8358,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInstanceIDFromProviderID(t *testing.T) {
testCases := []struct {
providerID string
instanceID string
fail bool
}{
{
providerID: "aws://i-0194bbdb81a49b169",
instanceID: "i-0194bbdb81a49b169",
fail: false,
},
{
providerID: "i-0194bbdb81a49b169",
instanceID: "",
fail: true,
},
}
for _, test := range testCases {
instanceID, err := instanceIDFromProviderID(test.providerID)
if (err != nil) != test.fail {
t.Errorf("%s yielded `err != nil` as %t. expected %t", test.providerID, (err != nil), test.fail)
}
if test.fail {
continue
}
if instanceID != test.instanceID {
t.Errorf("%s yielded %s. expected %s", test.providerID, instanceID, test.instanceID)
}
}
} | explode_data.jsonl/12864 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
2523,
915,
3830,
5179,
915,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
19979,
915,
914,
198,
197,
56256,
915,
914,
198,
197,
63052,
981,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_StoreOpen(t *testing.T) {
tmpDir, _ := ioutil.TempDir("", "store_test")
s := New(tmpDir, "127.0.0.1", []string{"127.0.0.1"})
if s == nil {
t.Fatalf("failed to create store")
}
if err := s.Open(); err != nil {
t.Fatalf("failed to open store: %s", err)
}
t.Cleanup(func() {
s.Close()
os.RemoveAll(tmpDir)
})
} | explode_data.jsonl/74886 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
92684,
5002,
1155,
353,
8840,
836,
8,
341,
20082,
6184,
11,
716,
1669,
43144,
65009,
6184,
19814,
330,
4314,
4452,
1138,
1903,
1669,
1532,
10368,
6184,
11,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
497,
3056,
917,
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 TestListSelect(t *testing.T) {
list := New()
list.Add("a", "b", "c")
selectedList := list.Select(func(index int, value interface{}) bool {
return value.(string) >= "a" && value.(string) <= "b"
})
if actualValue, _ := selectedList.Get(0); actualValue != "a" {
t.Errorf("Got %v expected %v", actualValue, "value: a")
}
if actualValue, _ := selectedList.Get(1); actualValue != "b" {
t.Errorf("Got %v expected %v", actualValue, "value: b")
}
if selectedList.Size() != 2 {
t.Errorf("Got %v expected %v", selectedList.Size(), 3)
}
} | explode_data.jsonl/18295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
852,
3379,
1155,
353,
8840,
836,
8,
341,
14440,
1669,
1532,
741,
14440,
1904,
445,
64,
497,
330,
65,
497,
330,
66,
1138,
70631,
852,
1669,
1140,
14752,
18552,
7195,
526,
11,
897,
3749,
28875,
1807,
341,
197,
853,
897,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMqMsgStream_AsProducer(t *testing.T) {
f := &fixture{t: t}
parameters := f.setup()
defer f.teardown()
factory := &ProtoUDFactory{}
for i := range parameters {
func(client mqclient.Client) {
m, err := NewMqMsgStream(context.Background(), 100, 100, client, factory.NewUnmarshalDispatcher())
assert.Nil(t, err)
// empty channel name
m.AsProducer([]string{""})
}(parameters[i].client)
}
} | explode_data.jsonl/55277 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
44,
80,
6611,
3027,
62741,
45008,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
609,
59612,
90,
83,
25,
259,
532,
67543,
1669,
282,
25338,
741,
16867,
282,
31853,
37496,
2822,
1166,
2919,
1669,
609,
31549,
4656,
4153,
16094,
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 TestConnectionError(t *testing.T) {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("dialClosedPort: Listen failed: %v", err)
}
addr := l.Addr().String()
l.Close()
_, err = DownloadHTTP(TransferDetails{Url: url.URL{Host: addr, Scheme: "http"}, Proxy: false}, filepath.Join(t.TempDir(), "test.txt"), "")
assert.IsType(t, &ConnectionSetupError{}, err)
} | explode_data.jsonl/22513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
4526,
1454,
1155,
353,
8840,
836,
8,
341,
8810,
11,
1848,
1669,
4179,
68334,
445,
27161,
497,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
15,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
67,
530,
26884,
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... | 2 |
func TestUsesLibraries(t *testing.T) {
bp := `
java_sdk_library {
name: "foo",
srcs: ["a.java"],
api_packages: ["foo"],
sdk_version: "current",
}
java_sdk_library {
name: "qux",
srcs: ["a.java"],
api_packages: ["qux"],
sdk_version: "current",
}
java_sdk_library {
name: "quuz",
srcs: ["a.java"],
api_packages: ["quuz"],
sdk_version: "current",
}
java_sdk_library {
name: "fred",
srcs: ["a.java"],
api_packages: ["fred"],
sdk_version: "current",
}
java_sdk_library {
name: "bar",
srcs: ["a.java"],
api_packages: ["bar"],
sdk_version: "current",
}
java_sdk_library {
name: "runtime-library",
srcs: ["a.java"],
sdk_version: "current",
}
java_library {
name: "static-runtime-helper",
srcs: ["a.java"],
libs: ["runtime-library"],
sdk_version: "current",
}
// A library that has to use "provides_uses_lib", because:
// - it is not an SDK library
// - its library name is different from its module name
java_library {
name: "non-sdk-lib",
provides_uses_lib: "com.non.sdk.lib",
installable: true,
srcs: ["a.java"],
}
android_app {
name: "app",
srcs: ["a.java"],
libs: [
"qux",
"quuz.stubs"
],
static_libs: [
"static-runtime-helper",
// statically linked component libraries should not pull their SDK libraries,
// so "fred" should not be added to class loader context
"fred.stubs",
],
uses_libs: [
"foo",
"non-sdk-lib"
],
sdk_version: "current",
optional_uses_libs: [
"bar",
"baz",
],
}
android_app_import {
name: "prebuilt",
apk: "prebuilts/apk/app.apk",
certificate: "platform",
uses_libs: [
"foo",
"non-sdk-lib",
"android.test.runner"
],
optional_uses_libs: [
"bar",
"baz",
],
}
`
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.MissingUsesLibraries = []string{"baz"}
}),
).RunTestWithBp(t, bp)
app := result.ModuleForTests("app", "android_common")
prebuilt := result.ModuleForTests("prebuilt", "android_common")
// Test that implicit dependencies on java_sdk_library instances are passed to the manifest.
// This should not include explicit `uses_libs`/`optional_uses_libs` entries.
actualManifestFixerArgs := app.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
expectManifestFixerArgs := `--extract-native-libs=true ` +
`--uses-library qux ` +
`--uses-library quuz ` +
`--uses-library foo ` + // TODO(b/132357300): "foo" should not be passed to manifest_fixer
`--uses-library com.non.sdk.lib ` + // TODO(b/132357300): "com.non.sdk.lib" should not be passed to manifest_fixer
`--uses-library bar ` + // TODO(b/132357300): "bar" should not be passed to manifest_fixer
`--uses-library runtime-library`
android.AssertStringEquals(t, "manifest_fixer args", expectManifestFixerArgs, actualManifestFixerArgs)
// Test that all libraries are verified (library order matters).
verifyCmd := app.Rule("verify_uses_libraries").RuleParams.Command
verifyArgs := `--uses-library foo ` +
`--uses-library com.non.sdk.lib ` +
`--uses-library qux ` +
`--uses-library quuz ` +
`--uses-library runtime-library ` +
`--optional-uses-library bar ` +
`--optional-uses-library baz `
android.AssertStringDoesContain(t, "verify cmd args", verifyCmd, verifyArgs)
// Test that all libraries are verified for an APK (library order matters).
verifyApkCmd := prebuilt.Rule("verify_uses_libraries").RuleParams.Command
verifyApkArgs := `--uses-library foo ` +
`--uses-library com.non.sdk.lib ` +
`--uses-library android.test.runner ` +
`--optional-uses-library bar ` +
`--optional-uses-library baz `
android.AssertStringDoesContain(t, "verify apk cmd args", verifyApkCmd, verifyApkArgs)
// Test that all present libraries are preopted, including implicit SDK dependencies, possibly stubs
cmd := app.Rule("dexpreopt").RuleParams.Command
w := `--target-context-for-sdk any ` +
`PCL[/system/framework/qux.jar]#` +
`PCL[/system/framework/quuz.jar]#` +
`PCL[/system/framework/foo.jar]#` +
`PCL[/system/framework/non-sdk-lib.jar]#` +
`PCL[/system/framework/bar.jar]#` +
`PCL[/system/framework/runtime-library.jar]`
android.AssertStringDoesContain(t, "dexpreopt app cmd args", cmd, w)
// Test conditional context for target SDK version 28.
android.AssertStringDoesContain(t, "dexpreopt app cmd 28", cmd,
`--target-context-for-sdk 28`+
` PCL[/system/framework/org.apache.http.legacy.jar] `)
// Test conditional context for target SDK version 29.
android.AssertStringDoesContain(t, "dexpreopt app cmd 29", cmd,
`--target-context-for-sdk 29`+
` PCL[/system/framework/android.hidl.manager-V1.0-java.jar]`+
`#PCL[/system/framework/android.hidl.base-V1.0-java.jar] `)
// Test conditional context for target SDK version 30.
// "android.test.mock" is absent because "android.test.runner" is not used.
android.AssertStringDoesContain(t, "dexpreopt app cmd 30", cmd,
`--target-context-for-sdk 30`+
` PCL[/system/framework/android.test.base.jar] `)
cmd = prebuilt.Rule("dexpreopt").RuleParams.Command
android.AssertStringDoesContain(t, "dexpreopt prebuilt cmd", cmd,
`--target-context-for-sdk any`+
` PCL[/system/framework/foo.jar]`+
`#PCL[/system/framework/non-sdk-lib.jar]`+
`#PCL[/system/framework/android.test.runner.jar]`+
`#PCL[/system/framework/bar.jar] `)
// Test conditional context for target SDK version 30.
// "android.test.mock" is present because "android.test.runner" is used.
android.AssertStringDoesContain(t, "dexpreopt prebuilt cmd 30", cmd,
`--target-context-for-sdk 30`+
` PCL[/system/framework/android.test.base.jar]`+
`#PCL[/system/framework/android.test.mock.jar] `)
} | explode_data.jsonl/58502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2414
} | [
2830,
3393,
68965,
9194,
14876,
1155,
353,
8840,
836,
8,
341,
2233,
79,
1669,
22074,
197,
56171,
61783,
39461,
341,
298,
11609,
25,
330,
7975,
756,
298,
41144,
82,
25,
4383,
64,
10848,
8097,
298,
54299,
41874,
25,
4383,
7975,
8097,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDestroySnapshot(t *testing.T) {
c, err := NewContainer(ContainerName)
if err != nil {
t.Errorf(err.Error())
}
snapshot := Snapshot{Name: SnapshotName}
if err := c.DestroySnapshot(snapshot); err != nil {
t.Errorf(err.Error())
}
} | explode_data.jsonl/2812 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
14245,
15009,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
4502,
75145,
675,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
3964,
6141,
2398,
197,
630,
1903,
9601,
1669,
68697,
63121,
25,
68697,
675,
532,
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
] | 3 |
func TestPolicyManagementEvents(t *testing.T) {
tests := []struct {
want WebhookPolicyManagement
closer bool
}{
{WebhookPolicyManagement{policyOwner{ID: "dummy1", Name: "foobar1"}}, false},
{WebhookPolicyManagement{policyOwner{ID: "dummy2", Name: "foobar2"}}, true},
}
for _, test := range tests {
events, close := PolicyManagementEvents()
if test.closer {
defer close()
}
sendPolicyManagementEvent(test.want)
got := <-events
if !reflect.DeepEqual(got, test.want) {
t.Error("Did not get expected event")
t.Error("got", got)
t.Error("want", test.want)
}
}
} | explode_data.jsonl/47925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
13825,
22237,
7900,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
50780,
256,
4895,
20873,
13825,
22237,
198,
197,
1444,
69215,
1807,
198,
197,
59403,
197,
197,
90,
5981,
20873,
13825,
22237,
90,
34790,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestHello(t *testing.T) {
want := "Hello"
if got := Hello(want); got != want {
t.Errorf("Hello()=%s, want=%s", got, want)
}
} | explode_data.jsonl/51160 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 59
} | [
2830,
3393,
9707,
1155,
353,
8840,
836,
8,
341,
50780,
1669,
330,
9707,
698,
743,
2684,
1669,
21927,
3622,
517,
1215,
2684,
961,
1366,
341,
197,
3244,
13080,
445,
9707,
368,
7846,
82,
11,
1366,
7846,
82,
497,
2684,
11,
1366,
340,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestFinalization(t *testing.T) {
stopCh, apiExtensionClient, clientPool, err := testserver.StartDefaultServer()
require.NoError(t, err)
defer close(stopCh)
noxuDefinition := testserver.NewNoxuCustomResourceDefinition(apiextensionsv1beta1.ClusterScoped)
noxuVersionClient, err := testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, clientPool)
require.NoError(t, err)
ns := "not-the-default"
name := "foo123"
noxuResourceClient := NewNamespacedCustomResourceClient(ns, noxuVersionClient, noxuDefinition)
instance := testserver.NewNoxuInstance(ns, name)
instance.SetFinalizers([]string{"noxu.example.com/finalizer"})
createdNoxuInstance, err := instantiateCustomResource(t, instance, noxuResourceClient, noxuDefinition)
require.NoError(t, err)
uid := createdNoxuInstance.GetUID()
err = noxuResourceClient.Delete(name, &metav1.DeleteOptions{
Preconditions: &metav1.Preconditions{
UID: &uid,
},
})
require.NoError(t, err)
// Deleting something with a finalizer sets deletion timestamp to a not-nil value but does not
// remove the object from the API server. Here we read it to confirm this.
gottenNoxuInstance, err := noxuResourceClient.Get(name)
require.NoError(t, err)
require.NotNil(t, gottenNoxuInstance.GetDeletionTimestamp())
// Trying to delete it again to confirm it will not remove the object because finalizer is still there.
err = noxuResourceClient.Delete(name, &metav1.DeleteOptions{
Preconditions: &metav1.Preconditions{
UID: &uid,
},
})
require.NoError(t, err)
// Removing the finalizers to allow the following delete remove the object.
// This step will fail if previous delete wrongly removed the object.
for {
gottenNoxuInstance.SetFinalizers(nil)
_, err = noxuResourceClient.Update(gottenNoxuInstance)
if err == nil {
break
}
if !errors.IsConflict(err) {
require.NoError(t, err) // Fail on unexpected error
}
gottenNoxuInstance, err = noxuResourceClient.Get(name)
require.NoError(t, err)
}
// Now when finalizer is not there it should be possible to actually remove the object from the server.
err = noxuResourceClient.Delete(name, &metav1.DeleteOptions{
Preconditions: &metav1.Preconditions{
UID: &uid,
},
})
require.NoError(t, err)
// Check that the object is actually gone.
_, err = noxuResourceClient.Get(name)
require.Error(t, err)
require.True(t, errors.IsNotFound(err), "%#v", err)
} | explode_data.jsonl/31051 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 823
} | [
2830,
3393,
19357,
2022,
1155,
353,
8840,
836,
8,
341,
62644,
1143,
11,
6330,
12049,
2959,
11,
2943,
10551,
11,
1848,
1669,
1273,
4030,
12101,
3675,
5475,
741,
17957,
35699,
1155,
11,
1848,
340,
16867,
3265,
60170,
1143,
692,
197,
41403... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWithStatementTaintingNoBundle(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
(() => {
let local = 1
let outer = 2
let outerDead = 3
with ({}) {
var hoisted = 4
let local = 5
hoisted++
local++
if (1) outer++
if (0) outerDead++
}
if (1) {
hoisted++
local++
outer++
outerDead++
}
})()
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
MinifyIdentifiers: true,
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38519 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
2354,
8636,
51,
70859,
2753,
8409,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
197,
5065,
58... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccAWSDBInstance_namePrefix(t *testing.T) {
var v rds.DBInstance
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDBInstanceConfig_namePrefix,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists("aws_db_instance.test", &v),
testAccCheckAWSDBInstanceAttributes(&v),
resource.TestMatchResourceAttr(
"aws_db_instance.test", "identifier", regexp.MustCompile("^tf-test-")),
),
},
},
})
} | explode_data.jsonl/33916 | {
"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,
14603,
36136,
3506,
2523,
1269,
14335,
1155,
353,
8840,
836,
8,
341,
2405,
348,
435,
5356,
22537,
2523,
271,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,
2915,
368,
314,
1273,
14603,
4703,
3973,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindByShortcode(t *testing.T) {
t.Run("return emoji by shortcode, if exists", func(t *testing.T) {
allEmoji := emoji.NewAllEmoji()
emojivotoService := EmojiServiceServer{
allEmoji: allEmoji,
}
emojiSearchedFor := allEmoji.List()[3]
response, err := emojivotoService.FindByShortcode(context.Background(), &pb.FindByShortcodeRequest{
Shortcode: emojiSearchedFor.Shortcode,
})
if err != nil {
t.Fatal(err)
}
if response.Emoji == nil {
t.Fatal("Didnt return an emoji")
}
if response.Emoji.Shortcode != emojiSearchedFor.Shortcode || response.Emoji.Unicode != emojiSearchedFor.Unicode {
t.Fatalf("Response didnt contain [%v]", response.Emoji)
}
})
t.Run("return nil if no emoji with such shortcode", func(t *testing.T) {
allEmoji := emoji.NewAllEmoji()
emojivotoService := EmojiServiceServer{
allEmoji: allEmoji,
}
response, err := emojivotoService.FindByShortcode(context.Background(), &pb.FindByShortcodeRequest{
Shortcode: "doesnt-really-exist",
})
if err != nil {
t.Fatal(err)
}
if response.Emoji != nil {
t.Fatalf("Expected to return nil for emoji, returned [%s]", response.Emoji)
}
})
} | explode_data.jsonl/26093 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 480
} | [
2830,
3393,
47131,
12472,
1851,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
689,
42365,
553,
75813,
11,
421,
6724,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
50960,
92731,
1669,
42365,
7121,
2403,
92731,
741,
197,
197,
6726,
73... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintMarkdownExplainTable(t *testing.T) {
expInfo, err := connTest.Explain("select 1", TraditionalExplainType, TraditionalFormatExplain)
if err != nil {
t.Error(err)
}
err = common.GoldenDiff(func() {
PrintMarkdownExplainTable(expInfo)
}, t.Name(), update)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/55048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
8994,
68005,
840,
20772,
2556,
1155,
353,
8840,
836,
8,
341,
48558,
1731,
11,
1848,
1669,
4534,
2271,
5121,
20772,
445,
1742,
220,
16,
497,
45460,
840,
20772,
929,
11,
45460,
4061,
840,
20772,
340,
743,
1848,
961,
2092,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRepeated(t *testing.T) {
salt := []byte("12345")
h, err := DefaultFactory.GetHasherWithSalt(SHA256, salt)
if err != nil {
t.Fatal("Unable to retrieve SHA256 Hasher")
}
h12345 := "dd712114fb283417de4da3512e17486adbda004060d0d1646508c8a2740d29b4"
h1 := fmt.Sprintf("%x", h.Hash(int64(1)).H)
h2 := fmt.Sprintf("%x", h.Hash(int64(1)).H)
if h1 != h2 || h1 != h12345 || h2 != h12345 {
t.Fatal("Mismatch in repeated hashing of the same value")
}
} | explode_data.jsonl/42614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
90989,
1155,
353,
8840,
836,
8,
1476,
1903,
3145,
1669,
3056,
3782,
445,
16,
17,
18,
19,
20,
5130,
9598,
11,
1848,
1669,
7899,
4153,
2234,
6370,
261,
2354,
47318,
3759,
17020,
17,
20,
21,
11,
12021,
340,
743,
1848,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEtcdCreatePodFailsWithoutNamespace(t *testing.T) {
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreatePod(api.NewContext(), &api.Pod{
TypeMeta: api.TypeMeta{
ID: "foo",
},
DesiredState: api.PodState{
Manifest: api.ContainerManifest{
Containers: []api.Container{
{
Name: "foo",
},
},
},
},
})
if err == nil || !strings.Contains(err.Error(), "namespace") {
t.Fatalf("expected error that namespace was missing from context")
}
} | explode_data.jsonl/8141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
31860,
4385,
4021,
23527,
37,
6209,
26040,
22699,
1155,
353,
8840,
836,
8,
341,
1166,
726,
2959,
1669,
7375,
7121,
52317,
31860,
4385,
2959,
1155,
340,
1166,
726,
2959,
8787,
1552,
284,
830,
198,
197,
29172,
1669,
1532,
2271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestThrottleRecursiveBlkioStats(t *testing.T) {
helper := NewCgroupTestUtil("blkio", t)
defer helper.cleanup()
helper.writeFileContents(map[string]string{
"blkio.io_service_bytes_recursive": "",
"blkio.io_serviced_recursive": "",
"blkio.io_queued_recursive": "",
"blkio.sectors_recursive": "",
"blkio.io_service_time_recursive": "",
"blkio.io_wait_time_recursive": "",
"blkio.io_merged_recursive": "",
"blkio.time_recursive": "",
"blkio.throttle.io_service_bytes_recursive": throttleServiceBytesRecursive,
"blkio.throttle.io_serviced_recursive": throttleServicedRecursive,
})
blkio := &BlkioGroup{}
actualStats := *cgroups.NewStats()
err := blkio.GetStats(helper.CgroupPath, &actualStats)
if err != nil {
t.Fatal(err)
}
// Verify expected stats.
expectedStats := cgroups.BlkioStats{}
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 8, 0, 110305281, "Read")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 8, 0, 231, "Write")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 8, 0, 421, "Sync")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 8, 0, 110305281, "Async")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 8, 0, 110305281, "Total")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 252, 0, 110305281, "Read")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 252, 0, 231, "Write")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 252, 0, 421, "Sync")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 252, 0, 110305281, "Async")
appendBlkioStatEntry(&expectedStats.IoServiceBytesRecursive, 252, 0, 110305281, "Total")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 8, 0, 1641, "Read")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 8, 0, 231, "Write")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 8, 0, 421, "Sync")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 8, 0, 1641, "Async")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 8, 0, 1641, "Total")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 252, 0, 1641, "Read")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 252, 0, 231, "Write")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 252, 0, 421, "Sync")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 252, 0, 1641, "Async")
appendBlkioStatEntry(&expectedStats.IoServicedRecursive, 252, 0, 1641, "Total")
expectBlkioStatsEquals(t, expectedStats, actualStats.BlkioStats)
} | explode_data.jsonl/45844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1071
} | [
2830,
3393,
1001,
27535,
78542,
4923,
74,
815,
16635,
1155,
353,
8840,
836,
8,
341,
9598,
2947,
1669,
1532,
34,
4074,
2271,
2742,
445,
34989,
815,
497,
259,
340,
16867,
13137,
87689,
741,
9598,
2947,
70007,
14803,
9147,
14032,
30953,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStrArray_Sum(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []string{"0", "1", "2", "3", "4", "5", "6"}
a2 := []string{"0", "a", "3", "4", "5", "6"}
array1 := garray.NewStrArrayFrom(a1)
array2 := garray.NewStrArrayFrom(a2)
t.Assert(array1.Sum(), 21)
t.Assert(array2.Sum(), 18)
})
} | explode_data.jsonl/53105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
2580,
1857,
1098,
372,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
917,
4913,
15,
497,
330,
16,
497,
330,
17,
497,
330,
18,
497,
330,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
testKubelet := newTestKubelet(t)
fakeRuntime := testKubelet.fakeRuntime
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
kubelet := testKubelet.kubelet
now := unversioned.Now()
startTime := unversioned.NewTime(now.Time.Add(-1 * time.Minute))
exceededActiveDeadlineSeconds := int64(300)
pods := []*api.Pod{
{
ObjectMeta: api.ObjectMeta{
UID: "12345678",
Name: "bar",
Namespace: "new",
},
Spec: api.PodSpec{
Containers: []api.Container{
{Name: "foo"},
},
ActiveDeadlineSeconds: &exceededActiveDeadlineSeconds,
},
Status: api.PodStatus{
StartTime: &startTime,
},
},
}
fakeRuntime.PodList = []*kubecontainer.Pod{
{
ID: "12345678",
Name: "bar",
Namespace: "new",
Containers: []*kubecontainer.Container{
{Name: "foo"},
},
},
}
kubelet.podManager.SetPods(pods)
kubelet.HandlePodUpdates(pods)
status, found := kubelet.statusManager.GetPodStatus(pods[0].UID)
if !found {
t.Errorf("expected to found status for pod %q", pods[0].UID)
}
if status.Phase == api.PodFailed {
t.Fatalf("expected pod status to not be %q", status.Phase)
}
} | explode_data.jsonl/43350 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 557
} | [
2830,
3393,
12154,
23527,
82,
21468,
2623,
1649,
23527,
82,
4792,
6986,
2623,
6727,
31246,
6583,
1249,
9408,
1155,
353,
8840,
836,
8,
341,
18185,
42,
3760,
1149,
1669,
501,
2271,
42,
3760,
1149,
1155,
340,
1166,
726,
15123,
1669,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestIdPGPNotEldest(t *testing.T) {
tc := SetupEngineTest(t, "id")
defer tc.Cleanup()
// create new user, then add pgp key
u := CreateAndSignupFakeUser(tc, "login")
uis := libkb.UIs{LogUI: tc.G.UI.GetLogUI(), SecretUI: u.NewSecretUI()}
_, _, key := armorKey(t, tc, u.Email)
eng, err := NewPGPKeyImportEngineFromBytes(tc.G, []byte(key), true)
if err != nil {
t.Fatal(err)
}
m := NewMetaContextForTest(tc).WithUIs(uis)
if err := RunEngine2(m, eng); err != nil {
t.Fatal(err)
}
Logout(tc)
idUI, _, err := runIdentify(&tc, u.Username)
if err != nil {
t.Fatal(err)
}
checkDisplayKeys(t, idUI, 1, 1)
} | explode_data.jsonl/52987 | {
"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,
764,
11383,
47,
2623,
6582,
4979,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
18626,
4571,
2271,
1155,
11,
330,
307,
1138,
16867,
17130,
727,
60639,
2822,
197,
322,
1855,
501,
1196,
11,
1221,
912,
17495,
79,
1376,
198,
1067... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClose(t *testing.T) {
defer func() {
r := recover()
assert.NotNil(t, r)
}()
bc := newTestChain(t)
_, err := bc.genBlocks(10)
require.NoError(t, err)
bc.Close()
// It's a hack, but we use internal knowledge of MemoryStore
// implementation which makes it completely unusable (up to panicing)
// after Close().
_ = bc.dao.Store.Put([]byte{0}, []byte{1})
// This should never be executed.
assert.Nil(t, t)
} | explode_data.jsonl/74544 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
7925,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
368,
341,
197,
7000,
1669,
11731,
741,
197,
6948,
93882,
1155,
11,
435,
340,
197,
69826,
2233,
66,
1669,
501,
2271,
18837,
1155,
340,
197,
6878,
1848,
1669,
17916,
22822,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_unnestSpecFiles(t *testing.T) {
tests := []struct {
name string
files SpecFiles
want SpecFiles
}{
{
name: "basic",
files: SpecFiles{
{
Name: "a",
Path: "a",
Children: SpecFiles{
{
Name: "b",
Path: "a/b",
},
{
Name: "c",
Path: "a/c",
Children: SpecFiles{
{
Name: "d",
Path: "a/c/d",
},
{
Name: "e",
Path: "a/c/e",
},
},
},
},
},
{
Name: "b",
Path: "b",
Children: SpecFiles{
{
Name: "c",
Path: "b/c",
Children: SpecFiles{
{
Name: "d",
Path: "b/c/d",
},
},
},
},
},
},
want: SpecFiles{
{
Name: "b",
Path: "a/b",
},
{
Name: "d",
Path: "a/c/d",
},
{
Name: "e",
Path: "a/c/e",
},
{
Name: "d",
Path: "b/c/d",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
unnestedFiles := tt.files.unnest()
assert.ElementsMatch(t, unnestedFiles, tt.want)
})
}
} | explode_data.jsonl/3241 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 761
} | [
2830,
3393,
4907,
21414,
8327,
10809,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
74075,
10956,
10809,
198,
197,
50780,
220,
10956,
10809,
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... | 1 |
func TestJsonSortByName(t *testing.T) {
assert := assert.New(t)
settings := testutil.Settings().WithSections().With(&print.Settings{
SortByName: true,
}).Build()
expected, err := testutil.GetExpected("json", "json-SortByName")
assert.Nil(err)
options, err := module.NewOptions().With(&module.Options{
SortBy: &module.SortBy{
Name: true,
},
})
assert.Nil(err)
module, err := testutil.GetModule(options)
assert.Nil(err)
printer := NewJSON(settings)
actual, err := printer.Print(module, settings)
assert.Nil(err)
assert.Equal(expected, actual)
} | explode_data.jsonl/40844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
5014,
10231,
16898,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
62930,
1669,
1273,
1314,
27000,
1005,
2354,
38122,
1005,
2354,
2099,
1350,
27000,
515,
197,
7568,
371,
16898,
25,
830,
345,
197,
16630,
110... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBSTree_InsertNode(t *testing.T) {
bstree := NewBSTree(6, &intComparator{})
bstree.InsertNode(7)
bstree.InsertNode(5)
bstree.InsertNode(2)
bstree.InsertNode(4)
bstree.Print()
} | explode_data.jsonl/41659 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
61006,
765,
76417,
1955,
1155,
353,
8840,
836,
8,
341,
2233,
267,
765,
1669,
1532,
61006,
765,
7,
21,
11,
609,
396,
38658,
6257,
692,
2233,
267,
765,
23142,
1955,
7,
22,
340,
2233,
267,
765,
23142,
1955,
7,
20,
340,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWithPathParametersWithInvalidPath(t *testing.T) {
p := "path%2*end"
m := map[string]interface{}{
"path1": p,
}
if _, err := Prepare(&http.Request{}, WithBaseURL("https://microsoft.com/"), WithPathParameters("/{path1}/", m)); err == nil {
t.Fatalf("autorest: WithPath should fail for invalid URL escape for path '%v' ", p)
}
} | explode_data.jsonl/20943 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
89534,
9706,
2354,
7928,
1820,
1155,
353,
8840,
836,
8,
972,
3223,
1669,
330,
2343,
4,
17,
9,
408,
5031,
2109,
1669,
2415,
14032,
31344,
6257,
1666,
197,
197,
70688,
16,
788,
281,
1871,
197,
1771,
743,
8358,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNamespaceFlushState(t *testing.T) {
ctrl := xtest.NewController(t)
defer ctrl.Finish()
ns, closer := newTestNamespace(t)
defer closer()
var (
blockStart = xtime.Now().Truncate(2 * time.Hour)
expectedFlushState = fileOpState{
ColdVersionRetrievable: 2,
}
shard0 = NewMockdatabaseShard(ctrl)
)
shard0.EXPECT().FlushState(blockStart).Return(expectedFlushState, nil)
ns.shards[0] = shard0
flushState, err := ns.FlushState(0, blockStart)
require.NoError(t, err)
require.Equal(t, expectedFlushState, flushState)
} | explode_data.jsonl/35383 | {
"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,
22699,
46874,
1397,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
856,
1944,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
84041,
11,
12128,
1669,
501,
2271,
22699,
1155,
340,
16867,
12128,
2822,
2405,
2399,
197,
47996,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTracesExporter(t *testing.T) {
cleanup, err := obsreporttest.SetupRecordedMetricsTest()
require.NoError(t, err)
defer cleanup()
factory := NewFactory()
recorder, cfg := newRecorder(t)
params := componenttest.NewNopExporterCreateSettings()
te, err := factory.CreateTracesExporter(context.Background(), params, cfg)
assert.NoError(t, err)
assert.NotNil(t, te, "failed to create trace exporter")
traces := pdata.NewTraces()
resourceSpans := traces.ResourceSpans()
span := resourceSpans.AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty()
span.SetName("foobar")
err = te.ConsumeTraces(context.Background(), traces)
assert.NoError(t, err)
obsreporttest.CheckExporterTraces(t, cfg.ID(), 1, 0)
payloads := recorder.Payloads()
require.Len(t, payloads.Transactions, 1)
assert.Equal(t, "foobar", payloads.Transactions[0].Name)
assert.NoError(t, te.Shutdown(context.Background()))
} | explode_data.jsonl/37016 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
1282,
2434,
88025,
1155,
353,
8840,
836,
8,
341,
1444,
60639,
11,
1848,
1669,
7448,
11736,
1944,
39820,
6471,
291,
27328,
2271,
741,
17957,
35699,
1155,
11,
1848,
340,
16867,
21290,
2822,
1166,
2919,
1669,
1532,
4153,
741,
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 TestSerialize_TimestampUnits(t *testing.T) {
tests := []struct {
name string
timestampUnits time.Duration
expected string
}{
{
name: "default of 1s",
timestampUnits: 0,
expected: `{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":1525478795}`,
},
{
name: "1ns",
timestampUnits: 1 * time.Nanosecond,
expected: `{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":1525478795123456789}`,
},
{
name: "1ms",
timestampUnits: 1 * time.Millisecond,
expected: `{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":1525478795123}`,
},
{
name: "10ms",
timestampUnits: 10 * time.Millisecond,
expected: `{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":152547879512}`,
},
{
name: "15ms is reduced to 10ms",
timestampUnits: 15 * time.Millisecond,
expected: `{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":152547879512}`,
},
{
name: "65ms is reduced to 10ms",
timestampUnits: 65 * time.Millisecond,
expected: `{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":152547879512}`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := MustMetric(
metric.New(
"cpu",
map[string]string{},
map[string]interface{}{
"value": 42.0,
},
time.Unix(1525478795, 123456789),
),
)
s, _ := NewSerializer(tt.timestampUnits)
actual, err := s.Serialize(m)
require.NoError(t, err)
require.Equal(t, tt.expected+"\n", string(actual))
})
}
} | explode_data.jsonl/47349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 791
} | [
2830,
3393,
15680,
1139,
4702,
26314,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
3244,
4702,
26314,
882,
33795,
198,
197,
42400,
981,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
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 TestSendAll(t *testing.T) {
t.Parallel()
testCases := []struct {
scenario string
mockStream grpcMock.ClientStreamMocker
input interface{}
expectedError string
}{
{
scenario: "input is nil",
mockStream: grpcMock.NoMockClientStream,
expectedError: `not a slice: <nil>`,
},
{
scenario: "input is not a slice",
mockStream: grpcMock.NoMockClientStream,
input: &grpctest.Item{},
expectedError: `not a slice: *grpctest.Item`,
},
{
scenario: "send error",
mockStream: grpcMock.MockClientStream(func(s *grpcMock.ClientStream) {
s.On("SendMsg", mock.Anything).
Return(errors.New("send error"))
}),
input: test.DefaultItems(),
expectedError: `send error`,
},
{
scenario: "success with a slice of struct",
mockStream: grpcMock.MockClientStream(func(s *grpcMock.ClientStream) {
for _, i := range test.DefaultItems() {
s.On("SendMsg", i).Once().
Return(nil)
}
}),
input: test.DefaultItems(),
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.scenario, func(t *testing.T) {
t.Parallel()
err := stream.SendAll(tc.mockStream(t), tc.input)
if tc.expectedError == "" {
assert.NoError(t, err)
} else {
assert.EqualError(t, err, tc.expectedError)
}
})
}
} | explode_data.jsonl/72037 | {
"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,
11505,
2403,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
37302,
1669,
3056,
1235,
341,
197,
29928,
20413,
414,
914,
198,
197,
77333,
3027,
262,
47900,
11571,
11716,
3027,
11571,
261,
198,
197,
22427,
260,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBroadcastTxSync(t *testing.T) {
require := require.New(t)
mempool := node.MempoolReactor().Mempool
initMempoolSize := mempool.Size()
for i, c := range GetClients() {
_, _, tx := MakeTxKV()
bres, err := c.BroadcastTxSync(tx)
require.Nil(err, "%d: %+v", i, err)
require.Equal(bres.Code, abci.CodeTypeOK) // FIXME
require.Equal(initMempoolSize+1, mempool.Size())
txs := mempool.Reap(1)
require.EqualValues(tx, txs[0])
mempool.Flush()
}
} | explode_data.jsonl/48948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
43362,
31584,
12154,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
2109,
3262,
1749,
1669,
2436,
1321,
3262,
1749,
693,
5621,
1005,
44,
3262,
1749,
198,
28248,
44,
3262,
1749,
1695,
1669,
1833,
10285,
246... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNew(t *testing.T) {
path := pathToPhpFpm
process := phpfpm.NewProcess(path)
if want, have := path, process.Exec; want != have {
t.Errorf("expected %#v, got %#v", want, have)
}
} | explode_data.jsonl/49279 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
1815,
1249,
50144,
37,
5187,
198,
53314,
1669,
1319,
15897,
5187,
7121,
7423,
5581,
340,
743,
1366,
11,
614,
1669,
1815,
11,
1882,
30798,
26,
1366,
961,
614,
341,
197,
3244,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImageRef_RemoveICCProfile(t *testing.T) {
Startup(nil)
image, err := NewImageFromFile(resources + "jpg-24bit-icc-adobe-rgb.jpg")
require.NoError(t, err)
defer image.Close()
require.True(t, image.HasIPTC())
err = image.RemoveICCProfile()
require.NoError(t, err)
assert.False(t, image.HasICCProfile())
assert.True(t, image.HasIPTC())
} | explode_data.jsonl/38835 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
1906,
3945,
66843,
87202,
8526,
1155,
353,
8840,
836,
8,
341,
197,
39076,
27907,
692,
31426,
11,
1848,
1669,
1532,
1906,
43633,
52607,
488,
330,
17974,
12,
17,
19,
4489,
12,
47638,
25747,
15422,
12,
16509,
4819,
1138,
17957,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIndexerOnUpdate(t *testing.T) {
myRowID := EncodeSequence(1)
var multiKeyIndex MultiKeyIndex
ctx := NewMockContext()
storeKey := sdk.NewKVStoreKey("test")
store := prefix.NewStore(ctx.KVStore(storeKey), []byte{multiKeyIndex.prefix})
specs := map[string]struct {
srcFunc IndexerFunc
expAddedKeys []RowID
expDeletedKeys []RowID
expErr error
addFunc func(sdk.KVStore, interface{}, RowID) error
}{
"single key - same key, no update": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return []interface{}{uint64(1)}, nil
},
},
"single key - different key, replaced": {
srcFunc: func(value interface{}) ([]interface{}, error) {
keys := []uint64{1, 2}
return []interface{}{keys[value.(int)]}, nil
},
expAddedKeys: []RowID{
append(EncodeSequence(2), myRowID...),
},
expDeletedKeys: []RowID{
append(EncodeSequence(1), myRowID...),
},
},
"multi key - same key, no update": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return []interface{}{uint64(1), uint64(2)}, nil
},
},
"multi key - replaced": {
srcFunc: func(value interface{}) ([]interface{}, error) {
keys := []uint64{1, 2, 3, 4}
return []interface{}{keys[value.(int)], keys[value.(int)+2]}, nil
},
expAddedKeys: []RowID{
append(EncodeSequence(2), myRowID...),
append(EncodeSequence(4), myRowID...),
},
expDeletedKeys: []RowID{
append(EncodeSequence(1), myRowID...),
append(EncodeSequence(3), myRowID...),
},
},
"empty key": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return []interface{}{}, nil
},
},
"nil key": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return nil, nil
},
},
"empty key in slice": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return []interface{}{[]byte{}}, nil
},
},
"nil key in slice": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return []interface{}{nil}, nil
},
expErr: fmt.Errorf("type %T not allowed as key part", nil),
},
"error case with new value": {
srcFunc: func(value interface{}) ([]interface{}, error) {
return nil, stdErrors.New("test")
},
expErr: stdErrors.New("test"),
},
"error case with old value": {
srcFunc: func(value interface{}) ([]interface{}, error) {
var err error
if value.(int)%2 == 1 {
err = stdErrors.New("test")
}
return []interface{}{uint64(1)}, err
},
expErr: stdErrors.New("test"),
},
"error case on persisting new keys": {
srcFunc: func(value interface{}) ([]interface{}, error) {
keys := []uint64{1, 2}
return []interface{}{keys[value.(int)]}, nil
},
addFunc: func(_ sdk.KVStore, _ interface{}, _ RowID) error {
return stdErrors.New("test")
},
expErr: stdErrors.New("test"),
},
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
idx, err := NewIndexer(spec.srcFunc)
require.NoError(t, err)
if spec.expErr == nil {
err = idx.OnCreate(store, myRowID, 0)
require.NoError(t, err)
}
if spec.addFunc != nil {
idx.addFunc = spec.addFunc
}
err = idx.OnUpdate(store, myRowID, 1, 0)
if spec.expErr != nil {
require.Equal(t, spec.expErr, err)
return
}
require.NoError(t, err)
for _, key := range spec.expAddedKeys {
require.Equal(t, true, store.Has(key))
}
for _, key := range spec.expDeletedKeys {
require.Equal(t, false, store.Has(key))
}
})
}
} | explode_data.jsonl/42810 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1550
} | [
2830,
3393,
1552,
261,
1925,
4289,
1155,
353,
8840,
836,
8,
341,
13624,
3102,
915,
1669,
56562,
14076,
7,
16,
692,
2405,
7299,
1592,
1552,
17439,
1592,
1552,
198,
20985,
1669,
1532,
11571,
1972,
741,
57279,
1592,
1669,
45402,
7121,
8270... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParse(t *testing.T) {
ap := NewParser()
if ap == nil {
t.Fatalf("expected a parser.IngressAnnotation but returned nil")
}
testCases := []struct {
annotations map[string]string
expected Config
}{
{map[string]string{aliasAnn: "www.example.com"}, Config{Host: "www.example.com"}},
{map[string]string{aliasAnn: "*.example.com www.example.*"}, Config{Host: "*.example.com www.example.*"}},
{map[string]string{aliasAnn: `~^www\d+\.example\.com$`}, Config{Host: `~^www\d+\.example\.com$`}},
{map[string]string{aliasAnn: ""}, Config{}},
{map[string]string{}, Config{}},
{nil, Config{}},
}
ing := &extensions.Ingress{
ObjectMeta: meta_v1.ObjectMeta{
Name: "foo",
Namespace: api.NamespaceDefault,
},
Spec: extensions.IngressSpec{},
}
for _, testCase := range testCases {
ing.SetAnnotations(testCase.annotations)
result, _ := ap.Parse(ing)
if !result.(*Config).Equal(&testCase.expected) {
t.Errorf("expected %v but returned %v, annotations: %s", testCase.expected, result, testCase.annotations)
}
}
} | explode_data.jsonl/18066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
14463,
1155,
353,
8840,
836,
8,
341,
69898,
1669,
1532,
6570,
741,
743,
1443,
621,
2092,
341,
197,
3244,
30762,
445,
7325,
264,
6729,
5337,
2483,
19711,
714,
5927,
2092,
1138,
197,
630,
18185,
37302,
1669,
3056,
1235,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestName(t *testing.T) {
tests := []string{
"",
".",
"google..com",
"google.com",
"google..com.",
"google.com.",
".google.com.",
"www..google.com.",
"www.google.com.",
}
for _, test := range tests {
n, err := NewName(test)
if err != nil {
t.Errorf("Creating name for %q: %v", test, err)
continue
}
if ns := n.String(); ns != test {
t.Errorf("Got %#v.String() = %q, want = %q", n, ns, test)
continue
}
}
} | explode_data.jsonl/60549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
675,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
917,
515,
197,
197,
39680,
197,
197,
3263,
756,
197,
197,
1,
17485,
496,
874,
756,
197,
197,
1,
17485,
905,
756,
197,
197,
1,
17485,
496,
874,
10346,
197,
197,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSortedSetRemRangeByRank(t *testing.T) {
testRaw(t, func(c *client) {
c.Do("ZADD", "z",
"12", "zero kelvin",
"12", "minusfour",
"12", "one",
"12", "oneone",
"12", "two",
"12", "zwei",
"12", "three",
"12", "drei",
"12", "inf",
)
c.Do("ZREMRANGEBYRANK", "z", "-2", "-1")
c.Do("ZRANGE", "z", "0", "-1")
c.Do("ZRANGEBYSCORE", "z", "-inf", "inf")
c.Do("ZREMRANGEBYRANK", "z", "-2", "-1")
c.Do("ZRANGE", "z", "0", "-1")
c.Do("ZREMRANGEBYRANK", "z", "0", "-1")
c.Do("EXISTS", "z")
c.Do("ZREMRANGEBYRANK", "nosuch", "-2", "-1")
// failure cases
c.Error("wrong number", "ZREMRANGEBYRANK")
c.Error("wrong number", "ZREMRANGEBYRANK", "key")
c.Error("wrong number", "ZREMRANGEBYRANK", "key", "0")
c.Error("not an integer", "ZREMRANGEBYRANK", "key", "noint", "-1")
c.Error("not an integer", "ZREMRANGEBYRANK", "key", "0", "noint")
c.Error("wrong number", "ZREMRANGEBYRANK", "key", "0", "1", "too many")
c.Do("SET", "str", "I am a string")
c.Error("wrong kind", "ZREMRANGEBYRANK", "str", "0", "-1")
})
} | explode_data.jsonl/23345 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 535
} | [
2830,
3393,
51051,
1649,
6590,
6046,
1359,
22550,
1155,
353,
8840,
836,
8,
341,
18185,
20015,
1155,
11,
2915,
1337,
353,
2972,
8,
341,
197,
1444,
33596,
445,
57,
15665,
497,
330,
89,
756,
298,
197,
1,
16,
17,
497,
330,
14154,
48228,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_encode_empty_byte_array(t *testing.T) {
should := require.New(t)
bytes, err := json.Marshal([]byte{})
should.Nil(err)
should.Equal(`""`, string(bytes))
bytes, err = jsoner.DefaultAPI().Marshal([]byte{})
should.Nil(err)
should.Equal(`""`, string(bytes))
} | explode_data.jsonl/57883 | {
"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,
11224,
15124,
19737,
3858,
1155,
353,
8840,
836,
8,
341,
197,
5445,
1669,
1373,
7121,
1155,
340,
70326,
11,
1848,
1669,
2951,
37271,
10556,
3782,
37790,
197,
5445,
59678,
3964,
340,
197,
5445,
12808,
5809,
3014,
7808,
914,
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 TestConfigDefaults(t *testing.T) {
assert := assert.New(t)
c, err := NewConfig([]string{})
assert.Nil(err)
assert.Equal("warn", c.LogLevel)
assert.Equal("text", c.LogFormat)
assert.Equal("", c.AuthHost)
assert.Len(c.CookieDomains, 0)
assert.False(c.InsecureCookie)
assert.Equal("_forward_auth", c.CookieName)
assert.Equal("_forward_auth_csrf", c.CSRFCookieName)
assert.Equal("auth", c.DefaultAction)
assert.Equal("google", c.DefaultProvider)
assert.Len(c.Domains, 0)
assert.Equal(time.Second*time.Duration(43200), c.Lifetime)
assert.Equal("/_oauth", c.Path)
assert.Len(c.Whitelist, 0)
} | explode_data.jsonl/33751 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
2648,
16273,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
1444,
11,
1848,
1669,
1532,
2648,
10556,
917,
37790,
6948,
59678,
3964,
692,
6948,
12808,
445,
33481,
497,
272,
5247,
4449,
340,
6948,
12808,
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 TestEventIndexedWithArrayUnpack(t *testing.T) {
definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8[2]"},{"indexed": false, "name":"value2", "type":"string"}]}]`
type testStruct struct {
Value1 [2]uint8
Value2 string
}
abi, err := JSON(strings.NewReader(definition))
require.NoError(t, err)
var b bytes.Buffer
stringOut := "abc"
// number of fields that will be encoded * 32
b.Write(packNum(reflect.ValueOf(32)))
b.Write(packNum(reflect.ValueOf(len(stringOut))))
b.Write(common.RightPadBytes([]byte(stringOut), 32))
var rst testStruct
require.NoError(t, abi.Unpack(&rst, "test", b.Bytes()))
require.Equal(t, [2]uint8{0, 0}, rst.Value1)
require.Equal(t, stringOut, rst.Value2)
} | explode_data.jsonl/43928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
1556,
69941,
2354,
1857,
1806,
4748,
1155,
353,
8840,
836,
8,
341,
7452,
4054,
1669,
77644,
4913,
606,
788,
330,
1944,
497,
330,
1313,
788,
330,
3087,
497,
330,
24941,
788,
61753,
97473,
788,
830,
11,
330,
606,
3252,
957,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsGte(t *testing.T) {
validate := New()
i := true
PanicMatches(t, func() { _ = validate.Var(i, "gte") }, "Bad field type bool")
t1 := time.Now().UTC()
t1 = t1.Add(time.Hour * 24)
errs := validate.Var(t1, "gte")
Equal(t, errs, nil)
t2 := time.Now().UTC().Add(-time.Hour)
errs = validate.Var(t2, "gte")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gte")
type Test struct {
Now *time.Time `validate:"gte"`
}
s := &Test{
Now: &t1,
}
errs = validate.Struct(s)
Equal(t, errs, nil)
s = &Test{
Now: &t2,
}
errs = validate.Struct(s)
NotEqual(t, errs, nil)
AssertError(t, errs, "Test.Now", "Test.Now", "Now", "Now", "gte")
} | explode_data.jsonl/77311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 323
} | [
2830,
3393,
3872,
38,
665,
1155,
353,
8840,
836,
8,
341,
197,
7067,
1669,
1532,
741,
8230,
1669,
830,
198,
10025,
31270,
42470,
1155,
11,
2915,
368,
314,
716,
284,
9593,
87968,
1956,
11,
330,
55067,
899,
2470,
330,
17082,
2070,
943,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCorruptedClusterID(t *testing.T) {
defer leaktest.AfterTest(t)()
e := engine.NewInMem(roachpb.Attributes{}, 1<<20)
defer e.Close()
cfg := bootstrapNodeConfig()
if _, err := bootstrapCluster(
context.TODO(), cfg, []engine.Engine{e}, cfg.Settings.Version.BootstrapVersion(), kv.MakeTxnMetrics(metric.TestSampleInterval),
); err != nil {
t.Fatal(err)
}
// Set the cluster ID to the empty UUID.
sIdent := roachpb.StoreIdent{
ClusterID: uuid.UUID{},
NodeID: 1,
StoreID: 1,
}
if err := engine.MVCCPutProto(context.Background(), e, nil, keys.StoreIdentKey(), hlc.Timestamp{}, nil, &sIdent); err != nil {
t.Fatal(err)
}
engines := []engine.Engine{e}
_, serverAddr, cfg, node, stopper := createTestNode(util.TestAddr, engines, nil, t)
stopper.Stop(context.TODO())
bootstrappedEngines, newEngines, cv, err := inspectEngines(
context.TODO(), engines, cfg.Settings.Version.MinSupportedVersion,
cfg.Settings.Version.ServerVersion, node.clusterID)
if err != nil {
t.Fatal(err)
}
if err := node.start(
context.Background(), serverAddr, bootstrappedEngines, newEngines,
roachpb.Attributes{}, roachpb.Locality{}, cv,
); !testutils.IsError(err, "unidentified store") {
t.Errorf("unexpected error %v", err)
}
} | explode_data.jsonl/52655 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 493
} | [
2830,
3393,
10580,
85954,
28678,
915,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
7727,
1669,
4712,
7121,
641,
18816,
7,
64500,
16650,
31384,
22655,
220,
16,
2442,
17,
15,
340,
16867,
384,
10421,
2822,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestService_Delete(t *testing.T) {
testCases := []struct {
repoErr error
}{
{
sgerrors.ErrNotFound,
},
{
nil,
},
}
for _, testCase := range testCases {
m := new(testutils.MockStorage)
m.On("Delete", context.Background(), mock.Anything, mock.Anything).
Return(testCase.repoErr)
service := NewService("", m, nil)
err := service.Delete(context.Background(), "key")
if err != testCase.repoErr {
t.Errorf("expected error %v actual %v", testCase.repoErr, err)
}
}
} | explode_data.jsonl/2001 | {
"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,
1860,
57418,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
17200,
5368,
7747,
1465,
198,
197,
59403,
197,
197,
515,
298,
1903,
70,
7650,
27862,
10372,
345,
197,
197,
1583,
197,
197,
515,
298,
8413... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSNSAccessPolicy(t *testing.T) {
const arn = "arn:aws:sns:eu-west-1:111122223333:stage-package-Message"
t.Run("should return an error if the arn is invalid", func(t *testing.T) {
_, err := aws.SNSAccessPolicy("invalid")
assert.ErrorExists(t, err, true)
})
t.Run("should generate valid json", func(t *testing.T) {
p, err := aws.SNSAccessPolicy(arn)
assert.ErrorExists(t, err, false)
err = json.Unmarshal([]byte(p), &map[string]interface{}{})
assert.ErrorExists(t, err, false)
})
t.Run("should return the policy", func(t *testing.T) {
p, err := aws.SNSAccessPolicy(arn)
assert.ErrorExists(t, err, false)
if act, exp := gjson.Get(p, "Statement.0.Resource").Str, arn; act != exp {
t.Errorf("got %s, expected %s", act, exp)
}
if act, exp := gjson.Get(p, "Statement.0.Condition.StringEquals.AWS:SourceOwner").Str, "111122223333"; act != exp {
t.Errorf("got %s, expected %s", act, exp)
}
})
} | explode_data.jsonl/19317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
50,
2448,
6054,
13825,
1155,
353,
8840,
836,
8,
341,
4777,
796,
77,
284,
330,
1885,
25,
8635,
14495,
4412,
25,
20128,
37602,
12,
16,
25,
16,
16,
16,
16,
17,
17,
17,
17,
18,
18,
18,
18,
25,
20743,
44135,
12,
2052,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseNameValOldFormat(t *testing.T) {
directive := Directive{}
node, err := parseNameVal("foo bar", "LABEL", &directive)
assert.Check(t, err)
expected := &Node{
Value: "foo",
Next: &Node{Value: "bar"},
}
assert.DeepEqual(t, expected, node, cmpNodeOpt)
} | explode_data.jsonl/12093 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
14463,
675,
2208,
18284,
4061,
1155,
353,
8840,
836,
8,
341,
2698,
1226,
533,
1669,
56752,
16094,
20831,
11,
1848,
1669,
4715,
675,
2208,
445,
7975,
3619,
497,
330,
63290,
497,
609,
72863,
340,
6948,
10600,
1155,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestArrayScanBackend(t *testing.T) {
db := openTestConn(t)
defer db.Close()
for _, tt := range []struct {
s string
d sql.Scanner
e interface{}
}{
{`ARRAY[true, false]`, new(BoolArray), &BoolArray{true, false}},
{`ARRAY[E'\\xdead', E'\\xbeef']`, new(ByteaArray), &ByteaArray{{'\xDE', '\xAD'}, {'\xBE', '\xEF'}}},
{`ARRAY[1.2, 3.4]`, new(Float64Array), &Float64Array{1.2, 3.4}},
{`ARRAY[1, 2, 3]`, new(Int64Array), &Int64Array{1, 2, 3}},
{`ARRAY['a', E'\\b', 'c"', 'd,e']`, new(StringArray), &StringArray{`a`, `\b`, `c"`, `d,e`}},
} {
err := db.QueryRow(`SELECT ` + tt.s).Scan(tt.d)
if err != nil {
t.Errorf("Expected no error when scanning %s into %T, got %v", tt.s, tt.d, err)
}
if !reflect.DeepEqual(tt.d, tt.e) {
t.Errorf("Expected %v when scanning %s into %T, got %v", tt.e, tt.s, tt.d, tt.d)
}
}
} | explode_data.jsonl/5351 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 428
} | [
2830,
3393,
1857,
26570,
29699,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
1787,
2271,
9701,
1155,
340,
16867,
2927,
10421,
2822,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
1903,
914,
198,
197,
2698,
5704,
32098,
198,
197,
772... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTags(t *testing.T) {
suite := NewSuite(t, WithFeaturesPath("features/tags.feature"), WithTags("@tag"))
suite.AddStep(`fail the test`, fail)
suite.AddStep(`the test should pass`, pass)
suite.Run()
} | explode_data.jsonl/69372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
15930,
1155,
353,
8840,
836,
8,
341,
96572,
1669,
1532,
28000,
1155,
11,
3085,
21336,
1820,
445,
20304,
84460,
29591,
3975,
3085,
15930,
10662,
4578,
5455,
96572,
1904,
8304,
5809,
18403,
279,
1273,
7808,
3690,
340,
96572,
190... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetDownloadURLWithInternalErrorInGetAssetShouldReturnProperResponse(t *testing.T) {
rec := httptest.NewRecorder()
req, err := http.NewRequest(constants.RequestMethodGet,
fmt.Sprintf("%s?id=%s&timeout=111013", constants.AssetsURL, constants.MockID), nil)
require.NoError(t, err)
db := &test.MockDb{Err: errors.New("")}
upd := &test.MockUploader{}
env := &config.Env{AssetUploader: upd, Store: db}
GetDownloadURL(env).ServeHTTP(rec, req)
assert.Equal(t, http.StatusInternalServerError, rec.Code)
buf, err := ioutil.ReadAll(rec.Body)
require.NoError(t, err)
contentType := rec.Header().Get(constants.HeaderContentType)
assert.Equal(t, constants.ApplicationJSON, contentType)
respMsg := ""
require.NoError(t, json.Unmarshal(buf, &respMsg))
assert.Equal(t, constants.InternalServerErrorMessage, respMsg)
} | explode_data.jsonl/34294 | {
"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,
1949,
11377,
3144,
2354,
11569,
1454,
641,
1949,
16604,
14996,
5598,
1336,
712,
2582,
1155,
353,
8840,
836,
8,
341,
67904,
1669,
54320,
70334,
7121,
47023,
741,
24395,
11,
1848,
1669,
1758,
75274,
80368,
68940,
1949,
345,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRegressionDot1QPriority(t *testing.T) {
d := &Dot1Q{
Priority: 2,
}
out := gopacket.NewSerializeBuffer()
gopacket.SerializeLayers(out, gopacket.SerializeOptions{}, d)
if err := d.DecodeFromBytes(out.Bytes(), gopacket.NilDecodeFeedback); err != nil {
t.Errorf("could not decode encoded dot1q")
} else if d.Priority != 2 {
t.Errorf("priority mismatch, want 2 got %d", d.Priority)
}
} | explode_data.jsonl/42265 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
45200,
34207,
16,
48,
20555,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
609,
34207,
16,
48,
515,
197,
10025,
8773,
25,
220,
17,
345,
197,
532,
13967,
1669,
342,
453,
5709,
7121,
15680,
4095,
741,
3174,
453,
5709,
32859,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMessageParser_ParseMessage(t *testing.T) {
msg := newTestDataMessage("Test")
msgParser := NewParser()
msgParser.Setup()
msgParser.Parse(msg.Bytes(), nil)
msgParser.Events.MessageParsed.Attach(events.NewClosure(func(msgParsedEvent *MessageParsedEvent) {
log.Infof("parsed message")
}))
} | explode_data.jsonl/67124 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
2052,
6570,
77337,
2052,
1155,
353,
8840,
836,
8,
341,
21169,
1669,
501,
83920,
2052,
445,
2271,
5130,
21169,
6570,
1669,
1532,
6570,
741,
21169,
6570,
39820,
741,
21169,
6570,
8937,
8119,
36868,
1507,
2092,
692,
21169,
6570,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRobotDevicesToJSON(t *testing.T) {
r := newTestRobot("Robot99")
json := NewJSONRobot(r)
gobottest.Assert(t, len(json.Devices), r.Devices().Len())
gobottest.Assert(t, json.Devices[0].Name, "Device1")
gobottest.Assert(t, json.Devices[0].Driver, "*gobot.testDriver")
gobottest.Assert(t, json.Devices[0].Connection, "Connection1")
gobottest.Assert(t, len(json.Devices[0].Commands), 1)
} | explode_data.jsonl/24443 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
43374,
40835,
1249,
5370,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
501,
2271,
43374,
445,
43374,
24,
24,
1138,
30847,
1669,
1532,
5370,
43374,
2601,
340,
3174,
674,
1716,
477,
11711,
1155,
11,
2422,
9304,
77611,
1216,
701,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPushToRemoteFailureBranchNotExisting(t *testing.T) {
testRepo := newTestRepo(t)
defer testRepo.cleanup(t)
err := testRepo.sut.PushToRemote(git.DefaultRemote, "some-branch")
require.NotNil(t, err)
} | explode_data.jsonl/14033 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
16644,
1249,
24703,
17507,
18197,
2623,
53067,
1155,
353,
8840,
836,
8,
341,
18185,
25243,
1669,
501,
2271,
25243,
1155,
340,
16867,
1273,
25243,
87689,
1155,
692,
9859,
1669,
1273,
25243,
514,
332,
34981,
1249,
24703,
3268,
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 |
func TestAsString(t *testing.T) {
cases := []struct {
in starlark.Value
got, err string
}{
{starlark.String("foo"), "foo", ""},
{starlark.String("\"foo'"), "\"foo'", ""},
{starlark.Bool(true), "", "invalid syntax"},
}
for i, c := range cases {
got, err := AsString(c.in)
if !(err == nil && c.err == "" || err != nil && err.Error() == c.err) {
t.Errorf("case %d error mismatch. expected: '%s', got: '%s'", i, c.err, err)
continue
}
if c.got != got {
t.Errorf("case %d. expected: '%s', got: '%s'", i, c.got, got)
}
}
} | explode_data.jsonl/20981 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
26582,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
17430,
981,
6774,
75,
838,
6167,
198,
197,
3174,
354,
11,
1848,
914,
198,
197,
59403,
197,
197,
90,
11870,
75,
838,
6431,
445,
7975,
3975,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSandboxHasNoIO(t *testing.T) {
ctx := context.Background()
sandbox, err := newService(&observation.TestContext).CreateSandbox(ctx, CreateOptions{})
if err != nil {
t.Fatalf("unexpected error creating sandbox: %s", err)
}
defer sandbox.Close()
t.Run("default", func(t *testing.T) {
script := `
io.open('service_test.go', 'rb')
`
if _, err := sandbox.RunScript(ctx, RunOptions{}, script); err == nil {
t.Fatalf("expected error running script")
} else if !strings.Contains(err.Error(), "attempt to index a non-table object(nil) with key 'open'") {
t.Fatalf("unexpected error running script: %s", err)
}
})
t.Run("module", func(t *testing.T) {
script := `
local io = require("io")
io.open('service_test.go', 'rb')
`
if _, err := sandbox.RunScript(ctx, RunOptions{}, script); err == nil {
t.Fatalf("expected error running script")
} else if !strings.Contains(err.Error(), "module io not found") {
t.Fatalf("unexpected error running script: %s", err)
}
})
} | explode_data.jsonl/21497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
50,
31536,
10281,
2753,
3810,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
2822,
1903,
31536,
11,
1848,
1669,
501,
1860,
2099,
77960,
8787,
1972,
568,
4021,
50,
31536,
7502,
11,
4230,
3798,
37790,
743,
1848,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHashSetNX(t *testing.T) {
s, err := Run()
ok(t, err)
defer s.Close()
c, err := proto.Dial(s.Addr())
ok(t, err)
defer c.Close()
// New Hash
must1(t, c, "HSETNX", "wim", "zus", "jet")
must0(t, c, "HSETNX", "wim", "zus", "jet")
// Just a new key
must1(t, c, "HSETNX", "wim", "aap", "noot")
// Wrong key type
s.Set("foo", "bar")
mustDo(t, c,
"HSETNX", "foo", "nosuch", "nosuch",
proto.Error("WRONGTYPE Operation against a key holding the wrong kind of value"),
)
} | explode_data.jsonl/11368 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
44601,
43304,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
6452,
741,
59268,
1155,
11,
1848,
340,
16867,
274,
10421,
741,
1444,
11,
1848,
1669,
18433,
98462,
1141,
93626,
2398,
59268,
1155,
11,
1848,
340,
16867,
272,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTLSConnection(t *testing.T) {
// Start up a TLS Server
server, port := setupServer(t, httptest.NewTLSServer)
defer server.Close()
// Parse its URL
serverURL, err := url.Parse(server.URL)
require.NoError(t, err)
// Determine the IP address the server's hostname resolves to
ips, err := net.LookupHost(serverURL.Hostname())
require.NoError(t, err)
require.Len(t, ips, 1)
ip := ips[0]
// Parse the cert so we can test against it
cert, err := x509.ParseCertificate(server.TLS.Certificates[0].Certificate[0])
require.NoError(t, err)
// Save the server's cert to a file so heartbeat can use it
certFile := hbtest.CertToTempFile(t, cert)
require.NoError(t, certFile.Close())
defer os.Remove(certFile.Name())
event := testTLSTCPCheck(t, ip, port, certFile.Name())
testslike.Test(
t,
lookslike.Strict(lookslike.Compose(
hbtest.TLSChecks(0, 0, cert),
hbtest.RespondingTCPChecks(),
hbtest.BaseChecks(ip, "up", "tcp"),
hbtest.SummaryChecks(1, 0),
hbtest.SimpleURLChecks(t, "ssl", serverURL.Hostname(), port),
)),
event.Fields,
)
} | explode_data.jsonl/54636 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 431
} | [
2830,
3393,
45439,
4526,
1155,
353,
8840,
836,
8,
341,
197,
322,
5145,
705,
264,
41654,
8422,
198,
41057,
11,
2635,
1669,
6505,
5475,
1155,
11,
54320,
70334,
7121,
13470,
1220,
2836,
340,
16867,
3538,
10421,
2822,
197,
322,
14775,
1181,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteQueuedJob(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
job := addTestJob(t, r, "queue1")
result, err := r.DeleteJobs([]*api.Job{job})
if err != nil {
t.Fatalf("deleting jobs failed with error %s", err)
}
err, deletionOccurred := result[job]
assert.Nil(t, err)
assert.True(t, deletionOccurred)
})
} | explode_data.jsonl/32047 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
6435,
25776,
3260,
12245,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
68577,
1669,
912,
2271,
12245,
1155,
11,
435,
11,
330,
4584,
16,
5130,
197,
9559,
11,
1848,
1669,
435,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCacheError(t *testing.T) {
cache := newErrTestStatter(errors.New("cache error"))
backend := newTestStatter()
st := NewCachedBlobStatter(cache, backend)
ctx := context.Background()
dgst := digest.Digest("dontvalidate")
_, err := st.Stat(ctx, dgst)
if err != distribution.ErrBlobUnknown {
t.Fatalf("Unexpected error %v, expected %v", err, distribution.ErrBlobUnknown)
}
desc := distribution.Descriptor{
Digest: dgst,
}
if err := backend.SetDescriptor(ctx, dgst, desc); err != nil {
t.Fatal(err)
}
actual, err := st.Stat(ctx, dgst)
if err != nil {
t.Fatal(err)
}
if actual.Digest != desc.Digest {
t.Fatalf("Unexpected descriptor %v, expected %v", actual, desc)
}
if len(cache.sets) > 0 {
t.Fatalf("Set should not be called after stat error")
}
} | explode_data.jsonl/33139 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 308
} | [
2830,
3393,
8233,
1454,
1155,
353,
8840,
836,
8,
341,
52680,
1669,
501,
7747,
2271,
623,
1650,
38881,
7121,
445,
9360,
1465,
5455,
197,
20942,
1669,
501,
2271,
623,
1650,
741,
18388,
1669,
1532,
70293,
37985,
623,
1650,
31933,
11,
19163... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.