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 TestFleetUpdates(t *testing.T) {
t.Parallel()
fixtures := map[string]func() *v1alpha1.Fleet{
"recreate": func() *v1alpha1.Fleet {
flt := defaultFleet()
flt.Spec.Strategy.Type = appsv1.RecreateDeploymentStrategyType
return flt
},
"rolling": func() *v1alpha1.Fleet {
flt := defaultFleet()
flt.Spec.Strategy.Type = appsv1.RollingUpdateDeploymentStrategyType
return flt
},
}
for k, v := range fixtures {
t.Run(k, func(t *testing.T) {
alpha1 := framework.AgonesClient.StableV1alpha1()
flt := v()
flt.Spec.Template.ObjectMeta.Annotations = map[string]string{key: red}
flt, err := alpha1.Fleets(defaultNs).Create(flt)
if assert.Nil(t, err) {
defer alpha1.Fleets(defaultNs).Delete(flt.ObjectMeta.Name, nil) // nolint:errcheck
}
err = framework.WaitForFleetGameServersCondition(flt, func(gs v1alpha1.GameServer) bool {
return gs.ObjectMeta.Annotations[key] == red
})
assert.Nil(t, err)
// if the generation has been updated, it's time to try again.
err = wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
flt, err = framework.AgonesClient.StableV1alpha1().Fleets(defaultNs).Get(flt.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
fltCopy := flt.DeepCopy()
fltCopy.Spec.Template.ObjectMeta.Annotations[key] = green
_, err = framework.AgonesClient.StableV1alpha1().Fleets(defaultNs).Update(fltCopy)
if err != nil {
logrus.WithError(err).Warn("Could not update fleet, trying again")
return false, nil
}
return true, nil
})
assert.Nil(t, err)
err = framework.WaitForFleetGameServersCondition(flt, func(gs v1alpha1.GameServer) bool {
return gs.ObjectMeta.Annotations[key] == green
})
assert.Nil(t, err)
})
}
} | explode_data.jsonl/9437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 758
} | [
2830,
3393,
37,
18973,
37091,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
941,
18513,
1669,
2415,
14032,
60,
2830,
368,
353,
85,
16,
7141,
16,
991,
18973,
515,
197,
197,
1,
265,
3182,
788,
2915,
368,
353,
85,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKMSArnValidateRegion(t *testing.T) {
config := `keyName: test-key-name
s3URI: s3://mybucket/mydir
region: us-west-1
clusterName: test-cluster-name
kmsKeyArn: "arn:aws:kms:eu-west-1:xxxxxxxxx:key/xxxxxxxxxxxxxxxxxxx"
`
confBody := config + externalDNSNameConfig + availabilityZoneConfig
_, err := ClusterFromBytes([]byte(confBody))
if err == nil || !strings.Contains(err.Error(), "same region") {
t.Errorf("Expecting validation error for mismatching KMS key ARN and region config: %s\n%s", err, confBody)
}
} | explode_data.jsonl/4383 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
42,
4826,
58331,
17926,
14091,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
1565,
792,
675,
25,
1273,
16173,
11494,
198,
82,
18,
10301,
25,
274,
18,
1110,
2408,
30410,
34198,
3741,
198,
3943,
25,
601,
37602,
12,
16,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRobotstxtOrg(t *testing.T) {
t.Parallel()
const robotsText005 = `User-agent: Google
Disallow:
User-agent: *
Disallow: /`
r, err := FromString(robotsText005)
require.NoError(t, err)
expectAccess(t, r, false, "/path/page1.html", "SomeBot")
expectAccess(t, r, true, "/path/page1.html", "Googlebot")
} | explode_data.jsonl/51679 | {
"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,
43374,
267,
2252,
42437,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
4777,
28707,
1178,
15,
15,
20,
284,
1565,
1474,
41935,
25,
5085,
198,
87854,
510,
1474,
41935,
25,
1213,
87854,
25,
608,
3989,
7000,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCmdAddTwoContainersWithAnnotation(t *testing.T) {
defer resetGlobalTestVariables()
testContainers = []string{"mockContainer", "mockContainer2"}
testAnnotations[injectAnnotationKey] = "false"
testCmdAdd(t)
} | explode_data.jsonl/17789 | {
"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,
15613,
2212,
11613,
74632,
2354,
19711,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
11646,
2271,
22678,
2822,
18185,
74632,
284,
3056,
917,
4913,
16712,
4502,
497,
330,
16712,
4502,
17,
16707,
18185,
21418,
15375,
583,
19711,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEOF(t *testing.T) {
r := stringReader("")
if _, err := r.ReadSentence(); err != io.EOF {
t.Fatal("EOF should be reached")
}
if _, err := r.ReadSentence(); err != io.EOF {
t.Fatal("reading from an EOF reader should return EOF")
}
} | explode_data.jsonl/43878 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
23483,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
914,
5062,
31764,
743,
8358,
1848,
1669,
435,
6503,
84564,
2129,
1848,
961,
6399,
86492,
341,
197,
3244,
26133,
445,
23483,
1265,
387,
8643,
1138,
197,
630,
743,
8358,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInt32_Remove(t *testing.T) {
testcases := []struct {
name string
s Int32
input []int32
expect []int32
}{
{
name: "test Int32 Remove, inputs nothing",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{},
expect: []int32{1, 2, 3},
},
{
name: "test Int32 Remove, inputs multiple exit elements",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{1, 3},
expect: []int32{2},
},
{
name: "test Int32 Remove, inputs multiple non-exit elements",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{0, 6, 7},
expect: []int32{1, 2, 3},
},
}
for _, tc := range testcases {
t.Logf("running scenario: %s", tc.name)
tc.s.Remove(tc.input...)
validateInt32(t, tc.s, tc.expect)
}
} | explode_data.jsonl/62319 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
1072,
18,
17,
66843,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
1903,
414,
1333,
18,
17,
198,
197,
22427,
220,
3056,
396,
18,
17,
198,
197,
24952,
3056,
396,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfig_URLRetries3FailsThenPasses(t *testing.T) {
httpLoadConfigRetryInterval = 0 * time.Second
responseCounter := 0
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if responseCounter <= 2 {
w.WriteHeader(http.StatusNotFound)
} else {
w.WriteHeader(http.StatusOK)
}
responseCounter++
}))
defer ts.Close()
c := NewConfig()
require.NoError(t, c.LoadConfig(ts.URL))
require.Equal(t, 4, responseCounter)
} | explode_data.jsonl/72178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
2648,
8000,
12020,
4019,
18,
37,
6209,
12209,
12187,
288,
1155,
353,
8840,
836,
8,
341,
28080,
5879,
2648,
51560,
10256,
284,
220,
15,
353,
882,
32435,
198,
21735,
14099,
1669,
220,
15,
198,
57441,
1669,
54320,
70334,
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... | 2 |
func TestExchangeHealth(t *testing.T) {
client := v1.New(nil)
e, err := client.ExchangeHealth(health.NewForExchange(types.FXBTCJPY))
assert.NoError(t, err)
fmt.Printf("%+v\n", e)
} | explode_data.jsonl/41199 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
31564,
14542,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
348,
16,
7121,
27907,
340,
7727,
11,
1848,
1669,
2943,
86997,
14542,
7,
12120,
7121,
2461,
31564,
52613,
991,
55,
59118,
27188,
56,
1171,
6948,
35699,
1155,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSlicesOfDifferentTypesAndOrders(t *testing.T) {
h, err := DefaultFactory.GetHasherWithSalt(SHA256, []byte("12345"))
if err != nil {
t.Fatal("Unable to retrieve SHA256 Hasher")
}
h1 := h.Hash([]interface{}{1, "Hello", float64(3.22)}).H
h2 := h.Hash([]interface{}{"Hello", 1, float64(3.22)}).H
if !bytes.Equal(h1, h2) {
t.Fatal("Slices equivalent, hashes should not be different")
}
} | explode_data.jsonl/42622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
50,
37414,
2124,
69123,
4173,
3036,
24898,
1155,
353,
8840,
836,
8,
1476,
9598,
11,
1848,
1669,
7899,
4153,
2234,
6370,
261,
2354,
47318,
3759,
17020,
17,
20,
21,
11,
3056,
3782,
445,
16,
17,
18,
19,
20,
5455,
743,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNewDatumValue(t *testing.T) {
Convey("datum values should convert", t, func() {
Convey("string should convert", func() {
s1 := "abc"
So(s1, ShouldEqual, NewDatumValue(sfxmodel.Datum{StrValue: &s1}).(datapoint.StringValue).String())
})
Convey("floats should convert", func() {
f1 := 1.2
So(f1, ShouldEqual, NewDatumValue(sfxmodel.Datum{DoubleValue: &f1}).(datapoint.FloatValue).Float())
})
Convey("int should convert", func() {
i1 := int64(3)
So(i1, ShouldEqual, NewDatumValue(sfxmodel.Datum{IntValue: &i1}).(datapoint.IntValue).Int())
})
})
} | explode_data.jsonl/81473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
3564,
68036,
1130,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
55933,
2750,
1265,
5508,
497,
259,
11,
2915,
368,
341,
197,
93070,
5617,
445,
917,
1265,
5508,
497,
2915,
368,
341,
298,
1903,
16,
1669,
330,
13683,
698,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateDbEventSubscriptionName(t *testing.T) {
validNames := []string{
"valid-name",
"valid02-name",
"Valid-Name1",
}
for _, v := range validNames {
_, errors := validateDbEventSubscriptionName(v, "name")
if len(errors) != 0 {
t.Fatalf("%q should be a valid RDS Event Subscription Name: %q", v, errors)
}
}
invalidNames := []string{
"Here is a name with: colon",
"and here is another * invalid name",
"also $ invalid",
"This . is also %% invalid@!)+(",
"*",
"",
" ",
"_",
// length > 255
strings.Repeat("W", 256),
}
for _, v := range invalidNames {
_, errors := validateDbEventSubscriptionName(v, "name")
if len(errors) == 0 {
t.Fatalf("%q should be an invalid RDS Event Subscription Name", v)
}
}
} | explode_data.jsonl/78583 | {
"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,
17926,
7994,
1556,
33402,
675,
1155,
353,
8840,
836,
8,
341,
56322,
7980,
1669,
3056,
917,
515,
197,
197,
1,
1891,
11494,
756,
197,
197,
1,
1891,
15,
17,
11494,
756,
197,
197,
1,
4088,
12,
675,
16,
756,
197,
532,
2023,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetHandlerIsCopy(t *testing.T) {
// We need to make sure the returned handler is a copy
err := Register("copyprinter", NewTestHandler)
if err != nil {
t.Fatal("Should have registred just fine")
}
handler, err := GetHandler("copyprinter")
if err != nil {
t.Fatal("Should have found copy printer")
}
secondHandler, err := GetHandler("copyprinter")
if err != nil {
t.Fatal("Should have gotten a second printer just fine")
}
cfg := handler.GetConfiguration()
if cfg == nil {
t.Fatal("Config should not be nil")
}
cfg2 := secondHandler.GetConfiguration()
if cfg2 == nil {
t.Fatal("Should not be nil")
}
// Now cfg should not be the same
cfg.AddProperty("test", "testing", false)
err = cfg.SetProperty("test", "hello")
if err != nil {
t.Fatal(err)
}
testProp := cfg2.GetProperty("test")
if testProp != nil {
t.Fatal("Cfg2 has the testProp")
}
} | explode_data.jsonl/75193 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
1949,
3050,
3872,
12106,
1155,
353,
8840,
836,
8,
1476,
197,
322,
1205,
1184,
311,
1281,
2704,
279,
5927,
7013,
374,
264,
2975,
198,
9859,
1669,
8451,
445,
8560,
62956,
497,
1532,
2271,
3050,
340,
743,
1848,
961,
2092,
341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestValidDeprecatedCSPReport(t *testing.T) {
tests := []struct {
name string
report string
want collector.CSPReport
}{
{
name: "Basic",
report: `{
"csp-report": {
"blocked-uri": "https://evil.com/",
"disposition": "enforce",
"document-uri": "https://example.com/blah/blah",
"effective-directive": "script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
"original-policy": "object-src 'none'; script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
"referrer": "https://example.com/",
"script-sample": "alert(1)",
"status-code": 200,
"violated-directive": "script-src",
"source-file": "stuff.js"
}
}`,
want: collector.CSPReport{
BlockedURL: "https://evil.com/",
Disposition: "enforce",
DocumentURL: "https://example.com/blah/blah",
EffectiveDirective: "script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
OriginalPolicy: "object-src 'none'; script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
Referrer: "https://example.com/",
Sample: "alert(1)",
StatusCode: 200,
ViolatedDirective: "script-src",
SourceFile: "stuff.js",
},
},
{
name: "No csp-report key",
report: `{
"blocked-uri": "https://evil.com/",
"disposition": "enforce",
"document-uri": "https://example.com/blah/blah",
"effective-directive": "script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
"original-policy": "object-src 'none'; script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
"referrer": "https://example.com/",
"script-sample": "alert(1)",
"status-code": 200,
"violated-directive": "script-src",
"source-file": "stuff.js"
}`,
want: collector.CSPReport{
BlockedURL: "https://evil.com/",
Disposition: "enforce",
DocumentURL: "https://example.com/blah/blah",
EffectiveDirective: "script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
OriginalPolicy: "object-src 'none'; script-src sha256.eZcc0TlUfnQi64XLdiN5c/Vh2vtDbPaGtXRFyE7dRLo=",
Referrer: "https://example.com/",
Sample: "alert(1)",
StatusCode: 200,
ViolatedDirective: "script-src",
SourceFile: "stuff.js",
},
},
{
name: "lineno and colno",
report: `{
"csp-report": {
"lineno": 15,
"colno": 10
}
}`,
want: collector.CSPReport{
LineNumber: 15,
ColumnNumber: 10,
},
},
{
name: "line-number and column-number",
report: `{
"csp-report": {
"line-number": 15,
"column-number": 10
}
}`,
want: collector.CSPReport{
LineNumber: 15,
ColumnNumber: 10,
},
},
{
name: "Both lineno and colno, and line-number and column-number",
report: `{
"csp-report": {
"lineno": 7,
"colno": 8,
"line-number": 15,
"column-number": 10
}
}`,
want: collector.CSPReport{
LineNumber: 7,
ColumnNumber: 8,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := collector.Handler(func(r collector.Report) {
t.Fatalf("expected generic reports handler not to be called")
}, func(r collector.CSPReport) {
if diff := cmp.Diff(tt.want, r); diff != "" {
t.Errorf("report mismatch (-want +got):\n%s", diff)
}
})
req := safehttptest.NewRequest(safehttp.MethodPost, "/collector", strings.NewReader(tt.report))
req.Header.Set("Content-Type", "application/csp-report")
fakeRW, rr := safehttptest.NewFakeResponseWriter()
h.ServeHTTP(fakeRW, req)
if got, want := rr.Code, int(safehttp.StatusNoContent); got != want {
t.Errorf("rr.Code got: %v want: %v", got, want)
}
if diff := cmp.Diff(map[string][]string{}, map[string][]string(rr.Header())); diff != "" {
t.Errorf("rr.Header() mismatch (-want +got):\n%s", diff)
}
if got, want := rr.Body.String(), ""; got != want {
t.Errorf("rr.Body() got: %q want: %q", got, want)
}
})
}
} | explode_data.jsonl/66396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2055
} | [
2830,
3393,
4088,
51344,
34,
4592,
10361,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
69931,
914,
198,
197,
50780,
256,
31953,
727,
4592,
10361,
198,
197,
59403,
197,
197,
515,
298,
1160... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMasqueradeRule(t *testing.T) {
for _, testcase := range []bool{false, true} {
ipt := iptablestest.NewFake().SetHasRandomFully(testcase)
ipvs := ipvstest.NewFake()
ipset := ipsettest.NewFake(testIPSetVersion)
fp := NewFakeProxier(ipt, ipvs, ipset, nil, nil, v1.IPv4Protocol)
makeServiceMap(fp)
fp.syncProxyRules()
postRoutingRules := ipt.GetRules(string(kubePostroutingChain))
if !hasJump(postRoutingRules, "MASQUERADE", "") {
t.Errorf("Failed to find -j MASQUERADE in %s chain", kubePostroutingChain)
}
if hasMasqRandomFully(postRoutingRules) != testcase {
probs := map[bool]string{false: "found", true: "did not find"}
t.Errorf("%s --random-fully in -j MASQUERADE rule in %s chain for HasRandomFully()=%v", probs[testcase], kubePostroutingChain, testcase)
}
}
} | explode_data.jsonl/44353 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
43649,
15959,
1021,
11337,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
70080,
1669,
2088,
3056,
2641,
90,
3849,
11,
830,
92,
341,
197,
8230,
417,
1669,
66068,
480,
267,
477,
7121,
52317,
1005,
1649,
10281,
13999,
67386,
8623,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetMarginOrder(t *testing.T) {
request := okgroup.GetSpotOrderRequest{
OrderID: "1234",
InstrumentID: currency.NewPairWithDelimiter(currency.BTC.String(), currency.USD.String(), "-").Upper().String(),
}
_, err := o.GetMarginOrder(request)
testStandardErrorHandling(t, err)
} | explode_data.jsonl/30189 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
1949,
21681,
4431,
1155,
353,
8840,
836,
8,
341,
23555,
1669,
5394,
4074,
2234,
47049,
4431,
1900,
515,
197,
197,
4431,
915,
25,
414,
330,
16,
17,
18,
19,
756,
197,
197,
56324,
915,
25,
11413,
7121,
12443,
2354,
91098,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAPICopyObjectPartHandler(t *testing.T) {
defer DetectTestLeak(t)()
ExecObjectLayerAPITest(t, testAPICopyObjectPartHandler, []string{"CopyObjectPart"})
} | explode_data.jsonl/10701 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 57
} | [
2830,
3393,
2537,
1317,
1266,
1190,
5800,
3050,
1155,
353,
8840,
836,
8,
341,
16867,
33287,
2271,
2304,
585,
1155,
8,
741,
197,
10216,
1190,
9188,
2537,
952,
477,
1155,
11,
1273,
2537,
1317,
1266,
1190,
5800,
3050,
11,
3056,
917,
4913... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestBuildURLShouldReturnHTTPWithoutUseSSL(t *testing.T) {
url := buildURL(config.Endpoint{
APIKey: "bar",
Host: "foo",
UseSSL: false,
})
assert.Equal(t, "http://foo/v1/input", url)
} | explode_data.jsonl/82444 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
11066,
3144,
14996,
5598,
9230,
26040,
10253,
22594,
1155,
353,
8840,
836,
8,
341,
19320,
1669,
1936,
3144,
8754,
90409,
515,
197,
197,
7082,
1592,
25,
330,
2257,
756,
197,
197,
9296,
25,
256,
330,
7975,
756,
197,
95023,
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 |
func TestSimpleGet(t *testing.T) {
c := NewLRUExpireCache(10)
c.Add("long-lived", "12345", 10*time.Hour)
expectEntry(t, c, "long-lived", "12345")
} | explode_data.jsonl/44518 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
16374,
1949,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
20117,
52,
8033,
554,
8233,
7,
16,
15,
340,
1444,
1904,
445,
4825,
61854,
497,
330,
16,
17,
18,
19,
20,
497,
220,
16,
15,
77053,
73550,
340,
24952,
5874,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestMultiModuleModDiagnostics(t *testing.T) {
testenv.NeedsGo1Point(t, 14)
const mod = `
-- a/go.mod --
module mod.com
go 1.14
require (
example.com v1.2.3
)
-- a/main.go --
package main
func main() {}
-- b/go.mod --
module mod.com
go 1.14
-- b/main.go --
package main
import "example.com/blah"
func main() {
blah.SaySomething()
}
`
withOptions(
WithProxyFiles(workspaceProxy),
WithModes(Experimental),
).run(t, mod, func(t *testing.T, env *Env) {
env.Await(
env.DiagnosticAtRegexp("a/go.mod", "example.com v1.2.3"),
env.DiagnosticAtRegexp("b/go.mod", "module mod.com"),
)
})
} | explode_data.jsonl/3748 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
20358,
3332,
4459,
35,
18938,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
2067,
68,
6767,
10850,
16,
2609,
1155,
11,
220,
16,
19,
692,
4777,
1463,
284,
22074,
313,
264,
25525,
10929,
39514,
4352,
1463,
905,
271,
3346,
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 TestEnqueueUniqueIn(t *testing.T) {
pool := newTestPool(t)
ns := "work"
cleanKeyspace(ns, pool)
enqueuer := NewEnqueuer(ns, pool)
// Enqueue two unique jobs -- ensure one job sticks.
job, err := enqueuer.EnqueueUniqueIn("wat", 300, Q{"a": 1, "b": "cool"})
assert.NoError(t, err)
if assert.NotNil(t, job) {
assert.Equal(t, "wat", job.Name)
assert.True(t, len(job.ID) > 10) // Something is in it
assert.True(t, job.EnqueuedAt > (time.Now().Unix()-10)) // Within 10 seconds
assert.True(t, job.EnqueuedAt < (time.Now().Unix()+10)) // Within 10 seconds
assert.Equal(t, "cool", job.ArgString("b"))
assert.EqualValues(t, 1, job.ArgInt64("a"))
assert.NoError(t, job.ArgError())
assert.EqualValues(t, job.EnqueuedAt+300, job.RunAt)
}
job, err = enqueuer.EnqueueUniqueIn("wat", 10, Q{"a": 1, "b": "cool"})
assert.NoError(t, err)
assert.Nil(t, job)
// Get the job
score, j := jobOnZset(pool, redisKeyScheduled(ns))
assert.True(t, score > time.Now().Unix()+290) // We don't want to overwrite the time
assert.True(t, score <= time.Now().Unix()+300)
assert.Equal(t, "wat", j.Name)
assert.True(t, len(j.ID) > 10) // Something is in it
assert.True(t, j.EnqueuedAt > (time.Now().Unix()-10)) // Within 10 seconds
assert.True(t, j.EnqueuedAt < (time.Now().Unix()+10)) // Within 10 seconds
assert.Equal(t, "cool", j.ArgString("b"))
assert.EqualValues(t, 1, j.ArgInt64("a"))
assert.NoError(t, j.ArgError())
assert.True(t, j.Unique)
// Now try to enqueue more stuff and ensure it
job, err = enqueuer.EnqueueUniqueIn("wat", 300, Q{"a": 1, "b": "coolio"})
assert.NoError(t, err)
assert.NotNil(t, job)
job, err = enqueuer.EnqueueUniqueIn("wat", 300, nil)
assert.NoError(t, err)
assert.NotNil(t, job)
job, err = enqueuer.EnqueueUniqueIn("wat", 300, nil)
assert.NoError(t, err)
assert.Nil(t, job)
job, err = enqueuer.EnqueueUniqueIn("taw", 300, nil)
assert.NoError(t, err)
assert.NotNil(t, job)
} | explode_data.jsonl/40373 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 850
} | [
2830,
3393,
1702,
4584,
22811,
641,
1155,
353,
8840,
836,
8,
341,
85273,
1669,
501,
2271,
10551,
1155,
340,
84041,
1669,
330,
1778,
698,
1444,
2675,
8850,
1306,
39417,
11,
7314,
340,
81848,
591,
8801,
1669,
1532,
1702,
591,
8801,
39417,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRGB_Sprint(t *testing.T) {
RGBs := []RGB{{0, 0, 0}, {127, 127, 127}, {255, 255, 255}}
for _, rgb := range RGBs {
t.Run("", func(t *testing.T) {
internal.TestSprintContains(t, func(a interface{}) string {
return rgb.Sprint(a)
})
})
}
} | explode_data.jsonl/62950 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
18184,
1098,
1350,
1155,
353,
8840,
836,
8,
341,
11143,
5381,
82,
1669,
3056,
18184,
2979,
15,
11,
220,
15,
11,
220,
15,
2137,
314,
16,
17,
22,
11,
220,
16,
17,
22,
11,
220,
16,
17,
22,
2137,
314,
17,
20,
20,
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 TestBackpressureBuffer_stop(t *testing.T) {
t.SkipNow()
for _, c := range constructors {
t.Run(c.name, func(t *testing.T) {
// BufferCloseOnStop
var internal *internalBackpressureBuffer
init := func() {
bb := c.fn(&testWriter{})
internal = bb.internalBackpressureBuffer
bb.StartWorker(context.Background())
}
init()
init = nil // make sure that *BackpressureBuffer is lost
time.Sleep(time.Millisecond) // and make sure that the worker has started
require.Equal(t, int32(1+1<<16), atomic.LoadInt32(&internal.writerCounts))
runtime.GC() // the init func() and *BackpressureBuffer are lost, finalizer is created
time.Sleep(time.Millisecond) // make sure the finalizer was executed
runtime.GC() // finalizer is released
time.Sleep(time.Millisecond) // not needed, just to be safe
runtime.GC()
require.Equal(t, int32(0), atomic.LoadInt32(&internal.writerCounts))
be := <-internal.buffer
// depletionMark mark in the buffer indicates that any worker will stop
require.Equal(t, depletionMark, be.flushMark)
require.Equal(t, 0, len(internal.buffer))
})
}
} | explode_data.jsonl/29807 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 433
} | [
2830,
3393,
3707,
45974,
4095,
19039,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
7039,
2822,
2023,
8358,
272,
1669,
2088,
54717,
341,
197,
3244,
16708,
1337,
2644,
11,
2915,
1155,
353,
8840,
836,
8,
1476,
298,
197,
322,
10312,
7925,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncodeYAMLStream(t *testing.T) {
f := newFixture(t)
defer f.TearDown()
tf := fmt.Sprintf("expected = '''%s'''\n", yamlStream)
tf += fmt.Sprintf("observed = encode_yaml_stream(%s)\n", yamlStreamAsStarlark)
tf += `
load('assert.tilt', 'assert')
assert.equals(expected, str(observed))
`
f.File("Tiltfile", tf)
_, err := f.ExecFile("Tiltfile")
if err != nil {
fmt.Println(f.PrintOutput())
}
require.NoError(t, err)
} | explode_data.jsonl/10618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
32535,
56,
31102,
3027,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
836,
682,
4454,
2822,
3244,
69,
1669,
8879,
17305,
445,
7325,
284,
11456,
4,
82,
4605,
15777,
77,
497,
32246,
3027,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestValidateV1Beta1MissingChartVersion(t *testing.T) {
manifest := `---
apiVersion: manifests/v1beta1
metadata:
name: test-manifest
spec:
charts:
- name: chart1
namespace: default
`
_, err := Validate(manifest)
if err == nil || !strings.Contains(err.Error(), "version is required") {
t.Errorf("Didn't get expected error from manifest.TestValidateV1Beta1MissingChartVersion(), instead got: %s", err)
}
} | explode_data.jsonl/80473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
17926,
53,
16,
64811,
16,
25080,
14488,
5637,
1155,
353,
8840,
836,
8,
341,
197,
42315,
1669,
1565,
10952,
2068,
5637,
25,
83232,
5457,
16,
19127,
16,
198,
17637,
510,
220,
829,
25,
1273,
20477,
6962,
198,
9535,
510,
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... | 3 |
func TestProxyUpgradeConnectionErrorResponse(t *testing.T) {
var (
responder *fakeResponder
expectedErr = errors.New("EXPECTED")
)
proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
return &fakeConn{err: expectedErr}, nil
},
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
responder = &fakeResponder{t: t, w: w}
proxyHandler := NewUpgradeAwareHandler(
&url.URL{
Host: "fake-backend",
},
transport,
false,
true,
responder,
)
proxyHandler.ServeHTTP(w, r)
}))
defer proxy.Close()
// Send request to proxy server.
req, err := http.NewRequest("POST", "http://"+proxy.Listener.Addr().String()+"/some/path", nil)
require.NoError(t, err)
req.Header.Set(httpstream.HeaderConnection, httpstream.HeaderUpgrade)
resp, err := http.DefaultClient.Do(req)
require.NoError(t, err)
defer resp.Body.Close()
// Expect error response.
assert.True(t, responder.called)
assert.Equal(t, fakeStatusCode, resp.StatusCode)
msg, err := ioutil.ReadAll(resp.Body)
require.NoError(t, err)
assert.Contains(t, string(msg), expectedErr.Error())
} | explode_data.jsonl/35091 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 545
} | [
2830,
3393,
16219,
43861,
4526,
55901,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
10202,
20328,
256,
353,
30570,
30884,
198,
197,
42400,
7747,
284,
5975,
7121,
445,
80002,
1138,
197,
340,
197,
22803,
1669,
54320,
70334,
7121,
5475,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPubmaticInvalidInputParameters(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(DummyPubMaticServer))
defer server.Close()
conf := *adapters.DefaultHTTPAdapterConfig
an := NewPubmaticLegacyAdapter(&conf, server.URL)
ctx := context.Background()
pbReq := pbs.PBSRequest{}
pbBidder := pbs.PBSBidder{
BidderCode: "bannerCode",
AdUnits: []pbs.PBSAdUnit{
{
Code: "unitCode",
MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER},
BidID: "bidid",
Sizes: []openrtb2.Format{
{
W: 120,
H: 240,
},
},
},
},
}
pbReq.IsDebug = true
inValidPubmaticParams := []json.RawMessage{
// Invalid Request JSON
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@120x240\""),
// Missing adSlot in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\"}"),
// Missing publisher ID
json.RawMessage("{\"adSlot\": \"slot@120x240\"}"),
// Missing slot name in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"@120x240\"}"),
// Invalid adSize in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@120-240\"}"),
// Missing impression width and height in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@\"}"),
// Missing height in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@120\"}"),
// Missing width in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@x120\"}"),
// Incorrect width param in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@valx120\"}"),
// Incorrect height param in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@120xval\"}"),
// Empty slot name in AdUnits.Params,
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \" @120x240\"}"),
// Empty width in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@ x240\"}"),
// Empty height in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \"slot@120x \"}"),
// Empty height in AdUnits.Params
json.RawMessage("{\"publisherId\": \"10\", \"adSlot\": \" @120x \"}"),
// Invalid Keywords
json.RawMessage(`{"publisherId": "640", "adSlot": "slot1@336x280","keywords":{"pmZoneId":1},"wrapper":{"version":2,"profile":595}}`),
// Invalid Wrapper ext
json.RawMessage(`{"publisherId": "640", "adSlot": "slot1@336x280","keywords":{"pmZoneId":"Zone1,Zone2"},"wrapper":{"version":"2","profile":595}}`),
}
for _, param := range inValidPubmaticParams {
pbBidder.AdUnits[0].Params = param
_, err := an.Call(ctx, &pbReq, &pbBidder)
if err == nil {
t.Fatalf("Should get errors for params = %v", string(param))
}
}
} | explode_data.jsonl/77915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1101
} | [
2830,
3393,
29162,
37244,
7928,
2505,
9706,
1155,
353,
8840,
836,
8,
1476,
41057,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
5432,
8574,
29162,
44,
774,
5475,
1171,
16867,
3538,
10421,
2822,
67850,
1669,
353,
329,
17425,
13275,
9230,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGenerateWithAPG(t *testing.T) {
rootToken := "s.Ga5jyNq6kNfRMVQk2LY1j9iu" // nolint:gosec
mockLogger := logger.MockLogger{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Note: apg only available with gnome-desktop, expected to be missing on server Linux distros
gk := NewPasswordGenerator(mockLogger, "apg", []string{"-a", "1", "-n", "1", "-m", "12", "-x", "64"})
cr := NewCred(&http.Client{}, rootToken, gk, "", logger.MockLogger{})
p1, err := cr.GeneratePassword(ctx)
require.NoError(t, err, "failed to create credential")
p2, err := cr.GeneratePassword(ctx)
require.NoError(t, err, "failed to create credential")
assert.NotEqual(t, p1, p2, "each call to GeneratePassword should return a new password")
} | explode_data.jsonl/9462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 284
} | [
2830,
3393,
31115,
2354,
2537,
38,
1155,
353,
8840,
836,
8,
341,
33698,
3323,
1669,
330,
82,
1224,
64,
20,
73,
88,
45,
80,
21,
74,
45,
69,
23652,
53,
48,
74,
17,
8932,
16,
73,
24,
18738,
1,
442,
308,
337,
396,
70418,
960,
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... | 1 |
func TestGetJwtSession(t *testing.T) {
/* token payload:
{
"sub": "1234567890",
"aud": "https://test.myapp.com",
"name": "John Doe",
"email": "john@example.com",
"iss": "https://issuer.example.com",
"iat": 1553691215,
"exp": 1912151821
}
*/
goodJwt := "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9." +
"eyJzdWIiOiIxMjM0NTY3ODkwIiwiYXVkIjoiaHR0cHM6Ly90ZXN0Lm15YXBwLmNvbSIsIm5hbWUiOiJKb2huIERvZSIsImVtY" +
"WlsIjoiam9obkBleGFtcGxlLmNvbSIsImlzcyI6Imh0dHBzOi8vaXNzdWVyLmV4YW1wbGUuY29tIiwiaWF0IjoxNTUzNjkxMj" +
"E1LCJleHAiOjE5MTIxNTE4MjF9." +
"rLVyzOnEldUq_pNkfa-WiV8TVJYWyZCaM2Am_uo8FGg11zD7l-qmz3x1seTvqpH6Y0Ty00fmv6dJnGnC8WMnPXQiodRTfhBSe" +
"OKZMu0HkMD2sg52zlKkbfLTO6ic5VnbVgwjjrB8am_Ta6w7kyFUaB5C1BsIrrLMldkWEhynbb8"
keyset := NoOpKeySet{}
verifier := oidc.NewVerifier("https://issuer.example.com", keyset,
&oidc.Config{ClientID: "https://test.myapp.com", SkipExpiryCheck: true})
test, err := NewAuthOnlyEndpointTest("", func(opts *options.Options) {
opts.InjectRequestHeaders = []options.Header{
{
Name: "Authorization",
Values: []options.HeaderValue{
{
ClaimSource: &options.ClaimSource{
Claim: "id_token",
Prefix: "Bearer ",
},
},
},
},
{
Name: "X-Forwarded-User",
Values: []options.HeaderValue{
{
ClaimSource: &options.ClaimSource{
Claim: "user",
},
},
},
},
{
Name: "X-Forwarded-Email",
Values: []options.HeaderValue{
{
ClaimSource: &options.ClaimSource{
Claim: "email",
},
},
},
},
}
opts.InjectResponseHeaders = []options.Header{
{
Name: "Authorization",
Values: []options.HeaderValue{
{
ClaimSource: &options.ClaimSource{
Claim: "id_token",
Prefix: "Bearer ",
},
},
},
},
{
Name: "X-Auth-Request-User",
Values: []options.HeaderValue{
{
ClaimSource: &options.ClaimSource{
Claim: "user",
},
},
},
},
{
Name: "X-Auth-Request-Email",
Values: []options.HeaderValue{
{
ClaimSource: &options.ClaimSource{
Claim: "email",
},
},
},
},
}
opts.SkipJwtBearerTokens = true
opts.SetJWTBearerVerifiers(append(opts.GetJWTBearerVerifiers(), verifier))
})
if err != nil {
t.Fatal(err)
}
tp, _ := test.proxy.provider.(*TestProvider)
tp.GroupValidator = func(s string) bool {
return true
}
authHeader := fmt.Sprintf("Bearer %s", goodJwt)
test.req.Header = map[string][]string{
"Authorization": {authHeader},
}
test.proxy.ServeHTTP(test.rw, test.req)
if test.rw.Code >= 400 {
t.Fatalf("expected 3xx got %d", test.rw.Code)
}
// Check PassAuthorization, should overwrite Basic header
assert.Equal(t, test.req.Header.Get("Authorization"), authHeader)
assert.Equal(t, test.req.Header.Get("X-Forwarded-User"), "1234567890")
assert.Equal(t, test.req.Header.Get("X-Forwarded-Email"), "john@example.com")
// SetAuthorization and SetXAuthRequest
assert.Equal(t, test.rw.Header().Get("Authorization"), authHeader)
assert.Equal(t, test.rw.Header().Get("X-Auth-Request-User"), "1234567890")
assert.Equal(t, test.rw.Header().Get("X-Auth-Request-Email"), "john@example.com")
} | explode_data.jsonl/36420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1617
} | [
2830,
3393,
1949,
72756,
5283,
1155,
353,
8840,
836,
8,
341,
197,
1057,
3950,
7729,
510,
197,
515,
3677,
330,
1966,
788,
330,
16,
17,
18,
19,
20,
21,
22,
23,
24,
15,
756,
3677,
330,
7880,
788,
330,
2428,
1110,
1944,
12618,
676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMemory(t *testing.T) {
url, err := url.Parse("memory://")
if err != nil {
t.Fatalf(err.Error())
}
// create a new memory authenticator
mem, err := mistAuth.NewMemory(url)
if err != nil {
t.Fatalf(err.Error())
}
testAuth(mem, t)
} | explode_data.jsonl/71510 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
10642,
1155,
353,
8840,
836,
8,
1476,
19320,
11,
1848,
1669,
2515,
8937,
445,
17269,
1110,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
3964,
6141,
2398,
197,
630,
197,
322,
1855,
264,
501,
4938,
13210,
850,
198,
141... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_GET_statuses_user_timeline(t *testing.T) {
t.SkipNow()
kws := map[string]interface{}{
"mid": "yybyOssa9",
"type": 1,
"isBase62": 1,
}
var result string
err := api.GET_statuses_queryid(kws, &result)
debugCheckError(err)
debugPrintln(result)
// fmt.Println(result)
} | explode_data.jsonl/64149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 136
} | [
2830,
3393,
12702,
83702,
3317,
77560,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
7039,
741,
16463,
8915,
1669,
2415,
14032,
31344,
67066,
197,
197,
1,
16106,
788,
414,
330,
4807,
1694,
46,
52107,
24,
756,
197,
197,
44470,
788,
257,
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 TestRun(t *testing.T) {
db, err := model.NewSQLite3("../model/test.db")
if err != nil {
t.Errorf(`err should be nil, got %v`, err)
}
tearDown := model.TestCleanUpTemperatureAndHumidityFunc(t, db)
t.Cleanup(tearDown)
c := &Collector{
dht: &mockedDHT11{},
db: db,
}
err = c.Run(context.Background())
if err != nil {
t.Errorf(`err should be nil, got %v`, err)
}
var th model.TemperatureAndHumidity
err = db.QueryRowContext(context.Background(),
`select id, temperature, humidity, unixtimestamp from temperature_and_humidity limit 1`,
).Scan(&th.ID, &th.Temperature, &th.Humidity, &th.Unixtimestamp)
if err != nil {
t.Errorf(`err should be nil, got %v`, err)
}
if th.Temperature != 1.1 {
t.Errorf(`Temperature should be 1.1, got %f`, th.Temperature)
}
if th.Humidity != 2.2 {
t.Errorf(`Humidity should be 2.2, got %f`, th.Humidity)
}
} | explode_data.jsonl/13476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
6727,
1155,
353,
8840,
836,
8,
341,
20939,
11,
1848,
1669,
1614,
7121,
81772,
18,
17409,
2528,
12697,
7076,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
5809,
615,
1265,
387,
2092,
11,
2684,
1018,
85,
7808,
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... | 6 |
func TestRemove(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
pluginRemoveFunc: func(name string, options types.PluginRemoveOptions) error {
return nil
},
})
cmd := newRemoveCommand(cli)
cmd.SetArgs([]string{"plugin-foo"})
assert.NilError(t, cmd.Execute())
assert.Check(t, is.Equal("plugin-foo\n", cli.OutBuffer().String()))
} | explode_data.jsonl/70199 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
13021,
1155,
353,
8840,
836,
8,
341,
86448,
1669,
1273,
7121,
52317,
87014,
2099,
30570,
2959,
515,
197,
197,
9138,
13021,
9626,
25,
2915,
3153,
914,
11,
2606,
4494,
64378,
13021,
3798,
8,
1465,
341,
298,
853,
2092,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDiffRefBranch(t *testing.T) {
diff := &PostReceiveLine{OldCommitHash: "", NewCommitHash: "", Ref: "refs/heads/master"}
if diff.IsBranch() != true {
t.Errorf("Expected Ref %s to be a branch (IsBranch() -> false)", diff.Ref)
return
}
if diff.IsTag() == true {
t.Errorf("Expected Ref %s to be not a tag (IsTag() -> true)", diff.Ref)
return
}
if diff.RefName() != "master" {
t.Errorf("Expected Ref Name to be master, got: %s", diff.RefName())
return
}
} | explode_data.jsonl/12447 | {
"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,
21751,
3945,
18197,
1155,
353,
8840,
836,
8,
341,
80564,
1669,
609,
4133,
14742,
2460,
90,
18284,
33441,
6370,
25,
7342,
1532,
33441,
6370,
25,
7342,
8550,
25,
330,
16149,
14,
35810,
23303,
63159,
743,
3638,
4506,
18197,
368... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBreachedOutputSerialization(t *testing.T) {
for i := range breachedOutputs {
bo := &breachedOutputs[i]
var buf bytes.Buffer
if err := bo.Encode(&buf); err != nil {
t.Fatalf("unable to serialize breached output [%v]: %v",
i, err)
}
desBo := &breachedOutput{}
if err := desBo.Decode(&buf); err != nil {
t.Fatalf("unable to deserialize "+
"breached output [%v]: %v", i, err)
}
if !reflect.DeepEqual(bo, desBo) {
t.Fatalf("original and deserialized "+
"breached outputs not equal:\n"+
"original : %+v\n"+
"deserialized : %+v\n",
bo, desBo)
}
}
} | explode_data.jsonl/2932 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 270
} | [
2830,
3393,
50229,
3854,
5097,
35865,
1155,
353,
8840,
836,
8,
341,
2023,
600,
1669,
2088,
81066,
61438,
341,
197,
197,
749,
1669,
609,
20512,
3854,
61438,
989,
2533,
197,
2405,
6607,
5820,
22622,
271,
197,
743,
1848,
1669,
708,
50217,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshalNullObject(t *testing.T) {
var maps pb.Maps
if err := UnmarshalString(`{"mInt64Str":null}`, &maps); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(maps, pb.Maps{}) {
t.Errorf("got non-nil fields in [%#v]", maps)
}
} | explode_data.jsonl/63122 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
1806,
27121,
3280,
1190,
1155,
353,
8840,
836,
8,
341,
2405,
14043,
17310,
1321,
2625,
198,
743,
1848,
1669,
1230,
27121,
703,
5809,
4913,
76,
1072,
21,
19,
2580,
788,
2921,
28350,
609,
17640,
1215,
1848,
961,
2092,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAddToSecrets(t *testing.T) {
reader := setup(t)
cfg, _ := ReadCRSpecFromFile(reader)
cfg.Spec.AddToSecrets("qliksense", "mongo", "tadadaa", "sec")
rmap := make(map[string]string)
for _, nv := range cfg.Spec.Secrets["qliksense"] {
if rmap[nv.Name] == "" {
rmap[nv.Name] = "found"
continue
}
if rmap[nv.Name] == "found" {
rmap[nv.Name] = "duplicate"
}
}
if rmap["mongo"] == "duplicate" {
t.Fail()
}
} | explode_data.jsonl/60731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
2212,
1249,
19773,
82,
1155,
353,
8840,
836,
8,
341,
61477,
1669,
6505,
1155,
340,
50286,
11,
716,
1669,
4457,
8973,
8327,
43633,
21987,
692,
50286,
36473,
1904,
1249,
19773,
82,
445,
6905,
2787,
1117,
497,
330,
53070,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestWriteCertificateAuthorithyFilesIfNotExist(t *testing.T) {
setupCert, setupKey := createCACert(t)
caCert, caKey := createCACert(t)
var tests = []struct {
setupFunc func(pkiDir string) error
expectedError bool
expectedCa *x509.Certificate
}{
{ // ca cert does not exists > ca written
expectedCa: caCert,
},
{ // ca cert exists, is ca > existing ca used
setupFunc: func(pkiDir string) error {
return writeCertificateAuthorithyFilesIfNotExist(pkiDir, "dummy", setupCert, setupKey)
},
expectedCa: setupCert,
},
{ // some file exists, but it is not a valid ca cert > err
setupFunc: func(pkiDir string) error {
testutil.SetupEmptyFiles(t, pkiDir, "dummy.crt")
return nil
},
expectedError: true,
},
{ // cert exists, but it is not a ca > err
setupFunc: func(pkiDir string) error {
cert, key := createTestCert(t, setupCert, setupKey)
return writeCertificateFilesIfNotExist(pkiDir, "dummy", setupCert, cert, key)
},
expectedError: true,
},
}
for _, test := range tests {
// Create temp folder for the test case
tmpdir := testutil.SetupTempDir(t)
defer os.RemoveAll(tmpdir)
// executes setup func (if necessary)
if test.setupFunc != nil {
if err := test.setupFunc(tmpdir); err != nil {
t.Errorf("error executing setupFunc: %v", err)
continue
}
}
// executes create func
err := writeCertificateAuthorithyFilesIfNotExist(tmpdir, "dummy", caCert, caKey)
if !test.expectedError && err != nil {
t.Errorf("error writeCertificateAuthorithyFilesIfNotExist failed when not expected to fail: %v", err)
continue
} else if test.expectedError && err == nil {
t.Error("error writeCertificateAuthorithyFilesIfNotExist didn't failed when expected")
continue
} else if test.expectedError {
continue
}
// asserts expected files are there
testutil.AssertFileExists(t, tmpdir, "dummy.key", "dummy.crt")
// check created cert
resultingCaCert, _, err := pkiutil.TryLoadCertAndKeyFromDisk(tmpdir, "dummy")
if err != nil {
t.Errorf("failure reading created cert: %v", err)
continue
}
if !resultingCaCert.Equal(test.expectedCa) {
t.Error("created ca cert does not match expected ca cert")
}
}
} | explode_data.jsonl/58620 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 844
} | [
2830,
3393,
7985,
33202,
7133,
410,
88,
10809,
2679,
45535,
1155,
353,
8840,
836,
8,
341,
84571,
36934,
11,
6505,
1592,
1669,
1855,
92832,
529,
1155,
340,
197,
924,
36934,
11,
2162,
1592,
1669,
1855,
92832,
529,
1155,
692,
2405,
7032,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBot_GetChatAdministrators(t *testing.T) {
type fields struct {
apiClient apiClient
}
tests := []struct {
name string
fields fields
wantResult axon.A
wantErr bool
}{
{
name: "test1",
fields: fields{
apiClient: &mockAPIClient{
method: "getChatAdministrators",
interfaceMethod: func() interface{} {
return []interface{}{
map[string]interface{}{},
}
},
bytesMethod: func() []byte {
return []byte("[{}]")
},
},
},
wantResult: []interface{}{
map[string]interface{}{},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &Bot{
apiClient: tt.fields.apiClient,
}
gotResult, err := b.GetChatAdministrators(axon.O{})
if (err != nil) != tt.wantErr {
t.Errorf("Bot.GetChatAdministrators() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotResult, tt.wantResult) {
t.Errorf("Bot.GetChatAdministrators() = %v, want %v", gotResult, tt.wantResult)
}
})
}
} | explode_data.jsonl/46097 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 504
} | [
2830,
3393,
23502,
13614,
15672,
61263,
2973,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
54299,
2959,
6330,
2959,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
55276,
257,
5043,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNoPortError(t *testing.T) {
os.Setenv("PACHD_ADDRESS", "127.127.127.0")
c := tu.Cmd("pachctl", "version", "--timeout=1ns", "--no-port-forwarding")
var errMsg bytes.Buffer
c.Stdout = ioutil.Discard
c.Stderr = &errMsg
err := c.Run()
require.YesError(t, err) // 1ns should prevent even local connections
require.Matches(t, "does not seem to be host:port", errMsg.String())
} | explode_data.jsonl/70017 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
2753,
7084,
1454,
1155,
353,
8840,
836,
8,
341,
25078,
4202,
3160,
445,
47,
11873,
35,
20135,
497,
330,
16,
17,
22,
13,
16,
17,
22,
13,
16,
17,
22,
13,
15,
1138,
1444,
1669,
9765,
64512,
445,
79,
610,
12373,
497,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSet_UnmarshalValue(t *testing.T) {
type V struct {
Name string
Set *gset.Set
}
// JSON
gtest.C(t, func(t *gtest.T) {
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"set": []byte(`["k1","k2","k3"]`),
}, &v)
t.Assert(err, nil)
t.Assert(v.Name, "john")
t.Assert(v.Set.Size(), 3)
t.Assert(v.Set.Contains("k1"), true)
t.Assert(v.Set.Contains("k2"), true)
t.Assert(v.Set.Contains("k3"), true)
t.Assert(v.Set.Contains("k4"), false)
})
// Map
gtest.C(t, func(t *gtest.T) {
var v *V
err := gconv.Struct(g.Map{
"name": "john",
"set": g.Slice{"k1", "k2", "k3"},
}, &v)
t.Assert(err, nil)
t.Assert(v.Name, "john")
t.Assert(v.Set.Size(), 3)
t.Assert(v.Set.Contains("k1"), true)
t.Assert(v.Set.Contains("k2"), true)
t.Assert(v.Set.Contains("k3"), true)
t.Assert(v.Set.Contains("k4"), false)
})
} | explode_data.jsonl/34401 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 465
} | [
2830,
3393,
1649,
40687,
27121,
1130,
1155,
353,
8840,
836,
8,
341,
13158,
647,
2036,
341,
197,
21297,
914,
198,
197,
22212,
220,
353,
70,
746,
4202,
198,
197,
532,
197,
322,
4718,
198,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssuingTransactionList(t *testing.T) {
i := List(&stripe.IssuingTransactionListParams{})
// Verify that we can get at least one transaction
assert.True(t, i.Next())
assert.Nil(t, i.Err())
assert.NotNil(t, i.IssuingTransaction())
assert.Equal(t, "issuing.transaction", i.IssuingTransaction().Object)
} | explode_data.jsonl/7506 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
28216,
7471,
8070,
852,
1155,
353,
8840,
836,
8,
341,
8230,
1669,
1759,
2099,
61233,
2447,
778,
7471,
8070,
852,
4870,
6257,
692,
197,
322,
25429,
429,
582,
646,
633,
518,
3245,
825,
7745,
198,
6948,
32443,
1155,
11,
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... | 1 |
func TestErrorIsRaisedForChecksumMismatch(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/testContainer/testObject", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("ETag", "acbd18db4cc2f85cedef654fccc4a4d8")
w.WriteHeader(http.StatusCreated)
})
content := strings.NewReader("The sky was the color of television, tuned to a dead channel.")
res := Create(fake.ServiceClient(), "testContainer", "testObject", content, &CreateOpts{})
err := fmt.Errorf("Local checksum does not match API ETag header")
th.AssertDeepEquals(t, err, res.Err)
} | explode_data.jsonl/30752 | {
"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,
1454,
3872,
94914,
2461,
73190,
82572,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
70479,
1321,
2200,
63623,
4283,
1944,
4502,
12697,
1190,
497,
2915,
3622,
1758,
37508,
11,
435... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSimpleDaemonSetLaunchesPods(t *testing.T) {
forEachFeatureGate(t, func(t *testing.T) {
forEachStrategy(t, func(t *testing.T, strategy *apps.DaemonSetUpdateStrategy) {
server, closeFn, dc, informers, clientset := setup(t)
defer closeFn()
ns := framework.CreateTestingNamespace("simple-daemonset-test", server, t)
defer framework.DeleteTestingNamespace(ns, server, t)
dsClient := clientset.AppsV1().DaemonSets(ns.Name)
podClient := clientset.CoreV1().Pods(ns.Name)
nodeClient := clientset.CoreV1().Nodes()
podInformer := informers.Core().V1().Pods().Informer()
stopCh := make(chan struct{})
defer close(stopCh)
informers.Start(stopCh)
go dc.Run(5, stopCh)
// Start Scheduler
setupScheduler(t, clientset, informers, stopCh)
ds := newDaemonSet("foo", ns.Name)
ds.Spec.UpdateStrategy = *strategy
_, err := dsClient.Create(ds)
if err != nil {
t.Fatalf("Failed to create DaemonSet: %v", err)
}
defer cleanupDaemonSets(t, clientset, ds)
addNodes(nodeClient, 0, 5, nil, t)
validateDaemonSetPodsAndMarkReady(podClient, podInformer, 5, t)
validateDaemonSetStatus(dsClient, ds.Name, 5, t)
})
})
} | explode_data.jsonl/8554 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 487
} | [
2830,
3393,
16374,
89177,
1649,
32067,
288,
23527,
82,
1155,
353,
8840,
836,
8,
341,
2023,
4854,
13859,
42318,
1155,
11,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2023,
4854,
19816,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
8282,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAppExecInvalid(t *testing.T) {
tests := []App{
App{
Exec: nil,
},
App{
Exec: []string{},
User: "0",
Group: "0",
},
App{
Exec: []string{"app"},
User: "0",
Group: "0",
},
App{
Exec: []string{"bin/app", "arg1"},
User: "0",
Group: "0",
},
}
for i, tt := range tests {
if err := tt.assertValid(); err == nil {
t.Errorf("#%d: err == nil, want non-nil", i)
}
}
} | explode_data.jsonl/8861 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 225
} | [
2830,
3393,
2164,
10216,
7928,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
2164,
515,
197,
59557,
515,
298,
197,
10216,
25,
2092,
345,
197,
197,
1583,
197,
59557,
515,
298,
197,
10216,
25,
220,
3056,
917,
38837,
298,
31672,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGithubCloneURLs(t *testing.T) {
var repo github.Repository
repo.NameWithOwner = "foo/bar"
tests := []struct {
InstanceUrl string
RepoURL string
Token string
GitURLType string
Want string
}{
{"https://github.com", "https://github.com/foo/bar", "", "", "https://github.com/foo/bar"},
{"https://github.com", "https://github.com/foo/bar", "abcd", "", "https://abcd@github.com/foo/bar"},
{"https://github.com", "https://github.com/foo/bar", "abcd", "ssh", "git@github.com:foo/bar.git"},
}
for _, test := range tests {
t.Run(fmt.Sprintf("URL(%q) / Token(%q) / URLType(%q)", test.InstanceUrl, test.Token, test.GitURLType), func(t *testing.T) {
cfg := schema.GitHubConnection{
Url: test.InstanceUrl,
Token: test.Token,
GitURLType: test.GitURLType,
}
repo.URL = test.RepoURL
got, err := githubCloneURL(&repo, &cfg)
if err != nil {
t.Fatal(err)
}
if got != test.Want {
t.Fatalf("wrong cloneURL, got: %q, want: %q", got, test.Want)
}
})
}
} | explode_data.jsonl/39377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
78717,
37677,
3144,
82,
1155,
353,
8840,
836,
8,
341,
2405,
15867,
31004,
25170,
198,
17200,
5368,
2967,
2354,
13801,
284,
330,
7975,
49513,
1837,
78216,
1669,
3056,
1235,
341,
197,
197,
2523,
2864,
914,
198,
197,
197,
25243... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConnectConfigRequiresConnConfigFromParseConfig(t *testing.T) {
config := &pgx.ConnConfig{}
require.PanicsWithValue(t, "config must be created by ParseConfig", func() {
pgx.ConnectConfig(context.Background(), config)
})
} | explode_data.jsonl/39998 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
14611,
2648,
46961,
9701,
2648,
3830,
14463,
2648,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
609,
3517,
87,
50422,
2648,
16094,
17957,
1069,
276,
1211,
22767,
1155,
11,
330,
1676,
1969,
387,
3465,
553,
14775,
2648,
497,
291... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPathParamsBinder(t *testing.T) {
c := createTestContext("/api/user/999", nil, map[string]string{
"id": "1",
"nr": "2",
"slice": "3",
})
b := PathParamsBinder(c)
id := int64(99)
nr := int64(88)
var slice = make([]int64, 0)
var notExisting = make([]int64, 0)
err := b.Int64("id", &id).
Int64("nr", &nr).
Int64s("slice", &slice).
Int64s("not_existing", ¬Existing).
BindError()
assert.NoError(t, err)
assert.Equal(t, int64(1), id)
assert.Equal(t, int64(2), nr)
assert.Equal(t, []int64{3}, slice) // binding params to slice does not make sense but it should not panic either
assert.Equal(t, []int64{}, notExisting) // binding params to slice does not make sense but it should not panic either
} | explode_data.jsonl/82529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
1820,
4870,
44055,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1855,
2271,
1972,
4283,
2068,
11739,
14,
24,
24,
24,
497,
2092,
11,
2415,
14032,
30953,
515,
197,
197,
28700,
788,
262,
330,
16,
756,
197,
197,
1,
19618,
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... | 1 |
func TestWrapUnaryHandlerInvalid(t *testing.T) {
tests := []struct {
Name string
Func interface{}
}{
{"empty", func() {}},
{"not-a-function", 0},
{
"wrong-args-in",
func(context.Context) (*struct{}, error) {
return nil, nil
},
},
{
"wrong-ctx",
func(string, *struct{}) (*struct{}, error) {
return nil, nil
},
},
{
"wrong-req-body",
func(context.Context, string, int) (*struct{}, error) {
return nil, nil
},
},
{
"wrong-response",
func(context.Context, map[string]interface{}) error {
return nil
},
},
{
"non-pointer-req",
func(context.Context, struct{}) (*struct{}, error) {
return nil, nil
},
},
{
"non-pointer-res",
func(context.Context, *struct{}) (struct{}, error) {
return struct{}{}, nil
},
},
{
"non-string-key",
func(context.Context, map[int32]interface{}) (*struct{}, error) {
return nil, nil
},
},
{
"second-return-value-not-error",
func(context.Context, *struct{}) (*struct{}, *struct{}) {
return nil, nil
},
},
}
for _, tt := range tests {
assert.Panics(t, assert.PanicTestFunc(func() {
wrapUnaryHandler(tt.Name, tt.Func)
}), tt.Name)
}
} | explode_data.jsonl/3 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 559
} | [
2830,
3393,
26787,
94545,
3050,
7928,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
21297,
914,
198,
197,
197,
9626,
3749,
16094,
197,
59403,
197,
197,
4913,
3194,
497,
2915,
368,
4687,
1583,
197,
197,
4913,
1921,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHChaCha20(t *testing.T) {
// See draft-irtf-cfrg-xchacha-00, Section 2.2.1.
key := []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f}
nonce := []byte{0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4a,
0x00, 0x00, 0x00, 0x00, 0x31, 0x41, 0x59, 0x27}
expected := []byte{0x82, 0x41, 0x3b, 0x42, 0x27, 0xb2, 0x7b, 0xfe,
0xd3, 0x0e, 0x42, 0x50, 0x8a, 0x87, 0x7d, 0x73,
0xa0, 0xf9, 0xe4, 0xd5, 0x8a, 0x74, 0xa8, 0x53,
0xc1, 0x2e, 0xc4, 0x13, 0x26, 0xd3, 0xec, 0xdc,
}
result, err := HChaCha20(key[:], nonce[:])
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(expected, result) {
t.Errorf("want %x, got %x", expected, result)
}
} | explode_data.jsonl/80525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 509
} | [
2830,
3393,
39,
95971,
95971,
17,
15,
1155,
353,
8840,
836,
8,
341,
197,
322,
3496,
9960,
12,
2106,
69,
1786,
1626,
70,
6558,
331,
51576,
12,
15,
15,
11,
11113,
220,
17,
13,
17,
13,
16,
624,
23634,
1669,
3056,
3782,
90,
15,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTxPhantomValidation(t *testing.T) {
for _, testEnv := range testEnvs {
t.Logf("Running test for TestEnv = %s", testEnv.getName())
testLedgerID := "testtxphantomvalidation"
testEnv.init(t, testLedgerID, nil)
testTxPhantomValidation(t, testEnv)
testEnv.cleanup()
}
} | explode_data.jsonl/63605 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
31584,
3357,
30002,
13799,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
14359,
1669,
2088,
1273,
1702,
11562,
341,
197,
3244,
98954,
445,
18990,
1273,
369,
3393,
14359,
284,
1018,
82,
497,
1273,
14359,
8911,
2398,
197,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyLayers(t *testing.T) {
p, err := LoadFromString(testEmptyLayers)
if err != nil {
t.Error(err)
t.Fail()
return
}
assert.NotNil(t, p)
assert.Equal(t, 2, p.ModelVersion)
assert.NotNil(t, p.Content)
assert.Equal(t, "Sheep_1", p.Content.Name)
assert.Equal(t, 3, p.Content.Fps)
assert.Nil(t, p.Content.Layers)
} | explode_data.jsonl/30012 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
3522,
40235,
1155,
353,
8840,
836,
8,
341,
3223,
11,
1848,
1669,
8893,
44491,
8623,
3522,
40235,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
3244,
57243,
741,
197,
853,
198,
197,
532,
6948,
93882,
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... | 2 |
func Test_HistoryDBLedgerSourceCurrentLedger(t *testing.T) {
state := &State{
RWMutex: sync.RWMutex{},
current: Status{
HorizonStatus: HorizonStatus{
ExpHistoryLatest: 3,
},
},
}
ledgerSource := HistoryDBSource{
updateFrequency: 0,
state: state,
}
currentLedger := ledgerSource.CurrentLedger()
if currentLedger != 3 {
t.Errorf("CurrentLedger = %d, want 3", currentLedger)
}
} | explode_data.jsonl/34563 | {
"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,
2039,
2579,
3506,
60850,
1389,
3608,
5405,
60850,
1389,
1155,
353,
8840,
836,
8,
341,
24291,
1669,
609,
1397,
515,
197,
11143,
15210,
9371,
25,
12811,
2013,
15210,
9371,
38837,
197,
20121,
25,
8104,
515,
298,
13292,
269,
169... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIngressHandler_Receive_NoTTL(t *testing.T) {
client := &fakeClient{}
reporter := &mockReporter{}
handler := Handler{
Logger: zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())),
CeClient: client,
Reporter: reporter,
}
event := cloudevents.NewEvent(cloudevents.VersionV1)
resp := new(cloudevents.EventResponse)
tctx := http.TransportContext{Header: nethttp.Header{}, Method: validHTTPMethod, URI: validURI}
ctx := http.WithTransportContext(context.Background(), tctx)
_ = handler.receive(ctx, event, resp)
if client.sent {
t.Errorf("client should NOT invoke send function")
}
if !reporter.eventCountReported {
t.Errorf("event count should have been reported")
}
} | explode_data.jsonl/11033 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
641,
2483,
3050,
62,
14742,
36989,
51,
13470,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
609,
30570,
2959,
16094,
69931,
261,
1669,
609,
16712,
52766,
16094,
53326,
1669,
19954,
515,
197,
55861,
25,
256,
32978,
1944,
7121,
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... | 3 |
func TestCommas(t *testing.T) {
workflow, _ := fixture(t, "valid/commas.workflow")
for _, ac := range workflow.Actions {
assert.Equal(t, map[string]string{"FOO":"1", "BAR":"2", "BAZ":"3"}, ac.Env)
}
} | explode_data.jsonl/55678 | {
"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,
1092,
6899,
1155,
353,
8840,
836,
8,
341,
197,
56249,
11,
716,
1669,
12507,
1155,
11,
330,
1891,
14,
3621,
300,
72774,
1138,
2023,
8358,
1613,
1669,
2088,
28288,
72044,
341,
197,
6948,
12808,
1155,
11,
2415,
14032,
30953,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDirectProvider(t *testing.T) {
_, teardown := prepService(t)
defer teardown()
// login
jar, err := cookiejar.New(nil)
require.Nil(t, err)
client := &http.Client{Jar: jar, Timeout: 5 * time.Second}
resp, err := client.Get("http://127.0.0.1:8089/auth/direct/login?user=dev_direct&passwd=bad")
require.Nil(t, err)
defer resp.Body.Close()
assert.Equal(t, 403, resp.StatusCode)
resp, err = client.Get("http://127.0.0.1:8089/auth/direct/login?user=dev_direct&passwd=password")
require.Nil(t, err)
defer resp.Body.Close()
assert.Equal(t, 200, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
assert.Nil(t, err)
t.Logf("resp %s", string(body))
t.Logf("headers: %+v", resp.Header)
require.Equal(t, 2, len(resp.Cookies()))
assert.Equal(t, "JWT", resp.Cookies()[0].Name)
assert.NotEqual(t, "", resp.Cookies()[0].Value, "token set")
assert.Equal(t, 86400, resp.Cookies()[0].MaxAge)
assert.Equal(t, "XSRF-TOKEN", resp.Cookies()[1].Name)
assert.NotEqual(t, "", resp.Cookies()[1].Value, "xsrf cookie set")
resp, err = client.Get("http://127.0.0.1:8089/private")
require.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
assert.NoError(t, resp.Body.Close())
} | explode_data.jsonl/34048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 514
} | [
2830,
3393,
16027,
5179,
1155,
353,
8840,
836,
8,
341,
197,
6878,
49304,
1669,
21327,
1860,
1155,
340,
16867,
49304,
2822,
197,
322,
5858,
198,
12428,
277,
11,
1848,
1669,
12544,
19033,
7121,
27907,
340,
17957,
59678,
1155,
11,
1848,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAccKeycloakOpenidClient_updateRealm(t *testing.T) {
realmOne := "terraform-" + acctest.RandString(10)
realmTwo := "terraform-" + acctest.RandString(10)
clientId := "terraform-" + acctest.RandString(10)
resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakOpenidClientDestroy(),
Steps: []resource.TestStep{
{
Config: testKeycloakOpenidClient_updateRealmBefore(realmOne, realmTwo, clientId),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOpenidClientExistsWithCorrectProtocol("keycloak_openid_client.client"),
testAccCheckKeycloakOpenidClientBelongsToRealm("keycloak_openid_client.client", realmOne),
),
},
{
Config: testKeycloakOpenidClient_updateRealmAfter(realmOne, realmTwo, clientId),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOpenidClientExistsWithCorrectProtocol("keycloak_openid_client.client"),
testAccCheckKeycloakOpenidClientBelongsToRealm("keycloak_openid_client.client", realmTwo),
),
},
},
})
} | explode_data.jsonl/52126 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 438
} | [
2830,
3393,
14603,
1592,
88751,
5002,
307,
2959,
8882,
64290,
1155,
353,
8840,
836,
8,
341,
17200,
7673,
3966,
1669,
330,
61385,
27651,
488,
1613,
67880,
2013,
437,
703,
7,
16,
15,
340,
17200,
7673,
11613,
1669,
330,
61385,
27651,
488,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRegisterCommenter(t *testing.T) {
a := assert.New(t)
tt := NewStruct("TestType1", StructData{"Name": String("abc-123")})
nt := NewStruct("TestType2", StructData{"Name": String("abc-123")})
RegisterHRSCommenter("TestType1", "mylib1", TestCommenter{prefix: "MyTest: ", testType: tt.typeOf()})
s1 := EncodedValue(tt)
a.True(strings.Contains(s1, "// MyTest: abc-123"))
s1 = EncodedValue(nt)
a.False(strings.Contains(s1, "// MyTest: abc-123"))
RegisterHRSCommenter("TestType1", "mylib1", TestCommenter{prefix: "MyTest2: ", testType: tt.typeOf()})
s1 = EncodedValue(tt)
a.True(strings.Contains(s1, "// MyTest2: abc-123"))
UnregisterHRSCommenter("TestType1", "mylib1")
s1 = EncodedValue(tt)
a.False(strings.Contains(s1, "// MyTest2: abc-123"))
} | explode_data.jsonl/60911 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 308
} | [
2830,
3393,
8690,
10677,
261,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
692,
3244,
83,
1669,
1532,
9422,
445,
2271,
929,
16,
497,
16139,
1043,
4913,
675,
788,
923,
445,
13683,
12,
16,
17,
18,
899,
3518,
197,
406,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReset(t *testing.T) {
msr := NewInMemoryTransactionStore(DummyMatcher{}, 10)
m1 := Transaction{Request: &mock.Request{Host: "TEST1"}}
msr.Save(m1)
m2 := Transaction{Request: &mock.Request{Host: "TEST2"}}
msr.Save(m2)
if len(msr.matches) != 2 {
t.Fatalf("Invalid store len: %v", len(msr.matches))
}
if cap(msr.matches) != 10 {
t.Fatalf("Invalid store cap: %v", cap(msr.matches))
}
msr.Reset()
if len(msr.matches) != 0 {
t.Fatalf("Invalid store len: %v", len(msr.matches))
}
if cap(msr.matches) != 10 {
t.Fatalf("Invalid store cap: %v", cap(msr.matches))
}
} | explode_data.jsonl/44244 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 268
} | [
2830,
3393,
14828,
1155,
353,
8840,
836,
8,
1476,
47691,
81,
1669,
1532,
641,
10642,
8070,
6093,
5432,
8574,
37554,
22655,
220,
16,
15,
340,
2109,
16,
1669,
17869,
90,
1900,
25,
609,
16712,
9659,
90,
9296,
25,
330,
10033,
16,
95642,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDownloadAll(t *testing.T) {
chartPath := t.TempDir()
m := &Manager{
Out: new(bytes.Buffer),
RepositoryConfig: repoConfig,
RepositoryCache: repoCache,
ChartPath: chartPath,
}
signtest, err := loader.LoadDir(filepath.Join("testdata", "signtest"))
if err != nil {
t.Fatal(err)
}
if err := chartutil.SaveDir(signtest, filepath.Join(chartPath, "testdata")); err != nil {
t.Fatal(err)
}
local, err := loader.LoadDir(filepath.Join("testdata", "local-subchart"))
if err != nil {
t.Fatal(err)
}
if err := chartutil.SaveDir(local, filepath.Join(chartPath, "charts")); err != nil {
t.Fatal(err)
}
signDep := &chart.Dependency{
Name: signtest.Name(),
Repository: "file://./testdata/signtest",
Version: signtest.Metadata.Version,
}
localDep := &chart.Dependency{
Name: local.Name(),
Repository: "",
Version: local.Metadata.Version,
}
// create a 'tmpcharts' directory to test #5567
if err := os.MkdirAll(filepath.Join(chartPath, "tmpcharts"), 0755); err != nil {
t.Fatal(err)
}
if err := m.downloadAll([]*chart.Dependency{signDep, localDep}); err != nil {
t.Error(err)
}
if _, err := os.Stat(filepath.Join(chartPath, "charts", "signtest-0.1.0.tgz")); os.IsNotExist(err) {
t.Error(err)
}
} | explode_data.jsonl/24398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 554
} | [
2830,
3393,
11377,
2403,
1155,
353,
8840,
836,
8,
341,
197,
15941,
1820,
1669,
259,
65009,
6184,
741,
2109,
1669,
609,
2043,
515,
197,
197,
2662,
25,
1060,
501,
23158,
22622,
1326,
197,
197,
4624,
2648,
25,
15867,
2648,
345,
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... | 8 |
func TestAccAWSS3BucketObject_tags(t *testing.T) {
var obj1, obj2, obj3, obj4 s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
rInt := acctest.RandInt()
key := "test-key"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectConfig_withTags(rInt, key, "stuff"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj1),
testAccCheckAWSS3BucketObjectBody(&obj1, "stuff"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "3"),
resource.TestCheckResourceAttr(resourceName, "tags.Key1", "AAA"),
resource.TestCheckResourceAttr(resourceName, "tags.Key2", "BBB"),
resource.TestCheckResourceAttr(resourceName, "tags.Key3", "CCC"),
),
},
{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectConfig_withUpdatedTags(rInt, key, "stuff"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj2),
testAccCheckAWSS3BucketObjectVersionIdEquals(&obj2, &obj1),
testAccCheckAWSS3BucketObjectBody(&obj2, "stuff"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "4"),
resource.TestCheckResourceAttr(resourceName, "tags.Key2", "BBB"),
resource.TestCheckResourceAttr(resourceName, "tags.Key3", "X X"),
resource.TestCheckResourceAttr(resourceName, "tags.Key4", "DDD"),
resource.TestCheckResourceAttr(resourceName, "tags.Key5", "E:/"),
),
},
{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectConfig_withNoTags(rInt, key, "stuff"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj3),
testAccCheckAWSS3BucketObjectVersionIdEquals(&obj3, &obj2),
testAccCheckAWSS3BucketObjectBody(&obj3, "stuff"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
),
},
{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectConfig_withTags(rInt, key, "changed stuff"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj4),
testAccCheckAWSS3BucketObjectVersionIdDiffers(&obj4, &obj3),
testAccCheckAWSS3BucketObjectBody(&obj4, "changed stuff"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "3"),
resource.TestCheckResourceAttr(resourceName, "tags.Key1", "AAA"),
resource.TestCheckResourceAttr(resourceName, "tags.Key2", "BBB"),
resource.TestCheckResourceAttr(resourceName, "tags.Key3", "CCC"),
),
},
},
})
} | explode_data.jsonl/64969 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1109
} | [
2830,
3393,
14603,
14419,
1220,
18,
36018,
1190,
16333,
1155,
353,
8840,
836,
8,
341,
2405,
2839,
16,
11,
2839,
17,
11,
2839,
18,
11,
2839,
19,
274,
18,
25618,
5097,
198,
50346,
675,
1669,
330,
8635,
643,
18,
38749,
5314,
6035,
698,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnmarshalError(t *testing.T) {
for _, c := range testUnmarshalCases {
s := s3.New(unit.Session)
s.Handlers.Send.Clear()
s.Handlers.Send.PushBack(func(r *request.Request) {
r.HTTPResponse = c.RespFn()
r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode)
})
_, err := s.PutBucketAcl(&s3.PutBucketAclInput{
Bucket: aws.String("bucket"), ACL: aws.String("public-read"),
})
assert.Error(t, err)
assert.Equal(t, c.Code, err.(awserr.Error).Code())
assert.Equal(t, c.Msg, err.(awserr.Error).Message())
assert.Equal(t, c.ReqID, err.(awserr.RequestFailure).RequestID())
}
} | explode_data.jsonl/69504 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
1806,
27121,
1454,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
1273,
1806,
27121,
37302,
341,
197,
1903,
1669,
274,
18,
7121,
24144,
20674,
340,
197,
1903,
35308,
9254,
20176,
13524,
741,
197,
1903,
35308,
925... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResultType(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
rs, err := tk.Exec(`select cast(null as char(30))`)
require.NoError(t, err)
req := rs.NewChunk(nil)
err = rs.Next(context.Background(), req)
require.NoError(t, err)
require.True(t, req.GetRow(0).IsNull(0))
require.Equal(t, mysql.TypeVarString, rs.Fields()[0].Column.FieldType.GetType())
} | explode_data.jsonl/5777 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
2077,
929,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
324... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCropParams(t *testing.T) {
src := image.NewNRGBA(image.Rect(0, 0, 64, 128))
tests := []struct {
opt Options
x0, y0, x1, y1 int
}{
{Options{CropWidth: 10, CropHeight: 0}, 0, 0, 10, 128},
{Options{CropWidth: 0, CropHeight: 10}, 0, 0, 64, 10},
{Options{CropWidth: -1, CropHeight: -1}, 0, 0, 64, 128},
{Options{CropWidth: 50, CropHeight: 100}, 0, 0, 50, 100},
{Options{CropWidth: 100, CropHeight: 100}, 0, 0, 64, 100},
{Options{CropX: 50, CropY: 100}, 50, 100, 64, 128},
{Options{CropX: 50, CropY: 100, CropWidth: 100, CropHeight: 150}, 50, 100, 64, 128},
{Options{CropX: -50, CropY: -50}, 14, 78, 64, 128},
{Options{CropY: 0.5, CropWidth: 0.5}, 0, 64, 32, 128},
}
for _, tt := range tests {
want := image.Rect(tt.x0, tt.y0, tt.x1, tt.y1)
got := cropParams(src, tt.opt)
if !got.Eq(want) {
t.Errorf("cropParams(%v) returned %v, want %v", tt.opt, got, want)
}
}
} | explode_data.jsonl/11690 | {
"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,
62146,
4870,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
2168,
7121,
45,
58927,
10075,
32153,
7,
15,
11,
220,
15,
11,
220,
21,
19,
11,
220,
16,
17,
23,
1171,
78216,
1669,
3056,
1235,
341,
197,
64838,
310,
14566,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestParseVolumeBindMount(t *testing.T) {
for _, path := range []string{"./foo", "~/thing", "../other", "/foo", "/home/user"} {
volume, err := parseVolume(path + ":/target")
expected := types.ServiceVolumeConfig{
Type: "bind",
Source: path,
Target: "/target",
}
assert.NoError(t, err)
assert.Equal(t, expected, volume)
}
} | explode_data.jsonl/70097 | {
"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,
14463,
18902,
9950,
16284,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1815,
1669,
2088,
3056,
917,
4913,
1725,
7975,
497,
48188,
1596,
497,
7005,
1575,
497,
3521,
7975,
497,
3521,
5117,
11739,
9207,
341,
197,
5195,
4661,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestJetStreamImport(t *testing.T) {
conf := createConfFile(t, []byte(`
listen: 127.0.0.1:-1
no_auth_user: rip
jetstream: {max_mem_store: 64GB, max_file_store: 10TB}
accounts: {
JS: {
jetstream: enabled
users: [ {user: dlc, password: foo} ]
exports [ { service: "$JS.API.>" }, { service: "foo" }]
},
U: {
users: [ {user: rip, password: bar} ]
imports [
{ service: { subject: "$JS.API.>", account: JS } , to: "dlc.>" }
{ service: { subject: "foo", account: JS } }
]
},
}
`))
defer os.Remove(conf)
s, _ := RunServerWithConfig(conf)
defer s.Shutdown()
if config := s.JetStreamConfig(); config != nil {
defer os.RemoveAll(config.StoreDir)
}
// Create a stream using JSM.
ncm, err := nats.Connect(s.ClientURL(), nats.UserInfo("dlc", "foo"))
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
defer ncm.Close()
jsm, err := ncm.JetStream()
if err != nil {
t.Fatal(err)
}
_, err = jsm.AddStream(&nats.StreamConfig{
Name: "TEST",
Subjects: []string{"foo", "bar"},
})
if err != nil {
t.Fatalf("stream create failed: %v", err)
}
// Client with the imports.
nc, err := nats.Connect(s.ClientURL())
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
defer nc.Close()
// Since we import with a prefix from above we can use that when creating our JS context.
js, err := nc.JetStream(nats.APIPrefix("dlc"))
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
msg := []byte("Hello JS Import!")
if _, err = js.Publish("foo", msg); err != nil {
t.Fatalf("Unexpected publish error: %v", err)
}
} | explode_data.jsonl/29165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 689
} | [
2830,
3393,
35641,
3027,
11511,
1155,
353,
8840,
836,
8,
341,
67850,
1669,
1855,
15578,
1703,
1155,
11,
3056,
3782,
61528,
197,
14440,
268,
25,
220,
16,
17,
22,
13,
15,
13,
15,
13,
16,
10944,
16,
198,
197,
72104,
14014,
3317,
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... | 8 |
func TestUserService_EnableUser(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
apiName := "enableUser"
response, err := ReadData(apiName, "UserService")
if err != nil {
t.Errorf("Failed to read response data due to: %v", err)
}
fmt.Fprintf(writer, response[apiName])
}))
defer server.Close()
client := NewClient(server.URL, "APIKEY", "SECRETKEY", true)
params := client.User.NewEnableUserParams("cd2b5afa-db4d-4532-88ec-1356a273e534")
resp, err := client.User.EnableUser(params)
if err != nil {
t.Errorf("Failed to enable user due to %v", err)
return
}
if resp == nil || resp.State != "enabled" {
t.Errorf("Failed to enable user")
}
} | explode_data.jsonl/60343 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
60004,
65216,
1474,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
38356,
1758,
37508,
11,
1681,
353,
1254,
9659,
8,
341,
197,
54299,
675,
1669,
330,
12552,
1474,
698,
197,
21735,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Run_OneVolumeAttachAndDetachMultipleNodesWithReadWriteMany(t *testing.T) {
// Arrange
volumePluginMgr, fakePlugin := volumetesting.GetTestVolumePluginMgr(t)
dsw := cache.NewDesiredStateOfWorld(volumePluginMgr)
asw := cache.NewActualStateOfWorld(volumePluginMgr)
fakeKubeClient := controllervolumetesting.CreateTestClient()
fakeRecorder := &record.FakeRecorder{}
ad := operationexecutor.NewOperationExecutor(operationexecutor.NewOperationGenerator(fakeKubeClient, volumePluginMgr, fakeRecorder, false /* checkNodeCapabilitiesBeforeMount */))
nsu := statusupdater.NewFakeNodeStatusUpdater(false /* returnError */)
reconciler := NewReconciler(
reconcilerLoopPeriod, maxWaitForUnmountDuration, syncLoopPeriod, false, dsw, asw, ad, nsu, fakeRecorder)
podName1 := "pod-uid1"
podName2 := "pod-uid2"
volumeName := v1.UniqueVolumeName("volume-name")
volumeSpec := controllervolumetesting.GetTestVolumeSpec(string(volumeName), volumeName)
volumeSpec.PersistentVolume.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadWriteMany}
nodeName1 := k8stypes.NodeName("node-name1")
nodeName2 := k8stypes.NodeName("node-name2")
dsw.AddNode(nodeName1, false /*keepTerminatedPodVolumes*/)
dsw.AddNode(nodeName2, false /*keepTerminatedPodVolumes*/)
generatedVolumeName, podAddErr := dsw.AddPod(types.UniquePodName(podName1), controllervolumetesting.NewPod(podName1, podName1), volumeSpec, nodeName1)
if podAddErr != nil {
t.Fatalf("AddPod failed. Expected: <no error> Actual: <%v>", podAddErr)
}
_, podAddErr = dsw.AddPod(types.UniquePodName(podName2), controllervolumetesting.NewPod(podName2, podName2), volumeSpec, nodeName2)
if podAddErr != nil {
t.Fatalf("AddPod failed. Expected: <no error> Actual: <%v>", podAddErr)
}
// Act
ch := make(chan struct{})
go reconciler.Run(ch)
defer close(ch)
// Assert
waitForNewAttacherCallCount(t, 2 /* expectedCallCount */, fakePlugin)
verifyNewAttacherCallCount(t, false /* expectZeroNewAttacherCallCount */, fakePlugin)
waitForTotalAttachCallCount(t, 2 /* expectedAttachCallCount */, fakePlugin)
verifyNewDetacherCallCount(t, true /* expectZeroNewDetacherCallCount */, fakePlugin)
waitForDetachCallCount(t, 0 /* expectedDetachCallCount */, fakePlugin)
waitForAttachedToNodesCount(t, 2 /* expectedNodeCount */, generatedVolumeName, asw)
// Act
dsw.DeletePod(types.UniquePodName(podName1), generatedVolumeName, nodeName1)
volumeExists := dsw.VolumeExists(generatedVolumeName, nodeName1)
if volumeExists {
t.Fatalf(
"Deleted pod %q from volume %q/node %q. Volume should also be deleted but it still exists.",
podName1,
generatedVolumeName,
nodeName1)
}
// Assert -- Timer will triger detach
waitForNewDetacherCallCount(t, 1 /* expectedCallCount */, fakePlugin)
verifyNewAttacherCallCount(t, false /* expectZeroNewAttacherCallCount */, fakePlugin)
waitForTotalAttachCallCount(t, 2 /* expectedAttachCallCount */, fakePlugin)
verifyNewDetacherCallCount(t, false /* expectZeroNewDetacherCallCount */, fakePlugin)
waitForTotalDetachCallCount(t, 1 /* expectedDetachCallCount */, fakePlugin)
// Act
dsw.DeletePod(types.UniquePodName(podName2), generatedVolumeName, nodeName2)
volumeExists = dsw.VolumeExists(generatedVolumeName, nodeName2)
if volumeExists {
t.Fatalf(
"Deleted pod %q from volume %q/node %q. Volume should also be deleted but it still exists.",
podName2,
generatedVolumeName,
nodeName2)
}
// Assert -- Timer will triger detach
waitForNewDetacherCallCount(t, 2 /* expectedCallCount */, fakePlugin)
verifyNewAttacherCallCount(t, false /* expectZeroNewAttacherCallCount */, fakePlugin)
waitForTotalAttachCallCount(t, 2 /* expectedAttachCallCount */, fakePlugin)
verifyNewDetacherCallCount(t, false /* expectZeroNewDetacherCallCount */, fakePlugin)
waitForTotalDetachCallCount(t, 2 /* expectedDetachCallCount */, fakePlugin)
} | explode_data.jsonl/63370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1314
} | [
2830,
3393,
84158,
68201,
18902,
30485,
3036,
89306,
32089,
12288,
2354,
58610,
8441,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
5195,
4661,
11546,
25567,
11,
12418,
11546,
1669,
62820,
57824,
287,
2234,
2271,
18902,
11546,
25567,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMinerStart(t *testing.T) {
mock := gomock.NewController(t)
defer mock.Finish()
cfg := defaultMockCfg(mock)
ovs := NewMockOverseer(mock)
ovs.EXPECT().Spool(gomock.Any(), gomock.Any()).AnyTimes().Return(nil)
status_chan := make(chan pb.TaskStatusReply_Status)
info := ContainerInfo{
status: &pb.TaskStatusReply{Status: pb.TaskStatusReply_RUNNING},
ID: "deadbeef-cafe-dead-beef-cafedeadbeef",
}
ovs.EXPECT().Start(gomock.Any(), gomock.Any()).Times(1).Return(status_chan, info, nil)
builder := MinerBuilder{}
m, err := builder.Config(cfg).Overseer(ovs).Build()
require.NotNil(t, m)
require.Nil(t, err)
reply, err := m.Start(context.Background(), &pb.MinerStartRequest{Id: "test"})
require.NotNil(t, reply)
require.Nil(t, err)
id, ok := m.getTaskIdByContainerId("deadbeef-cafe-dead-beef-cafedeadbeef")
assert.True(t, ok)
assert.Equal(t, id, "test")
} | explode_data.jsonl/44509 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 374
} | [
2830,
3393,
6217,
261,
3479,
1155,
353,
8840,
836,
8,
341,
77333,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
991,
18176,
2822,
50286,
1669,
1638,
11571,
42467,
30389,
692,
197,
859,
82,
1669,
1532,
11571,
1918,
325,
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... | 1 |
func TestGistStats_String(t *testing.T) {
v := GistStats{
TotalGists: Int(0),
PrivateGists: Int(0),
PublicGists: Int(0),
}
want := `github.GistStats{TotalGists:0, PrivateGists:0, PublicGists:0}`
if got := v.String(); got != want {
t.Errorf("GistStats.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33241 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
38,
380,
16635,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
479,
380,
16635,
515,
197,
197,
7595,
38,
1671,
25,
256,
1333,
7,
15,
1326,
197,
197,
16787,
38,
1671,
25,
1333,
7,
15,
1326,
197,
73146,
38,
1671,
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 TestAccKeycloakSamlIdentityProvider_extraConfig(t *testing.T) {
t.Parallel()
samlName := acctest.RandomWithPrefix("tf-acc")
customConfigValue := acctest.RandomWithPrefix("tf-acc")
resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakSamlIdentityProviderDestroy(),
Steps: []resource.TestStep{
{
Config: testKeycloakSamlIdentityProvider_extra_config(samlName, "dummyConfig", customConfigValue),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakSamlIdentityProviderHasCustomConfigValue("keycloak_saml_identity_provider.saml", customConfigValue),
),
},
},
})
} | explode_data.jsonl/76729 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
14603,
1592,
88751,
50,
9467,
18558,
5179,
31858,
2648,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1903,
9467,
675,
1669,
1613,
67880,
26709,
2354,
14335,
445,
8935,
12,
4475,
1138,
1444,
1450,
2648,
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 TestSessionReceiver_acceptSession(t *testing.T) {
client, cleanup, queueName := setupLiveTest(t, &admin.QueueProperties{
RequiresSession: to.Ptr(true),
})
defer cleanup()
ctx := context.Background()
// send a message to a specific session
sender, err := client.NewSender(queueName, nil)
require.NoError(t, err)
err = sender.SendMessage(ctx, &Message{
Body: []byte("session-based message"),
SessionID: to.Ptr("session-1"),
}, nil)
require.NoError(t, err)
receiver, err := client.AcceptSessionForQueue(ctx, queueName, "session-1", nil)
require.NoError(t, err)
messages, err := receiver.inner.ReceiveMessages(ctx, 1, nil)
require.NoError(t, err)
require.EqualValues(t, "session-based message", messages[0].Body)
require.EqualValues(t, "session-1", *messages[0].SessionID)
require.NoError(t, receiver.CompleteMessage(ctx, messages[0], nil))
require.EqualValues(t, "session-1", receiver.SessionID())
sessionState, err := receiver.GetSessionState(ctx, nil)
require.NoError(t, err)
require.Nil(t, sessionState)
require.NoError(t, receiver.SetSessionState(ctx, []byte("hello"), nil))
sessionState, err = receiver.GetSessionState(ctx, nil)
require.NoError(t, err)
require.EqualValues(t, "hello", string(sessionState))
} | explode_data.jsonl/70558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 438
} | [
2830,
3393,
5283,
25436,
35728,
5283,
1155,
353,
8840,
836,
8,
341,
25291,
11,
21290,
11,
7177,
675,
1669,
6505,
20324,
2271,
1155,
11,
609,
2882,
50251,
7903,
515,
197,
197,
46961,
5283,
25,
311,
94989,
3715,
1326,
197,
3518,
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 TestConvertMapStringStringToStrings(t *testing.T) {
type in struct {
mp map[string]string
delimiter string
}
var tcs = []struct {
name string
input in
expected []string
}{
{
name: tt.Name{
Given: "map[string]string and delimiter",
When: "map is empty",
Then: "return converted data",
}.Construct(),
input: in{
delimiter: ":",
},
expected: []string{},
},
{
name: tt.Name{
Given: "map[string]string and delimiter",
When: "delimiter is empty",
Then: "return converted data",
}.Construct(),
input: in{
mp: map[string]string{
"hello": "world",
"user": "pass",
},
},
expected: []string{"helloworld", "userpass"},
},
{
name: tt.Name{
Given: "map[string]string and delimiter",
When: "both not empty",
Then: "return converted data",
}.Construct(),
input: in{
mp: map[string]string{
"hello": "world",
"user": "pass",
},
delimiter: ":",
},
expected: []string{"hello:world", "user:pass"},
},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
actual := ConvertMapStringStringToStrings(tc.input.mp, tc.input.delimiter)
// Sort to avoid mismatch.
sort.Slice(actual[:], func(i, j int) bool {
return actual[i] > actual[j]
})
sort.Slice(tc.expected[:], func(i, j int) bool {
return tc.expected[i] > tc.expected[j]
})
tt.Equal(t, tc.expected, actual)
})
}
} | explode_data.jsonl/9697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 678
} | [
2830,
3393,
12012,
2227,
703,
703,
5870,
82,
1155,
353,
8840,
836,
8,
341,
13158,
304,
2036,
341,
197,
53230,
286,
2415,
14032,
30953,
198,
197,
69509,
17700,
914,
198,
197,
630,
2405,
259,
4837,
284,
3056,
1235,
341,
197,
11609,
257,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWidthAndPrecision(t *testing.T) {
for i, tt := range startests {
s := Sprintf(tt.fmt, tt.in...)
if s != tt.out {
t.Errorf("#%d: %q: got %q expected %q", i, tt.fmt, s, tt.out)
}
}
} | explode_data.jsonl/46267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
3327,
3036,
55501,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
17853,
1669,
2088,
1191,
17966,
341,
197,
1903,
1669,
328,
2517,
47152,
833,
2501,
11,
17853,
1858,
31218,
197,
743,
274,
961,
17853,
2532,
341,
298,
3244,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDeSerializeStruct(t *testing.T) {
t.Skip("skipping TestDeSerializeStruct")
u := User{}
err := FromGOB64("Iv+BAwEBBFVzZXIB/4IAAQIBAklkAQQAAQROYW1lAQwAAAAR/4IBFAEKaGFycnkgZGF5bwA=", &u)
if err != nil {
t.Errorf("FromGOB64 error: %s", err)
}
if u.ID != 10 {
t.Errorf("FromGOB64 result: %+v", u)
}
} | explode_data.jsonl/30431 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
1912,
15680,
9422,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
445,
4886,
5654,
3393,
1912,
15680,
9422,
5130,
10676,
1669,
2657,
16094,
9859,
1669,
5542,
15513,
33,
21,
19,
445,
40,
85,
10,
7064,
86,
8264,
19883,
53,
89,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRun(t *testing.T) {
t.Run("struct", func(t *testing.T) {
type testcase struct {
Bool bool
Int int
String string
Pointer *struct{}
Slice []byte
}
testcases := map[string]interface{}{
"bool": testcase{Bool: true},
"int": testcase{Int: 1},
"string": testcase{String: "test"},
"pointer": testcase{Pointer: &struct{}{}},
"slice": testcase{Slice: []byte("test")},
}
matrixtest.Run(t, testcases, func(testcase interface{}) func(t *testing.T) {
return func(t *testing.T) {
t.Log(testcase)
}
})
})
t.Run("map", func(t *testing.T) {
matrixtest.Run(t, map[string]interface{}{
"a": map[string]string{"a": "a"},
"b": map[string]string{"b": "b"},
"c": map[string]string{"c": "c"},
}, func(testcase interface{}) func(t *testing.T) {
return func(t *testing.T) {
t.Log(testcase)
}
})
})
} | explode_data.jsonl/48163 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
6727,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1235,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
13158,
70080,
2036,
341,
298,
197,
11233,
262,
1807,
198,
298,
57152,
257,
526,
198,
298,
4980,
220,
914,
198,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLongestConnected(t *testing.T) {
umap, err := types.NewURLsMap("mem1=http://10.1:2379,mem2=http://10.2:2379,mem3=http://10.3:2379")
if err != nil {
t.Fatal(err)
}
clus, err := membership.NewClusterFromURLsMap("test", umap)
if err != nil {
t.Fatal(err)
}
memberIDs := clus.MemberIDs()
tr := newNopTransporterWithActiveTime(memberIDs)
transferee, ok := longestConnected(tr, memberIDs)
if !ok {
t.Fatalf("unexpected ok %v", ok)
}
if memberIDs[0] != transferee {
t.Fatalf("expected first member %s to be transferee, got %s", memberIDs[0], transferee)
}
// make all members non-active
amap := make(map[types.ID]time.Time)
for _, id := range memberIDs {
amap[id] = time.Time{}
}
tr.(*nopTransporterWithActiveTime).reset(amap)
_, ok2 := longestConnected(tr, memberIDs)
if ok2 {
t.Fatalf("unexpected ok %v", ok)
}
} | explode_data.jsonl/69652 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
6583,
477,
21146,
1155,
353,
8840,
836,
8,
341,
197,
372,
391,
11,
1848,
1669,
4494,
7121,
3144,
82,
2227,
445,
10536,
16,
34717,
1110,
16,
15,
13,
16,
25,
17,
18,
22,
24,
11,
10536,
17,
34717,
1110,
16,
15,
13,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAliasFromConfig(t *testing.T) {
servers := map[string]*clientconfig.Server{
"foo": {
Server: "http://foo.com",
},
"foobar": {
Server: "http://foo.com/bar",
},
"foobaz": {
Server: "http://foo.com/baz",
},
"foobarlong": {
Server: "http://foo.com/bar/long",
},
}
config := &clientconfig.Config{
Servers: servers,
}
urlWant := map[string]string{
"http://foo.com/bs": "foo",
"http://foo.com": "foo",
"http://foo.com/bar/index-mysql": "foobar",
"http://foo.com/bar": "foobar",
"http://foo.com/baz/index-kv": "foobaz",
"http://foo.com/baz": "foobaz",
"http://foo.com/bar/long/disco": "foobarlong",
"http://foo.com/bar/long": "foobarlong",
}
for url, want := range urlWant {
alias := config.Alias(url)
if alias == "" {
t.Errorf("url %v matched nothing, wanted %v", url, want)
continue
}
if alias != want {
t.Errorf("url %v matched %v, wanted %v", url, alias, want)
}
}
} | explode_data.jsonl/75538 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
22720,
3830,
2648,
1155,
353,
8840,
836,
8,
341,
1903,
18729,
1669,
2415,
14032,
8465,
2972,
1676,
22997,
515,
197,
197,
1,
7975,
788,
341,
298,
92075,
25,
330,
1254,
1110,
7975,
905,
756,
197,
197,
1583,
197,
197,
1,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestZapError(t *testing.T) {
assert.NotNil(t, ZapError(nil))
assert.NotNil(t, ZapError(errors.New("test")))
assert.NotNil(t, ZapError(NewError("TEST", "Test")))
} | explode_data.jsonl/17712 | {
"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,
57,
391,
1454,
1155,
353,
8840,
836,
8,
341,
6948,
93882,
1155,
11,
69231,
1454,
27907,
1171,
6948,
93882,
1155,
11,
69231,
1454,
38881,
7121,
445,
1944,
29836,
6948,
93882,
1155,
11,
69231,
1454,
35063,
1454,
445,
10033,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestPart1(t *testing.T) {
for _, test := range tests1 {
t.Run(test.name, func(*testing.T) {
got := part1(test.input)
if got != test.want {
t.Errorf("after %s recipes, got %v, want %v", test.input, got, test.want)
}
})
}
} | explode_data.jsonl/29927 | {
"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,
5800,
16,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
7032,
16,
341,
197,
3244,
16708,
8623,
2644,
11,
2915,
4071,
8840,
836,
8,
341,
298,
3174,
354,
1669,
949,
16,
8623,
10046,
340,
298,
743,
2684,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNamedListOpts(t *testing.T) {
var v []string
o := NewNamedListOptsRef("foo-name", &v, nil)
o.Set("foo")
if o.String() != "[foo]" {
t.Errorf("%s != [foo]", o.String())
}
if o.Name() != "foo-name" {
t.Errorf("%s != foo-name", o.Name())
}
if len(v) != 1 {
t.Errorf("expected foo to be in the values, got %v", v)
}
} | explode_data.jsonl/26384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
15810,
852,
43451,
1155,
353,
8840,
836,
8,
341,
2405,
348,
3056,
917,
198,
22229,
1669,
1532,
15810,
852,
43451,
3945,
445,
7975,
11494,
497,
609,
85,
11,
2092,
692,
22229,
4202,
445,
7975,
1138,
743,
297,
6431,
368,
961,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCleanup(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, ocproto.Header{})
k := app.ConsortiumKeeper
// add auths
auth := &types.ValidatorAuth{
OperatorAddress: string(valAddr),
CreationAllowed: true,
}
require.NoError(t, k.SetValidatorAuth(ctx, auth))
// cleanup
k.Cleanup(ctx)
require.Equal(t, []*types.ValidatorAuth{}, k.GetValidatorAuths(ctx))
} | explode_data.jsonl/41782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
67335,
1155,
353,
8840,
836,
8,
341,
28236,
1669,
1643,
676,
39820,
3576,
340,
20985,
1669,
906,
13018,
2164,
7121,
1972,
3576,
11,
17796,
15110,
15753,
6257,
692,
16463,
1669,
906,
94594,
371,
2356,
77233,
271,
197,
322,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_GetManagerRankList(t *testing.T) {
assert.Equal(t, len(game.GetRankList()), 2)
assert.Equal(t, game.GetManagerRankList()[0].TeamName, "Vidar")
assert.Equal(t, game.GetManagerRankList()[1].TeamName, "E99")
} | explode_data.jsonl/77178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
13614,
2043,
22550,
852,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
2422,
15096,
2234,
22550,
852,
11858,
220,
17,
340,
6948,
12808,
1155,
11,
1809,
2234,
2043,
22550,
852,
10116,
15,
936,
14597,
675,
11,
330,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAlwaysSetEnableAggregatedAPIsToFalseIfRBACDisabled(t *testing.T) {
mockCS := getMockBaseContainerService("1.10.3")
properties := mockCS.Properties
properties.OrchestratorProfile.OrchestratorType = Kubernetes
properties.OrchestratorProfile.KubernetesConfig.EnableRbac = to.BoolPtr(false)
properties.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs = true
mockCS.setOrchestratorDefaults(true, true)
if properties.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs {
t.Fatalf("expected EnableAggregatedAPIs to be manually set to false in update scenario, instead got %t",
properties.OrchestratorProfile.KubernetesConfig.EnableAggregatedAPIs)
}
} | explode_data.jsonl/33884 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
37095,
1649,
11084,
9042,
93040,
7082,
82,
1249,
4049,
2679,
29259,
1706,
25907,
1155,
353,
8840,
836,
8,
341,
77333,
6412,
1669,
633,
11571,
3978,
4502,
1860,
445,
16,
13,
16,
15,
13,
18,
1138,
86928,
1669,
7860,
6412,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPageWithEmoji(t *testing.T) {
for _, enableEmoji := range []bool{true, false} {
v := viper.New()
v.Set("enableEmoji", enableEmoji)
b := newTestSitesBuilder(t)
b.WithViper(v)
b.WithSimpleConfigFile()
b.WithContent("page-emoji.md", `---
title: "Hugo Smile"
---
This is a :smile:.
<!--more-->
Another :smile: This is :not: :an: :emoji:.
O :christmas_tree:
Write me an :e-mail: or :email:?
Too many colons: :: ::: :::: :?: :!: :.:
If you dislike this video, you can hit that :-1: button :stuck_out_tongue_winking_eye:,
but if you like it, hit :+1: and get subscribed!
`)
b.CreateSites().Build(BuildCfg{})
if enableEmoji {
b.AssertFileContent("public/page-emoji/index.html",
"This is a 😄",
"Another 😄",
"This is :not: :an: :emoji:.",
"O 🎄",
"Write me an 📧 or ✉️?",
"Too many colons: :: ::: :::: :?: :!: :.:",
"you can hit that 👎 button 😜,",
"hit 👍 and get subscribed!",
)
} else {
b.AssertFileContent("public/page-emoji/index.html",
"This is a :smile:",
"Another :smile:",
"This is :not: :an: :emoji:.",
"O :christmas_tree:",
"Write me an :e-mail: or :email:?",
"Too many colons: :: ::: :::: :?: :!: :.:",
"you can hit that :-1: button :stuck_out_tongue_winking_eye:,",
"hit :+1: and get subscribed!",
)
}
}
} | explode_data.jsonl/60630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 618
} | [
2830,
3393,
2665,
2354,
92731,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
7283,
92731,
1669,
2088,
3056,
2641,
90,
1866,
11,
895,
92,
341,
197,
5195,
1669,
95132,
7121,
741,
197,
5195,
4202,
445,
12552,
92731,
497,
7283,
92731,
340,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestStringSimplify(t *testing.T) {
b := gen.String("abc")
simple := b.Simplify()
tt.Equal(t, "string abc", fmt.Sprintf("%T %v", simple, simple))
} | explode_data.jsonl/64878 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
703,
50,
70206,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
4081,
6431,
445,
13683,
1138,
1903,
6456,
1669,
293,
808,
70206,
2822,
3244,
83,
12808,
1155,
11,
330,
917,
39022,
497,
8879,
17305,
4430,
51,
1018,
85,
497,
4285,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddAndGet(t *testing.T) {
testObj := testObject{
key: "foo",
val: "bar",
}
objectCache := NewFakeObjectCache(func() (interface{}, error) {
return nil, fmt.Errorf("Unexpected Error: updater should never be called in this test")
}, 1*time.Hour, clock.NewFakeClock(time.Now()))
err := objectCache.Add(testObj.key, testObj.val)
if err != nil {
t.Errorf("Unable to add obj %#v by key: %s", testObj, testObj.key)
}
value, err := objectCache.Get(testObj.key)
if err != nil {
t.Errorf("Unable to get obj %#v by key: %s", testObj, testObj.key)
}
if value.(string) != testObj.val {
t.Errorf("Expected to get cached value: %#v, but got: %s", testObj.val, value.(string))
}
} | explode_data.jsonl/44027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
2212,
97726,
1155,
353,
8840,
836,
8,
341,
18185,
5261,
1669,
1273,
1190,
515,
197,
23634,
25,
330,
7975,
756,
197,
19302,
25,
330,
2257,
756,
197,
532,
35798,
8233,
1669,
1532,
52317,
1190,
8233,
18552,
368,
320,
4970,
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 TestOpenPlatformSiteNotMatch(t *testing.T) {
result := getOpenPlatformSiteDetail(-1)
if result.Message != "" {
t.Errorf("error message mismatch: expected %s, but got %s", "EMPTY_STRING", result.Message)
}
result = getOpenPlatformSiteDetail(1999999)
if result.Message != "" {
t.Errorf("error message mismatch: expected %s, but got %s", "EMPTY_STRING", result.Message)
}
result = getOpenPlatformSiteDetail(3000000)
if result.Message != "" {
t.Errorf("error message mismatch: expected %s, but got %s", "EMPTY_STRING", result.Message)
}
} | explode_data.jsonl/26983 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
5002,
17296,
17597,
2623,
8331,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
633,
5002,
17296,
17597,
10649,
4080,
16,
340,
743,
1102,
8472,
961,
1591,
341,
197,
3244,
13080,
445,
841,
1943,
35301,
25,
3601,
1018,
82,
11,
714... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInject(t *testing.T) {
defines := config.ProcessDefines(map[string]config.DefineData{
"chain.prop": {
DefineFunc: func(args config.DefineArgs) js_ast.E {
return &js_ast.EIdentifier{Ref: args.FindSymbol(args.Loc, "replace")}
},
},
"obj.defined": {
DefineFunc: func(args config.DefineArgs) js_ast.E {
return &js_ast.EString{Value: js_lexer.StringToUTF16("defined")}
},
},
"injectedAndDefined": {
DefineFunc: func(args config.DefineArgs) js_ast.E {
return &js_ast.EString{Value: js_lexer.StringToUTF16("should be used")}
},
},
})
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
let sideEffects = console.log('this should be renamed')
let collide = 123
console.log(obj.prop)
console.log(obj.defined)
console.log(injectedAndDefined)
console.log(chain.prop.test)
console.log(collide)
console.log(re_export)
`,
"/inject.js": `
export let obj = {}
export let sideEffects = console.log('side effects')
export let noSideEffects = /* @__PURE__ */ console.log('side effects')
export let injectedAndDefined = 'should not be used'
`,
"/node_modules/unused/index.js": `
console.log('This is unused but still has side effects')
`,
"/node_modules/sideEffects-false/index.js": `
console.log('This is unused and has no side effects')
`,
"/node_modules/sideEffects-false/package.json": `{
"sideEffects": false
}`,
"/replacement.js": `
export let replace = {
test() {}
}
`,
"/collision.js": `
export let collide = 123
`,
"/re-export.js": `
export {re_export} from 'external-pkg'
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
Defines: &defines,
OutputFormat: config.FormatCommonJS,
InjectAbsPaths: []string{
"/inject.js",
"/node_modules/unused/index.js",
"/node_modules/sideEffects-false/index.js",
"/replacement.js",
"/collision.js",
"/re-export.js",
},
ExternalModules: config.ExternalModules{
NodeModules: map[string]bool{
"external-pkg": true,
},
},
},
})
} | explode_data.jsonl/38583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 979
} | [
2830,
3393,
13738,
1155,
353,
8840,
836,
8,
341,
7452,
1543,
1669,
2193,
29012,
73816,
9147,
14032,
60,
1676,
49947,
482,
1043,
515,
197,
197,
1,
8819,
18417,
788,
341,
298,
197,
35338,
9626,
25,
2915,
7356,
2193,
49947,
482,
4117,
8,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddRouter(t *testing.T) {
describeTests("Test AddRouter method")
router := Router{}
testAddRoot(router, t)
testAddOneSegment(router, t)
testAddManySegments(router, t)
testAddDuplicateEndpoint(router, t)
} | explode_data.jsonl/34492 | {
"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,
2212,
9523,
1155,
353,
8840,
836,
8,
341,
82860,
18200,
445,
2271,
2691,
9523,
1714,
5130,
67009,
1669,
10554,
31483,
18185,
2212,
8439,
61210,
11,
259,
340,
18185,
2212,
3966,
21086,
61210,
11,
259,
340,
18185,
2212,
8441,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlacementPolicyCache(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set @@tidb_enable_exchange_partition = 1")
defer func() {
tk.MustExec("set @@tidb_enable_exchange_partition = 0")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
}()
initTable := func() []string {
tk.MustExec("drop table if exists t2")
tk.MustExec("drop table if exists t1")
tk.MustExec(`create table t1(id int) partition by range(id)
(partition p0 values less than (100), partition p1 values less than (200))`)
is := dom.InfoSchema()
tb, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t1"))
require.NoError(t, err)
partDefs := tb.Meta().GetPartitionInfo().Definitions
sort.Slice(partDefs, func(i, j int) bool { return partDefs[i].Name.L < partDefs[j].Name.L })
rows := []string{}
for k, v := range partDefs {
ptID := placement.GroupID(v.ID)
is.SetBundle(&placement.Bundle{
ID: ptID,
Rules: []*placement.Rule{{Count: k}},
})
rows = append(rows, fmt.Sprintf("%s 0 test t1 %s <nil> %d ", ptID, v.Name.L, k))
}
return rows
}
// test drop
_ = initTable()
//tk.MustQuery("select * from information_schema.placement_policy order by REPLICAS").Check(testkit.Rows(rows...))
tk.MustExec("alter table t1 drop partition p0")
//tk.MustQuery("select * from information_schema.placement_policy").Check(testkit.Rows(rows[1:]...))
_ = initTable()
//tk.MustQuery("select * from information_schema.placement_policy order by REPLICAS").Check(testkit.Rows(rows...))
tk.MustExec("drop table t1")
//tk.MustQuery("select * from information_schema.placement_policy").Check(testkit.Rows())
// test truncate
_ = initTable()
//tk.MustQuery("select * from information_schema.placement_policy order by REPLICAS").Check(testkit.Rows(rows...))
tk.MustExec("alter table t1 truncate partition p0")
//tk.MustQuery("select * from information_schema.placement_policy").Check(testkit.Rows(rows[1:]...))
_ = initTable()
//tk.MustQuery("select * from information_schema.placement_policy order by REPLICAS").Check(testkit.Rows(rows...))
tk.MustExec("truncate table t1")
//tk.MustQuery("select * from information_schema.placement_policy").Check(testkit.Rows())
// test exchange
_ = initTable()
//tk.MustQuery("select * from information_schema.placement_policy order by REPLICAS").Check(testkit.Rows(rows...))
tk.MustExec("create table t2(id int)")
tk.MustExec("alter table t1 exchange partition p0 with table t2")
//tk.MustQuery("select * from information_schema.placement_policy").Check(testkit.Rows())
} | explode_data.jsonl/77382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 989
} | [
2830,
3393,
28237,
13825,
8233,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4719,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
3036,
13636,
1155,
340,
16867,
4240,
741,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
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 TestValidSignalForPlatform(t *testing.T) {
isValidSignal := ValidSignalForPlatform(syscall.Signal(0))
assert.Check(t, is.Equal(false, isValidSignal))
for _, sigN := range SignalMap {
isValidSignal = ValidSignalForPlatform(syscall.Signal(sigN))
assert.Check(t, is.Equal(true, isValidSignal))
}
} | explode_data.jsonl/62498 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
4088,
26810,
2461,
17296,
1155,
353,
8840,
836,
8,
341,
19907,
4088,
26810,
1669,
7818,
26810,
2461,
17296,
18140,
6659,
75669,
7,
15,
1171,
6948,
10600,
1155,
11,
374,
12808,
3576,
11,
26171,
26810,
4390,
2023,
8358,
8366,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClient_ShowJobRun_Exists(t *testing.T) {
t.Parallel()
app, cleanup := cltest.NewApplication(t, cltest.EthMockRegisterChainID)
defer cleanup()
require.NoError(t, app.Start())
j := cltest.NewJobWithWebInitiator()
assert.NoError(t, app.Store.CreateJob(&j))
jr := cltest.CreateJobRunViaWeb(t, app, j, `{"result":"100"}`)
client, r := app.NewClientAndRenderer()
set := flag.NewFlagSet("test", 0)
set.Parse([]string{jr.ID.String()})
c := cli.NewContext(nil, set, nil)
assert.NoError(t, client.ShowJobRun(c))
assert.Equal(t, 1, len(r.Renders))
assert.Equal(t, jr.ID, r.Renders[0].(*presenters.JobRun).ID)
} | explode_data.jsonl/78833 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
2959,
79665,
12245,
6727,
62,
15575,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
28236,
11,
21290,
1669,
1185,
1944,
7121,
4988,
1155,
11,
1185,
1944,
5142,
339,
11571,
8690,
18837,
915,
340,
16867,
21290,
741,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBreakerEvents(t *testing.T) {
c := clock.NewMock()
cb := NewBreaker()
cb.Clock = c
events := cb.Subscribe()
cb.Trip()
if e := <-events; e != BreakerTripped {
t.Fatalf("expected to receive a trip event, got %d", e)
}
c.Add(cb.nextBackOff + 1)
cb.Ready()
if e := <-events; e != BreakerReady {
t.Fatalf("expected to receive a breaker ready event, got %d", e)
}
cb.Reset()
if e := <-events; e != BreakerReset {
t.Fatalf("expected to receive a reset event, got %d", e)
}
cb.Fail()
if e := <-events; e != BreakerFail {
t.Fatalf("expected to receive a fail event, got %d", e)
}
} | explode_data.jsonl/60796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
22524,
261,
7900,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
8866,
7121,
11571,
741,
63810,
1669,
1532,
22524,
261,
741,
63810,
79248,
284,
272,
198,
90873,
1669,
9858,
82628,
2822,
63810,
836,
4561,
741,
743,
384,
1669,
9119... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNasTypeNewCause5GMM(t *testing.T) {
a := nasType.NewCause5GMM(nasMessage.DeregistrationRequestUETerminatedDeregistrationCause5GMMType)
assert.NotNil(t, a)
} | explode_data.jsonl/51894 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
45,
300,
929,
3564,
60912,
20,
38,
8035,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
17141,
929,
7121,
60912,
20,
38,
8035,
1445,
300,
2052,
909,
52633,
4048,
1900,
52,
1348,
261,
51199,
35,
52633,
4048,
60912,
20,
38,
80... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeGovStore(t *testing.T) {
cdc := makeTestCodec()
endTime := time.Now().UTC()
content := gov.ContentFromProposalType("test", "test", gov.ProposalTypeText)
proposal := gov.NewProposal(content, 1, endTime, endTime.Add(24*time.Hour))
proposalIDBz := make([]byte, 8)
binary.LittleEndian.PutUint64(proposalIDBz, 1)
deposit := gov.NewDeposit(1, delAddr1, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())))
vote := gov.NewVote(1, delAddr1, gov.OptionYes)
kvPairs := cmn.KVPairs{
cmn.KVPair{Key: gov.ProposalKey(1), Value: cdc.MustMarshalBinaryLengthPrefixed(proposal)},
cmn.KVPair{Key: gov.InactiveProposalQueueKey(1, endTime), Value: proposalIDBz},
cmn.KVPair{Key: gov.DepositKey(1, delAddr1), Value: cdc.MustMarshalBinaryLengthPrefixed(deposit)},
cmn.KVPair{Key: gov.VoteKey(1, delAddr1), Value: cdc.MustMarshalBinaryLengthPrefixed(vote)},
cmn.KVPair{Key: []byte{0x99}, Value: []byte{0x99}},
}
tests := []struct {
name string
expectedLog string
}{
{"proposals", fmt.Sprintf("%v\n%v", proposal, proposal)},
{"proposal IDs", "proposalIDA: 1\nProposalIDB: 1"},
{"deposits", fmt.Sprintf("%v\n%v", deposit, deposit)},
{"votes", fmt.Sprintf("%v\n%v", vote, vote)},
{"other", ""},
}
for i, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
switch i {
case len(tests) - 1:
require.Panics(t, func() { DecodeGovStore(cdc, cdc, kvPairs[i], kvPairs[i]) }, tt.name)
default:
require.Equal(t, tt.expectedLog, DecodeGovStore(cdc, cdc, kvPairs[i], kvPairs[i]), tt.name)
}
})
}
} | explode_data.jsonl/13743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 697
} | [
2830,
3393,
32564,
66901,
6093,
1155,
353,
8840,
836,
8,
341,
1444,
7628,
1669,
1281,
2271,
36913,
2822,
6246,
1462,
1669,
882,
13244,
1005,
21183,
2822,
27751,
1669,
47625,
12614,
3830,
98637,
929,
445,
1944,
497,
330,
1944,
497,
47625,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReflectCallVariadic(t *testing.T) {
const SCRIPT = `
var r = f("Hello %s, %d", "test", 42);
if (r !== "Hello test, 42") {
throw new Error("test 1 has failed: " + r);
}
r = f("Hello %s, %d", ["test", 42]);
if (r !== "Hello test, 42") {
throw new Error("test 2 has failed: " + r);
}
r = f("Hello %s, %s", "test");
if (r !== "Hello test, %!s(MISSING)") {
throw new Error("test 3 has failed: " + r);
}
r = f();
if (r !== "") {
throw new Error("test 4 has failed: " + r);
}
`
vm := New()
vm.Set("f", fmt.Sprintf)
prg := MustCompile("test.js", SCRIPT, false)
_, err := vm.RunProgram(prg)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/10499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
72789,
7220,
56135,
36214,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
435,
284,
282,
445,
9707,
1018,
82,
11,
1018,
67,
497,
330,
1944,
497,
220,
19,
17,
317,
743,
320,
81,
4376,
330,
9707,
1273,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestHypervisorDefaultsInitrd(t *testing.T) {
assert := assert.New(t)
tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)
testInitrdPath := filepath.Join(tmpdir, "initrd")
testInitrdLinkPath := filepath.Join(tmpdir, "initrd-link")
err = createEmptyFile(testInitrdPath)
assert.NoError(err)
err = syscall.Symlink(testInitrdPath, testInitrdLinkPath)
assert.NoError(err)
savedInitrdPath := defaultInitrdPath
defer func() {
defaultInitrdPath = savedInitrdPath
}()
defaultInitrdPath = testInitrdPath
h := hypervisor{}
p, err := h.initrd()
assert.Error(err)
assert.Equal(p, "", "default Image path wrong")
// test path resolution
defaultInitrdPath = testInitrdLinkPath
h = hypervisor{}
p, err = h.initrd()
assert.Error(err)
assert.Equal(p, "")
} | explode_data.jsonl/11735 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 309
} | [
2830,
3393,
39,
1082,
31396,
16273,
3803,
6498,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
8623,
6184,
11,
14676,
6948,
35699,
3964,
340,
16867,
2643,
84427,
10368,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiUnsub(t *testing.T) {
ps := New(1)
defer ps.Shutdown()
ch := ps.Sub("t1", "t2", "t3")
ps.Unsub(ch, "t1")
ps.Pub("hi", "t1")
ps.Pub("hello", "t2")
ps.Unsub(ch, "t2", "t3")
checkContents(t, ch, []string{"hello"})
} | explode_data.jsonl/44261 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
20358,
1806,
1966,
1155,
353,
8840,
836,
8,
341,
35009,
1669,
1532,
7,
16,
340,
16867,
4726,
10849,
18452,
2822,
23049,
1669,
4726,
12391,
445,
83,
16,
497,
330,
83,
17,
497,
330,
83,
18,
5130,
35009,
10616,
1966,
7520,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTLSWithBasicAuth(t *testing.T) {
Convey("Make a new controller", t, func() {
caCert, err := ioutil.ReadFile(CACert)
So(err, ShouldBeNil)
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
htpasswdPath := test.MakeHtpasswdFile()
defer os.Remove(htpasswdPath)
port := test.GetFreePort()
baseURL := test.GetBaseURL(port)
secureBaseURL := test.GetSecureBaseURL(port)
resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool, MinVersion: tls.VersionTLS12})
defer func() { resty.SetTLSClientConfig(nil) }()
conf := config.New()
conf.HTTP.Port = port
conf.HTTP.TLS = &config.TLSConfig{
Cert: ServerCert,
Key: ServerKey,
}
conf.HTTP.Auth = &config.AuthConfig{
HTPasswd: config.AuthHTPasswd{
Path: htpasswdPath,
},
}
ctlr := api.NewController(conf)
ctlr.Config.Storage.RootDirectory = t.TempDir()
go startServer(ctlr)
defer stopServer(ctlr)
test.WaitTillServerReady(baseURL)
// accessing insecure HTTP site should fail
resp, err := resty.R().Get(baseURL)
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusBadRequest)
// without creds, should get access error
resp, err = resty.R().Get(secureBaseURL + "/v2/")
So(err, ShouldBeNil)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusUnauthorized)
var e api.Error
err = json.Unmarshal(resp.Body(), &e)
So(err, ShouldBeNil)
// with creds, should get expected status code
resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL)
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusNotFound)
resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/")
So(resp, ShouldNotBeNil)
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
})
} | explode_data.jsonl/77687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 734
} | [
2830,
3393,
45439,
2354,
15944,
5087,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
8078,
264,
501,
6461,
497,
259,
11,
2915,
368,
341,
197,
197,
924,
36934,
11,
1848,
1669,
43144,
78976,
3025,
1706,
529,
340,
197,
76912,
3964,
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 TestNetworkFailure(t *testing.T) {
var dials uint32
errDialer := func(network, addr string) (net.Conn, error) {
atomic.AddUint32(&dials, 1)
return nil, errors.New("network down")
}
cmgr, err := New(&Config{
TargetOutbound: 5,
RetryDuration: 5 * time.Millisecond,
Dial: errDialer,
GetNewAddress: func() (net.Addr, error) {
return &net.TCPAddr{
IP: net.ParseIP("127.0.0.1"),
Port: 18555,
}, nil
},
OnConnection: func(c *ConnReq, conn net.Conn) {
t.Fatalf("network failure: got unexpected connection - %v", c.Addr)
},
})
if err != nil {
t.Fatalf("New error: %v", err)
}
cmgr.Start()
time.AfterFunc(10*time.Millisecond, cmgr.Stop)
cmgr.Wait()
wantMaxDials := uint32(75)
if atomic.LoadUint32(&dials) > wantMaxDials {
t.Fatalf("network failure: unexpected number of dials - got %v, want < %v",
atomic.LoadUint32(&dials), wantMaxDials)
}
} | explode_data.jsonl/53952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
12320,
17507,
1155,
353,
8840,
836,
8,
341,
2405,
294,
10309,
2622,
18,
17,
198,
9859,
35,
530,
261,
1669,
2915,
46542,
11,
10789,
914,
8,
320,
4711,
50422,
11,
1465,
8,
341,
197,
78739,
1904,
21570,
18,
17,
2099,
67,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.