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 TestSecretContentReferenceProviderError(t *testing.T) {
buf := bytes.NewBufferString("")
log.SetOutput(buf)
f := newFixture(t)
secretName, secretKey, secretValue := "web-metric-secret", "apikey", "12345"
arg := "success-rate"
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Namespace: metav1.NamespaceDefault,
},
Data: map[string][]byte{
secretKey: []byte(secretValue),
},
}
defer f.Close()
c, _, _ := f.newController(noResyncPeriodFunc)
f.kubeclient.CoreV1().Secrets(metav1.NamespaceDefault).Create(context.TODO(), secret, metav1.CreateOptions{})
run := &v1alpha1.AnalysisRun{
ObjectMeta: metav1.ObjectMeta{
Namespace: metav1.NamespaceDefault,
},
Spec: v1alpha1.AnalysisRunSpec{
Args: []v1alpha1.Argument{
{
Name: "secret",
ValueFrom: &v1alpha1.ValueFrom{
SecretKeyRef: &v1alpha1.SecretKeyRef{
Name: secretName,
Key: secretKey,
},
},
},
{
Name: "metric-name",
Value: &arg,
},
},
Metrics: []v1alpha1.Metric{{
Name: "rate",
SuccessCondition: "result > {{args.metric-name}}",
Provider: v1alpha1.MetricProvider{
Web: &v1alpha1.WebMetric{
Headers: []v1alpha1.WebMetricHeader{{
Key: "apikey",
Value: "{{args.secret}}",
}},
},
},
}},
},
}
error := fmt.Errorf("Error with Header Value: %v", secretValue)
expectedValue := "Error with Header Value: *****"
measurement := newMeasurement(v1alpha1.AnalysisPhaseError)
measurement.Message = error.Error()
f.provider.On("Run", mock.Anything, mock.Anything, mock.Anything).Return(measurement)
newRun := c.reconcileAnalysisRun(run)
logMessage := buf.String()
assert.Equal(t, expectedValue, newRun.Status.MetricResults[0].Measurements[0].Message)
assert.False(t, strings.Contains(logMessage, "12345"))
assert.True(t, strings.Contains(logMessage, "*****"))
} | explode_data.jsonl/75836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 834
} | [
2830,
3393,
19773,
2762,
8856,
5179,
1454,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
5820,
7121,
4095,
703,
31764,
6725,
4202,
5097,
10731,
340,
1166,
1669,
501,
18930,
1155,
340,
197,
20474,
675,
11,
6234,
1592,
11,
6234,
1130,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNilMonitoringPort(t *testing.T) {
opts := DefaultOptions()
opts.HTTPPort = 0
opts.HTTPSPort = 0
s := RunServer(opts)
defer s.Shutdown()
if s.MonitorAddr() != nil {
t.Fatal("HttpAddr should be nil.")
}
} | explode_data.jsonl/3611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
19064,
98062,
7084,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
7899,
3798,
741,
64734,
27358,
7084,
284,
220,
15,
198,
64734,
27358,
4592,
371,
284,
220,
15,
198,
1903,
1669,
6452,
5475,
30885,
692,
16867,
274,
10849,
18452,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQueryLogger_fields(t *testing.T) {
opts := EngineOpts{
Logger: nil,
Reg: nil,
MaxSamples: 10,
Timeout: 10 * time.Second,
}
engine := NewEngine(opts)
f1 := NewFakeQueryLogger()
engine.SetQueryLogger(f1)
ctx, cancelCtx := context.WithCancel(context.Background())
ctx = NewOriginContext(ctx, map[string]interface{}{"foo": "bar"})
defer cancelCtx()
query := engine.newTestQuery(func(ctx context.Context) error {
return contextDone(ctx, "test statement execution")
})
res := query.Exec(ctx)
require.NoError(t, res.Err)
expected := []string{"foo", "bar"}
for i, field := range expected {
v := f1.logs[len(f1.logs)-len(expected)+i].(string)
require.Equal(t, field, v)
}
} | explode_data.jsonl/35562 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
2859,
7395,
12132,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
8200,
43451,
515,
197,
55861,
25,
257,
2092,
345,
197,
197,
3477,
25,
286,
2092,
345,
197,
197,
5974,
39571,
25,
220,
16,
15,
345,
197,
197,
7636,
25,
262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestString_ToBytes(t *testing.T) {
tests := []struct {
name string
e String
want Bytes
}{
{name: "", e: String{"abc"}, want: Bytes{[]byte("abc")}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.e.ToBytes(); !got.Equal(tt.want) {
t.Errorf("String.ToBytes() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/34791 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
703,
38346,
7078,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
923,
198,
197,
50780,
30024,
198,
197,
59403,
197,
197,
47006,
25,
7342,
384,
25,
923,
4913,
13683,
14345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOKExFuture_PlaceFutureOrder2(t *testing.T) {
t.Log(okex.OKExFuture.PlaceFutureOrder2(0, &goex.FutureOrder{
Currency: goex.EOS_USD,
ContractName: goex.QUARTER_CONTRACT,
OType: goex.OPEN_BUY,
OrderType: goex.ORDER_FEATURE_ORDINARY,
Price: 5.9,
Amount: 10,
LeverRate: 10}))
} | explode_data.jsonl/3929 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
3925,
840,
24206,
1088,
26536,
24206,
4431,
17,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
60207,
327,
15480,
840,
24206,
86675,
24206,
4431,
17,
7,
15,
11,
609,
3346,
327,
76356,
4431,
515,
197,
6258,
5088,
25,
257,
728,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListenChangeEvent(t *testing.T) {
t.SkipNow()
cache := storage.CreateNamespaceConfig("abc")
buildNotifyResult(t)
group := sync.WaitGroup{}
group.Add(1)
listener := &CustomChangeListener{
t: t,
group: &group,
}
cache.AddChangeListener(listener)
group.Wait()
//运行完清空变更队列
cache.RemoveChangeListener(listener)
} | explode_data.jsonl/45538 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
38714,
76498,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
7039,
741,
52680,
1669,
5819,
7251,
22699,
2648,
445,
13683,
1138,
69371,
28962,
2077,
1155,
340,
44260,
1669,
12811,
28384,
2808,
16094,
44260,
1904,
7,
16,
692,
14440,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCatalog_ListServices_Blocking(t *testing.T) {
t.Parallel()
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
defer s1.Shutdown()
codec := rpcClient(t, s1)
defer codec.Close()
args := structs.DCSpecificRequest{
Datacenter: "dc1",
}
var out structs.IndexedServices
testrpc.WaitForLeader(t, s1.RPC, "dc1")
// Run the query
if err := msgpackrpc.CallWithCodec(codec, "Catalog.ListServices", &args, &out); err != nil {
t.Fatalf("err: %v", err)
}
// Setup a blocking query
args.MinQueryIndex = out.Index
args.MaxQueryTime = time.Second
// Async cause a change
idx := out.Index
start := time.Now()
go func() {
time.Sleep(100 * time.Millisecond)
if err := s1.fsm.State().EnsureNode(idx+1, &structs.Node{Node: "foo", Address: "127.0.0.1"}); err != nil {
t.Fatalf("err: %v", err)
}
if err := s1.fsm.State().EnsureService(idx+2, "foo", &structs.NodeService{ID: "db", Service: "db", Tags: []string{"primary"}, Address: "127.0.0.1", Port: 5000}); err != nil {
t.Fatalf("err: %v", err)
}
}()
// Re-run the query
out = structs.IndexedServices{}
if err := msgpackrpc.CallWithCodec(codec, "Catalog.ListServices", &args, &out); err != nil {
t.Fatalf("err: %v", err)
}
// Should block at least 100ms
if time.Since(start) < 100*time.Millisecond {
t.Fatalf("too fast")
}
// Check the indexes
if out.Index != idx+2 {
t.Fatalf("bad: %v", out)
}
// Should find the service
if len(out.Services) != 2 {
t.Fatalf("bad: %v", out)
}
} | explode_data.jsonl/49230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 621
} | [
2830,
3393,
41606,
27104,
11025,
51779,
287,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
1155,
340,
16867,
2643,
84427,
14161,
16,
340,
16867,
274,
16,
10849,
18452,
741,
43343,
66,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStubsVersions(t *testing.T) {
bp := `
cc_library {
name: "libfoo",
srcs: ["foo.c"],
stubs: {
versions: ["29", "R", "current"],
},
}
`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.Platform_version_active_codenames = []string{"R"}
ctx := testCcWithConfig(t, config)
variants := ctx.ModuleVariantsForTests("libfoo")
for _, expectedVer := range []string{"29", "R", "current"} {
expectedVariant := "android_arm_armv7-a-neon_shared_" + expectedVer
if !inList(expectedVariant, variants) {
t.Errorf("missing expected variant: %q", expectedVariant)
}
}
} | explode_data.jsonl/53366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
623,
15738,
69015,
1155,
353,
8840,
836,
8,
341,
2233,
79,
1669,
22074,
197,
63517,
39461,
341,
298,
11609,
25,
330,
2740,
7975,
756,
298,
41144,
82,
25,
4383,
7975,
520,
8097,
298,
18388,
15738,
25,
341,
571,
197,
28290,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreate(t *testing.T) {
tcs := []struct {
resource string
name string
namespace string
obj *unstructured.Unstructured
path string
}{
{
resource: "rtest",
name: "normal_create",
path: "/apis/gtest/vtest/rtest",
obj: getObject("gtest/vTest", "rTest", "normal_create"),
},
{
resource: "rtest",
name: "namespaced_create",
namespace: "nstest",
path: "/apis/gtest/vtest/namespaces/nstest/rtest",
obj: getObject("gtest/vTest", "rTest", "namespaced_create"),
},
}
for _, tc := range tcs {
gv := &schema.GroupVersion{Group: "gtest", Version: "vtest"}
resource := &metav1.APIResource{Name: tc.resource, Namespaced: len(tc.namespace) != 0}
cl, srv, err := getClientServer(gv, func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
t.Errorf("Create(%q) got HTTP method %s. wanted POST", tc.name, r.Method)
}
if r.URL.Path != tc.path {
t.Errorf("Create(%q) got path %s. wanted %s", tc.name, r.URL.Path, tc.path)
}
w.Header().Set("Content-Type", runtime.ContentTypeJSON)
data, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Errorf("Create(%q) unexpected error reading body: %v", tc.name, err)
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Write(data)
})
if err != nil {
t.Errorf("unexpected error when creating client: %v", err)
continue
}
defer srv.Close()
got, err := cl.Resource(resource, tc.namespace).Create(tc.obj)
if err != nil {
t.Errorf("unexpected error when creating %q: %v", tc.name, err)
continue
}
if !reflect.DeepEqual(got, tc.obj) {
t.Errorf("Create(%q) want: %v\ngot: %v", tc.name, tc.obj, got)
}
}
} | explode_data.jsonl/37544 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 776
} | [
2830,
3393,
4021,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
50346,
220,
914,
198,
197,
11609,
414,
914,
198,
197,
56623,
914,
198,
197,
22671,
981,
353,
359,
51143,
10616,
51143,
198,
197,
26781,
414,
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... | 4 |
func TestSchemaParser_SimpleInputObjectWithArgsShouldFail(t *testing.T) {
body := `
input Hello {
world(foo: Int): String
}`
_, err := Parse(ParseParams{
Source: body,
Options: ParseOptions{
NoSource: true,
},
})
expectedError := &gqlerrors.Error{
Type: gqlerrors.ErrorTypeSyntax,
Message: `Syntax Error GraphQL (3:8) Expected :, found (
2: input Hello {
3: world(foo: Int): String
^
4: }
`,
Stack: `Syntax Error GraphQL (3:8) Expected :, found (
2: input Hello {
3: world(foo: Int): String
^
4: }
`,
Nodes: []ast.Node{},
Source: source.New("GraphQL", `
input Hello {
world(foo: Int): String
}`),
Positions: []int{22},
Locations: []location.SourceLocation{
{Line: 3, Column: 8},
},
}
if err == nil {
t.Fatalf("expected error, expected: %v, got: %v", expectedError, nil)
}
if !reflect.DeepEqual(expectedError, err) {
t.Fatalf("unexpected document, expected: %v, got: %v", expectedError, err)
}
} | explode_data.jsonl/51233 | {
"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,
8632,
6570,
1098,
6456,
2505,
1190,
2354,
4117,
14996,
19524,
1155,
353,
8840,
836,
8,
341,
35402,
1669,
22074,
1355,
21927,
341,
220,
1879,
71880,
25,
1333,
1648,
923,
198,
5541,
271,
197,
6878,
1848,
1669,
14775,
71812,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewInstanceUUID(t *testing.T) {
b, err := NewBeat("testbeat", "", "0.9")
if err != nil {
panic(err)
}
// Make sure the ID's are different
differentUUID, err := uuid.NewV4()
if err != nil {
t.Fatalf("error while generating ID: %v", err)
}
assert.NotEqual(t, b.Info.ID, differentUUID)
} | explode_data.jsonl/47187 | {
"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,
3564,
2523,
24754,
1155,
353,
8840,
836,
8,
972,
2233,
11,
1848,
1669,
1532,
43658,
445,
1944,
22227,
497,
7342,
330,
15,
13,
24,
6060,
743,
1848,
961,
2092,
972,
197,
30764,
3964,
1218,
197,
2570,
197,
322,
7405,
2704,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetIndexer(t *testing.T) {
i := cache.NewIndexer(
cache.DeletionHandlingMetaNamespaceKeyFunc,
cache.Indexers{})
helper.SetIndexer(i)
assert.Equal(t, i, helper.indexer, "should set the indexer")
} | explode_data.jsonl/15642 | {
"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,
1649,
1552,
261,
1155,
353,
8840,
836,
8,
341,
8230,
1669,
6500,
7121,
1552,
261,
1006,
197,
52680,
8934,
52625,
38606,
12175,
22699,
1592,
9626,
345,
197,
52680,
18338,
388,
37790,
9598,
2947,
4202,
1552,
261,
1956,
340,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestEnqueueLossy(t *testing.T) {
finite_tests.EnqueueLossy(t, func(size int) interface {
goqueue.Owner
finite.EnqueueLossy
} {
return finite.New(size)
})
} | explode_data.jsonl/54509 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
1702,
4584,
39838,
88,
1155,
353,
8840,
836,
8,
341,
1166,
15856,
32509,
65625,
39838,
88,
1155,
11,
2915,
6856,
526,
8,
3749,
341,
197,
30680,
4584,
49920,
198,
197,
1166,
15856,
65625,
39838,
88,
198,
197,
92,
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 |
func TestGetVersion(t *testing.T) {
testSet := []struct {
Str string
Expected Version
}{
{"tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b", Version0},
{"tarsum+sha256", Version0},
{"tarsum", Version0},
{"tarsum.dev", VersionDev},
{"tarsum.dev+sha256:deadbeef", VersionDev},
}
for _, ts := range testSet {
v, err := GetVersionFromTarsum(ts.Str)
if err != nil {
t.Fatalf("%q : %s", err, ts.Str)
}
if v != ts.Expected {
t.Errorf("expected %d (%q), got %d (%q)", ts.Expected, ts.Expected, v, v)
}
}
// test one that does not exist, to ensure it errors
str := "weak+md5:abcdeabcde"
_, err := GetVersionFromTarsum(str)
if err != ErrNotVersion {
t.Fatalf("%q : %s", err, str)
}
} | explode_data.jsonl/63050 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
1949,
5637,
1155,
353,
8840,
836,
8,
341,
18185,
1649,
1669,
3056,
1235,
341,
197,
197,
2580,
414,
914,
198,
197,
197,
18896,
6079,
198,
197,
59403,
197,
197,
4913,
26737,
1242,
10,
15247,
17,
20,
21,
55976,
20,
23,
8316... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldReturnOneErrorAndNoWarningsWhenValidationOfMatchSpecificationOfApplicationConfigIsCalledAndValueCannotBeParsed(t *testing.T) {
resourceHandle := NewApplicationConfigResourceHandle()
schema := resourceHandle.MetaData().Schema
value := invalidMatchSpecification
warns, errs := schema[ApplicationConfigFieldMatchSpecification].ValidateFunc(value, ApplicationConfigFieldMatchSpecification)
require.Empty(t, warns)
require.Len(t, errs, 1)
} | explode_data.jsonl/64924 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
14996,
5598,
3966,
1454,
3036,
2753,
20140,
4498,
13799,
2124,
8331,
56139,
2124,
4988,
2648,
3872,
20960,
3036,
1130,
17444,
3430,
82959,
1155,
353,
8840,
836,
8,
341,
50346,
6999,
1669,
1532,
4988,
2648,
4783,
6999,
741,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandlerCallJSON(t *testing.T) {
SetSerializer(json.NewSerializer())
handler.register(&TestComp{}, nil)
m := JSONMessage{Code: 1, Data: "hello world"}
data, err := serializeOrRaw(m)
if err != nil {
t.Fail()
}
msg := message.New()
msg.Route = "TestComp.HandleJSON"
msg.Type = message.Request
msg.Data = data
agent := newAgent(nil)
handler.processMessage(agent, msg)
} | explode_data.jsonl/39827 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
3050,
7220,
5370,
1155,
353,
8840,
836,
8,
341,
22212,
13909,
9304,
7121,
13909,
2398,
53326,
9929,
2099,
2271,
13552,
22655,
2092,
692,
2109,
1669,
4718,
2052,
90,
2078,
25,
220,
16,
11,
2885,
25,
330,
14990,
1879,
16707,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMessageTransaction_ValidateCustom2(t *testing.T) {
xmss := helper.GetAliceXMSS(6)
message := make([]byte, 80)
for i := 0; i < len(message); i++ {
message[i] = 0
}
fee := uint64(1)
xmssPK := misc.UCharVectorToBytes(xmss.PK())
messageTx := NewTestMessageTransaction(string(message), fee, xmssPK, nil)
// Transaction must not be nil, as the message size is still within limit
assert.NotNil(t, messageTx.tx)
} | explode_data.jsonl/10387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
2052,
8070,
62,
17926,
10268,
17,
1155,
353,
8840,
836,
8,
341,
10225,
76,
778,
1669,
13137,
2234,
61686,
52337,
1220,
7,
21,
340,
24753,
1669,
1281,
10556,
3782,
11,
220,
23,
15,
340,
2023,
600,
1669,
220,
15,
26,
600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDesCfbEncrypt(t *testing.T) {
data := "hello world"
key := "abcdefgh"
desCfbEncrypt := DesCfbEncrypt([]byte(data), []byte(key))
desCfbDecrypt := DesCfbDecrypt(desCfbEncrypt, []byte(key))
if string(desCfbDecrypt) != data {
internal.LogFailedTestInfo(t, "DesCfbEncrypt/DesCfbDecrypt", data, data, string(desCfbDecrypt))
t.FailNow()
}
} | explode_data.jsonl/7308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
4896,
34,
10798,
61520,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
330,
14990,
1879,
698,
23634,
1669,
330,
56747,
1837,
52912,
34,
10798,
61520,
1669,
3874,
34,
10798,
61520,
10556,
3782,
2592,
701,
3056,
3782,
4857,
1171,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_isPrimitiveType(t *testing.T) {
scenarios := []struct {
input interface{}
output bool
}{
{nil, true},
{5, true},
{math.Pi, true},
{false, true},
{struct{}{}, false},
}
for i, s := range scenarios {
t.Run(fmt.Sprintf("Scenario #%d", i), func(t *testing.T) {
assert.Equal(t, s.output, isPrimitiveType(s.input))
})
}
} | explode_data.jsonl/20504 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
6892,
33313,
929,
1155,
353,
8840,
836,
8,
341,
29928,
60494,
1669,
3056,
1235,
341,
197,
22427,
220,
3749,
16094,
197,
21170,
1807,
198,
197,
59403,
197,
197,
90,
8385,
11,
830,
1583,
197,
197,
90,
20,
11,
830,
1583,
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 TestReplaceReplacesMatchesWithSpecifiedText(t *testing.T) {
t.Parallel()
input := "hello world"
tcs := []struct {
search, replace, want string
}{
{
search: "hello",
replace: "bye",
want: "bye world\n",
},
{
search: "Does not exist in input",
replace: "Will not appear in output",
want: "hello world\n",
},
{
search: " world",
replace: " string with newline\n",
want: "hello string with newline\n\n",
},
{
search: "hello",
replace: "Ж9",
want: "Ж9 world\n",
},
}
for _, tc := range tcs {
got, err := script.Echo(input).Replace(tc.search, tc.replace).String()
if err != nil {
t.Fatal(err)
}
if tc.want != got {
t.Error(cmp.Diff(tc.want, got))
}
}
} | explode_data.jsonl/51496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 346
} | [
2830,
3393,
23107,
693,
26078,
42470,
2354,
8327,
1870,
1178,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22427,
1669,
330,
14990,
1879,
698,
3244,
4837,
1669,
3056,
1235,
341,
197,
45573,
11,
8290,
11,
1366,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSendUserMessage(t *testing.T) {
messageService := MockMessageService{}
message := Message{
User: "Unit",
Friend: "Test",
Text: "We mock you!",
Id: 1}
err := SendUserMessage(messageService, message)
if err != nil {
t.Errorf("TestSendUserMessage: Got an error: %v\n", err)
}
messages, err := CheckMessages(messageService, "Test")
if err != nil {
t.Errorf("TestSendUserMessage: Got an error on chec: %v\n", err)
}
expected := 1
result := len(messages)
if result != expected {
t.Errorf("TestSendUserMessage: Expected: %d, got %d\n", expected, result)
}
} | explode_data.jsonl/13349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
11505,
1474,
2052,
1155,
353,
8840,
836,
8,
341,
24753,
1860,
1669,
14563,
2052,
1860,
16094,
24753,
1669,
4856,
515,
197,
31672,
25,
256,
330,
4562,
756,
197,
12727,
5039,
25,
330,
2271,
756,
197,
49635,
25,
256,
330,
165... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigLoadConfigurationFailTOMLConfigFileInvalidContents(t *testing.T) {
if os.Geteuid() == 0 {
t.Skip(testDisabledNeedNonRoot)
}
tmpdir, err := ioutil.TempDir(testDir, "runtime-config-")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
testLoadConfiguration(t, tmpdir,
func(config testRuntimeConfig, configFile string, ignoreLogging bool) (bool, error) {
expectFail := true
err := createFile(config.ConfigPath,
`<?xml version="1.0"?>
<foo>I am not TOML! ;-)</foo>
<bar>I am invalid XML!`)
if err != nil {
return expectFail, err
}
return expectFail, nil
})
} | explode_data.jsonl/5121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
2648,
5879,
7688,
19524,
51,
1898,
43,
2648,
1703,
7928,
14803,
1155,
353,
8840,
836,
8,
341,
743,
2643,
2234,
68,
2423,
368,
621,
220,
15,
341,
197,
3244,
57776,
8623,
25907,
23657,
8121,
8439,
340,
197,
630,
20082,
3741,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatterJSONIndent(test *testing.T) {
object := struct {
Value int
Message string
}{
Value: 5,
Message: "text",
}
formatted, err := formatter.Format("{p | json | indent}", object)
assert.NoError(test, err)
assert.Equal(test, "{\n\t\"Value\": 5,\n\t\"Message\": \"text\"\n}", formatted)
} | explode_data.jsonl/39801 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
14183,
5370,
42729,
8623,
353,
8840,
836,
8,
341,
35798,
1669,
2036,
341,
197,
47399,
256,
526,
198,
197,
46733,
914,
198,
197,
59403,
197,
47399,
25,
256,
220,
20,
345,
197,
46733,
25,
330,
1318,
756,
197,
630,
37410,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccMinioIAMGroupPolicy_basic(t *testing.T) {
var groupPolicy1, groupPolicy2 string
rInt := acctest.RandInt()
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckIAMGroupPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccIAMGroupPolicyConfig(rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckIAMGroupPolicyExists(
"minio_iam_group.group",
"minio_iam_group_policy.foo",
&groupPolicy1,
),
),
},
{
ResourceName: "minio_iam_group_policy.foo",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccIAMGroupPolicyConfigUpdate(rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckIAMGroupPolicyExists(
"minio_iam_group.group",
"minio_iam_group_policy.bar",
&groupPolicy2,
),
testAccCheckMinioIAMGroupPolicyNameChanged(&groupPolicy1, &groupPolicy2),
),
},
{
ResourceName: "minio_iam_group_policy.bar",
ImportState: true,
ImportStateVerify: true,
},
},
})
} | explode_data.jsonl/7178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 532
} | [
2830,
3393,
14603,
6217,
815,
73707,
2808,
13825,
34729,
1155,
353,
8840,
836,
8,
341,
2405,
1874,
13825,
16,
11,
1874,
13825,
17,
914,
198,
7000,
1072,
1669,
1613,
67880,
2013,
437,
1072,
741,
50346,
41288,
7957,
2271,
1155,
11,
5101,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventPayload(t *testing.T) {
cases := map[string]struct {
Path string
Expected PushOrPullRequestEventPayload
}{
"pull request": {
Path: "./testdata/pr-event-payload-example.json",
Expected: PushOrPullRequestEventPayload{
PullRequest: &PullRequest{
Number: 2,
},
Repository: &Repository{
Name: "Hello-World",
Owner: User{Login: "Codertocat"},
},
},
},
"push": {
Path: "./testdata/push-event-payload-example.json",
Expected: PushOrPullRequestEventPayload{
PullRequest: nil,
Repository: &Repository{
Name: "Hello-World",
Owner: User{Login: "Codertocat"},
},
},
},
}
for desc, c := range cases {
t.Run(desc, func(t *testing.T) {
jsonBytes, err := os.ReadFile(c.Path)
if err != nil {
t.Errorf("want nil, got %#v", err)
return
}
var payload PushOrPullRequestEventPayload
if err := json.Unmarshal(jsonBytes, &payload); err != nil {
t.Errorf("want nil, got %#v", err)
return
}
if !reflect.DeepEqual(payload, c.Expected) {
t.Error(cmp.Diff(c.Expected, payload))
}
})
}
} | explode_data.jsonl/49296 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 505
} | [
2830,
3393,
1556,
29683,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
69640,
257,
914,
198,
197,
197,
18896,
22950,
2195,
36068,
1900,
1556,
29683,
198,
197,
59403,
197,
197,
1,
23441,
1681,
788,
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... | 4 |
func TestByParent(t *testing.T) {
archive1, _ := fakeTar()
archive2, _ := fakeTar()
archive3, _ := fakeTar()
graph, _ := tempGraph(t)
defer nukeGraph(graph)
parentImage := &image.Image{
ID: stringid.GenerateNonCryptoID(),
Comment: "parent",
Created: time.Now(),
Parent: "",
}
childImage1 := &image.Image{
ID: stringid.GenerateNonCryptoID(),
Comment: "child1",
Created: time.Now(),
Parent: parentImage.ID,
}
childImage2 := &image.Image{
ID: stringid.GenerateNonCryptoID(),
Comment: "child2",
Created: time.Now(),
Parent: parentImage.ID,
}
err := graph.Register(v1Descriptor{parentImage}, archive1)
if err != nil {
t.Fatal(err)
}
err = graph.Register(v1Descriptor{childImage1}, archive2)
if err != nil {
t.Fatal(err)
}
err = graph.Register(v1Descriptor{childImage2}, archive3)
if err != nil {
t.Fatal(err)
}
byParent := graph.ByParent()
numChildren := len(byParent[parentImage.ID])
if numChildren != 2 {
t.Fatalf("Expected 2 children, found %d", numChildren)
}
} | explode_data.jsonl/64326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 427
} | [
2830,
3393,
1359,
8387,
1155,
353,
8840,
836,
8,
341,
197,
16019,
16,
11,
716,
1669,
12418,
62733,
741,
197,
16019,
17,
11,
716,
1669,
12418,
62733,
741,
197,
16019,
18,
11,
716,
1669,
12418,
62733,
2822,
66616,
11,
716,
1669,
2730,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDefaultLabeller_OverrideRunId(t *testing.T) {
labeller := NewLabeller(config.SkaffoldOptions{
CustomLabels: []string{RunIDLabel + "=ID"},
})
labels := labeller.Labels()
testutil.CheckDeepEqual(t, "ID", labels[RunIDLabel])
} | explode_data.jsonl/31971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
3675,
29046,
7073,
62,
2177,
6727,
764,
1155,
353,
8840,
836,
8,
341,
8810,
370,
7073,
1669,
1532,
29046,
7073,
8754,
808,
74,
2649,
813,
3798,
515,
197,
6258,
1450,
23674,
25,
3056,
917,
90,
6727,
915,
2476,
488,
37827,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEachFloat32(t *testing.T) {
v := &Value{data: []float32{float32(1), float32(1), float32(1), float32(1), float32(1)}}
count := 0
replacedVals := make([]float32, 0)
assert.Equal(t, v, v.EachFloat32(func(i int, val float32) bool {
count++
replacedVals = append(replacedVals, val)
// abort early
if i == 2 {
return false
}
return true
}))
assert.Equal(t, count, 3)
assert.Equal(t, replacedVals[0], v.MustFloat32Slice()[0])
assert.Equal(t, replacedVals[1], v.MustFloat32Slice()[1])
assert.Equal(t, replacedVals[2], v.MustFloat32Slice()[2])
} | explode_data.jsonl/23507 | {
"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,
4854,
5442,
18,
17,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
3056,
3649,
18,
17,
90,
3649,
18,
17,
7,
16,
701,
2224,
18,
17,
7,
16,
701,
2224,
18,
17,
7,
16,
701,
2224,
18,
17,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestXRef_NeuterCrossReferences(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
// Issue #1 to test against
itarget := testCreateIssue(t, 1, 2, "title1", "content1", false)
// Issue mentioning issue #1
title := fmt.Sprintf("title2, mentions #%d", itarget.Index)
i := testCreateIssue(t, 1, 2, title, "content2", false)
ref := AssertExistsAndLoadBean(t, &Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0}).(*Comment)
assert.Equal(t, CommentTypeIssueRef, ref.Type)
assert.Equal(t, references.XRefActionNone, ref.RefAction)
d := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
i.Title = "title2, no mentions"
assert.NoError(t, i.ChangeTitle(d, title))
ref = AssertExistsAndLoadBean(t, &Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0}).(*Comment)
assert.Equal(t, CommentTypeIssueRef, ref.Type)
assert.Equal(t, references.XRefActionNeutered, ref.RefAction)
} | explode_data.jsonl/23002 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
55,
3945,
1604,
68,
27951,
28501,
31712,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
2271,
5988,
12367,
197,
322,
25226,
671,
16,
311,
1273,
2348,
198,
23374,
1284,
1669,
1273,
4021,
42006,
1155,
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,
1... | 1 |
func TestMapStringByte_ToYAML(t *testing.T) {
Convey("TestMapStringByte.ToYAML", t, func() {
Convey("Ordered", func() {
var k string = "4a7a68b8-5250-4e55-b6ab-cb4167edeb99"
var v byte = 231
test := omap.NewMapStringByte(1)
So(test.Put(k, v), ShouldPointTo, test)
So(test.Len(), ShouldEqual, 1)
c, d := test.ToYAML()
So(d, ShouldBeNil)
So(c.Kind, ShouldEqual, yaml.SequenceNode)
So(c.LongTag(), ShouldEqual, xyml.TagOrderedMap)
So(len(c.Content), ShouldEqual, 1)
So(xyml.IsMap(c.Content[0]), ShouldBeTrue)
})
Convey("Unordered", func() {
var k string = "565f3ef6-63ca-4b2a-89ff-3980c52d2d15"
var v byte = 128
test := omap.NewMapStringByte(1)
test.SerializeOrdered(false)
So(test.Put(k, v), ShouldPointTo, test)
So(test.Len(), ShouldEqual, 1)
c, d := test.ToYAML()
So(d, ShouldBeNil)
So(c.Kind, ShouldEqual, yaml.MappingNode)
So(c.LongTag(), ShouldEqual, xyml.TagMap)
So(len(c.Content), ShouldEqual, 2)
})
})
} | explode_data.jsonl/5062 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
2227,
703,
7153,
38346,
56,
31102,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2271,
2227,
703,
7153,
3274,
56,
31102,
497,
259,
11,
2915,
368,
341,
197,
93070,
5617,
445,
54384,
497,
2915,
368,
341,
298,
2405,
595,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestForEach(t *testing.T) {
items := []int{23, 24, 2, 5, 10}
interfaceItems := make([]interface{}, len(items))
itemsSum := 0
for i, v := range items {
interfaceItems[i] = v
itemsSum += v
}
a := New(interfaceItems)
a.ForEach(forEach)
if sum != itemsSum {
t.Log("ForEach should execute function on each item of the array")
t.Log("Expected", itemsSum, "\n Got", sum)
t.Fail()
}
} | explode_data.jsonl/47104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
91392,
1155,
353,
8840,
836,
8,
341,
46413,
1669,
3056,
396,
90,
17,
18,
11,
220,
17,
19,
11,
220,
17,
11,
220,
20,
11,
220,
16,
15,
532,
58915,
1564,
4353,
1669,
1281,
10556,
4970,
22655,
2422,
24337,
1171,
46413,
919... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigsMappingKeystore(t *testing.T) {
secret := "mapping_secret"
//expected config
config, _ := common.NewConfigFrom(map[string]interface{}{
"correct": "config",
"password": secret,
})
path := getTemporaryKeystoreFile()
defer os.Remove(path)
// store the secret
keystore := createAnExistingKeystore(path, secret)
tests := []struct {
mapping string
event bus.Event
expected []*common.Config
}{
// Match config
{
mapping: `
- condition.equals:
foo: 3
config:
- correct: config
password: "${PASSWORD}"`,
event: bus.Event{
"foo": 3,
},
expected: []*common.Config{config},
},
}
for _, test := range tests {
var mappings MapperSettings
config, err := common.NewConfigWithYAML([]byte(test.mapping), "")
if err != nil {
t.Fatal(err)
}
if err := config.Unpack(&mappings); err != nil {
t.Fatal(err)
}
mapper, err := NewConfigMapper(mappings, keystore, nil)
if err != nil {
t.Fatal(err)
}
res := mapper.GetConfig(test.event)
assert.Equal(t, test.expected, res)
}
} | explode_data.jsonl/50995 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 432
} | [
2830,
3393,
84905,
6807,
6608,
63373,
1155,
353,
8840,
836,
8,
341,
197,
20474,
1669,
330,
40792,
21962,
698,
197,
322,
7325,
2193,
198,
25873,
11,
716,
1669,
4185,
7121,
2648,
3830,
9147,
14032,
31344,
67066,
197,
197,
1,
19928,
788,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocale(t *testing.T) {
trans := New()
expected := "zh_Hans_MO"
if trans.Locale() != expected {
t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale())
}
} | explode_data.jsonl/43890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
19231,
1155,
353,
8840,
836,
8,
1476,
72453,
1669,
1532,
741,
42400,
1669,
330,
23815,
2039,
596,
18089,
1837,
743,
1356,
59094,
368,
961,
3601,
341,
197,
3244,
13080,
445,
18896,
7677,
82,
6,
24528,
7677,
82,
22772,
3601,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetServerStatusGood(t *testing.T) {
_, err := GetServerStatus("mc.syfaro.net", 25565)
if err != nil {
t.Log(err)
t.Fail()
}
} | explode_data.jsonl/24169 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
1949,
5475,
2522,
15216,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
2126,
5475,
2522,
445,
12887,
77577,
69,
17165,
5071,
497,
220,
17,
20,
20,
21,
20,
340,
743,
1848,
961,
2092,
341,
197,
3244,
5247,
3964,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestGreaterEqualUInts(t *testing.T) {
t.Parallel()
match, err := path.GreaterEqual(&testType1{
UInts: []uint{2, 4, 7},
}, "uints", "5")
require.Nil(t, err)
require.True(t, match)
match, err = path.GreaterEqual(&testType1{
UInts: []uint{2, 4, 7},
}, "uints", "7")
require.Nil(t, err)
require.True(t, match)
match, err = path.GreaterEqual(&testType1{
UInts: []uint{2, 4, 7},
}, "uints", "8")
require.Nil(t, err)
require.False(t, match)
} | explode_data.jsonl/78474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
41366,
2993,
18777,
82,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
47706,
11,
1848,
1669,
1815,
1224,
28362,
2993,
2099,
1944,
929,
16,
515,
197,
87190,
82,
25,
3056,
2496,
90,
17,
11,
220,
19,
11,
220,
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 Test_cuttingRope(t *testing.T) {
type args struct {
n int
}
tests := []struct {
name string
args args
want int
}{
{"1", args{2}, 1},
{"2", args{10}, 36},
{"3", args{100}, 703522804},
{"4", args{1000}, 620946522},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := cuttingRope(tt.args.n); got != tt.want {
t.Errorf("cuttingRope() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/64676 | {
"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,
41317,
1280,
49,
2792,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
9038,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
198,
197,
59403,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConfigWithMissingAttributes(t *testing.T) {
tests := []struct {
desc string
cfg Config
expectErr string
}{
{
desc: "missing level",
cfg: Config{
Encoding: "json",
},
expectErr: "missing Level",
},
{
desc: "missing encoder time in encoder config",
cfg: Config{
Level: NewAtomicLevelAt(zapcore.InfoLevel),
Encoding: "json",
EncoderConfig: zapcore.EncoderConfig{
MessageKey: "msg",
TimeKey: "ts",
},
},
expectErr: "missing EncodeTime in EncoderConfig",
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
cfg := tt.cfg
_, err := cfg.Build()
require.Error(t, err)
assert.Equal(t, tt.expectErr, err.Error())
})
}
} | explode_data.jsonl/27450 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
2648,
2354,
25080,
10516,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
414,
914,
198,
197,
50286,
981,
5532,
198,
197,
24952,
7747,
914,
198,
197,
59403,
197,
197,
515,
298,
41653,
25,
330,
30616... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReleaseMount(t *testing.T) {
mount, err := CreateMount()
assert.NoError(t, err)
require.NotNil(t, mount)
assert.NoError(t, mount.Release())
// call release again to ensure idempotency of the func
assert.NoError(t, mount.Release())
} | explode_data.jsonl/29511 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
16077,
16284,
1155,
353,
8840,
836,
8,
341,
2109,
629,
11,
1848,
1669,
4230,
16284,
741,
6948,
35699,
1155,
11,
1848,
340,
17957,
93882,
1155,
11,
6470,
692,
6948,
35699,
1155,
11,
6470,
58693,
2398,
197,
322,
1618,
4879,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlayerState(t *testing.T) {
client, server := testClientFile(http.StatusOK, "test_data/player_state.txt")
defer server.Close()
state, err := client.PlayerState()
if err != nil {
t.Error(err)
return
}
if len(state.PlaybackContext.ExternalURLs) != 1 {
t.Error("Expected one external url")
}
if state.Item == nil {
t.Error("Expected item to be a track")
}
if state.Timestamp != 1491302708055 {
t.Error("Expected timestamp to be 1491302708055")
}
if state.Progress != 102509 {
t.Error("Expected progress to be 102509")
}
if state.Playing {
t.Error("Expected not to be playing")
}
} | explode_data.jsonl/80125 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
4476,
1397,
1155,
353,
8840,
836,
8,
341,
25291,
11,
3538,
1669,
1273,
2959,
1703,
19886,
52989,
11,
330,
1944,
1769,
59503,
4387,
3909,
1138,
16867,
3538,
10421,
2822,
24291,
11,
1848,
1669,
2943,
23756,
1397,
741,
743,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProductsDBIntegration(t *testing.T) {
if os.Getenv(`SKIP_INTEGRATION`) == `true` {
t.Skip()
}
if widgetProduct == nil {
t.Error(`Product struct not define; can't continue. This probbaly indicates a setup failure in 'model_test.go'.`)
} else {
if t.Run(`ProductsDBSetup`, testProductDBSetup) {
if sqldb.DB == nil { // test was skipped, but we still need to setup
setupDB()
}
t.Run(`ProductGet`, testProductGet)
t.Run(`ProductCreate`, testProductCreate)
t.Run(`ProductUpdate`, testProductUpdate)
t.Run(`ProductGetInTxn`, testProductGetInTxn)
t.Run(`ProductCreateInTxn`, testProductCreateInTxn)
t.Run(`ProductUpdateInTxn`, testProductUpdateInTxn)
}
}
} | explode_data.jsonl/5953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 303
} | [
2830,
3393,
17746,
3506,
52464,
1155,
353,
8840,
836,
8,
341,
220,
421,
2643,
64883,
5809,
91799,
2158,
68003,
3495,
32881,
621,
1565,
1866,
63,
341,
262,
259,
57776,
741,
220,
555,
220,
421,
9086,
4816,
621,
2092,
341,
262,
259,
6141... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestSettleInvoicePaymentAddrRequired(t *testing.T) {
t.Parallel()
ctx := newTestContext(t)
defer ctx.cleanup()
allSubscriptions, err := ctx.registry.SubscribeNotifications(0, 0)
require.Nil(t, err)
defer allSubscriptions.Cancel()
// Subscribe to the not yet existing invoice.
subscription, err := ctx.registry.SubscribeSingleInvoice(
testInvoicePaymentHash,
)
require.NoError(t, err)
defer subscription.Cancel()
require.Equal(
t, subscription.invoiceRef.PayHash(), &testInvoicePaymentHash,
)
// Add the invoice, which requires the MPP payload to always be
// included due to its set of feature bits.
addIdx, err := ctx.registry.AddInvoice(
testPayAddrReqInvoice, testInvoicePaymentHash,
)
require.NoError(t, err)
require.Equal(t, int(addIdx), 1)
// We expect the open state to be sent to the single invoice subscriber.
select {
case update := <-subscription.Updates:
if update.State != channeldb.ContractOpen {
t.Fatalf("expected state ContractOpen, but got %v",
update.State)
}
case <-time.After(testTimeout):
t.Fatal("no update received")
}
// We expect a new invoice notification to be sent out.
select {
case newInvoice := <-allSubscriptions.NewInvoices:
if newInvoice.State != channeldb.ContractOpen {
t.Fatalf("expected state ContractOpen, but got %v",
newInvoice.State)
}
case <-time.After(testTimeout):
t.Fatal("no update received")
}
hodlChan := make(chan interface{}, 1)
// Now try to settle the invoice, the testPayload doesn't have any mpp
// information, so it should be forced to the updateLegacy path then
// fail as a required feature bit exists.
resolution, err := ctx.registry.NotifyExitHopHtlc(
testInvoicePaymentHash, testInvoice.Terms.Value,
uint32(testCurrentHeight)+testInvoiceCltvDelta-1,
testCurrentHeight, getCircuitKey(10), hodlChan, testPayload,
)
require.NoError(t, err)
failResolution, ok := resolution.(*HtlcFailResolution)
if !ok {
t.Fatalf("expected fail resolution, got: %T",
resolution)
}
require.Equal(t, failResolution.AcceptHeight, testCurrentHeight)
require.Equal(t, failResolution.Outcome, ResultAddressMismatch)
} | explode_data.jsonl/59120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 755
} | [
2830,
3393,
1649,
11239,
34674,
20188,
13986,
8164,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
1669,
501,
2271,
1972,
1155,
340,
16867,
5635,
87689,
2822,
50960,
3136,
29966,
11,
1848,
1669,
5635,
55568,
82628,
34736,
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... | 8 |
func TestOCIRequestSigner_SignEmptyBody(t *testing.T) {
s := ociRequestSigner{KeyProvider: testKeyProvider{},
ShouldHashBody: defaultBodyHashPredicate,
}
u, _ := url.Parse(testURL2)
r := http.Request{
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
Header: make(http.Header),
URL: u,
}
bodyBuffer := bytes.NewBufferString("")
r.Body = ioutil.NopCloser(bodyBuffer)
r.ContentLength = int64(bodyBuffer.Len())
r.Header.Set(requestHeaderDate, "Thu, 05 Jan 2014 21:31:40 GMT")
r.Header.Set(requestHeaderContentType, "application/json")
r.Header.Set(requestHeaderContentLength, strconv.FormatInt(r.ContentLength, 10))
r.Method = http.MethodPost
err := s.Sign(&r)
assert.NoError(t, err)
assert.Equal(t, r.ContentLength, int64(0))
assert.NotEmpty(t, r.Header.Get(requestHeaderAuthorization))
assert.NotEmpty(t, r.Header.Get(requestHeaderXContentSHA256))
} | explode_data.jsonl/64283 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 352
} | [
2830,
3393,
63983,
1900,
7264,
261,
1098,
622,
3522,
5444,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
93975,
1900,
7264,
261,
90,
1592,
5179,
25,
1273,
1592,
5179,
38837,
197,
197,
14996,
6370,
5444,
25,
1638,
5444,
6370,
36329,
345,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAccountKeyCache(t *testing.T) {
m := Manager{Cache: newMemCache()}
ctx := context.Background()
k1, err := m.accountKey(ctx)
if err != nil {
t.Fatal(err)
}
k2, err := m.accountKey(ctx)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(k1, k2) {
t.Errorf("account keys don't match: k1 = %#v; k2 = %#v", k1, k2)
}
} | explode_data.jsonl/51427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
7365,
1592,
8233,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
10567,
90,
8233,
25,
501,
18816,
8233,
23509,
20985,
1669,
2266,
19047,
741,
16463,
16,
11,
1848,
1669,
296,
18786,
1592,
7502,
340,
743,
1848,
961,
2092,
341,
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... | 4 |
func TestCancelByIDForParent(t *testing.T) {
client := v1.New(&v1.Config{
Key: os.Getenv("BFKEY"),
Secret: os.Getenv("BFSECRET"),
})
err := client.CancelByIDForParent(cancels.NewByIDForParent(
types.FXBTCJPY,
"JRF20200314-044600-538282",
))
assert.NoError(t, err)
fmt.Printf("%+v %+v\n", client.Limit.Remain(true), client.Limit.Remain(false))
} | explode_data.jsonl/41213 | {
"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,
9269,
60572,
2461,
8387,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
348,
16,
7121,
2099,
85,
16,
10753,
515,
197,
55242,
25,
262,
2643,
64883,
445,
19883,
4784,
4461,
197,
7568,
50856,
25,
2643,
64883,
445,
19883,
65310,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestScanRightDeleteRandom(t *testing.T) {
const numElements = 1000
const numTimes = 100
const numScanners = 10
l := New()
stop := make(chan struct{})
els := make([]*CElement, numElements)
for i := 0; i < numElements; i++ {
el := l.PushBack(i)
els[i] = el
}
// Launch scanner routines that will rapidly iterate over elements.
for i := 0; i < numScanners; i++ {
go func(scannerID int) {
var el *CElement
restartCounter := 0
counter := 0
FOR_LOOP:
for {
select {
case <-stop:
fmt.Println("stopped")
break FOR_LOOP
default:
}
if el == nil {
el = l.FrontWait()
restartCounter++
}
el = el.Next()
counter++
}
fmt.Printf("Scanner %v restartCounter: %v counter: %v\n", scannerID, restartCounter, counter)
}(i)
}
// Remove an element, push back an element.
for i := 0; i < numTimes; i++ {
// Pick an element to remove
rmElIdx := cmn.RandIntn(len(els))
rmEl := els[rmElIdx]
// Remove it
l.Remove(rmEl)
//fmt.Print(".")
// Insert a new element
newEl := l.PushBack(-1*i - 1)
els[rmElIdx] = newEl
if i%100000 == 0 {
fmt.Printf("Pushed %vK elements so far...\n", i/1000)
}
}
// Stop scanners
close(stop)
// time.Sleep(time.Second * 1)
// And remove all the elements.
for el := l.Front(); el != nil; el = el.Next() {
l.Remove(el)
}
if l.Len() != 0 {
t.Fatal("Failed to remove all elements from CList")
}
} | explode_data.jsonl/12513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 707
} | [
2830,
3393,
26570,
5979,
6435,
13999,
1155,
353,
8840,
836,
8,
8022,
4777,
1629,
11868,
284,
220,
16,
15,
15,
15,
319,
4777,
1629,
18889,
284,
220,
16,
15,
15,
319,
4777,
1629,
3326,
24003,
284,
220,
16,
15,
871,
8810,
1669,
1532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOnDemandGossip(t *testing.T) {
t.Parallel()
// Scenario: update the metadata and ensure only 1 dissemination
// takes place when membership is not empty
cs := &cryptoService{}
adapter := new(gossipAdapterMock)
configureAdapter(adapter)
gossipedEvents := make(chan struct{})
conf := conf
conf.PublishStateInfoInterval = time.Millisecond * 200
adapter.On("GetConf").Return(conf)
adapter.On("GetMembership").Return([]discovery.NetworkMember{})
adapter.On("Gossip", mock.Anything).Run(func(mock.Arguments) {
gossipedEvents <- struct{}{}
})
adapter.On("Forward", mock.Anything)
gc := NewGossipChannel(pkiIDInOrg1, orgInChannelA, cs, channelA, adapter, api.JoinChannelMessage(&joinChanMsg{}),
disabledMetrics)
defer gc.Stop()
select {
case <-gossipedEvents:
assert.Fail(t, "Should not have gossiped because metadata has not been updated yet")
case <-time.After(time.Millisecond * 500):
}
gc.UpdateLedgerHeight(0)
select {
case <-gossipedEvents:
case <-time.After(time.Second):
assert.Fail(t, "Didn't gossip within a timely manner")
}
select {
case <-gossipedEvents:
case <-time.After(time.Second):
assert.Fail(t, "Should have gossiped a second time, because membership is empty")
}
adapter = new(gossipAdapterMock)
configureAdapter(adapter, []discovery.NetworkMember{{}}...)
adapter.On("Gossip", mock.Anything).Run(func(mock.Arguments) {
gossipedEvents <- struct{}{}
})
adapter.On("Forward", mock.Anything)
gc.(*gossipChannel).Adapter = adapter
select {
case <-gossipedEvents:
case <-time.After(time.Second):
assert.Fail(t, "Should have gossiped a third time")
}
select {
case <-gossipedEvents:
assert.Fail(t, "Should not have gossiped a fourth time, because dirty flag should have been turned off")
case <-time.After(time.Millisecond * 500):
}
gc.UpdateLedgerHeight(1)
select {
case <-gossipedEvents:
case <-time.After(time.Second):
assert.Fail(t, "Should have gossiped a block now, because got a new StateInfo message")
}
} | explode_data.jsonl/66332 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 690
} | [
2830,
3393,
1925,
81027,
38,
41473,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
58663,
25,
2647,
279,
11160,
323,
5978,
1172,
220,
16,
86664,
198,
197,
322,
4990,
1992,
979,
15871,
374,
537,
4287,
271,
71899,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLogger(t *testing.T) {
runTests(t, func(t *testing.T, test testCase, c *Config) {
l := c.Logger
assert.Equal(t, testPkg+test.mark, l.Package)
assert.Equal(t, testLevel+test.mark, l.Level)
assert.Equal(t, logFile+test.mark, l.File)
assert.Equal(t, logColors, l.Colors)
assert.Equal(t, logTimestamp+test.mark, l.Timestamp)
assert.Len(t, l.Fields, 2)
fields := newKeyValueMap(l.Fields)
for k, v := range fields {
assert.Equal(t, testFields[k]+test.mark, v)
}
})
} | explode_data.jsonl/20566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
7395,
1155,
353,
8840,
836,
8,
341,
56742,
18200,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
1273,
54452,
11,
272,
353,
2648,
8,
341,
197,
8810,
1669,
272,
12750,
198,
197,
6948,
12808,
1155,
11,
1273,
47,
7351,
10,
1944,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapProxy_Destroy(t *testing.T) {
testKey := "testingKey"
testValue := "testingValue"
mp.Put(testKey, testValue)
mp.Destroy()
mp, _ := client.GetMap("myMap")
res, err := mp.Get(testKey)
AssertNilf(t, err, res, "get returned a wrong value")
} | explode_data.jsonl/57041 | {
"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,
2227,
16219,
79266,
1155,
353,
8840,
836,
8,
341,
18185,
1592,
1669,
330,
8840,
1592,
698,
18185,
1130,
1669,
330,
8840,
1130,
698,
53230,
39825,
8623,
1592,
11,
1273,
1130,
340,
53230,
57011,
741,
53230,
11,
716,
1669,
2943... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parseRequestUnicastTransmissionMultiTLV(t *testing.T) {
raw := []uint8{0x0c, 0x02, 0x00, 0x4a, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x59, 0x9f, 0xff, 0xfe, 0x55, 0xaf, 0x4e, 0x00, 0x01, 0x00, 0x00, 0x05, 0x7f, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x04, 0x00, 0x06, 0xb0, 0x01, 0x00, 0x00, 0x00, 0x3c, // first TLV
0x00, 0x04, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, // second TLV
0x00, 0x04, 0x00, 0x06, 0x90, 0x01, 0x00, 0x00, 0x00, 0x3c, // third TLV
0x00, 0x00, // extra 2 bytes for udp6 checksum
}
packet := new(Signaling)
err := FromBytes(raw, packet)
require.Nil(t, err)
want := Signaling{
Header: Header{
SdoIDAndMsgType: NewSdoIDAndMsgType(MessageSignaling, 0),
Version: 2,
MessageLength: uint16(len(raw) - 2),
DomainNumber: 0,
MinorSdoID: 0,
FlagField: FlagUnicast,
CorrectionField: 0,
MessageTypeSpecific: 0,
SourcePortIdentity: PortIdentity{
PortNumber: 1,
ClockIdentity: 13283824497738493774,
},
SequenceID: 0,
ControlField: 5,
LogMessageInterval: 0x7f,
},
TargetPortIdentity: PortIdentity{
PortNumber: 0xffff,
ClockIdentity: 0xffffffffffffffff,
},
TLVs: []TLV{
&RequestUnicastTransmissionTLV{
TLVHead: TLVHead{
TLVType: TLVRequestUnicastTransmission,
LengthField: 6,
},
MsgTypeAndReserved: NewUnicastMsgTypeAndFlags(MessageAnnounce, 0),
LogInterMessagePeriod: 1,
DurationField: 60,
},
&RequestUnicastTransmissionTLV{
TLVHead: TLVHead{
TLVType: TLVRequestUnicastTransmission,
LengthField: 6,
},
MsgTypeAndReserved: NewUnicastMsgTypeAndFlags(MessageSync, 0),
LogInterMessagePeriod: 1,
DurationField: 60,
},
&RequestUnicastTransmissionTLV{
TLVHead: TLVHead{
TLVType: TLVRequestUnicastTransmission,
LengthField: 6,
},
MsgTypeAndReserved: NewUnicastMsgTypeAndFlags(MessageDelayResp, 0),
LogInterMessagePeriod: 1,
DurationField: 60,
},
},
}
require.Equal(t, want, *packet)
b, err := Bytes(packet)
require.Nil(t, err)
assert.Equal(t, raw, b)
// test generic DecodePacket as well
pp, err := DecodePacket(raw)
require.Nil(t, err)
assert.Equal(t, &want, pp)
} | explode_data.jsonl/25148 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1231
} | [
2830,
3393,
21039,
1900,
1806,
35446,
91201,
20358,
13470,
53,
1155,
353,
8840,
836,
8,
341,
76559,
1669,
3056,
2496,
23,
90,
15,
87,
15,
66,
11,
220,
15,
87,
15,
17,
11,
220,
15,
87,
15,
15,
11,
220,
15,
87,
19,
64,
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... | 1 |
func TestDeletePod(t *testing.T) {
stopCh := make(chan struct{})
fakeClientset := fake.NewSimpleClientset()
controller := NewNoExecuteTaintManager(fakeClientset, getPodFromClientset(fakeClientset), getNodeFromClientset(fakeClientset), getPodsAssignedToNode(fakeClientset))
controller.recorder = testutil.NewFakeRecorder()
go controller.Run(stopCh)
controller.taintedNodes = map[string][]v1.Taint{
"node1": {createNoExecuteTaint(1)},
}
controller.PodUpdated(testutil.NewPod("pod1", "node1"), nil)
// wait a bit to see if nothing will panic
time.Sleep(timeForControllerToProgress)
close(stopCh)
} | explode_data.jsonl/47586 | {
"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,
6435,
23527,
1155,
353,
8840,
836,
8,
341,
62644,
1143,
1669,
1281,
35190,
2036,
37790,
1166,
726,
2959,
746,
1669,
12418,
7121,
16374,
2959,
746,
741,
61615,
1669,
1532,
2753,
17174,
51,
1641,
2043,
74138,
2959,
746,
11,
63... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCopySchemaShardTask(t *testing.T) {
fake := fakevtctlclient.NewFakeVtctlClient()
vtctlclient.RegisterFactory("fake", fake.FakeVtctlClientFactory)
flag.Set("vtctl_client_protocol", "fake")
fake.RegisterResult([]string{"CopySchemaShard", "test_keyspace/0", "test_keyspace/2"},
"", // No output.
nil) // No error.
task := &CopySchemaShardTask{}
parameters := map[string]string{
"keyspace": "test_keyspace",
"source_shard": "0",
"dest_shard": "2",
"vtctld_endpoint": "localhost:15000",
}
err := validateParameters(task, parameters)
if err != nil {
t.Fatalf("Not all required parameters were specified: %v", err)
}
newTasks, _ /* output */, err := task.Run(parameters)
if newTasks != nil {
t.Errorf("Task should not emit new tasks: %v", newTasks)
}
if err != nil {
t.Errorf("Task should not fail: %v", err)
}
} | explode_data.jsonl/79109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
12106,
8632,
2016,
567,
6262,
1155,
353,
8840,
836,
8,
341,
1166,
726,
1669,
12418,
9708,
12373,
2972,
7121,
52317,
53,
83,
12373,
2959,
741,
5195,
83,
12373,
2972,
19983,
4153,
445,
30570,
497,
12418,
991,
726,
53,
83,
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... | 4 |
func TestNewSingleListener(t *testing.T) {
// mock ingress rules
rs := []extensions.IngressRule{
{
Host: hosts[0],
IngressRuleValue: extensions.IngressRuleValue{
HTTP: &extensions.HTTPIngressRuleValue{
Paths: []extensions.HTTPIngressPath{{
Path: paths[0],
Backend: extensions.IngressBackend{
ServiceName: svcs[0],
ServicePort: intstr.IntOrString{
Type: 0,
IntVal: svcPorts[0],
},
},
},
},
},
},
},
}
// mock ingress options
o := &NewDesiredListenersOptions{
Annotations: &annotations.Annotations{
Ports: []annotations.PortData{{ports[0], "HTTP"}},
IgnoreHostHeader: aws.Bool(false),
},
Logger: logger,
IngressRules: rs,
}
// validate expected listener results vs actual
ls, err := NewDesiredListeners(o)
if err != nil {
t.Errorf("Failed to create listeners. Error: %s", err.Error())
}
expProto := "HTTP"
if schemes[0] {
expProto = "HTTPS"
}
switch {
case len(ls) != 1:
t.Errorf("Created %d listeners, should have been %d", len(ls), 1)
case *ls[0].ls.desired.Port != ports[0]:
t.Errorf("Port was %d should have been %d", *ls[0].ls.desired.Port, ports[0])
case *ls[0].ls.desired.Protocol != expProto:
t.Errorf("Invalid protocol was %s should have been %s", *ls[0].ls.desired.Protocol, expProto)
case len(ls[0].rules) != 2:
t.Errorf("Quantity of rules attached to listener is invalid. Was %d, expected %d.", len(ls[0].rules), 2)
}
} | explode_data.jsonl/27659 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 645
} | [
2830,
3393,
3564,
10888,
2743,
1155,
353,
8840,
836,
8,
341,
197,
322,
7860,
78559,
5601,
198,
41231,
1669,
3056,
27609,
5337,
2483,
11337,
515,
197,
197,
515,
298,
197,
9296,
25,
18432,
58,
15,
1259,
298,
70167,
2483,
11337,
1130,
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... | 7 |
func TestOutputIntegrationTableTest(t *testing.T) {
buf := &bytes.Buffer{}
shouldFail := []Output{
{Output: buf, SendOutputToError: true},
}
shouldPass := []Output{
{Output: buf, Error: buf},
{SuppressError: true, SuppressOutput: true},
{Output: buf, SendErrorToOutput: true},
}
for idx, opt := range shouldFail {
assert.Error(t, opt.Validate(), "%d: %+v", idx, opt)
}
for idx, opt := range shouldPass {
assert.NoError(t, opt.Validate(), "%d: %+v", idx, opt)
}
} | explode_data.jsonl/4847 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
5097,
52464,
2556,
2271,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
609,
9651,
22622,
16094,
197,
5445,
19524,
1669,
3056,
5097,
515,
197,
197,
90,
5097,
25,
6607,
11,
11000,
5097,
1249,
1454,
25,
830,
1583,
197,
630,
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 TestRecordCodec_NativeToBinary_Map(t *testing.T) {
record := map[interface{}]interface{}{
"age": 20,
"name": "bob",
"address": "20. Classy Street",
"date": time.Now(),
}
var codec codecs.RecordCodec
encoded, err := codec.NativeToBinary(record, []byte{})
if err != nil {
tests.FailedWithError(err, "Should have successfully encoded value with record codec")
}
tests.Passed("Should have successfully encoded value with record codec")
if jsonEncoded, err := json.Marshal(record); err == nil {
tests.Info("JSON Encoded Length: %d", len(jsonEncoded))
tests.Info("Voxa Encoded Length: %d", len(encoded))
}
res := &(map[interface{}]interface{}{})
err = codec.BinaryToNative(encoded, reflect.ValueOf(res))
if err != nil {
tests.FailedWithError(err, "Should have successfully decoded value with record codec")
}
tests.Passed("Should have successfully decoded value with record codec")
if !matchAllIn(getValues(record), getValues(*res)) {
tests.Failed("Should have matching values in input and output")
}
tests.Passed("Should have matching values in input and output")
} | explode_data.jsonl/29908 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 375
} | [
2830,
3393,
6471,
36913,
98233,
1249,
21338,
56992,
1155,
353,
8840,
836,
8,
341,
71952,
1669,
2415,
58,
4970,
78134,
4970,
67066,
197,
197,
1,
424,
788,
257,
220,
17,
15,
345,
197,
197,
31486,
788,
262,
330,
47086,
756,
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... | 5 |
func TestRangeFindAll(t *testing.T) {
for _, test := range []struct {
rs Ranges
r Range
want []FoundRange
wantNext Range
wantPresent bool
}{
{
r: Range{Pos: 1, Size: 0},
rs: Ranges{},
want: []FoundRange(nil),
},
{
r: Range{Pos: 1, Size: 1},
rs: Ranges{},
want: []FoundRange{
{
R: Range{Pos: 1, Size: 1},
Present: false,
},
},
},
{
r: Range{Pos: 1, Size: 2},
rs: Ranges{
Range{Pos: 1, Size: 10},
},
want: []FoundRange{
{
R: Range{Pos: 1, Size: 2},
Present: true,
},
},
},
{
r: Range{Pos: 1, Size: 10},
rs: Ranges{
Range{Pos: 1, Size: 2},
},
want: []FoundRange{
{
R: Range{Pos: 1, Size: 2},
Present: true,
},
{
R: Range{Pos: 3, Size: 8},
Present: false,
},
},
},
{
r: Range{Pos: 5, Size: 5},
rs: Ranges{
Range{Pos: 4, Size: 2},
Range{Pos: 7, Size: 1},
Range{Pos: 9, Size: 2},
},
want: []FoundRange{
{
R: Range{Pos: 5, Size: 1},
Present: true,
},
{
R: Range{Pos: 6, Size: 1},
Present: false,
},
{
R: Range{Pos: 7, Size: 1},
Present: true,
},
{
R: Range{Pos: 8, Size: 1},
Present: false,
},
{
R: Range{Pos: 9, Size: 1},
Present: true,
},
},
},
} {
what := fmt.Sprintf("test r=%v, rs=%v", test.r, test.rs)
checkRanges(t, test.rs, what)
got := test.rs.FindAll(test.r)
assert.Equal(t, test.want, got, what)
}
} | explode_data.jsonl/2642 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 922
} | [
2830,
3393,
6046,
9885,
2403,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
41231,
688,
431,
5520,
198,
197,
7000,
1843,
16437,
198,
197,
50780,
286,
3056,
6650,
6046,
198,
197,
50780,
5847,
262,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRegistryConfigurationSignaureTopLevel(t *testing.T) {
config := registryConfiguration{
DefaultDocker: ®istryNamespace{SigStore: "=default", SigStoreStaging: "=default+w"},
Docker: map[string]registryNamespace{},
}
for _, ns := range []string{
"localhost",
"localhost:5000",
"example.com",
"example.com/ns1",
"example.com/ns1/ns2",
"example.com/ns1/ns2/repo",
"example.com/ns1/ns2/repo:notlatest",
} {
config.Docker[ns] = registryNamespace{SigStore: ns, SigStoreStaging: ns + "+w"}
}
for _, c := range []struct{ input, expected string }{
{"example.com/ns1/ns2/repo:notlatest", "example.com/ns1/ns2/repo:notlatest"},
{"example.com/ns1/ns2/repo:unmatched", "example.com/ns1/ns2/repo"},
{"example.com/ns1/ns2/notrepo:notlatest", "example.com/ns1/ns2"},
{"example.com/ns1/notns2/repo:notlatest", "example.com/ns1"},
{"example.com/notns1/ns2/repo:notlatest", "example.com"},
{"unknown.example.com/busybox", "=default"},
{"localhost:5000/busybox", "localhost:5000"},
{"localhost/busybox", "localhost"},
{"localhost:9999/busybox", "=default"},
} {
dr := dockerRefFromString(t, "//"+c.input)
res := config.signatureTopLevel(dr, false)
assert.Equal(t, c.expected, res, c.input)
res = config.signatureTopLevel(dr, true) // test that forWriting is correctly propagated
assert.Equal(t, c.expected+"+w", res, c.input)
}
config = registryConfiguration{
Docker: map[string]registryNamespace{
"unmatched": {SigStore: "a", SigStoreStaging: "b"},
},
}
dr := dockerRefFromString(t, "//thisisnotmatched")
res := config.signatureTopLevel(dr, false)
assert.Equal(t, "", res)
res = config.signatureTopLevel(dr, true)
assert.Equal(t, "", res)
} | explode_data.jsonl/63963 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 696
} | [
2830,
3393,
15603,
7688,
7264,
64,
552,
5366,
4449,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
19424,
7688,
515,
197,
91084,
35,
13659,
25,
609,
29172,
22699,
90,
47246,
6093,
25,
37827,
2258,
497,
41560,
6093,
623,
4118,
25,
37827,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNewIoBufferBytes(t *testing.T) {
for i := 0; i < 1024; i++ {
s := randString(i)
b := NewIoBufferBytes([]byte(s))
if !bytes.Equal(b.Bytes(), []byte(s)) {
t.Errorf("Expect %s but got %s", s, b.String())
}
}
} | explode_data.jsonl/24047 | {
"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,
3564,
42799,
4095,
7078,
1155,
353,
8840,
836,
8,
341,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
17,
19,
26,
600,
1027,
341,
197,
1903,
1669,
10382,
703,
1956,
340,
197,
2233,
1669,
1532,
42799,
4095,
7078,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckLocalDns(t *testing.T) {
for resolv, result := range map[string]bool{`# Dynamic
nameserver 10.0.2.3
search docker.com`: false,
`# Dynamic
#nameserver 127.0.0.1
nameserver 10.0.2.3
search docker.com`: false,
`# Dynamic
nameserver 10.0.2.3 #not used 127.0.1.1
search docker.com`: false,
`# Dynamic
#nameserver 10.0.2.3
#search docker.com`: true,
`# Dynamic
nameserver 127.0.0.1
search docker.com`: true,
`# Dynamic
nameserver 127.0.1.1
search docker.com`: true,
`# Dynamic
`: true,
``: true,
} {
if CheckLocalDns([]byte(resolv)) != result {
t.Fatalf("Wrong local dns detection: {%s} should be %v", resolv, result)
}
}
} | explode_data.jsonl/57524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 281
} | [
2830,
3393,
3973,
7319,
35,
4412,
1155,
353,
8840,
836,
8,
341,
2023,
592,
35315,
11,
1102,
1669,
2088,
2415,
14032,
96436,
90,
63,
2,
21886,
198,
11400,
2836,
220,
16,
15,
13,
15,
13,
17,
13,
18,
198,
1836,
26588,
905,
44622,
895... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerKeepAliveMonitor(t *testing.T) {
inactivityDetected := false
ld, err := coapNet.NewListenUDP("udp4", "")
require.NoError(t, err)
defer func() {
err := ld.Close()
require.NoError(t, err)
}()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*8)
defer cancel()
checkClose := semaphore.NewWeighted(2)
err = checkClose.Acquire(ctx, 2)
require.NoError(t, err)
sd := udp.NewServer(
udp.WithOnNewClientConn(func(cc *client.ClientConn) {
cc.AddOnClose(func() {
checkClose.Release(1)
})
}),
udp.WithKeepAlive(3, 100*time.Millisecond, func(cc inactivity.ClientConn) {
require.False(t, inactivityDetected)
inactivityDetected = true
err := cc.Close()
require.NoError(t, err)
}),
udp.WithPeriodicRunner(periodic.New(ctx.Done(), time.Millisecond*10)),
)
var serverWg sync.WaitGroup
defer func() {
sd.Stop()
serverWg.Wait()
}()
serverWg.Add(1)
go func() {
defer serverWg.Done()
err := sd.Serve(ld)
require.NoError(t, err)
}()
cc, err := udp.Dial(
ld.LocalAddr().String(),
udp.WithInactivityMonitor(time.Millisecond*10, func(cc inactivity.ClientConn) {
time.Sleep(time.Millisecond * 500)
err := cc.Close()
require.NoError(t, err)
}),
udp.WithPeriodicRunner(periodic.New(ctx.Done(), time.Millisecond*10)),
)
require.NoError(t, err)
cc.AddOnClose(func() {
checkClose.Release(1)
})
// send ping to create serverside connection
ctx, cancel = context.WithTimeout(ctx, time.Second)
defer cancel()
err = cc.Ping(ctx)
require.NoError(t, err)
err = checkClose.Acquire(ctx, 2)
require.NoError(t, err)
require.True(t, inactivityDetected)
} | explode_data.jsonl/34014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 686
} | [
2830,
3393,
5475,
19434,
32637,
30098,
1155,
353,
8840,
836,
8,
341,
17430,
7175,
17076,
1569,
1669,
895,
271,
197,
507,
11,
1848,
1669,
1062,
391,
6954,
7121,
38714,
41648,
445,
31101,
19,
497,
14676,
17957,
35699,
1155,
11,
1848,
340,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFileMoveBadPath(t *testing.T) {
createTestFile()
eng := New()
err := eng.Execute(`$file.move('test', '/blah/test');`)
if err == nil {
t.Fail()
}
defer os.Remove("test")
} | explode_data.jsonl/36288 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
1703,
9860,
17082,
1820,
1155,
353,
8840,
836,
8,
341,
39263,
2271,
1703,
741,
197,
826,
1669,
1532,
741,
9859,
1669,
2922,
13827,
5809,
3,
1192,
13635,
492,
1944,
516,
3353,
70614,
12697,
4667,
24183,
743,
1848,
621,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestZipContainsAllInternalTables(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop(context.Background())
rows, err := db.Query(`
SELECT concat('crdb_internal.', table_name) as name FROM [ SHOW TABLES FROM crdb_internal ] WHERE
table_name NOT IN (
-- whitelisted tables that don't need to be in debug zip
'backward_dependencies',
'builtin_functions',
'create_statements',
'forward_dependencies',
'index_columns',
'table_columns',
'table_indexes',
'ranges',
'ranges_no_leases',
'predefined_comments',
'session_trace',
'session_variables',
'tables'
)
ORDER BY name ASC`)
assert.NoError(t, err)
var tables []string
for rows.Next() {
var table string
assert.NoError(t, rows.Scan(&table))
tables = append(tables, table)
}
tables = append(tables, "system.jobs", "system.descriptor", "system.namespace")
sort.Strings(tables)
var exp []string
exp = append(exp, debugZipTablesPerNode...)
exp = append(exp, debugZipTablesPerCluster...)
sort.Strings(exp)
assert.Equal(t, exp, tables)
} | explode_data.jsonl/43507 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
31047,
23805,
2403,
11569,
21670,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
1903,
11,
2927,
11,
716,
1669,
3538,
6031,
12101,
5475,
1155,
11,
2331,
8787,
5475,
4117,
37790,
16867,
274,
775... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeployInjectOverrideCommandClearsOldCommandButNotArgs(t *testing.T) {
f := newIBDFixture(t, k8s.EnvGKE)
defer f.TearDown()
cmd := model.ToUnixCmd("./foo.sh bar")
manifest := NewSanchoDockerBuildManifestWithYaml(f, testyaml.SanchoYAMLWithCommand)
iTarg := manifest.ImageTargetAt(0).WithOverrideCommand(cmd)
manifest = manifest.WithImageTarget(iTarg)
_, err := f.ibd.BuildAndDeploy(f.ctx, f.st, buildTargets(manifest), store.BuildStateSet{})
if err != nil {
t.Fatal(err)
}
entities, err := k8s.ParseYAMLFromString(f.k8s.Yaml)
if err != nil {
t.Fatal(err)
}
if !assert.Equal(t, 1, len(entities)) {
return
}
d := entities[0].Obj.(*v1.Deployment)
if !assert.Equal(t, 1, len(d.Spec.Template.Spec.Containers)) {
return
}
c := d.Spec.Template.Spec.Containers[0]
assert.Equal(t, cmd.Argv, c.Command)
assert.Equal(t, []string{"something", "something_else"}, c.Args)
} | explode_data.jsonl/38273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
69464,
13738,
2177,
4062,
14008,
82,
18284,
4062,
3983,
2623,
4117,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
3256,
5262,
12735,
1155,
11,
595,
23,
82,
81214,
38,
3390,
340,
16867,
282,
836,
682,
4454,
2822,
25920,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPathPayment(t *testing.T) {
kp0 := newKeypair0()
kp2 := newKeypair2()
sourceAccount := NewSimpleAccount(kp2.Address(), int64(187316408680450))
abcdAsset := CreditAsset{"ABCD", kp0.Address()}
pathPayment := PathPayment{
SendAsset: NativeAsset{},
SendMax: "10",
Destination: kp2.Address(),
DestAsset: NativeAsset{},
DestAmount: "1",
Path: []Asset{abcdAsset},
}
received, err := newSignedTransaction(
TransactionParams{
SourceAccount: &sourceAccount,
IncrementSequenceNum: true,
Operations: []Operation{&pathPayment},
BaseFee: MinBaseFee,
Timebounds: NewInfiniteTimeout(),
},
network.TestNetworkPassphrase,
kp2,
)
assert.NoError(t, err)
expected := "AAAAAgAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAGQAAKpdAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgAAAAAAAAAABfXhAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAAAAJiWgAAAAAEAAAABQUJDRAAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAAAAAAABLhVZmAAAAEBdpC1C/0aBSMtXJrfhl3Vp9rQ1IyWFd2MBeAPNsyAYamEjuqIDqCzzUbd8PiBggIH0eEPZaWsfsAl1qEBER0sO"
assert.Equal(t, expected, received, "Base 64 XDR should match")
} | explode_data.jsonl/20682 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 573
} | [
2830,
3393,
1820,
20188,
1155,
353,
8840,
836,
8,
341,
16463,
79,
15,
1669,
501,
6608,
1082,
1310,
15,
741,
16463,
79,
17,
1669,
501,
6608,
1082,
1310,
17,
741,
47418,
7365,
1669,
1532,
16374,
7365,
5969,
79,
17,
26979,
1507,
526,
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 TestValidateGenesis(t *testing.T) {
genValidators1 := make([]types.Validator, 1, 5)
pk := ed25519.GenPrivKey().PubKey()
genValidators1[0] = types.NewValidator(sdk.ValAddress(pk.Address()), pk, types.NewDescription("", "", "", ""))
genValidators1[0].Tokens = sdk.OneDec()
genValidators1[0].DelegatorShares = sdk.OneDec()
tests := []struct {
name string
mutate func(*types.GenesisState)
wantErr bool
}{
{"default", func(*types.GenesisState) {}, false},
// validate genesis validators
{"duplicate validator", func(data *types.GenesisState) {
(*data).Validators = genValidators1
(*data).Validators = append((*data).Validators, genValidators1[0])
}, true},
{"no delegator shares", func(data *types.GenesisState) {
(*data).Validators = genValidators1
(*data).Validators[0].DelegatorShares = sdk.ZeroDec()
}, true},
{"jailed and bonded validator", func(data *types.GenesisState) {
(*data).Validators = genValidators1
(*data).Validators[0].Jailed = true
(*data).Validators[0].Status = sdk.Bonded
}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
genesisState := types.DefaultGenesisState()
tt.mutate(&genesisState)
if tt.wantErr {
assert.Error(t, ValidateGenesis(genesisState))
} else {
assert.NoError(t, ValidateGenesis(genesisState))
}
})
}
} | explode_data.jsonl/9753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 537
} | [
2830,
3393,
17926,
84652,
1155,
353,
8840,
836,
8,
341,
82281,
31748,
16,
1669,
1281,
10556,
9242,
13,
14256,
11,
220,
16,
11,
220,
20,
340,
3223,
74,
1669,
1578,
17,
20,
20,
16,
24,
65384,
32124,
1592,
1005,
29162,
1592,
741,
82281... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPos(t *testing.T) {
// corner case: empty source
s := new(Scanner).Init(strings.NewReader(""))
checkPos(t, s.Pos(), Position{Offset: 0, Line: 1, Column: 1})
s.Peek() // peek doesn't affect the position
checkPos(t, s.Pos(), Position{Offset: 0, Line: 1, Column: 1})
// corner case: source with only a newline
s = new(Scanner).Init(strings.NewReader("\n"))
checkPos(t, s.Pos(), Position{Offset: 0, Line: 1, Column: 1})
checkNextPos(t, s, 1, 2, 1, '\n')
// after EOF position doesn't change
for i := 10; i > 0; i-- {
checkScanPos(t, s, 1, 2, 1, EOF)
}
if s.ErrorCount != 0 {
t.Errorf("%d errors", s.ErrorCount)
}
// corner case: source with only a single character
s = new(Scanner).Init(strings.NewReader("本"))
checkPos(t, s.Pos(), Position{Offset: 0, Line: 1, Column: 1})
checkNextPos(t, s, 3, 1, 2, '本')
// after EOF position doesn't change
for i := 10; i > 0; i-- {
checkScanPos(t, s, 3, 1, 2, EOF)
}
if s.ErrorCount != 0 {
t.Errorf("%d errors", s.ErrorCount)
}
// positions after calling Next
s = new(Scanner).Init(strings.NewReader(" foo६४ \n\n本語\n"))
checkNextPos(t, s, 1, 1, 2, ' ')
s.Peek() // peek doesn't affect the position
checkNextPos(t, s, 2, 1, 3, ' ')
checkNextPos(t, s, 3, 1, 4, 'f')
checkNextPos(t, s, 4, 1, 5, 'o')
checkNextPos(t, s, 5, 1, 6, 'o')
checkNextPos(t, s, 8, 1, 7, '६')
checkNextPos(t, s, 11, 1, 8, '४')
checkNextPos(t, s, 12, 1, 9, ' ')
checkNextPos(t, s, 13, 1, 10, ' ')
checkNextPos(t, s, 14, 2, 1, '\n')
checkNextPos(t, s, 15, 3, 1, '\n')
checkNextPos(t, s, 18, 3, 2, '本')
checkNextPos(t, s, 21, 3, 3, '語')
checkNextPos(t, s, 22, 4, 1, '\n')
// after EOF position doesn't change
for i := 10; i > 0; i-- {
checkScanPos(t, s, 22, 4, 1, EOF)
}
if s.ErrorCount != 0 {
t.Errorf("%d errors", s.ErrorCount)
}
// positions after calling Scan
s = new(Scanner).Init(strings.NewReader("abc\n本語\n\nx"))
s.Mode = 0
s.Whitespace = 0
checkScanPos(t, s, 0, 1, 1, 'a')
s.Peek() // peek doesn't affect the position
checkScanPos(t, s, 1, 1, 2, 'b')
checkScanPos(t, s, 2, 1, 3, 'c')
checkScanPos(t, s, 3, 1, 4, '\n')
checkScanPos(t, s, 4, 2, 1, '本')
checkScanPos(t, s, 7, 2, 2, '語')
checkScanPos(t, s, 10, 2, 3, '\n')
checkScanPos(t, s, 11, 3, 1, '\n')
checkScanPos(t, s, 12, 4, 1, 'x')
// after EOF position doesn't change
for i := 10; i > 0; i-- {
checkScanPos(t, s, 13, 4, 2, EOF)
}
if s.ErrorCount != 0 {
t.Errorf("%d errors", s.ErrorCount)
}
} | explode_data.jsonl/56537 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1132
} | [
2830,
3393,
4859,
1155,
353,
8840,
836,
8,
341,
197,
322,
9131,
1142,
25,
4287,
2530,
198,
1903,
1669,
501,
7,
31002,
568,
3803,
51442,
68587,
73303,
25157,
4859,
1155,
11,
274,
44208,
1507,
12380,
90,
6446,
25,
220,
15,
11,
7083,
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... | 9 |
func TestServicePackagesInvalidType(t *testing.T) {
assert := assert.New(t)
collection := servicePackagesCollection()
var route Route
route.Name = kong.String("my-route")
route.ID = kong.String("first")
txn := collection.db.Txn(true)
txn.Insert(servicePackageTableName, &route)
txn.Commit()
assert.Panics(func() {
collection.Get("my-route")
})
assert.Panics(func() {
collection.GetAll()
})
} | explode_data.jsonl/51007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
1860,
69513,
7928,
929,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
1444,
1908,
1669,
2473,
69513,
6482,
2822,
2405,
6021,
9572,
198,
7000,
2133,
2967,
284,
595,
644,
6431,
445,
2408,
81559,
1138,
7000,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTLSClusterOf3UsingDiscovery(t *testing.T) {
defer testutil.AfterTest(t)
dc := NewCluster(t, 1)
dc.Launch(t)
defer dc.Terminate(t)
// init discovery token space
dcc := MustNewHTTPClient(t, dc.URLs(), nil)
dkapi := client.NewKeysAPI(dcc)
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
if _, err := dkapi.Create(ctx, "/_config/size", fmt.Sprintf("%d", 3)); err != nil {
t.Fatal(err)
}
cancel()
c := NewClusterByConfig(t,
&ClusterConfig{
Size: 3,
PeerTLS: &testTLSInfo,
DiscoveryURL: dc.URL(0) + "/v2/keys"},
)
c.Launch(t)
defer c.Terminate(t)
clusterMustProgress(t, c.Members)
} | explode_data.jsonl/16291 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
13470,
3540,
75,
4993,
2124,
18,
16429,
67400,
1155,
353,
8840,
836,
8,
341,
16867,
1273,
1314,
36892,
2271,
1155,
340,
87249,
1669,
1532,
28678,
1155,
11,
220,
16,
340,
87249,
1214,
18423,
1155,
340,
16867,
19402,
836,
261,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileHeaderRoundTrip64(t *testing.T) {
fh := &FileHeader{
Name: "foo.txt",
UncompressedSize64: 9876543210,
ModifiedTime: 1234,
ModifiedDate: 5678,
}
testHeaderRoundTrip(fh, uint32max, fh.UncompressedSize64, t)
} | explode_data.jsonl/18860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
1703,
4047,
27497,
56352,
21,
19,
1155,
353,
8840,
836,
8,
341,
1166,
71,
1669,
609,
1703,
4047,
515,
197,
21297,
25,
2290,
330,
7975,
3909,
756,
197,
197,
1806,
45703,
1695,
21,
19,
25,
220,
24,
23,
22,
21,
20,
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 TestHeadTracker_ResubscribeOnSubscriptionError(t *testing.T) {
t.Parallel()
g := gomega.NewGomegaWithT(t)
db := pgtest.NewGormDB(t)
config := newCfg(t)
orm := headtracker.NewORM(db, cltest.FixtureChainID)
ethClient, sub := cltest.NewEthClientAndSubMockWithDefaultChain(t)
chchHeaders := make(chan chan<- *eth.Head, 1)
ethClient.On("SubscribeNewHead", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) { chchHeaders <- args.Get(1).(chan<- *eth.Head) }).
Twice().
Return(sub, nil)
ethClient.On("HeadByNumber", mock.Anything, (*big.Int)(nil)).Return(cltest.Head(0), nil)
sub.On("Unsubscribe").Return()
sub.On("Err").Return(nil)
checker := &cltest.MockHeadTrackable{}
ht := createHeadTrackerWithChecker(ethClient, config, orm, checker)
// connect
assert.Nil(t, ht.Start())
assert.Equal(t, int32(0), checker.OnNewLongestChainCount())
headers := <-chchHeaders
g.Eventually(func() bool { return ht.headTracker.Connected() }, 5*time.Second, 5*time.Millisecond).Should(gomega.Equal(true))
// trigger reconnect loop
close(headers)
// wait for full disconnect and a new subscription
g.Eventually(func() int32 { return checker.OnNewLongestChainCount() }, 5*time.Second, 5*time.Millisecond).Should(gomega.Equal(int32(1)))
// stop
assert.NoError(t, ht.Stop())
} | explode_data.jsonl/63751 | {
"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,
12346,
31133,
92815,
392,
6273,
1925,
33402,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
20939,
1669,
17495,
1944,
7121,
38,
493,
3506,
1155,
340,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInfoCacheInit(t *testing.T) {
log, buf := logging.NewTestLogger(t.Name())
defer common.ShowBufferOnFailure(t, buf)
enabled := atm.NewBool(true)
scanResults := []netdetect.FabricScan{
{Provider: "ofi+sockets", DeviceName: "eth0_node0", NUMANode: 0},
{Provider: "ofi+sockets", DeviceName: "eth1_node0", NUMANode: 0},
{Provider: "ofi+sockets", DeviceName: "eth2_node0", NUMANode: 0},
{Provider: "ofi+sockets", DeviceName: "eth3_node0", NUMANode: 0},
{Provider: "ofi+sockets", DeviceName: "eth0_node1", NUMANode: 1},
{Provider: "ofi+sockets", DeviceName: "eth1_node1", NUMANode: 1},
{Provider: "ofi+sockets", DeviceName: "eth0_node2", NUMANode: 2},
{Provider: "ofi+sockets", DeviceName: "eth1_node2", NUMANode: 2},
{Provider: "ofi+sockets", DeviceName: "eth2_node2", NUMANode: 2},
{Provider: "ofi+sockets", DeviceName: "eth3_node2", NUMANode: 2}}
aiCache := attachInfoCache{log: log, enabled: enabled}
err := aiCache.initResponseCache(&mgmtpb.GetAttachInfoResp{}, scanResults)
common.AssertEqual(t, err, nil, "initResponseCache error")
for name, tc := range map[string]struct {
numaNode int
numDevs int
}{
"info cache response for numa 0": {
numaNode: 0,
numDevs: 4,
},
"info cache response for numa 1": {
numaNode: 1,
numDevs: 2,
},
"info cache response for numa 2": {
numaNode: 2,
numDevs: 4,
},
} {
t.Run(name, func(t *testing.T) {
numDevs := len(aiCache.numaDeviceMarshResp[tc.numaNode])
common.AssertEqual(t, numDevs, tc.numDevs,
fmt.Sprintf("initResponseCache error - expected %d cached responses, got %d", tc.numDevs, numDevs))
})
}
} | explode_data.jsonl/33011 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 676
} | [
2830,
3393,
1731,
8233,
3803,
1155,
353,
8840,
836,
8,
341,
6725,
11,
6607,
1669,
8392,
7121,
2271,
7395,
1155,
2967,
2398,
16867,
4185,
9060,
4095,
1925,
17507,
1155,
11,
6607,
340,
197,
15868,
1669,
69787,
7121,
11233,
3715,
340,
1903... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewServer(t *testing.T) {
t.Log("Run through NewServer constructor")
tmpDir, err := ioutil.TempDir("", "")
Ok(t, err)
_, err = server.NewServer(server.UserConfig{
DataDir: tmpDir,
AtlantisURL: "http://example.com",
}, server.Config{})
Ok(t, err)
} | explode_data.jsonl/15313 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
3564,
5475,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
445,
6727,
1526,
1532,
5475,
4692,
1138,
20082,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
197,
11578,
1155,
11,
1848,
340,
197,
6878,
1848,
284,
3538,
7121,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteBoard(t *testing.T) {
ctx := context.Background()
board := createTestBoard(ctx)
city := createTestCity(ctx, board.ID)
space := app.CitySpace{
CityID: city.ID,
Order: 1,
SpaceType: app.TraderID,
}
var err error
if err = repo.CreateCitySpace(ctx, &space); err != nil {
t.Fatalf("Error saving test space: %+v", err)
}
if city, err = repo.GetCityByID(ctx, city.ID); err != nil {
t.Fatalf("Error reloading city: %+v", err)
}
if len(city.CitySpaces) != 1 {
t.Error("CitySpaces HasMany relationship is not loading")
}
req := httptest.NewRequest("DELETE", fmt.Sprintf("/boards/%d", board.ID), nil)
req.Header.Set("X-Requested-With", "XMLHttpRequest")
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
if !httpassert.Success(t, w) {
t.Log("Body:", w.Body)
}
httpassert.JavascriptContentType(t, w)
} | explode_data.jsonl/12550 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
6435,
11932,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
59868,
1669,
1855,
2271,
11932,
7502,
340,
1444,
487,
1669,
1855,
2271,
12730,
7502,
11,
4479,
9910,
340,
1903,
1306,
1669,
906,
58794,
9914,
515,
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... | 5 |
func TestDriver(t *testing.T) {
var tests = []validationTest{
{
value: "vkasdhfasjdf",
shouldErr: true,
},
{
value: "",
shouldErr: true,
},
}
runValidations(t, tests, "vm-driver", IsValidDriver)
} | explode_data.jsonl/77929 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
11349,
1155,
353,
8840,
836,
8,
1476,
2405,
7032,
284,
3056,
12284,
2271,
515,
197,
197,
515,
298,
16309,
25,
257,
330,
48363,
300,
30621,
14847,
73,
2940,
756,
298,
197,
5445,
7747,
25,
830,
345,
197,
197,
1583,
197,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateDataPlaneNamespace(t *testing.T) {
testCases := []struct {
ns string
result string
}{
{
"",
"data-plane-ns-test-cat data plane namespace exists",
},
{
"bad-ns",
"data-plane-ns-test-cat data plane namespace exists: The \"bad-ns\" namespace does not exist",
},
}
for i, tc := range testCases {
tc := tc // pin
t.Run(fmt.Sprintf("%d/%s", i, tc.ns), func(t *testing.T) {
hc := NewHealthChecker(
[]CategoryID{},
&Options{
DataPlaneNamespace: tc.ns,
},
)
var err error
hc.kubeAPI, err = k8s.NewFakeAPI()
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}
// create a synthetic category that only includes the "data plane namespace exists" check
hc.addCheckAsCategory("data-plane-ns-test-cat", LinkerdDataPlaneChecks, "data plane namespace exists")
expectedResults := []string{
tc.result,
}
obs := newObserver()
hc.RunChecks(obs.resultFn)
if !reflect.DeepEqual(obs.results, expectedResults) {
t.Fatalf("Expected results %v, but got %v", expectedResults, obs.results)
}
})
}
} | explode_data.jsonl/19143 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 467
} | [
2830,
3393,
17926,
1043,
34570,
22699,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
84041,
257,
914,
198,
197,
9559,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
39680,
298,
197,
97115,
89549,
12,
4412,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAdjustGrandparentOverlapBytesForFlush(t *testing.T) {
// 500MB in Lbase
var lbaseFiles []*manifest.FileMetadata
const lbaseSize = 5 << 20
for i := 0; i < 100; i++ {
lbaseFiles =
append(lbaseFiles, &manifest.FileMetadata{Size: lbaseSize, FileNum: FileNum(i)})
}
const maxOutputFileSize = 2 << 20
// 20MB max overlap, so flush split into 25 files.
const maxOverlapBytes = 20 << 20
ls := manifest.NewLevelSliceSpecificOrder(lbaseFiles)
testCases := []struct {
flushingBytes uint64
adjustedOverlapBytes uint64
}{
// Flushes large enough that 25 files is acceptable.
{flushingBytes: 128 << 20, adjustedOverlapBytes: 20971520},
{flushingBytes: 64 << 20, adjustedOverlapBytes: 20971520},
// Small increase in adjustedOverlapBytes.
{flushingBytes: 32 << 20, adjustedOverlapBytes: 32768000},
// Large increase in adjusterOverlapBytes, to limit to 4 files.
{flushingBytes: 1 << 20, adjustedOverlapBytes: 131072000},
}
for _, tc := range testCases {
t.Run("", func(t *testing.T) {
c := compaction{
grandparents: ls,
maxOverlapBytes: maxOverlapBytes,
maxOutputFileSize: maxOutputFileSize,
}
adjustGrandparentOverlapBytesForFlush(&c, tc.flushingBytes)
require.Equal(t, tc.adjustedOverlapBytes, c.maxOverlapBytes)
})
}
} | explode_data.jsonl/51422 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 479
} | [
2830,
3393,
38616,
40151,
3765,
82171,
7078,
2461,
46874,
1155,
353,
8840,
836,
8,
341,
197,
322,
220,
20,
15,
15,
8412,
304,
444,
3152,
198,
2405,
326,
3152,
10809,
29838,
42315,
8576,
14610,
198,
4777,
326,
3152,
1695,
284,
220,
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 TestAttributes_FilterSpans(t *testing.T) {
testCases := []testCase{
{
name: "apply processor",
serviceName: "svcB",
inputAttributes: map[string]pdata.AttributeValue{},
expectedAttributes: map[string]pdata.AttributeValue{
"attribute1": pdata.NewAttributeValueInt(123),
},
},
{
name: "apply processor with different value for exclude property",
serviceName: "svcB",
inputAttributes: map[string]pdata.AttributeValue{
"NoModification": pdata.NewAttributeValueBool(false),
},
expectedAttributes: map[string]pdata.AttributeValue{
"attribute1": pdata.NewAttributeValueInt(123),
"NoModification": pdata.NewAttributeValueBool(false),
},
},
{
name: "incorrect name for include property",
serviceName: "noname",
inputAttributes: map[string]pdata.AttributeValue{},
expectedAttributes: map[string]pdata.AttributeValue{},
},
{
name: "attribute match for exclude property",
serviceName: "svcB",
inputAttributes: map[string]pdata.AttributeValue{
"NoModification": pdata.NewAttributeValueBool(true),
},
expectedAttributes: map[string]pdata.AttributeValue{
"NoModification": pdata.NewAttributeValueBool(true),
},
},
}
factory := NewFactory()
cfg := factory.CreateDefaultConfig()
oCfg := cfg.(*Config)
oCfg.Actions = []processorhelper.ActionKeyValue{
{Key: "attribute1", Action: processorhelper.INSERT, Value: 123},
}
oCfg.Include = &filterconfig.MatchProperties{
Services: []string{"svcA", "svcB.*"},
Config: *createConfig(filterset.Regexp),
}
oCfg.Exclude = &filterconfig.MatchProperties{
Attributes: []filterconfig.Attribute{
{Key: "NoModification", Value: true},
},
Config: *createConfig(filterset.Strict),
}
tp, err := factory.CreateTracesProcessor(context.Background(), component.ProcessorCreateSettings{}, cfg, consumertest.NewNop())
require.Nil(t, err)
require.NotNil(t, tp)
for _, tt := range testCases {
runIndividualTestCase(t, tt, tp)
}
} | explode_data.jsonl/76281 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 796
} | [
2830,
3393,
10516,
68935,
6406,
596,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
66194,
515,
197,
197,
515,
298,
11609,
25,
310,
330,
10280,
17654,
756,
298,
52934,
675,
25,
257,
330,
58094,
33,
756,
298,
22427,
10516,
25,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStatefulSetControllerCreates(t *testing.T) {
set := newStatefulSet(3)
ssc, spc, _ := newFakeStatefulSetController(set)
if err := scaleUpStatefulSetController(set, ssc, spc); err != nil {
t.Errorf("Failed to turn up StatefulSet : %s", err)
}
if obj, _, err := spc.setsIndexer.Get(set); err != nil {
t.Error(err)
} else {
set = obj.(*apps.StatefulSet)
}
if set.Status.Replicas != 3 {
t.Errorf("set.Status.Replicas = %v; want 3", set.Status.Replicas)
}
} | explode_data.jsonl/18605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
1397,
1262,
1649,
2051,
54868,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
36848,
1262,
1649,
7,
18,
340,
34472,
66,
11,
978,
66,
11,
716,
1669,
501,
52317,
1397,
1262,
1649,
2051,
14171,
340,
743,
1848,
1669,
5452,
2324,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFlowAction(t *testing.T) {
permit, err := policydb.GetFlowDescriptionFromFlowString("permit in ip from any to any")
assert.NoError(t, err)
assert.Equal(t, permit.Action, protos.FlowDescription_PERMIT)
deny, err := policydb.GetFlowDescriptionFromFlowString("deny in ip from any to any")
assert.NoError(t, err)
assert.Equal(t, deny.Action, protos.FlowDescription_DENY)
} | explode_data.jsonl/76962 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
18878,
2512,
1155,
353,
8840,
836,
8,
341,
197,
39681,
11,
1848,
1669,
4842,
1999,
2234,
18878,
5009,
3830,
18878,
703,
445,
39681,
304,
5997,
504,
894,
311,
894,
1138,
6948,
35699,
1155,
11,
1848,
340,
6948,
12808,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_emailBody(t *testing.T) {
type args struct {
callbackURL string
expiry string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
{
name: "valid mail body",
args: args{
callbackURL: "https://example.com",
expiry: "expiry_date",
},
want: fmt.Sprintf(
DefaultEmailOTPPayload,
"https://example.com",
"expiry_date",
),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := emailBody(tt.args.callbackURL, tt.args.expiry); got != tt.want {
t.Errorf("emailBody() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/58089 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
9172,
5444,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
43350,
3144,
914,
198,
197,
48558,
33770,
414,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
5078... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRegisterMsgServiceTwice(t *testing.T) {
// Setup baseapp.
encCfg := simapp.MakeTestEncodingConfig()
msr := middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry)
testdata.RegisterInterfaces(encCfg.InterfaceRegistry)
// First time registering service shouldn't panic.
require.NotPanics(t, func() {
testdata.RegisterMsgServer(
msr,
testdata.MsgServerImpl{},
)
})
// Second time should panic.
require.Panics(t, func() {
testdata.RegisterMsgServer(
msr,
testdata.MsgServerImpl{},
)
})
} | explode_data.jsonl/2231 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
8690,
6611,
1860,
22816,
558,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
2331,
676,
624,
197,
954,
42467,
1669,
1643,
676,
50133,
2271,
14690,
2648,
741,
47691,
81,
1669,
29679,
7121,
6611,
1860,
9523,
66941,
42467,
4106... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJSONPatch(t *testing.T) {
tests := []struct {
obj runtime.Object
fragment string
expected runtime.Object
expectErr bool
}{
{
obj: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"run": "test",
},
},
},
fragment: `[ {"op": "add", "path": "/metadata/labels/foo", "value": "bar"} ]`,
expected: &corev1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"run": "test",
"foo": "bar",
},
},
Spec: corev1.PodSpec{},
},
},
{
obj: &corev1.Pod{},
fragment: "invalid json",
expected: &corev1.Pod{},
expectErr: true,
},
{
obj: &corev1.Pod{},
fragment: `[ {"op": "add", "path": "/metadata/labels/foo", "value": "bar"} ]`,
expectErr: true,
},
}
codec := runtime.NewCodec(scheme.DefaultJSONEncoder(),
scheme.Codecs.UniversalDecoder(scheme.Scheme.PrioritizedVersionsAllGroups()...))
for i, test := range tests {
out, err := JSONPatch(codec, test.obj, test.fragment)
if !test.expectErr {
if err != nil {
t.Errorf("testcase[%d], unexpected error: %v", i, err)
} else if !apiequality.Semantic.DeepEqual(test.expected, out) {
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out))
}
}
if test.expectErr && err == nil {
t.Errorf("testcase[%d], unexpected non-error", i)
}
}
} | explode_data.jsonl/38772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 749
} | [
2830,
3393,
5370,
43622,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22671,
981,
15592,
8348,
198,
197,
1166,
6017,
220,
914,
198,
197,
42400,
220,
15592,
8348,
198,
197,
24952,
7747,
1807,
198,
197,
59403,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInstrumentationLibrarySpansSlice_CopyTo(t *testing.T) {
dest := NewInstrumentationLibrarySpansSlice()
// Test CopyTo to empty
NewInstrumentationLibrarySpansSlice().CopyTo(dest)
assert.EqualValues(t, NewInstrumentationLibrarySpansSlice(), dest)
// Test CopyTo larger slice
generateTestInstrumentationLibrarySpansSlice().CopyTo(dest)
assert.EqualValues(t, generateTestInstrumentationLibrarySpansSlice(), dest)
// Test CopyTo same size slice
generateTestInstrumentationLibrarySpansSlice().CopyTo(dest)
assert.EqualValues(t, generateTestInstrumentationLibrarySpansSlice(), dest)
} | explode_data.jsonl/63247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
56324,
367,
16915,
6406,
596,
33236,
77637,
1249,
1155,
353,
8840,
836,
8,
341,
49616,
1669,
1532,
56324,
367,
16915,
6406,
596,
33236,
741,
197,
322,
3393,
14540,
1249,
311,
4287,
198,
197,
3564,
56324,
367,
16915,
6406,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGet(t *testing.T) {
defer leaktest.AfterTest(t)()
emptyKeys := []roachpb.KeyValue{}
someKeys := []roachpb.KeyValue{
plainKV("a", "vala"),
plainKV("c", "valc"),
plainKV("d", "vald"),
}
aVal := roachpb.MakeValueFromString("vala")
bVal := roachpb.MakeValueFromString("valc")
cVal := roachpb.MakeValueFromString("vald")
testCases := []struct {
values []roachpb.KeyValue
key string
value *roachpb.Value
}{
{emptyKeys, "a", nil},
{emptyKeys, "b", nil},
{emptyKeys, "c", nil},
{emptyKeys, "d", nil},
{emptyKeys, "e", nil},
{someKeys, "", nil},
{someKeys, "b", nil},
{someKeys, "e", nil},
{someKeys, "a0", nil},
{someKeys, "a", &aVal},
{someKeys, "c", &bVal},
{someKeys, "d", &cVal},
}
cfg := config.NewSystemConfig(config.DefaultZoneConfigRef())
for tcNum, tc := range testCases {
cfg.Values = tc.values
if val := cfg.GetValue([]byte(tc.key)); !proto.Equal(val, tc.value) {
t.Errorf("#%d: expected=%s, found=%s", tcNum, tc.value, val)
}
}
} | explode_data.jsonl/25320 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 449
} | [
2830,
3393,
1949,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
197,
3194,
8850,
1669,
3056,
64500,
16650,
9610,
1130,
16094,
1903,
635,
8850,
1669,
3056,
64500,
16650,
9610,
1130,
515,
197,
197,
20772,
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... | 3 |
func TestBuildTags_UpdatePolicy_None(t *testing.T) {
c := buildCluster(ClusterParams{CloudProvider: "aws", UpdatePolicy: api.UpdatePolicyExternal})
tags, err := buildCloudupTags(c)
if err != nil {
t.Fatalf("buildTags error: %v", err)
}
nodeUpTags, err := buildNodeupTags(api.InstanceGroupRoleNode, c, tags)
if err != nil {
t.Fatalf("buildNodeupTags error: %v", err)
}
if nodeUpTags.Has("_automatic_upgrades") {
t.Fatal("nodeUpTag _automatic_upgrades found unexpectedly")
}
} | explode_data.jsonl/27906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
11066,
15930,
47393,
13825,
52523,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1936,
28678,
43644,
4993,
4870,
90,
16055,
5179,
25,
330,
8635,
497,
5549,
13825,
25,
6330,
16689,
13825,
25913,
8824,
3244,
2032,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStatus_Update(t *testing.T) {
mockdriver := MockSchedulerDriver{}
// setup expectations
mockdriver.On("KillTask", util.NewTaskID("test-task-001")).Return(mesos.Status_DRIVER_RUNNING, nil)
testScheduler := &KubernetesScheduler{
offers: offers.CreateRegistry(offers.RegistryConfig{
Compat: func(o *mesos.Offer) bool {
return true
},
// remember expired offers so that we can tell if a previously scheduler offer relies on one
LingerTTL: schedcfg.DefaultOfferLingerTTL,
TTL: schedcfg.DefaultOfferTTL,
ListenerDelay: schedcfg.DefaultListenerDelay,
}),
slaves: newSlaveStorage(),
driver: &mockdriver,
taskRegistry: podtask.NewInMemoryRegistry(),
}
taskStatus_task_starting := util.NewTaskStatus(
util.NewTaskID("test-task-001"),
mesos.TaskState_TASK_RUNNING,
)
testScheduler.StatusUpdate(testScheduler.driver, taskStatus_task_starting)
taskStatus_task_running := util.NewTaskStatus(
util.NewTaskID("test-task-001"),
mesos.TaskState_TASK_RUNNING,
)
testScheduler.StatusUpdate(testScheduler.driver, taskStatus_task_running)
taskStatus_task_failed := util.NewTaskStatus(
util.NewTaskID("test-task-001"),
mesos.TaskState_TASK_FAILED,
)
testScheduler.StatusUpdate(testScheduler.driver, taskStatus_task_failed)
//assert that mock was invoked
mockdriver.AssertExpectations(t)
} | explode_data.jsonl/63776 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 527
} | [
2830,
3393,
2522,
47393,
1155,
353,
8840,
836,
8,
1476,
77333,
12521,
1669,
14563,
38878,
11349,
16094,
197,
322,
6505,
16665,
198,
77333,
12521,
8071,
445,
53734,
6262,
497,
4094,
7121,
6262,
915,
445,
1944,
52579,
12,
15,
15,
16,
1519... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTransaction(t *testing.T) {
t.Skip()
client := NewClient(&Config{
URL: "https://api-kylin.eosasia.one",
Debug: true,
})
tx, err := client.GetTransaction("3d43785ceca9a919e73b547487d9da6dad246f05425e513035e373c67310bc47")
if err != nil {
t.Error(err)
}
fmt.Println(tx)
} | explode_data.jsonl/58351 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
1949,
8070,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
741,
25291,
1669,
1532,
2959,
2099,
2648,
515,
197,
79055,
25,
256,
330,
2428,
1110,
2068,
12,
7891,
3732,
1734,
436,
35159,
30973,
756,
197,
34424,
25,
830,
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... | 2 |
func TestWorkQueueOneTaskWithCancel(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
q := NewWorkQueue(ctx)
q.Add("some work", func(ctx context.Context) error {
time.Sleep(10 * time.Millisecond)
return nil
})
q.Wait()
if q.Err() == nil {
t.Error("expected error")
return
}
expected := "context canceled"
if q.Err().Error() != expected {
t.Errorf("expected error %q, got: %q", q.Err().Error(), expected)
}
} | explode_data.jsonl/23555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 176
} | [
2830,
3393,
6776,
7554,
3966,
6262,
2354,
9269,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
84441,
741,
18534,
1669,
1532,
6776,
7554,
7502,
340,
18534,
1904,
445,
14689,
975,
497,
2915,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRepoLoadsAllTemplatesDefined(t *testing.T) {
var b bytes.Buffer
repo := NewRepository(nil)
err := repo.AddFile("multiple", multipleDefinitions)
assert.NoError(t, err)
templ, err := repo.Get("multiple")
assert.Nil(t, err)
err = templ.Execute(&b, nil)
assert.Nil(t, err)
assert.Equal(t, "", b.String())
templ, err = repo.Get("T1")
assert.Nil(t, err)
err = templ.Execute(&b, nil)
assert.Nil(t, err)
assert.Equal(t, "T1", b.String())
} | explode_data.jsonl/49688 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
25243,
78517,
2403,
51195,
29361,
1155,
353,
8840,
836,
8,
1476,
2405,
293,
5820,
22622,
198,
17200,
5368,
1669,
1532,
4624,
27907,
692,
9859,
1669,
15867,
1904,
1703,
445,
35673,
497,
5248,
50542,
340,
6948,
35699,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestObjectGetString(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionWithObject(t)
defer rollback()
contents, err := c.ObjectGetString(ctx, CONTAINER, OBJECT)
if err != nil {
t.Fatal(err)
}
if contents != CONTENTS {
t.Error("Contents wrong")
}
} | explode_data.jsonl/12682 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
1190,
48905,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
2354,
1190,
1155,
340,
16867,
60414,
741,
197,
17610,
11,
1848,
1669,
272,
8348,
48905,
7502,
11,
16120,
34521,
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... | 3 |
func TestProtocol_HandleWithdrawStake(t *testing.T) {
require := require.New(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
tests := []struct {
// create stake fields
caller address.Address
amount string
initBalance int64
selfstaking bool
// action fields
index uint64
gasPrice *big.Int
gasLimit uint64
nonce uint64
// block context
blkHeight uint64
blkTimestamp time.Time
ctxTimestamp time.Time
blkGasLimit uint64
// if unstake
unstake bool
// withdraw fields
withdrawIndex uint64
// expected result
err error
status iotextypes.ReceiptStatus
}{
// fetchCaller ErrNotEnoughBalance
{
identityset.Address(2),
"100990000000000000000",
101,
false,
0,
big.NewInt(unit.Qev),
10000,
1,
1,
time.Now(),
time.Now(),
10000,
true,
0,
nil,
iotextypes.ReceiptStatus_ErrNotEnoughBalance,
},
// fetchBucket ReceiptStatus_ErrInvalidBucketIndex
{
identityset.Address(2),
"100000000000000000000",
101,
false,
0,
big.NewInt(unit.Qev),
10000,
1,
1,
time.Now(),
time.Now(),
10000,
true,
1,
nil,
iotextypes.ReceiptStatus_ErrInvalidBucketIndex,
},
// check unstake time,ReceiptStatus_ErrWithdrawBeforeUnstake
{
identityset.Address(2),
"100000000000000000000",
101,
false,
0,
big.NewInt(unit.Qev),
10000,
1,
1,
time.Now(),
time.Now(),
10000,
false,
0,
nil,
iotextypes.ReceiptStatus_ErrWithdrawBeforeUnstake,
},
// check ReceiptStatus_ErrWithdrawBeforeMaturity
{
identityset.Address(2),
"100000000000000000000",
101,
false,
0,
big.NewInt(unit.Qev),
10000,
1,
1,
time.Now(),
time.Now(),
10000,
true,
0,
nil,
iotextypes.ReceiptStatus_ErrWithdrawBeforeMaturity,
},
// delxxx cannot happen,because unstake first called without error
// ReceiptStatus_Success
{
identityset.Address(2),
"100000000000000000000",
101,
false,
0,
big.NewInt(unit.Qev),
10000,
1,
1,
time.Now(),
time.Now().Add(time.Hour * 500),
10000,
true,
0,
nil,
iotextypes.ReceiptStatus_Success,
},
}
for _, test := range tests {
sm, p, _, candidate, _ := initAll(t, ctrl)
require.NoError(setupAccount(sm, test.caller, test.initBalance))
ctx, createCost := initCreateStake(t, sm, candidate.Owner, test.initBalance, big.NewInt(unit.Qev), test.gasLimit, test.nonce, test.blkHeight, test.blkTimestamp, test.blkGasLimit, p, candidate, test.amount, false)
var actCost *big.Int
if test.unstake {
act, err := action.NewUnstake(test.nonce, test.index, nil, test.gasLimit, big.NewInt(unit.Qev))
require.NoError(err)
intrinsic, err := act.IntrinsicGas()
actCost, err = act.Cost()
require.NoError(err)
require.NoError(err)
ctx = protocol.WithActionCtx(context.Background(), protocol.ActionCtx{
Caller: test.caller,
GasPrice: test.gasPrice,
IntrinsicGas: intrinsic,
Nonce: test.nonce + 1,
})
ctx = protocol.WithBlockCtx(ctx, protocol.BlockCtx{
BlockHeight: 1,
BlockTimeStamp: time.Now().Add(time.Duration(1) * 24 * time.Hour),
GasLimit: 1000000,
})
_, err = p.Handle(ctx, act, sm)
require.NoError(err)
}
withdraw, err := action.NewWithdrawStake(test.nonce, test.withdrawIndex,
nil, test.gasLimit, test.gasPrice)
require.NoError(err)
actionCtx := protocol.MustGetActionCtx(ctx)
blkCtx := protocol.MustGetBlockCtx(ctx)
ctx = protocol.WithActionCtx(context.Background(), protocol.ActionCtx{
Caller: actionCtx.Caller,
GasPrice: actionCtx.GasPrice,
IntrinsicGas: actionCtx.IntrinsicGas,
Nonce: actionCtx.Nonce + 1,
})
ctx = protocol.WithBlockCtx(ctx, protocol.BlockCtx{
BlockHeight: blkCtx.BlockHeight,
BlockTimeStamp: test.ctxTimestamp,
GasLimit: blkCtx.GasLimit,
})
r, err := p.Handle(ctx, withdraw, sm)
require.Equal(test.err, errors.Cause(err))
if r != nil {
require.Equal(uint64(test.status), r.Status)
} else {
require.Equal(test.status, iotextypes.ReceiptStatus_Failure)
}
if test.err == nil && test.status == iotextypes.ReceiptStatus_Success {
// test bucket index and bucket
_, err := getCandBucketIndices(sm, candidate.Owner)
require.Error(err)
_, err = getVoterBucketIndices(sm, candidate.Owner)
require.Error(err)
// test staker's account
caller, err := accountutil.LoadAccount(sm, hash.BytesToHash160(test.caller.Bytes()))
require.NoError(err)
withdrawCost, err := withdraw.Cost()
require.NoError(err)
require.Equal(test.nonce+2, caller.Nonce)
total := big.NewInt(0)
withdrawAmount, ok := new(big.Int).SetString(test.amount, 10)
require.True(ok)
require.Equal(unit.ConvertIotxToRau(test.initBalance), total.Add(total, caller.Balance).Add(total, actCost).Add(total, withdrawCost).Add(total, createCost).Sub(total, withdrawAmount))
}
}
} | explode_data.jsonl/64533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2206
} | [
2830,
3393,
20689,
42714,
92261,
623,
726,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
340,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
741,
78216,
1669,
3056,
1235,
341,
197,
197,
322,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestCodeUint8(t *testing.T) {
var buf = make([]byte, 1)
var v uint8 = 128
var n uint64
n = EncodeUint8(buf, v)
var d uint8
n = DecodeUint8(buf[:n], &d)
if v != d {
t.Errorf("error %d != %d", v, d)
}
if n != 1 {
t.Errorf("error %d != %d", n, len(buf[:n]))
}
} | explode_data.jsonl/58545 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
2078,
21570,
23,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
284,
1281,
10556,
3782,
11,
220,
16,
340,
2405,
348,
2622,
23,
284,
220,
16,
17,
23,
198,
2405,
308,
2622,
21,
19,
198,
9038,
284,
56562,
21570,
23,
10731,
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... | 3 |
func TestReconcileAnalysisRunTerminateSiblingAfterFail(t *testing.T) {
f := newFixture(t)
defer f.Close()
c, _, _ := f.newController(noResyncPeriodFunc)
// mocks terminate to cancel the in-progress measurement
f.provider.On("Terminate", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(newMeasurement(v1alpha1.AnalysisPhaseSuccessful), nil)
for _, status := range []v1alpha1.AnalysisPhase{v1alpha1.AnalysisPhaseFailed, v1alpha1.AnalysisPhaseInconclusive, v1alpha1.AnalysisPhaseError} {
run := newTerminatingRun(status, false)
newRun := c.reconcileAnalysisRun(run)
assert.Equal(t, status, newRun.Status.Phase)
assert.Equal(t, status, newRun.Status.MetricResults[1].Phase)
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, newRun.Status.MetricResults[0].Phase)
// ensure the in-progress measurement is now terminated
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, newRun.Status.MetricResults[0].Measurements[0].Phase)
assert.NotNil(t, newRun.Status.MetricResults[0].Measurements[0].FinishedAt)
assert.Equal(t, "Metric Terminated", newRun.Status.MetricResults[0].Message)
assert.Equal(t, "Metric Terminated", newRun.Status.MetricResults[0].Measurements[0].Message)
}
} | explode_data.jsonl/75830 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 426
} | [
2830,
3393,
693,
40446,
457,
26573,
6727,
62519,
35643,
6025,
19524,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
10421,
741,
1444,
11,
8358,
716,
1669,
282,
4618,
2051,
39205,
1061,
1721,
23750,
9626,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStatesSpecError(t *testing.T) {
mux := new(http.ServeMux)
mux.HandleFunc("/oauth/token", serveJSON("{\"access_token\": \"ghi789\"}"))
mux.HandleFunc("/api/1/vehicles", serveJSON(VehiclesJSON))
mux.HandleFunc("/api/1/vehicles/1234/", serveJSON(ErrorJSON))
ts := httptest.NewServer(mux)
defer ts.Close()
client := NewTestClient(ts)
Convey("Should get error", t, func() {
vehicles, _ := client.Vehicles()
vehicle := vehicles[0]
_, err := vehicle.VehicleState()
So(err, ShouldNotBeNil)
})
} | explode_data.jsonl/18855 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
23256,
8327,
1454,
1155,
353,
8840,
836,
8,
341,
2109,
2200,
1669,
501,
19886,
83535,
44,
2200,
340,
2109,
2200,
63623,
4283,
34363,
54386,
497,
8683,
5370,
99141,
5211,
6458,
11693,
7245,
75076,
22,
23,
24,
2105,
92,
5455,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImageSave(t *testing.T) {
expectedURL := "/images/get"
client := &Client{
client: newMockClient(func(r *http.Request) (*http.Response, error) {
if !strings.HasPrefix(r.URL.Path, expectedURL) {
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, r.URL)
}
query := r.URL.Query()
names := query["names"]
expectedNames := []string{"image_id1", "image_id2"}
if !reflect.DeepEqual(names, expectedNames) {
return nil, fmt.Errorf("names not set in URL query properly. Expected %v, got %v", names, expectedNames)
}
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte("response"))),
}, nil
}),
}
saveResponse, err := client.ImageSave(context.Background(), []string{"image_id1", "image_id2"})
if err != nil {
t.Fatal(err)
}
response, err := ioutil.ReadAll(saveResponse)
if err != nil {
t.Fatal(err)
}
saveResponse.Close()
if string(response) != "response" {
t.Fatalf("expected response to contain 'response', got %s", string(response))
}
} | explode_data.jsonl/22737 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 420
} | [
2830,
3393,
1906,
8784,
1155,
353,
8840,
836,
8,
341,
42400,
3144,
1669,
3521,
3642,
23302,
698,
25291,
1669,
609,
2959,
515,
197,
25291,
25,
501,
11571,
2959,
18552,
2601,
353,
1254,
9659,
8,
4609,
1254,
12574,
11,
1465,
8,
341,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPlanCachePointGetAndTableDual(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
orgEnable := core.PreparedPlanCacheEnabled()
defer core.SetPreparedPlanCache(orgEnable)
core.SetPreparedPlanCache(true)
se, err := session.CreateSession4TestWithOpt(store, &session.Opt{
PreparedPlanCache: kvcache.NewSimpleLRUCache(100, 0.1, math.MaxUint64),
})
require.NoError(t, err)
tk := testkit.NewTestKitWithSession(t, store, se)
tk.MustExec("use test")
tk.MustExec("drop table if exists t0, t1, t2, t3, t4")
tk.MustExec("create table t0(c1 varchar(20), c2 varchar(20), c3 bigint(20), primary key(c1, c2))")
tk.MustExec("insert into t0 values('0000','7777',1)")
tk.MustExec("prepare s0 from 'select * from t0 where c1=? and c2>=? and c2<=?'")
tk.MustExec("set @a0='0000', @b0='9999'")
// TableDual is forbidden for plan-cache, a TableReader be built and cached.
tk.MustQuery("execute s0 using @a0, @b0, @a0").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s0 using @a0, @a0, @b0").Check(testkit.Rows("0000 7777 1"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
tk.MustExec("create table t1(c1 varchar(20), c2 varchar(20), c3 bigint(20), primary key(c1, c2))")
tk.MustExec("insert into t1 values('0000','7777',1)")
tk.MustExec("prepare s1 from 'select * from t1 where c1=? and c2>=? and c2<=?'")
tk.MustExec("set @a1='0000', @b1='9999'")
// IndexLookup plan would be built, we should cache it.
tk.MustQuery("execute s1 using @a1, @b1, @b1").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s1 using @a1, @a1, @b1").Check(testkit.Rows("0000 7777 1"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
tk.MustExec("create table t2(c1 bigint(20) primary key, c2 varchar(20))")
tk.MustExec("insert into t2 values(1,'7777')")
tk.MustExec("prepare s2 from 'select * from t2 where c1>=? and c1<=?'")
tk.MustExec("set @a2=0, @b2=9")
// TableReader plan would be built, we should cache it.
tk.MustQuery("execute s2 using @a2, @a2").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s2 using @a2, @b2").Check(testkit.Rows("1 7777"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
tk.MustExec("create table t3(c1 int, c2 int, c3 int, unique key(c1), key(c2))")
tk.MustExec("insert into t3 values(2,1,1)")
tk.MustExec("prepare s3 from 'select /*+ use_index_merge(t3) */ * from t3 where (c1 >= ? and c1 <= ?) or c2 > 1'")
tk.MustExec("set @a3=1,@b3=3")
// TableReader plan would be built, we should cache it.
tk.MustQuery("execute s3 using @a3,@a3").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s3 using @a3,@b3").Check(testkit.Rows("2 1 1"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
tk.MustExec("prepare s3 from 'select /*+ use_index_merge(t3) */ * from t3 where (c1 >= ? and c1 <= ?) or c2 > 1'")
tk.MustExec("set @a3=1,@b3=3")
// TableReader plan would be built, we should cache it.
tk.MustQuery("execute s3 using @b3,@a3").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s3 using @a3,@b3").Check(testkit.Rows("2 1 1"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
tk.MustExec("create table t4(c1 int primary key, c2 int, c3 int, key(c2))")
tk.MustExec("insert into t4 values(2,1,1)")
tk.MustExec("prepare s4 from 'select /*+ use_index_merge(t4) */ * from t4 where (c1 >= ? and c1 <= ?) or c2 > 1'")
tk.MustExec("set @a4=1,@b4=3")
tk.MustQuery("execute s4 using @a4,@a4").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s4 using @a4,@b4").Check(testkit.Rows("2 1 1"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
tk.MustExec("prepare s4 from 'select /*+ use_index_merge(t4) */ * from t4 where (c1 >= ? and c1 <= ?) or c2 > 1'")
tk.MustExec("set @a4=1,@b4=3")
tk.MustQuery("execute s4 using @b4,@a4").Check(testkit.Rows())
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
tk.MustQuery("execute s4 using @a4,@b4").Check(testkit.Rows("2 1 1"))
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
} | explode_data.jsonl/5528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1817
} | [
2830,
3393,
20485,
8233,
2609,
1949,
3036,
2556,
85074,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
87625,
11084,
1669,
6200,
28770,
7212,
20485,
8233,
5462,
741,
16867,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateHTTPAPISpecBinding(t *testing.T) {
var (
validHTTPAPISpecRef = &mccpb.HTTPAPISpecReference{Name: "foo", Namespace: "bar"}
invalidHTTPAPISpecRef = &mccpb.HTTPAPISpecReference{Name: "foo", Namespace: "--bar"}
)
cases := []struct {
name string
in proto.Message
valid bool
}{
{
name: "no service",
in: &mccpb.HTTPAPISpecBinding{
Services: []*mccpb.IstioService{},
ApiSpecs: []*mccpb.HTTPAPISpecReference{validHTTPAPISpecRef},
},
},
{
name: "no spec",
in: &mccpb.HTTPAPISpecBinding{
Services: []*mccpb.IstioService{validService},
ApiSpecs: []*mccpb.HTTPAPISpecReference{},
},
},
{
name: "invalid spec",
in: &mccpb.HTTPAPISpecBinding{
Services: []*mccpb.IstioService{validService},
ApiSpecs: []*mccpb.HTTPAPISpecReference{invalidHTTPAPISpecRef},
},
},
{
name: "valid",
in: &mccpb.HTTPAPISpecBinding{
Services: []*mccpb.IstioService{validService},
ApiSpecs: []*mccpb.HTTPAPISpecReference{validHTTPAPISpecRef},
},
valid: true,
},
}
for _, c := range cases {
if got := ValidateHTTPAPISpecBinding(someName, someNamespace, c.in); (got == nil) != c.valid {
t.Errorf("ValidateHTTPAPISpecBinding(%v): got(%v) != want(%v): %v", c.name, got == nil, c.valid, got)
}
}
} | explode_data.jsonl/56902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 596
} | [
2830,
3393,
17926,
9230,
2537,
1637,
992,
15059,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
56322,
9230,
2537,
1637,
992,
3945,
256,
284,
609,
76,
638,
16650,
27358,
2537,
1637,
992,
8856,
63121,
25,
330,
7975,
497,
41962,
25,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDetachMemo(t *testing.T) {
defer leaktest.AfterTest(t)()
catalog := testcat.New()
if _, err := catalog.ExecuteDDL("CREATE TABLE abc (a INT PRIMARY KEY, b INT, c STRING, INDEX (c))"); err != nil {
t.Fatal(err)
}
var o xform.Optimizer
evalCtx := tree.MakeTestingEvalContext(cluster.MakeTestingClusterSettings())
testutils.BuildQuery(t, &o, catalog, &evalCtx, "SELECT * FROM abc WHERE c=$1")
before := o.DetachMemo()
if !o.Memo().IsEmpty() {
t.Error("memo expression should be reinitialized by DetachMemo")
}
testutils.BuildQuery(t, &o, catalog, &evalCtx, "SELECT a=$1 FROM abc")
after := o.Memo()
if after == before {
t.Error("after memo cannot be the same as the detached memo")
}
if !strings.Contains(after.RootExpr().String(), "variable: a [type=int]") {
t.Error("after memo did not contain expected operator")
}
if after.RootExpr().(memo.RelExpr).Memo() != after {
t.Error("after memo expression does not reference the after memo")
}
if before == o.Memo() {
t.Error("detached memo should not be reused")
}
if before.RootExpr().(memo.RelExpr).Memo() != before {
t.Error("detached memo expression does not reference the detached memo")
}
if !strings.Contains(before.RootExpr().String(), "variable: c [type=string]") {
t.Error("detached memo did not contain expected operator")
}
} | explode_data.jsonl/55156 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
89306,
46402,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1444,
7750,
1669,
1273,
4616,
7121,
741,
743,
8358,
1848,
1669,
16403,
13827,
58781,
445,
22599,
14363,
39022,
320,
64,
9221,
37467,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgRetire(t *testing.T) {
_, _, addr1 := testdata.KeyTestPubAddr()
tests := map[string]struct {
src MsgRetire
expErr bool
}{
"valid msg": {
src: MsgRetire{
Holder: addr1.String(),
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
Amount: "10",
},
},
Location: "AB-CDE FG1 345",
},
expErr: false,
},
"invalid msg without holder": {
src: MsgRetire{
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
Amount: "10",
},
},
Location: "AB-CDE FG1 345",
},
expErr: true,
},
"invalid msg with wrong holder address": {
src: MsgRetire{
Holder: "wrongHolder",
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
Amount: "10",
},
},
Location: "AB-CDE FG1 345",
},
expErr: true,
},
"invalid msg without credits": {
src: MsgRetire{
Holder: addr1.String(),
Location: "AB-CDE FG1 345",
},
expErr: true,
},
"invalid msg without Credits.BatchDenom": {
src: MsgRetire{
Holder: addr1.String(),
Credits: []*MsgRetire_RetireCredits{
{
Amount: "10",
},
},
Location: "AB-CDE FG1 345",
},
expErr: true,
},
"invalid msg without Credits.Amount": {
src: MsgRetire{
Holder: addr1.String(),
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
},
},
Location: "AB-CDE FG1 345",
},
expErr: true,
},
"invalid msg with wrong Credits.Amount": {
src: MsgRetire{
Holder: addr1.String(),
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
Amount: "abc",
},
},
Location: "AB-CDE FG1 345",
},
expErr: true,
},
"invalid msg without location": {
src: MsgRetire{
Holder: addr1.String(),
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
Amount: "10",
},
},
},
expErr: true,
},
"invalid msg with wrong location": {
src: MsgRetire{
Holder: addr1.String(),
Credits: []*MsgRetire_RetireCredits{
{
BatchDenom: "A00-00000000-00000000-000",
Amount: "10",
},
},
Location: "wrongLocation",
},
expErr: true,
},
}
for msg, test := range tests {
t.Run(msg, func(t *testing.T) {
err := test.src.ValidateBasic()
if test.expErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
} | explode_data.jsonl/65130 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1332
} | [
2830,
3393,
6611,
12020,
554,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
10789,
16,
1669,
1273,
691,
9610,
2271,
29162,
13986,
2822,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
41144,
262,
24205,
12020,
554,
198,
197,
48558,
7747,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSSHPOP_authorizeToken(t *testing.T) {
key, err := pemutil.Read("./testdata/secrets/ssh_user_ca_key")
assert.FatalError(t, err)
signer, ok := key.(crypto.Signer)
assert.Fatal(t, ok, "could not cast ssh signing key to crypto signer")
sshSigner, err := ssh.NewSignerFromSigner(signer)
assert.FatalError(t, err)
type test struct {
p *SSHPOP
token string
err error
code int
}
tests := map[string]func(*testing.T) test{
"fail/bad-token": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
return test{
p: p,
token: "foo",
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; error extracting sshpop header from token: extractSSHPOPCert; error parsing token: "),
}
},
"fail/cert-not-yet-valid": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{
CertType: ssh.UserCert,
ValidAfter: uint64(time.Now().Add(time.Minute).Unix()),
}, sshSigner)
assert.FatalError(t, err)
tok, err := generateSSHPOPToken(p, cert, jwk)
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; sshpop certificate validAfter is in the future"),
}
},
"fail/cert-past-validity": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{
CertType: ssh.UserCert,
ValidBefore: uint64(time.Now().Add(-time.Minute).Unix()),
}, sshSigner)
assert.FatalError(t, err)
tok, err := generateSSHPOPToken(p, cert, jwk)
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; sshpop certificate validBefore is in the past"),
}
},
"fail/no-signer-found": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{CertType: ssh.HostCert}, sshSigner)
assert.FatalError(t, err)
tok, err := generateSSHPOPToken(p, cert, jwk)
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; could not find valid ca signer to verify sshpop certificate"),
}
},
"fail/error-parsing-claims-bad-sig": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, _, err := createSSHCert(&ssh.Certificate{CertType: ssh.UserCert}, sshSigner)
assert.FatalError(t, err)
otherJWK, err := jose.GenerateJWK("EC", "P-256", "ES256", "sig", "", 0)
assert.FatalError(t, err)
tok, err := generateSSHPOPToken(p, cert, otherJWK)
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; error parsing sshpop token claims"),
}
},
"fail/invalid-claims-issuer": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{CertType: ssh.UserCert}, sshSigner)
assert.FatalError(t, err)
tok, err := generateToken("foo", "bar", testAudiences.Sign[0], "",
[]string{"test.smallstep.com"}, time.Now(), jwk, withSSHPOPFile(cert))
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; invalid sshpop token"),
}
},
"fail/invalid-audience": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{CertType: ssh.UserCert}, sshSigner)
assert.FatalError(t, err)
tok, err := generateToken("foo", p.GetName(), "invalid-aud", "",
[]string{"test.smallstep.com"}, time.Now(), jwk, withSSHPOPFile(cert))
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; sshpop token has invalid audience claim (aud)"),
}
},
"fail/empty-subject": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{CertType: ssh.UserCert}, sshSigner)
assert.FatalError(t, err)
tok, err := generateToken("", p.GetName(), testAudiences.Sign[0], "",
[]string{"test.smallstep.com"}, time.Now(), jwk, withSSHPOPFile(cert))
assert.FatalError(t, err)
return test{
p: p,
token: tok,
code: http.StatusUnauthorized,
err: errors.New("sshpop.authorizeToken; sshpop token subject cannot be empty"),
}
},
"ok": func(t *testing.T) test {
p, err := generateSSHPOP()
assert.FatalError(t, err)
cert, jwk, err := createSSHCert(&ssh.Certificate{CertType: ssh.UserCert}, sshSigner)
assert.FatalError(t, err)
tok, err := generateSSHPOPToken(p, cert, jwk)
assert.FatalError(t, err)
return test{
p: p,
token: tok,
}
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
tc := tt(t)
if claims, err := tc.p.authorizeToken(tc.token, testAudiences.Sign); err != nil {
sc, ok := err.(errs.StatusCoder)
assert.Fatal(t, ok, "error does not implement StatusCoder interface")
assert.Equals(t, sc.StatusCode(), tc.code)
if assert.NotNil(t, tc.err) {
assert.HasPrefix(t, err.Error(), tc.err.Error())
}
} else {
if assert.Nil(t, tc.err) {
assert.NotNil(t, claims)
}
}
})
}
} | explode_data.jsonl/67184 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2497
} | [
2830,
3393,
62419,
47262,
22938,
551,
3323,
1155,
353,
8840,
836,
8,
341,
23634,
11,
1848,
1669,
54184,
1314,
6503,
13988,
92425,
59587,
52710,
14,
25537,
3317,
49604,
3097,
1138,
6948,
26133,
1454,
1155,
11,
1848,
340,
69054,
261,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestListItem(t *testing.T) {
keyProject := sdk.ProjectKey{
Key: sdk.Key{
Name: "myKey",
Type: "ssh",
Public: "pubb",
Private: "privv",
},
ProjectID: 1,
}
result := listItem(keyProject, nil, false, nil, false, map[string]string{})
assert.Equal(t, 3, len(result))
result = listItem(keyProject, nil, false, []string{"name"}, false, map[string]string{})
assert.Equal(t, map[string]string{"name": "myKey"}, result)
result = listItem(keyProject, nil, false, []string{"NAME"}, false, map[string]string{})
assert.Equal(t, map[string]string{"name": "myKey"}, result)
} | explode_data.jsonl/70359 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
19045,
1155,
353,
8840,
836,
8,
341,
23634,
7849,
1669,
45402,
30944,
1592,
515,
197,
55242,
25,
45402,
9610,
515,
298,
21297,
25,
262,
330,
2408,
1592,
756,
298,
27725,
25,
262,
330,
25537,
756,
298,
73146,
25,
220,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.