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 Test_Properties_ValidateContainerRuntime(t *testing.T) {
p := &Properties{}
p.OrchestratorProfile = &OrchestratorProfile{}
p.OrchestratorProfile.OrchestratorType = Kubernetes
for _, runtime := range ContainerRuntimeValues {
p.OrchestratorProfile.KubernetesConfig = &KubernetesConfig{}
p.OrchestratorProfile.KubernetesConfig.ContainerRuntime = runtime
if err := p.validateContainerRuntime(); err != nil {
t.Errorf(
"should not error on containerRuntime=\"%s\"",
runtime,
)
}
}
p.OrchestratorProfile.KubernetesConfig.ContainerRuntime = "not-existing"
if err := p.validateContainerRuntime(); err == nil {
t.Errorf(
"should error on invalid containerRuntime",
)
}
p.OrchestratorProfile.KubernetesConfig.ContainerRuntime = KataContainers
p.AgentPoolProfiles = []*AgentPoolProfile{
{
OSType: Windows,
},
}
if err := p.validateContainerRuntime(); err == nil {
t.Errorf(
"should error on kata-containers for windows clusters",
)
}
p.OrchestratorProfile.KubernetesConfig.ContainerRuntime = Containerd
p.AgentPoolProfiles = []*AgentPoolProfile{
{
OSType: Windows,
},
}
if err := p.validateContainerRuntime(); err == nil {
t.Errorf(
"should error on containerd for windows clusters",
)
}
} | explode_data.jsonl/17875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 461
} | [
2830,
3393,
1088,
9249,
62,
17926,
4502,
15123,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
609,
7903,
16094,
3223,
90449,
331,
15111,
850,
8526,
284,
609,
2195,
331,
15111,
850,
8526,
16094,
3223,
90449,
331,
15111,
850,
8526,
90449,
331... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSerialization(t *testing.T) {
s, port := tcpudp.NewUDPServer(&defaultConf, true)
defer s.Stop()
m := createTimelineManager(port, false, false, defaultTransportSize, time.Second, nil)
defer m.Shutdown()
number := newNumberPoint(15)
serialized, err := m.SerializeJSON(numberPoint, toGenericParametersN(number)...)
if !assert.NoError(t, err, "no error expected when serializing number") {
return
}
message := tcpudp.MessageData{
Message: serialized,
}
testReceivedData(t, &message, number, false)
} | explode_data.jsonl/68116 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
35865,
1155,
353,
8840,
836,
8,
1476,
1903,
11,
2635,
1669,
28051,
31101,
7121,
4656,
5012,
2836,
2099,
2258,
15578,
11,
830,
340,
16867,
274,
30213,
2822,
2109,
1669,
1855,
59641,
2043,
21230,
11,
895,
11,
895,
11,
1638,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAssessMetricStatusConsecutiveErrors(t *testing.T) {
metric := v1alpha1.Metric{
Name: "success-rate",
Interval: "60s",
}
result := v1alpha1.MetricResult{
ConsecutiveError: 5,
Count: 5,
Measurements: []v1alpha1.Measurement{{
Phase: v1alpha1.AnalysisPhaseError,
StartedAt: timePtr(metav1.NewTime(time.Now().Add(-60 * time.Second))),
FinishedAt: timePtr(metav1.NewTime(time.Now().Add(-60 * time.Second))),
}},
}
assert.Equal(t, v1alpha1.AnalysisPhaseError, assessMetricStatus(metric, result, false))
assert.Equal(t, v1alpha1.AnalysisPhaseError, assessMetricStatus(metric, result, true))
result.ConsecutiveError = 4
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, assessMetricStatus(metric, result, true))
assert.Equal(t, v1alpha1.AnalysisPhaseRunning, assessMetricStatus(metric, result, false))
} | explode_data.jsonl/75820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 340
} | [
2830,
3393,
5615,
433,
54310,
2522,
1109,
85780,
13877,
1155,
353,
8840,
836,
8,
341,
2109,
16340,
1669,
348,
16,
7141,
16,
1321,
16340,
515,
197,
21297,
25,
257,
330,
5630,
43026,
756,
197,
197,
10256,
25,
330,
21,
15,
82,
756,
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 TestAggregateClosedConnectionsTimestamp(t *testing.T) {
conn := ConnectionStats{
Pid: 123,
Type: TCP,
Family: AFINET,
Source: util.AddressFromString("127.0.0.1"),
Dest: util.AddressFromString("127.0.0.1"),
MonotonicSentBytes: 3,
}
client := "client"
state := NewDefaultNetworkState()
// Register the client
assert.Len(t, state.Connections(client, latestEpochTime(), nil), 0)
conn.LastUpdateEpoch = latestEpochTime()
state.StoreClosedConnection(conn)
conn.LastUpdateEpoch = latestEpochTime()
state.StoreClosedConnection(conn)
conn.LastUpdateEpoch = latestEpochTime()
state.StoreClosedConnection(conn)
// Make sure the connections we get has the latest timestamp
assert.Equal(t, conn.LastUpdateEpoch, state.Connections(client, latestEpochTime(), nil)[0].LastUpdateEpoch)
} | explode_data.jsonl/22153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
64580,
26884,
54751,
20812,
1155,
353,
8840,
836,
8,
341,
32917,
1669,
11032,
16635,
515,
197,
10025,
307,
25,
394,
220,
16,
17,
18,
345,
197,
27725,
25,
2290,
26656,
345,
197,
12727,
5174,
25,
1797,
362,
16750,
1348,
345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_write_val_int_ptr(t *testing.T) {
should := require.New(t)
buf := &bytes.Buffer{}
stream := NewStream(ConfigDefault, buf, 4096)
val := 1001
stream.WriteVal(&val)
stream.Flush()
should.Nil(stream.Error)
should.Equal("1001", buf.String())
} | explode_data.jsonl/51206 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
9165,
6189,
4042,
4348,
1155,
353,
8840,
836,
8,
341,
197,
5445,
1669,
1373,
7121,
1155,
340,
26398,
1669,
609,
9651,
22622,
16094,
44440,
1669,
1532,
3027,
33687,
3675,
11,
6607,
11,
220,
19,
15,
24,
21,
340,
19302,
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 TestContainsString(t *testing.T) {
cases := []struct {
slice []string
value string
expect bool
}{
{[]string{"1"}, "1", true},
{[]string{"1"}, "2", false},
{[]string{"1", "2"}, "1", true},
{[]string{"1", "2"}, "3", false},
{nil, "3", false},
{nil, "", false},
}
for _, each := range cases {
t.Run(path.Join(each.slice...), func(t *testing.T) {
actual := Contains(each.slice, each.value)
assert.Equal(t, each.expect, actual)
})
}
} | explode_data.jsonl/76720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
23805,
703,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
1903,
4754,
220,
3056,
917,
198,
197,
16309,
220,
914,
198,
197,
24952,
1807,
198,
197,
59403,
197,
197,
90,
1294,
917,
4913,
16,
14345,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEnvironmentVariableOverrideArgument(t *testing.T) {
var args struct {
Foo string `arg:"env"`
}
setenv(t, "FOO", "bar")
os.Args = []string{"example", "--foo", "baz"}
MustParse(&args)
assert.Equal(t, "baz", args.Foo)
} | explode_data.jsonl/13037 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
12723,
7827,
2177,
9171,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
12727,
2624,
914,
1565,
858,
2974,
3160,
8805,
197,
532,
8196,
3160,
1155,
11,
330,
3788,
46,
497,
330,
2257,
1138,
25078,
51015,
284,
3056... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParse(t *testing.T) {
domain := newSplitQuery("test")
table := &Table{hashBy: "_col5", sortBy: "NA"}
queries, err := parseThriftDomain(domain, table.hashBy, table.sortBy)
assert.NoError(t, err)
assert.Len(t, queries, 1)
} | explode_data.jsonl/74843 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
14463,
1155,
353,
8840,
836,
8,
341,
2698,
3121,
1669,
501,
20193,
2859,
445,
1944,
1138,
26481,
1669,
609,
2556,
90,
8296,
1359,
25,
9000,
2074,
20,
497,
66913,
25,
330,
7326,
16707,
197,
42835,
11,
1848,
1669,
4715,
1001... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddExtraVar(t *testing.T) {
tests := []struct {
desc string
options *AnsibleAdhocOptions
err error
extraVarName string
extraVarValue interface{}
res map[string]interface{}
}{
{
desc: "Testing add an extraVar to a nil data structure",
options: &AnsibleAdhocOptions{
ExtraVars: nil,
},
err: nil,
extraVarName: "extra",
extraVarValue: "var",
res: map[string]interface{}{
"extra": "var",
},
},
{
desc: "Testing add an extraVar",
options: &AnsibleAdhocOptions{
ExtraVars: map[string]interface{}{
"extra1": "var1",
},
},
err: nil,
extraVarName: "extra",
extraVarValue: "var",
res: map[string]interface{}{
"extra1": "var1",
"extra": "var",
},
},
{
desc: "Testing add an existing extraVar",
options: &AnsibleAdhocOptions{
ExtraVars: map[string]interface{}{
"extra": "var",
},
},
err: errors.New("(adhoc::AddExtraVar)", "ExtraVar 'extra' already exist"),
extraVarName: "extra",
extraVarValue: "var",
res: nil,
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
t.Log(test.desc)
err := test.options.AddExtraVar(test.extraVarName, test.extraVarValue)
if err != nil && assert.Error(t, err) {
assert.Equal(t, test.err, err)
} else {
assert.Equal(t, test.res, test.options.ExtraVars, "Unexpected options value")
}
})
}
} | explode_data.jsonl/69691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 709
} | [
2830,
3393,
2212,
11612,
3962,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
688,
914,
198,
197,
35500,
981,
353,
69599,
1238,
2589,
88473,
3798,
198,
197,
9859,
1843,
1465,
198,
197,
8122,
2172,
3962,
675,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGenerateFixedName(t *testing.T) {
testCases := map[string]struct {
uid string
prefix string
expected string
}{
"standard": {
uid: "2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
prefix: "default-text-extractor",
expected: "default-text-extractor-2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
},
"too long": {
uid: "2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
prefix: "this-is-an-extremely-long-prefix-which-will-make-the-generated-name-too-long-",
expected: "this-is-an-extremely-long--2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
},
"uid starts with dash": {
uid: "-2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
prefix: "this-is-an-extremely-long-prefix-which-will-make-the-generated-name-too-long-",
expected: "this-is-an-extremely-long--2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
},
"prefix ends with dash": {
uid: "2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
prefix: "default-text-extractor-",
expected: "default-text-extractor-2d6c09e1-aa54-11e9-9d6a-42010a8a0062",
},
}
for n, tc := range testCases {
t.Run(n, func(t *testing.T) {
owner := &v1alpha1.Broker{
ObjectMeta: metav1.ObjectMeta{
UID: types.UID(tc.uid),
},
}
if actual := GenerateFixedName(owner, tc.prefix); actual != tc.expected {
t.Errorf("Expected %q, actual %q", tc.expected, actual)
}
})
}
} | explode_data.jsonl/53356 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 698
} | [
2830,
3393,
31115,
13520,
675,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
2423,
414,
914,
198,
197,
3223,
5060,
256,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
1,
20270,
788,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRequestUrlFor(t *testing.T) {
req := defaultRequest("GET", "http://localhost", nil, t)
path := "/foo/bar"
urlObj := req.UrlFor(path, nil)
if urlObj.Path != path {
t.Error(path + " was expected to be the path, but got " + urlObj.Path)
}
expected := "http://localhost/foo/bar"
if urlObj.String() != expected {
t.Error(expected + " was expected, but the returned URL was " + urlObj.String())
}
} | explode_data.jsonl/31841 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
1900,
2864,
2461,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
1638,
1900,
445,
3806,
497,
330,
1254,
1110,
8301,
497,
2092,
11,
259,
692,
26781,
1669,
3521,
7975,
49513,
1837,
19320,
5261,
1669,
4232,
41024,
2461,
5581,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestVet(t *testing.T) {
t.Parallel()
dir := fs.NewDir(t, "test-vet",
fs.WithFile("file.go", vetFile("root")),
fs.WithFile("file_test.go", vetExternalPackageFile("root_test")),
fs.WithDir("sub",
fs.WithFile("file.go", vetFile("sub"))),
fs.WithDir("excluded",
fs.WithFile("file.go", vetFile("excluded"))))
defer dir.Remove()
expected := Issues{
{Linter: "vet", Severity: "error", Path: "file.go", Line: 7, Col: 0, Message: "Printf format %d reads arg #1, but call has only 0 args"},
{Linter: "vet", Severity: "error", Path: "file.go", Line: 7, Col: 0, Message: "unreachable code"},
{Linter: "vet", Severity: "error", Path: "file_test.go", Line: 5, Col: 0, Message: "unreachable code"},
{Linter: "vet", Severity: "error", Path: "sub/file.go", Line: 7, Col: 0, Message: "Printf format %d reads arg #1, but call has only 0 args"},
{Linter: "vet", Severity: "error", Path: "sub/file.go", Line: 7, Col: 0, Message: "unreachable code"},
}
if version := runtime.Version(); strings.HasPrefix(version, "go1.8") || strings.HasPrefix(version, "go1.9") {
expected = Issues{
{Linter: "vet", Severity: "error", Path: "file.go", Line: 7, Col: 0, Message: "missing argument for Printf(\"%d\"): format reads arg 1, have only 0 args"},
{Linter: "vet", Severity: "error", Path: "file.go", Line: 7, Col: 0, Message: "unreachable code"},
{Linter: "vet", Severity: "error", Path: "file_test.go", Line: 5, Col: 0, Message: "unreachable code"},
{Linter: "vet", Severity: "error", Path: "sub/file.go", Line: 7, Col: 0, Message: "missing argument for Printf(\"%d\"): format reads arg 1, have only 0 args"},
{Linter: "vet", Severity: "error", Path: "sub/file.go", Line: 7, Col: 0, Message: "unreachable code"},
}
}
actual := RunLinter(t, "vet", dir.Path(), "--skip=excluded")
assert.Equal(t, expected, actual)
} | explode_data.jsonl/19399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 709
} | [
2830,
3393,
53,
295,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
48532,
1669,
8619,
7121,
6184,
1155,
11,
330,
1944,
8273,
295,
756,
197,
53584,
26124,
1703,
445,
1192,
18002,
497,
23313,
1703,
445,
2888,
30154,
197,
53584,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLogActions(t *testing.T) {
f := newPLMFixture(t)
defer f.TearDown()
f.kClient.SetLogsForPodContainer(podID, cName, "hello world!\ngoodbye world!\n")
state := f.store.LockMutableStateForTesting()
p := store.Pod{
PodID: podID,
Containers: []store.Container{NewRunningContainer(cName, cID)},
}
state.UpsertManifestTarget(manifestutils.NewManifestTargetWithPod(
model.Manifest{Name: "server"}, p))
f.store.UnlockMutableState()
f.plm.OnChange(f.ctx, f.store)
f.ConsumeLogActionsUntil("hello world!")
} | explode_data.jsonl/65265 | {
"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,
2201,
12948,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
2916,
44,
18930,
1155,
340,
16867,
282,
836,
682,
4454,
2822,
1166,
5202,
2959,
4202,
51053,
2461,
23527,
4502,
1295,
347,
915,
11,
272,
675,
11,
330,
14990,
1879... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMicrositeGet(t *testing.T) {
setup()
defer teardown()
addRestHandlerFunc("/assets/microsite/1005", func(w http.ResponseWriter, req *http.Request) {
testURLParam(t, req, "depth", "complete")
testMethod(t, req, "GET")
fmt.Fprint(w, `{"assetType":"Microsite","id":"10005","name":"A Test Microsite", "updatedAt": "1329842061","domains":["test.com", "example.com"]}`)
})
microsite, _, err := client.Microsites.Get(1005)
if err != nil {
t.Errorf("Microsites.Get recieved error: %v", err)
}
output := &Microsite{ID: 10005, Name: "A Test Microsite", UpdatedAt: 1329842061, Domains: []string{"test.com", "example.com"}}
testModels(t, "Microsites.Get", microsite, output)
} | explode_data.jsonl/7513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 265
} | [
2830,
3393,
34609,
9513,
1949,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
12718,
12416,
3050,
9626,
4283,
5160,
3183,
2754,
9513,
14,
16,
15,
15,
20,
497,
2915,
3622,
1758,
37508,
11,
4232,
353,
1254,
9659,
8,
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 |
func TestLogger_NewLogger(t *testing.T) {
l := loggerDefaults
l.File = t.TempDir() + "test.log"
l.Fields = []string{
"source=peaches",
"priority=1",
}
logger := l.NewLogger()
assert.NotNil(t, logger)
logger.Debug("hello world")
l.Package = log.LogrusLogger
logger = l.NewLogger()
assert.NotNil(t, logger)
l.Package = log.StdLogger
logger = l.NewLogger()
assert.NotNil(t, logger)
l.Package = log.ZapLogger
logger = l.NewLogger()
assert.NotNil(t, logger)
l.Package = "bad"
logger = l.NewLogger()
assert.NotNil(t, logger)
} | explode_data.jsonl/20569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
7395,
39582,
7395,
1155,
353,
8840,
836,
8,
341,
8810,
1669,
5925,
16273,
198,
8810,
8576,
284,
259,
65009,
6184,
368,
488,
330,
1944,
1665,
698,
8810,
42809,
284,
3056,
917,
515,
197,
197,
1,
2427,
28,
375,
14242,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWorkflowParallelismLimit(t *testing.T) {
cancel, controller := newController()
defer cancel()
ctx := context.Background()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
wf := unmarshalWF(workflowParallelismLimit)
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
wf, err = wfcset.Get(ctx, wf.ObjectMeta.Name, metav1.GetOptions{})
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
pods, err := listPods(woc)
assert.NoError(t, err)
assert.Equal(t, 2, len(pods.Items))
// operate again and make sure we don't schedule any more pods
makePodsPhase(ctx, woc, apiv1.PodRunning)
wf, err = wfcset.Get(ctx, wf.ObjectMeta.Name, metav1.GetOptions{})
assert.NoError(t, err)
// wfBytes, _ := json.MarshalIndent(wf, "", " ")
// log.Printf("%s", wfBytes)
woc = newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
pods, err = listPods(woc)
assert.NoError(t, err)
assert.Equal(t, 2, len(pods.Items))
} | explode_data.jsonl/70961 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
62768,
16547,
2142,
16527,
1155,
353,
8840,
836,
8,
341,
84441,
11,
6461,
1669,
501,
2051,
741,
16867,
9121,
2822,
20985,
1669,
2266,
19047,
741,
6692,
8316,
746,
1669,
6461,
1418,
69,
2972,
746,
18979,
45926,
73,
53,
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 TestToInt(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want int
}{
{
name: "",
args: args{
s: "21",
},
want: 21,
},
{
name: "",
args: args{
s: "not_int",
},
want: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ToInt(tt.args.s); got != tt.want {
t.Errorf("ToInt() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/5470 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
38544,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1903,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
198,
197,
59403,
197,
197,
515,
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... | 2 |
func TestExtractExampleCasesFromStatement(t *testing.T) {
for _, testCase := range []struct {
statement string
expectedOutput map[string]*common.LiteralCaseSettings
}{
{
statement: `Sumas
||input
First input
||output
First output
||description
yeah...
||input
Second input
||output
Second output
||end`,
expectedOutput: map[string]*common.LiteralCaseSettings{
"statement_001": {
Input: "First input",
ExpectedOutput: "First output",
Weight: big.NewRat(1, 1),
},
"statement_002": {
Input: "Second input",
ExpectedOutput: "Second output",
Weight: big.NewRat(1, 1),
},
},
},
{
statement: `Sumas
||input
Foo
||description
why is this missing an output?
||input
Foo
||input
Another missing output.
||end`,
expectedOutput: map[string]*common.LiteralCaseSettings{},
},
{
statement: `Sumas
||input
Foo
||output
missing the end thingy`,
expectedOutput: map[string]*common.LiteralCaseSettings{},
},
} {
actualOutput := extractExampleCasesFromStatement(testCase.statement)
if !reflect.DeepEqual(testCase.expectedOutput, actualOutput) {
t.Errorf(
"Failed to extract examples from %v. expected %v, got %v",
testCase.statement,
testCase.expectedOutput,
actualOutput,
)
}
}
} | explode_data.jsonl/63170 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 534
} | [
2830,
3393,
28959,
13314,
37302,
3830,
8636,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
54452,
1669,
2088,
3056,
1235,
341,
197,
89566,
414,
914,
198,
197,
42400,
5097,
2415,
14032,
8465,
5464,
1214,
9953,
4207,
6086,
198,
197,
59403,
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 TestOperatorRestart(t *testing.T) {
namespace := "ns"
context := newTestStartCluster(namespace)
c := newCluster(context, namespace, cephv1.NetworkSpec{}, true, v1.ResourceRequirements{})
c.ClusterInfo = test.CreateConfigDir(1)
// start a basic cluster
info, err := c.Start(c.ClusterInfo, c.rookVersion, cephver.Mimic, c.spec)
assert.Nil(t, err)
assert.True(t, info.IsInitialized())
validateStart(t, c)
c = newCluster(context, namespace, cephv1.NetworkSpec{}, true, v1.ResourceRequirements{})
// starting again should be a no-op, but will not result in an error
info, err = c.Start(c.ClusterInfo, c.rookVersion, cephver.Mimic, c.spec)
assert.Nil(t, err)
assert.True(t, info.IsInitialized())
validateStart(t, c)
} | explode_data.jsonl/57255 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
18461,
59354,
1155,
353,
8840,
836,
8,
1476,
56623,
1669,
330,
4412,
698,
28413,
1669,
501,
2271,
3479,
28678,
52397,
340,
1444,
1669,
501,
28678,
5378,
11,
4473,
11,
272,
23544,
85,
16,
30149,
8327,
22655,
830,
11,
348,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCheckStandard(t *testing.T) {
conf.Cfg = conf.InitConfig([]string{})
testTxout.scriptPubKey.ParsedOpCodes = make([]opcodes.ParsedOpCode, 5)
poc := opcodes.NewParsedOpCode(opcodes.OP_RETURN, 1, []byte{0x6a})
testTxout.scriptPubKey.ParsedOpCodes[0] = *poc
var p int
p, _ = testTxout.IsStandard()
assert.Equal(t, 5, p)
poc = opcodes.NewParsedOpCode(opcodes.OP_DUP, 1, []byte{0x76})
testTxout.scriptPubKey.ParsedOpCodes[0] = *poc
poc = opcodes.NewParsedOpCode(opcodes.OP_HASH160, 1, []byte{0xa9})
testTxout.scriptPubKey.ParsedOpCodes[1] = *poc
poc = opcodes.NewParsedOpCode(opcodes.OP_PUBKEYHASH, 20, []byte{0xfd})
testTxout.scriptPubKey.ParsedOpCodes[2] = *poc
poc = opcodes.NewParsedOpCode(opcodes.OP_EQUALVERIFY, 1, []byte{0x88})
testTxout.scriptPubKey.ParsedOpCodes[3] = *poc
poc = opcodes.NewParsedOpCode(opcodes.OP_CHECKSIG, 1, []byte{0xac})
testTxout.scriptPubKey.ParsedOpCodes[4] = *poc
p, _ = testTxout.IsStandard()
assert.Equal(t, 2, p)
} | explode_data.jsonl/38869 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 458
} | [
2830,
3393,
3973,
19781,
1155,
353,
8840,
836,
8,
341,
67850,
727,
4817,
284,
2335,
26849,
2648,
10556,
917,
37790,
18185,
31584,
411,
46713,
29162,
1592,
1069,
18112,
7125,
20871,
284,
1281,
10556,
453,
25814,
1069,
18112,
7125,
2078,
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 TestPriorityQueueBasic(t *testing.T) {
queue := NewPriorityQueue(nil)
assert.Equal(t, 0, queue.Length(), "Expected length = 0")
queue.Enqueue(simpleItem(1))
assert.Equal(t, 1, queue.Length(), "Expected length = 1")
i, ok := queue.Dequeue().(simpleItem)
assert.True(t, ok, "Expected cast to succeed")
assert.Equal(t, simpleItem(1), i, "Expected to dequeue simpleItem(1)")
queue.Close()
assert.Nil(t, queue.Dequeue(), "Expect nil dequeue")
} | explode_data.jsonl/69349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
20555,
7554,
15944,
1155,
353,
8840,
836,
8,
341,
46993,
1669,
1532,
20555,
7554,
27907,
340,
6948,
12808,
1155,
11,
220,
15,
11,
7177,
6833,
1507,
330,
18896,
3084,
284,
220,
15,
5130,
46993,
65625,
1141,
6456,
1234,
7,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBuildPipelines_NotSupportedDataType(t *testing.T) {
factories := createTestFactories()
tests := []struct {
configFile string
}{
{
configFile: "not_supported_processor_logs.yaml",
},
{
configFile: "not_supported_processor_metrics.yaml",
},
{
configFile: "not_supported_processor_traces.yaml",
},
}
for _, test := range tests {
t.Run(test.configFile, func(t *testing.T) {
cfg, err := configtest.LoadConfigAndValidate(path.Join("testdata", test.configFile), factories)
require.Nil(t, err)
allExporters, err := BuildExporters(componenttest.NewNopTelemetrySettings(), component.NewDefaultBuildInfo(), cfg, factories.Exporters)
assert.NoError(t, err)
pipelineProcessors, err := BuildPipelines(componenttest.NewNopTelemetrySettings(), component.NewDefaultBuildInfo(), cfg, allExporters, factories.Processors)
assert.Error(t, err)
assert.Zero(t, len(pipelineProcessors))
})
}
} | explode_data.jsonl/24782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
11066,
47,
93997,
60816,
34636,
22653,
1155,
353,
8840,
836,
8,
341,
1166,
52893,
1669,
1855,
2271,
17417,
2433,
2822,
78216,
1669,
3056,
1235,
341,
197,
25873,
1703,
914,
198,
197,
59403,
197,
197,
515,
298,
25873,
1703,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetIssueWatchers(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
iws, err := GetIssueWatchers(1, db.ListOptions{})
assert.NoError(t, err)
// Watcher is inactive, thus 0
assert.Len(t, iws, 0)
iws, err = GetIssueWatchers(2, db.ListOptions{})
assert.NoError(t, err)
// Watcher is explicit not watching
assert.Len(t, iws, 0)
iws, err = GetIssueWatchers(5, db.ListOptions{})
assert.NoError(t, err)
// Issue has no Watchers
assert.Len(t, iws, 0)
iws, err = GetIssueWatchers(7, db.ListOptions{})
assert.NoError(t, err)
// Issue has one watcher
assert.Len(t, iws, 1)
} | explode_data.jsonl/11892 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
1949,
42006,
14247,
388,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
19905,
28770,
3380,
2271,
5988,
12367,
8230,
8915,
11,
1848,
1669,
2126,
42006,
14247,
388,
7,
16,
11,
2927,
5814,
3798,
37790,
6948,
35699,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCanGetTagByNameOrID(t *testing.T) {
// Setup
db, err := sql.Open("knowledge", "identifier")
defer db.Close()
checkError(err)
rec := httptest.NewRecorder()
e := echo.New()
h := NewHandler(db, "secret")
// First register the user.
assert.NoError(t, registerUser(db, e, rec, h, user1JSON))
// Login the user
rec = httptest.NewRecorder()
assert.NoError(t, loginUser1(db, e, rec, h, user1LoginJSON))
token := getLoginToken(rec)
// Create the Tag
rec = httptest.NewRecorder()
assert.NoError(t, createTag(db, e, rec, h, token))
// Get the ID of the new Tag
var Tag models.Tag
json.Unmarshal([]byte(rec.Body.String()), &Tag)
id := Tag.TagID
// Setup to get the Tag by name.
rec = httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/tags/name/{name}", nil)
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
c := e.NewContext(req, rec)
c.SetPath("/tags/name/:name")
c.SetParamNames("name")
c.SetParamValues(Tag1Name)
// Assert
assert.NoError(t, h.GetTagByName(c))
var TagByName models.Tag
json.Unmarshal([]byte(rec.Body.String()), &TagByName)
assert.Equal(t, Tag1Name, TagByName.Name)
// Setup to get the Tag by id.
rec = httptest.NewRecorder()
req = httptest.NewRequest(http.MethodGet, "/tags/{id}", nil)
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
c = e.NewContext(req, rec)
c.SetPath("/tags/:id")
c.SetParamNames("id")
c.SetParamValues(fmt.Sprintf("%d", id))
// Assert
assert.NoError(t, h.GetTagByTagID(c))
var TagByID models.Tag
json.Unmarshal([]byte(rec.Body.String()), &TagByID)
assert.Equal(t, id, TagByID.TagID)
assert.Equal(t, Tag1Name, TagByID.Name)
} | explode_data.jsonl/59033 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 673
} | [
2830,
3393,
6713,
1949,
5668,
16898,
2195,
915,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
198,
20939,
11,
1848,
1669,
5704,
12953,
445,
89053,
497,
330,
15909,
1138,
16867,
2927,
10421,
741,
25157,
1454,
3964,
692,
67904,
1669,
543... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomer_UpdatePendingLineItem(t *testing.T) {
key := "test api key"
mockResponse := new(invdendpoint.PendingLineItem)
mockResponse.Id = int64(1234)
mockResponse.Name = "entity example 2"
server, err := invdmockserver.New(200, mockResponse, "json", true)
if err != nil {
t.Fatal(err)
}
defer server.Close()
conn := mockConnection(key, server)
defaultEntity := conn.NewCustomer()
subjectEntity := defaultEntity.NewPendingLineItem()
subjectEntity.Id = int64(1234)
subjectEntity, err = defaultEntity.UpdatePendingLineItem(subjectEntity)
if err != nil {
t.Fatal("Error:", err)
}
if subjectEntity.Name != "entity example 2" {
t.Fatal("Error: operation not completed correctly")
}
} | explode_data.jsonl/15026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
12792,
47393,
32027,
2460,
1234,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
330,
1944,
6330,
1376,
1837,
77333,
2582,
1669,
501,
5900,
16598,
32540,
96624,
2460,
1234,
340,
77333,
2582,
6444,
284,
526,
21,
19,
7,
16,
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... | 4 |
func TestExpireat(t *testing.T) {
s, err := Run()
ok(t, err)
defer s.Close()
c, err := redis.Dial("tcp", s.Addr())
ok(t, err)
// Not volatile yet
{
equals(t, 0, s.Expire("foo"))
b, err := redis.Int(c.Do("TTL", "foo"))
ok(t, err)
equals(t, -2, b)
}
// Set something
{
_, err := c.Do("SET", "foo", "bar")
ok(t, err)
// Key exists, but no Expire set yet.
b, err := redis.Int(c.Do("TTL", "foo"))
ok(t, err)
equals(t, -1, b)
n, err := redis.Int(c.Do("EXPIREAT", "foo", 1234567890))
ok(t, err)
equals(t, 1, n) // EXPIREAT returns 1 on success.
equals(t, 1234567890, s.Expire("foo"))
b, err = redis.Int(c.Do("TTL", "foo"))
ok(t, err)
equals(t, 1234567890, b)
equals(t, 1234567890, s.Expire("foo"))
}
} | explode_data.jsonl/23144 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 382
} | [
2830,
3393,
8033,
554,
266,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
6452,
741,
59268,
1155,
11,
1848,
340,
16867,
274,
10421,
741,
1444,
11,
1848,
1669,
20870,
98462,
445,
27161,
497,
274,
93626,
2398,
59268,
1155,
11,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPlaceSpotOrderLimit(t *testing.T) {
TestSetRealOrderDefaults(t)
request := okgroup.PlaceOrderRequest{
InstrumentID: spotCurrency,
Type: order.Limit.Lower(),
Side: order.Buy.Lower(),
Price: "-100",
Size: "100",
}
_, err := o.PlaceSpotOrder(&request)
testStandardErrorHandling(t, err)
} | explode_data.jsonl/30155 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
17371,
47049,
4431,
16527,
1155,
353,
8840,
836,
8,
341,
73866,
1649,
12768,
4431,
16273,
1155,
340,
23555,
1669,
5394,
4074,
86675,
4431,
1900,
515,
197,
197,
56324,
915,
25,
7702,
26321,
345,
197,
27725,
25,
260,
1973,
121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKymaFlags(t *testing.T) {
t.Parallel()
o := &cli.Options{}
c := NewCmd(o)
c.SetOutput(ioutil.Discard) // not interested in the command's output
// test default flag values
require.Equal(t, "", o.KubeconfigPath, "kubeconfig path must be empty when default")
require.False(t, o.Verbose, "Verbose flag must be false")
require.False(t, o.NonInteractive, "Non-interactive flag must be false")
// test passing flags
err := c.ParseFlags([]string{"--kubeconfig=/some/file", "--non-interactive=true", "--verbose=true"})
require.NoError(t, err)
require.Equal(t, "/some/file", o.KubeconfigPath, "kubeconfig path must be the same as the flag provided")
require.True(t, o.Verbose, "Verbose flag must be true")
require.True(t, o.NonInteractive, "Non-interactive flag must be true")
} | explode_data.jsonl/19896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
42,
1600,
64,
9195,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22229,
1669,
609,
19521,
22179,
16094,
1444,
1669,
1532,
15613,
10108,
340,
1444,
4202,
5097,
1956,
30158,
909,
47560,
8,
442,
537,
8014,
304,
279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMarshalResponse(t *testing.T) {
p := buildResponseBody()
output, err := json.Marshal(p)
if err != nil {
t.Error(err)
}
expected := `{"error":{"status":"INVALID_ARGUMENT","message":"The registration token is not a valid FCM registration token","details":[{"@type":"type.googleapis.com/google.firebase.fcm.v1.FcmError","errorCode":"INVALID_ARGUMENT"},{"@type":"type.googleapis.com/google.rpc.BadRequest"}]}}`
if string(output) != expected {
t.Errorf("mismatch decoded response:\ngot=%s\nexpected=%s", output, expected)
}
} | explode_data.jsonl/33446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
55438,
2582,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1936,
29637,
741,
21170,
11,
1848,
1669,
2951,
37271,
1295,
340,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
630,
42400,
1669,
1565,
4913,
841,
22317,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTransferAmount(t *testing.T) {
testCases := []struct {
name string
packet channeltypes.Packet
expAmount string
expError bool
}{
{
"empty packet",
channeltypes.Packet{},
"",
true,
},
{
"invalid packet data",
channeltypes.Packet{
Data: ibctesting.MockFailPacketData,
},
"",
true,
},
{
"invalid amount - empty",
channeltypes.Packet{
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "evmos1x2w87cvt5mqjncav4lxy8yfreynn273xn5335v",
Amount: "",
},
),
},
"",
true,
},
{
"invalid amount - non-int",
channeltypes.Packet{
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "evmos1x2w87cvt5mqjncav4lxy8yfreynn273xn5335v",
Amount: "test",
},
),
},
"test",
true,
},
{
"valid",
channeltypes.Packet{
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "evmos1x2w87cvt5mqjncav4lxy8yfreynn273xn5335v",
Amount: "10000",
},
),
},
"10000",
false,
},
{
"valid - IBCTriggerAmt",
channeltypes.Packet{
Data: transfertypes.ModuleCdc.MustMarshalJSON(
&transfertypes.FungibleTokenPacketData{
Sender: "cosmos1qql8ag4cluz6r4dz28p3w00dnc9w8ueulg2gmc",
Receiver: "evmos1x2w87cvt5mqjncav4lxy8yfreynn273xn5335v",
Amount: types.IBCTriggerAmt,
},
),
},
types.IBCTriggerAmt,
false,
},
}
for _, tc := range testCases {
amt, err := GetTransferAmount(tc.packet)
if tc.expError {
require.Error(t, err, tc.name)
} else {
require.NoError(t, err, tc.name)
require.Equal(t, tc.expAmount, amt)
}
}
} | explode_data.jsonl/59294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1067
} | [
2830,
3393,
1949,
21970,
10093,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
68802,
262,
5496,
9242,
93971,
198,
197,
48558,
10093,
914,
198,
197,
48558,
1454,
220,
1807,
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... | 3 |
func TestGetSubChainDBPath(t *testing.T) {
t.Parallel()
chainDBPath := getSubChainDBPath(1, config.Default.Chain.ChainDBPath)
trieDBPath := getSubChainDBPath(1, config.Default.Chain.TrieDBPath)
assert.Equal(t, "chain-1-chain.db", chainDBPath)
assert.Equal(t, "chain-1-trie.db", trieDBPath)
} | explode_data.jsonl/22965 | {
"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,
1949,
3136,
18837,
3506,
1820,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
8819,
3506,
1820,
1669,
633,
3136,
18837,
3506,
1820,
7,
16,
11,
2193,
13275,
98269,
98269,
3506,
1820,
340,
197,
8927,
3506,
1820,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteOrder(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() || !canManipulateRealOrders {
t.Skip("skipping test, either api keys or canManipulateRealOrders isnt set correctly")
}
_, err := f.DeleteOrder(context.Background(), "1031")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15193 | {
"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,
6435,
4431,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
1369,
753,
4814,
92876,
6334,
12768,
24898,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
11,
2987,
6330,
6894,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfig(t *testing.T) {
confFile := configfile(`{}`)
defer os.Remove(confFile)
conf := config.NewConfig()
err := conf.Load(confFile, logConfPath)
AssertThat(t, err, Is{nil})
} | explode_data.jsonl/37913 | {
"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,
2648,
1155,
353,
8840,
836,
8,
341,
67850,
1703,
1669,
2193,
1192,
5809,
90,
27085,
16867,
2643,
13270,
29879,
1703,
340,
67850,
1669,
2193,
7121,
2648,
741,
9859,
1669,
2335,
13969,
29879,
1703,
11,
1487,
15578,
1820,
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 |
func Test_Finalizer_AppendDefault(t *testing.T) {
// Arrange
handler, _ := newErrorsFakeHandler(mockErrorsArangoClientBackup{})
obj, deployment := newObjectSet(backupApi.ArangoBackupStateNone)
obj.Finalizers = []string{
"RANDOM",
"FINALIZERS",
}
// Act
createArangoDeployment(t, handler, deployment)
createArangoBackup(t, handler, obj)
require.NoError(t, handler.Handle(newItemFromBackup(operation.Update, obj)))
// Assert
newObj := refreshArangoBackup(t, handler, obj)
require.NotNil(t, newObj.Finalizers)
require.True(t, hasFinalizers(newObj))
} | explode_data.jsonl/5632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
77072,
3135,
36117,
408,
3675,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
53326,
11,
716,
1669,
501,
13877,
52317,
3050,
30389,
13877,
6953,
5170,
2959,
56245,
6257,
692,
22671,
11,
23172,
1669,
501,
1190,
1649,
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 TestPhases(t *testing.T) {
rand.Seed(time.Now().UTC().UnixNano())
color.Disable(true)
defer color.Disable(false)
spec.Run(t, "phases", testPhases, spec.Report(report.Terminal{}), spec.Sequential())
} | explode_data.jsonl/10024 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
3357,
2264,
1155,
353,
8840,
836,
8,
341,
7000,
437,
5732,
291,
9730,
13244,
1005,
21183,
1005,
55832,
83819,
12367,
21481,
10166,
480,
3715,
340,
16867,
1894,
10166,
480,
3576,
692,
98100,
16708,
1155,
11,
330,
759,
2264,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestInvocationBasic(t *testing.T) {
i := &Invocation{
Bindings: nil,
SuiteName: "test:mock",
Filename: "../demos/mock.yaml",
Dir: "",
Env: nil,
Seed: 42,
Verbose: true,
}
ctx := dsl.NewCtx(nil)
err := i.Exec(ctx)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/22496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
37443,
15944,
1155,
353,
8840,
836,
8,
341,
8230,
1669,
609,
37443,
515,
197,
197,
52843,
25,
220,
2092,
345,
197,
7568,
9302,
675,
25,
330,
1944,
25,
16712,
756,
197,
12727,
4033,
25,
220,
7005,
67,
14946,
90386,
33406,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldDetectPasswordPatterns(t *testing.T) {
filename := "secret.txt"
values := [7]string{"password", "secret", "key", "pwd", "pass", "pword", "passphrase"}
for i := 0; i < len(values); i++ {
shouldPassDetectionOfSecretPattern(filename, []byte(strings.ToTitle(values[i])+":UnsafeString"), t)
shouldPassDetectionOfSecretPattern(filename, []byte(values[i]+"=UnsafeString"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("."+values[i]+"=randomStringGoesHere}"), t)
shouldPassDetectionOfSecretPattern(filename, []byte(":"+values[i]+" randomStringGoesHere"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("\"SERVER_"+strings.ToUpper(values[i])+"\" : UnsafeString"), t)
shouldPassDetectionOfSecretPattern(filename, []byte(values[i]+"2-string : UnsafeString"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("<"+values[i]+" data=123> randomStringGoesHere </"+values[i]+">"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("<admin "+values[i]+"> randomStringGoesHere </my"+values[i]+">"), t)
}
shouldPassDetectionOfSecretPattern(filename, []byte("\"pw\" : UnsafeString"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("Pw=UnsafeString"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("<ConsumerKey>alksjdhfkjaklsdhflk12345adskjf</ConsumerKey>"), t)
shouldPassDetectionOfSecretPattern(filename, []byte("AWS key :"), t)
shouldPassDetectionOfSecretPattern(filename, []byte(`BEGIN RSA PRIVATE KEY-----
aghjdjadslgjagsfjlsgjalsgjaghjldasja
-----END RSA PRIVATE KEY`), t)
shouldPassDetectionOfSecretPattern(filename, []byte(`PWD=appropriate`), t)
shouldPassDetectionOfSecretPattern(filename, []byte(`pass=appropriate`), t)
shouldPassDetectionOfSecretPattern(filename, []byte(`adminpwd=appropriate`), t)
shouldFailDetectionOfSecretPattern(filename, []byte("\"pAsSWoRD\" :1234567"), t)
shouldFailDetectionOfSecretPattern(filename, []byte(`setPassword("12345678")`), t)
shouldFailDetectionOfSecretPattern(filename, []byte(`setenv(password, "12345678")`), t)
shouldFailDetectionOfSecretPattern(filename, []byte(`random=12345678)`), t)
} | explode_data.jsonl/82118 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 717
} | [
2830,
3393,
14996,
57193,
4876,
57656,
1155,
353,
8840,
836,
8,
341,
66434,
1669,
330,
20474,
3909,
698,
45939,
1669,
508,
22,
30953,
4913,
3833,
497,
330,
20474,
497,
330,
792,
497,
330,
25565,
497,
330,
6385,
497,
330,
79,
1158,
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... | 2 |
func TestInstallPluginFromURL(t *testing.T) {
replace := true
t.Run("incompatible server version", func(t *testing.T) {
h := &plugin.HelpersImpl{}
api := &plugintest.API{}
api.On("GetServerVersion").Return("5.1.0")
h.API = api
_, err := h.InstallPluginFromURL("", true)
assert.Error(t, err)
assert.Equal(t, "incompatible server version for plugin, minimum required version: 5.18.0, current version: 5.1.0", err.Error())
})
t.Run("error while parsing the download url", func(t *testing.T) {
h := &plugin.HelpersImpl{}
api := &plugintest.API{}
api.On("GetServerVersion").Return("5.19.0")
h.API = api
_, err := h.InstallPluginFromURL("http://%41:8080/", replace)
assert.Error(t, err)
assert.Equal(t, "error while parsing url: parse \"http://%41:8080/\": invalid URL escape \"%41\"", err.Error())
})
t.Run("errors out while downloading file", func(t *testing.T) {
h := &plugin.HelpersImpl{}
api := &plugintest.API{}
api.On("GetServerVersion").Return("5.19.0")
h.API = api
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusInternalServerError)
}))
defer testServer.Close()
url := testServer.URL
_, err := h.InstallPluginFromURL(url, replace)
assert.Error(t, err)
assert.Equal(t, "received 500 status code while downloading plugin from server", err.Error())
})
t.Run("downloads the file successfully", func(t *testing.T) {
h := &plugin.HelpersImpl{}
api := &plugintest.API{}
api.On("GetServerVersion").Return("5.19.0")
h.API = api
path, _ := fileutils.FindDir("tests")
tarData, err := ioutil.ReadFile(filepath.Join(path, "testplugin.tar.gz"))
require.NoError(t, err)
expectedManifest := &model.Manifest{Id: "testplugin"}
api.On("InstallPlugin", mock.Anything, false).Return(expectedManifest, nil)
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusOK)
_, _ = res.Write(tarData)
}))
defer testServer.Close()
url := testServer.URL
manifest, err := h.InstallPluginFromURL(url, false)
assert.NoError(t, err)
assert.Equal(t, "testplugin", manifest.Id)
})
t.Run("the url pointing to server is incorrect", func(t *testing.T) {
h := &plugin.HelpersImpl{}
api := &plugintest.API{}
api.On("GetServerVersion").Return("5.19.0")
h.API = api
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusNotFound)
}))
defer testServer.Close()
url := testServer.URL
_, err := h.InstallPluginFromURL(url, false)
assert.Error(t, err)
assert.Equal(t, "received 404 status code while downloading plugin from server", err.Error())
})
} | explode_data.jsonl/68787 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1043
} | [
2830,
3393,
24690,
11546,
3830,
3144,
1155,
353,
8840,
836,
8,
341,
197,
8156,
1669,
830,
271,
3244,
16708,
445,
258,
34842,
3538,
2319,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
9598,
1669,
609,
9138,
47651,
9673,
16094,
197,
542... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransportCancelRequestInDial(t *testing.T) {
defer afterTest(t)
if testing.Short() {
t.Skip("skipping test in -short mode")
}
var logbuf bytes.Buffer
eventLog := log.New(&logbuf, "", 0)
unblockDial := make(chan bool)
defer close(unblockDial)
inDial := make(chan bool)
tr := &Transport{
Dial: func(network, addr string) (net.Conn, error) {
eventLog.Println("dial: blocking")
inDial <- true
<-unblockDial
return nil, errors.New("nope")
},
}
cl := &Client{Transport: tr}
gotres := make(chan bool)
req, _ := NewRequest("GET", "http://something.no-network.tld/", nil)
go func() {
_, err := cl.Do(req)
eventLog.Printf("Get = %v", err)
gotres <- true
}()
select {
case <-inDial:
case <-time.After(5 * time.Second):
t.Fatal("timeout; never saw blocking dial")
}
eventLog.Printf("canceling")
tr.CancelRequest(req)
tr.CancelRequest(req) // used to panic on second call
select {
case <-gotres:
case <-time.After(5 * time.Second):
panic("hang. events are: " + logbuf.String())
}
got := logbuf.String()
want := `dial: blocking
canceling
Get = Get http://something.no-network.tld/: net/http: request canceled while waiting for connection
`
if got != want {
t.Errorf("Got events:\n%s\nWant:\n%s", got, want)
}
} | explode_data.jsonl/4901 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
27560,
9269,
1900,
641,
35,
530,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
304,
481,
8676,
3856,
1138,
197,
532,
2405,
1487,
5909,
5820... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTwoTimers(t *testing.T) {
MockMode = true
timer1 := NewTimer(5 * time.Second)
done1 := make(chan struct{})
timer2 := NewTimer(5 * time.Millisecond)
done2 := make(chan struct{})
go func() {
<-timer1.C()
done1 <- struct{}{}
}()
go func() {
<-timer2.C()
done2 <- struct{}{}
}()
Elapse(5 * time.Millisecond)
<-done2
Elapse(9995 * time.Millisecond)
<-done1
} | explode_data.jsonl/68926 | {
"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,
11613,
20217,
388,
1155,
353,
8840,
836,
8,
341,
9209,
1176,
3636,
284,
830,
198,
51534,
16,
1669,
1532,
10105,
7,
20,
353,
882,
32435,
340,
40495,
16,
1669,
1281,
35190,
2036,
6257,
692,
51534,
17,
1669,
1532,
10105,
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 TestTxnDelete(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
txn := ctx.dataBroker.NewTxn()
Expect(txn).NotTo(BeNil())
txn = txn.Delete("key")
Expect(txn).NotTo(BeNil())
err := txn.Commit(context.Background())
Expect(err).ToNot(HaveOccurred())
} | explode_data.jsonl/29441 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
31584,
77,
6435,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6505,
2271,
1155,
340,
16867,
5635,
31853,
37496,
2271,
2822,
3244,
42967,
1669,
5635,
2196,
65545,
7121,
31584,
77,
741,
35911,
27301,
77,
568,
2623,
1249,
76860,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDisk_usage(t *testing.T) {
path := "/"
if runtime.GOOS == "windows" {
path = "C:"
}
v, err := Usage(path)
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}
if v.Path != path {
t.Errorf("error %v", err)
}
} | explode_data.jsonl/25908 | {
"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,
47583,
31507,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
80455,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
26781,
284,
330,
34,
34300,
197,
532,
5195,
11,
1848,
1669,
24567,
5581,
340,
1903,
13389,
2679,
2623,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSaveCommit(t *testing.T) {
s := objmock.NewStore()
com1 := objhelpers.RandomCommit()
buf := bytes.NewBuffer(nil)
_, err := com1.WriteTo(buf)
require.NoError(t, err)
sum1, err := objects.SaveCommit(s, buf.Bytes())
require.NoError(t, err)
obj, err := objects.GetCommit(s, sum1)
require.NoError(t, err)
objhelpers.AssertCommitEqual(t, com1, obj)
com2 := objhelpers.RandomCommit()
buf.Reset()
_, err = com2.WriteTo(buf)
require.NoError(t, err)
sum2, err := objects.SaveCommit(s, buf.Bytes())
require.NoError(t, err)
sl, err := objects.GetAllCommitKeys(s)
require.NoError(t, err)
orig := [][]byte{sum1, sum2}
sort.Slice(orig, func(i, j int) bool {
return string(orig[i]) < string(orig[j])
})
assert.Equal(t, orig, sl)
require.NoError(t, objects.DeleteCommit(s, sum1))
bb := make([]byte, 1024)
_, _, err = objects.GetBlock(s, bb, sum1)
assert.Equal(t, objects.ErrKeyNotFound, err)
assert.True(t, objects.CommitExist(s, sum2))
require.NoError(t, objects.DeleteAllCommit(s))
assert.False(t, objects.CommitExist(s, sum2))
} | explode_data.jsonl/57831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 450
} | [
2830,
3393,
8784,
33441,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
2839,
16712,
7121,
6093,
2822,
32810,
16,
1669,
2839,
21723,
26709,
33441,
741,
26398,
1669,
5820,
7121,
4095,
27907,
340,
197,
6878,
1848,
1669,
469,
16,
4073,
1249,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQuery(t *testing.T) {
env := NewTestVDBEnv(t)
env.Cleanup("testquery_")
env.Cleanup("testquery_ns1")
env.Cleanup("testquery_ns2")
env.Cleanup("testquery_ns3")
defer env.Cleanup("testquery_")
defer env.Cleanup("testquery_ns1")
defer env.Cleanup("testquery_ns2")
defer env.Cleanup("testquery_ns3")
commontests.TestQuery(t, env.DBProvider)
} | explode_data.jsonl/594 | {
"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,
2859,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
1532,
2271,
53,
3506,
14359,
1155,
340,
57538,
727,
60639,
445,
1944,
1631,
62,
1138,
57538,
727,
60639,
445,
1944,
1631,
34728,
16,
1138,
57538,
727,
60639,
445,
1944,
1631,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSecret(t *testing.T) {
tests := []struct {
name string
secretNS string
secretName string
wantErr bool
want *corev1.Secret
}{
{
name: "Case: Valid request for retrieving a secret",
secretNS: "",
secretName: "foo",
want: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
},
wantErr: false,
},
{
name: "Case: Invalid request for retrieving a secret",
secretNS: "",
secretName: "foo2",
want: &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fakeClient, fakeClientSet := FakeNew()
// Fake getting Secret
fakeClientSet.Kubernetes.PrependReactor("get", "secrets", func(action ktesting.Action) (bool, runtime.Object, error) {
if tt.want.Name != tt.secretName {
return true, nil, fmt.Errorf("'get' called with a different secret name")
}
return true, tt.want, nil
})
returnValue, err := fakeClient.GetSecret(tt.secretName, tt.secretNS)
// Check for validating return value
if err == nil && returnValue != tt.want {
t.Errorf("error in return value got: %v, expected %v", returnValue, tt.want)
}
if !tt.wantErr == (err != nil) {
t.Errorf("\nclient.GetSecret(secretNS, secretName) unexpected error %v, wantErr %v", err, tt.wantErr)
}
})
}
} | explode_data.jsonl/65156 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 629
} | [
2830,
3393,
1949,
19773,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
197,
20474,
2448,
256,
914,
198,
197,
197,
20474,
675,
914,
198,
197,
50780,
7747,
262,
1807,
198,
197,
50780,
981,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNetStatsBasic(t *testing.T) {
logrus.SetLevel(logrus.DebugLevel)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ps := NewNetStats(ctx, 120*time.Second, 2*time.Second, 1)
time.Sleep(4 * time.Second)
assert.GreaterOrEqual(t, len(ps.NICs), 1)
for _, n := range ps.NICs {
_, ok := n.BytesRecv.Timeseries.Last()
assert.True(t, ok)
_, ok = n.PacketsRecv.Timeseries.Last()
assert.True(t, ok)
}
} | explode_data.jsonl/1476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
6954,
16635,
15944,
1155,
353,
8840,
836,
8,
341,
90822,
4202,
4449,
12531,
20341,
20345,
4449,
340,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
741,
35009,
1669,
1532,
6954,
16635,
7502,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSpacing(t *testing.T) {
var testTable = []struct {
input, expect string
}{
{"(=?ISO-8859-1?Q?a?=)", "(a)"},
{"(=?ISO-8859-1?Q?a?= b)", "(a b)"},
{"(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)", "(ab)"},
{"(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)", "(ab)"},
{"(=?ISO-8859-1?Q?a?=\r\n =?ISO-8859-1?Q?b?=)", "(ab)"},
{"(=?ISO-8859-1?Q?a_b?=)", "(a b)"},
{"(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)", "(a b)"},
}
for _, tt := range testTable {
result := DecodeHeader(tt.input)
assert.Equal(t, tt.expect, result,
"Expected %q, got %q for input %q", tt.expect, result, tt.input)
}
} | explode_data.jsonl/31261 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 350
} | [
2830,
3393,
27026,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
2556,
284,
3056,
1235,
341,
197,
22427,
11,
1720,
914,
198,
197,
59403,
197,
197,
4913,
7,
19884,
24167,
12,
23,
23,
20,
24,
12,
16,
30,
48,
98461,
59567,
11583,
11993,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOfferAddedToStorage(t *testing.T) {
storage := MakeMemoryStorage()
m := MakeMarket(time.Now, storage, makeMockAccounts())
o := Offer{Symbol: "m"}
m.Offer(o)
if len(storage.offers["m"]) != 1 {
t.Fatalf("%+v", storage)
}
} | explode_data.jsonl/66398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
39462,
19337,
1249,
5793,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
7405,
10642,
5793,
741,
2109,
1669,
7405,
38822,
9730,
13244,
11,
5819,
11,
1281,
11571,
41369,
2398,
22229,
1669,
24498,
90,
15090,
25,
330,
76,
1670... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParsePosOverflow(t *testing.T) {
t.Parallel()
// If line/col numbers gets larger than 16-bit, we should probably use a
// custom reader instead.
tests := []struct {
name, in, want string
}{
{
"LineOverflowIsValid",
strings.Repeat("\n", (1<<16)-1) + "foo; bar",
"<nil>",
},
{
"LineOverflowPosString",
strings.Repeat("\n", (1<<16)-1) + ")",
"?:1: ) can only be used to close a subshell",
},
{
"LineOverflowExtraPosString",
strings.Repeat("\n", (1<<16)+5) + ")",
"?:1: ) can only be used to close a subshell",
},
{
"ColOverflowPosString",
strings.Repeat(" ", (1<<16)-1) + ")",
"1:?: ) can only be used to close a subshell",
},
{
"ColOverflowExtraPosString",
strings.Repeat(" ", (1<<16)+5) + ")",
"1:?: ) can only be used to close a subshell",
},
{
"ColOverflowSkippedPosString",
strings.Repeat(" ", (1<<16)+5) + "\n)",
"2:1: ) can only be used to close a subshell",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
test := test
t.Parallel()
p := NewParser()
_, err := p.Parse(strings.NewReader(test.in), "")
got := fmt.Sprint(err)
if got != test.want {
t.Fatalf("want error %q, got %q", test.want, got)
}
})
}
} | explode_data.jsonl/55112 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 560
} | [
2830,
3393,
14463,
4859,
42124,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
1416,
1555,
14,
2074,
5109,
5221,
8131,
1091,
220,
16,
21,
15257,
11,
582,
1265,
4658,
990,
264,
198,
197,
322,
2526,
6604,
4518,
624,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_segmentNormalizedName(t *testing.T) {
testCases := []normalizedBankRecordID{
normalizeBankRecordID("20201212 575073 2,000 202,012,128,756"),
}
for _, tc := range testCases {
segments := segmentNormalizedName(tc)
t.Logf("%q got split into %d segments", string(tc), len(segments))
if cap(segments) != len(segments) {
t.Errorf("too large of a capacity encountered")
}
joined := strings.Join(segments, "")
if joined != string(tc) {
t.Errorf("round trip failed.\n\twant: %s\n\tgot: %s", string(tc), joined)
}
}
} | explode_data.jsonl/61108 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
28061,
12206,
20167,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
38460,
25828,
6471,
915,
515,
197,
197,
30590,
25828,
6471,
915,
445,
17,
15,
17,
15,
16,
17,
16,
17,
220,
20,
22,
20,
15,
22,
18,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestTimestamp(t *testing.T) {
assert.NotNil(t, testGetOptionsProvider(t, Timestamp(time.Now())), "it should be registered as a default option")
now := time.Now()
o := Timestamp(now)
assert.NotNil(t, o, "should not return a nil option")
assert.Implements(t, (*Option)(nil), o, "it should implement the Option interface")
assert.Equal(t, "timestamp", o.Class(), "it should use the right option class")
t.Run("MarshalJSON()", func(t *testing.T) {
assert.Equal(t, now.UTC().Format("2006-01-02T15:04:05"), testOptionsSerialize(t, o), "it should serialize to a string")
})
} | explode_data.jsonl/37942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
20812,
1155,
353,
8840,
836,
8,
972,
6948,
93882,
1155,
11,
1273,
1949,
3798,
5179,
1155,
11,
32758,
9730,
13244,
96501,
330,
275,
1265,
387,
9681,
438,
264,
1638,
2999,
30218,
80922,
1669,
882,
13244,
3568,
22229,
1669,
327... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetChaincodeDeploymentSpec(t *testing.T) {
pr := platforms.NewRegistry(&golang.Platform{})
_, err := utils.GetChaincodeDeploymentSpec([]byte("bad spec"), pr)
assert.Error(t, err, "Expected error with malformed spec")
cds, _ := proto.Marshal(&pb.ChaincodeDeploymentSpec{
ChaincodeSpec: &pb.ChaincodeSpec{
Type: pb.ChaincodeSpec_GOLANG,
},
})
_, err = utils.GetChaincodeDeploymentSpec(cds, pr)
assert.NoError(t, err, "Unexpected error getting deployment spec")
cds, _ = proto.Marshal(&pb.ChaincodeDeploymentSpec{
ChaincodeSpec: &pb.ChaincodeSpec{
Type: pb.ChaincodeSpec_UNDEFINED,
},
})
_, err = utils.GetChaincodeDeploymentSpec(cds, pr)
assert.Error(t, err, "Expected error with invalid spec type")
} | explode_data.jsonl/39986 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
1949,
18837,
1851,
75286,
8327,
1155,
353,
8840,
836,
8,
341,
25653,
1669,
15409,
7121,
15603,
2099,
70,
37287,
51227,
6257,
692,
197,
6878,
1848,
1669,
12439,
2234,
18837,
1851,
75286,
8327,
10556,
3782,
445,
13855,
1398,
397... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTeamsForUser(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Client := th.Client
team2 := &model.Team{DisplayName: "Name", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_INVITE}
rteam2, _ := Client.CreateTeam(team2)
teams, resp := Client.GetTeamsForUser(th.BasicUser.Id, "")
CheckNoError(t, resp)
require.Len(t, teams, 2, "wrong number of teams")
found1 := false
found2 := false
for _, t := range teams {
if t.Id == th.BasicTeam.Id {
found1 = true
} else if t.Id == rteam2.Id {
found2 = true
}
}
require.True(t, found1, "missing team")
require.True(t, found2, "missing team")
_, resp = Client.GetTeamsForUser("junk", "")
CheckBadRequestStatus(t, resp)
_, resp = Client.GetTeamsForUser(model.NewId(), "")
CheckForbiddenStatus(t, resp)
_, resp = Client.GetTeamsForUser(th.BasicUser2.Id, "")
CheckForbiddenStatus(t, resp)
_, resp = th.SystemAdminClient.GetTeamsForUser(th.BasicUser2.Id, "")
CheckNoError(t, resp)
} | explode_data.jsonl/70720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 398
} | [
2830,
3393,
1949,
60669,
2461,
1474,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
197,
9196,
17,
1669,
609,
2528,
65842,
90,
26456,
25,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestClient_wrongVersion(t *testing.T) {
process := helperProcess("test-proto-upgraded-plugin")
c := NewClient(&ClientConfig{
Cmd: process,
HandshakeConfig: testHandshake,
Plugins: testGRPCPluginMap,
AllowedProtocols: []Protocol{ProtocolGRPC},
})
defer c.Kill()
// Get the client
_, err := c.Client()
if err == nil {
t.Fatal("expected incorrect protocol version server")
}
} | explode_data.jsonl/57856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
2959,
75198,
5637,
1155,
353,
8840,
836,
8,
341,
53314,
1669,
13137,
7423,
445,
1944,
9838,
983,
5239,
23343,
23629,
1138,
1444,
1669,
1532,
2959,
2099,
2959,
2648,
515,
197,
6258,
2277,
25,
1060,
1882,
345,
197,
197,
2314,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsRunningAndReady(t *testing.T) {
set := newStatefulSet(3)
pod := newStatefulSetPod(set, 1)
if isRunningAndReady(pod) {
t.Error("isRunningAndReady does not respect Pod phase")
}
pod.Status.Phase = v1.PodRunning
if isRunningAndReady(pod) {
t.Error("isRunningAndReady does not respect Pod condition")
}
condition := v1.PodCondition{Type: v1.PodReady, Status: v1.ConditionTrue}
podutil.UpdatePodCondition(&pod.Status, &condition)
if !isRunningAndReady(pod) {
t.Error("Pod should be running and ready")
}
} | explode_data.jsonl/68372 | {
"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,
3872,
18990,
3036,
19202,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
36848,
1262,
1649,
7,
18,
340,
3223,
347,
1669,
36848,
1262,
1649,
23527,
14171,
11,
220,
16,
340,
743,
374,
18990,
3036,
19202,
1295,
347,
8,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGenerateMetricDatas(t *testing.T) {
mds, err := GenerateMetrics("testdata/generated_pict_pairs_metrics.txt")
require.NoError(t, err)
require.Equal(t, 25, len(mds))
} | explode_data.jsonl/31243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
31115,
54310,
47663,
1155,
353,
8840,
836,
8,
341,
2109,
5356,
11,
1848,
1669,
19813,
27328,
445,
92425,
79372,
620,
849,
36430,
37686,
3909,
1138,
17957,
35699,
1155,
11,
1848,
340,
17957,
12808,
1155,
11,
220,
17,
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 |
func TestContext2Plan_computedAttrRefTypeMismatch(t *testing.T) {
m := testModule(t, "plan-computed-attr-ref-type-mismatch")
p := testProvider("aws")
p.DiffFn = testDiffFn
p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {
var diags tfdiags.Diagnostics
if req.TypeName == "aws_instance" {
amiVal := req.Config.GetAttr("ami")
if amiVal.Type() != cty.String {
diags = diags.Append(fmt.Errorf("Expected ami to be cty.String, got %#v", amiVal))
}
}
return providers.ValidateResourceTypeConfigResponse{
Diagnostics: diags,
}
}
p.DiffFn = func(
info *InstanceInfo,
state *InstanceState,
c *ResourceConfig) (*InstanceDiff, error) {
switch info.Type {
case "aws_ami_list":
// Emulate a diff that says "we'll create this list and ids will be populated"
return &InstanceDiff{
Attributes: map[string]*ResourceAttrDiff{
"ids.#": &ResourceAttrDiff{NewComputed: true},
},
}, nil
case "aws_instance":
// If we get to the diff for instance, we should be able to assume types
ami, _ := c.Get("ami")
_ = ami.(string)
}
return nil, nil
}
p.ApplyFn = func(info *InstanceInfo, s *InstanceState, d *InstanceDiff) (*InstanceState, error) {
if info.Type != "aws_ami_list" {
t.Fatalf("Reached apply for unexpected resource type! %s", info.Type)
}
// Pretend like we make a thing and the computed list "ids" is populated
return &InstanceState{
ID: "someid",
Attributes: map[string]string{
"ids.#": "2",
"ids.0": "ami-abc123",
"ids.1": "ami-bcd345",
},
}, nil
}
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
})
_, diags := ctx.Plan()
if !diags.HasErrors() {
t.Fatalf("Succeeded; want type mismatch error for 'ami' argument")
}
expected := `Inappropriate value for attribute "ami"`
if errStr := diags.Err().Error(); !strings.Contains(errStr, expected) {
t.Fatalf("expected:\n\n%s\n\nto contain:\n\n%s", errStr, expected)
}
} | explode_data.jsonl/28722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 845
} | [
2830,
3393,
1972,
17,
20485,
2965,
19292,
13371,
3945,
929,
82572,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1273,
3332,
1155,
11,
330,
10393,
11476,
19292,
12,
2991,
43007,
10604,
1448,
24976,
1138,
3223,
1669,
1273,
5179,
445,
8635,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSessionDestroy(t *testing.T) {
t.Skip("s.destroy(true) is flakey")
t.Parallel()
sp, _, cleanup := setup(t, SessionPoolConfig{MinOpened: 1})
defer cleanup()
<-time.After(10 * time.Millisecond) // maintainer will create one session, we wait for it create session to avoid flakiness in test
sh, err := sp.take(context.Background())
if err != nil {
t.Errorf("cannot get session from session pool: %v", err)
}
s := sh.session
sh.recycle()
if d := s.destroy(true); d || !s.isValid() {
// Session should be remaining because of min open sessions constraint.
t.Errorf("session %s invalid, want it to stay alive. (destroy in expiration mode, success: %v)", s.id, d)
}
if d := s.destroy(false); !d || s.isValid() {
// Session should be destroyed.
t.Errorf("failed to destroy session %s. (destroy in default mode, success: %v)", s.id, d)
}
} | explode_data.jsonl/78701 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
5283,
14245,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
445,
82,
17278,
3715,
8,
374,
1320,
726,
88,
1138,
3244,
41288,
7957,
2822,
41378,
11,
8358,
21290,
1669,
6505,
1155,
11,
9164,
10551,
2648,
90,
6217,
53522,
25,
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... | 6 |
func TestAssessRunStatusMultipleFailures(t *testing.T) {
status, message, dryRunSummary := StartAssessRunStatusMultipleFailures(t, false)
assert.Equal(t, v1alpha1.AnalysisPhaseFailed, status)
assert.Equal(t, "Metric \"run-forever\" assessed Failed due to failed (1) > failureLimit (0)", message)
expectedDryRunSummary := v1alpha1.RunSummary{
Count: 0,
Successful: 0,
Failed: 0,
Inconclusive: 0,
Error: 0,
}
assert.Equal(t, &expectedDryRunSummary, dryRunSummary)
} | explode_data.jsonl/75846 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
5615,
433,
6727,
2522,
32089,
19524,
1413,
1155,
353,
8840,
836,
8,
341,
23847,
11,
1943,
11,
9058,
6727,
19237,
1669,
5145,
5615,
433,
6727,
2522,
32089,
19524,
1413,
1155,
11,
895,
340,
6948,
12808,
1155,
11,
348,
16,
71... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateToken(t *testing.T) {
resource.Require(t, resource.UnitTest)
manager := createManager(t)
identity := account.Identity{
ID: uuid.NewV4(),
Username: "testuser",
}
token, err := manager.Generate(identity)
ident, err := manager.Extract(token)
if err != nil {
t.Fatal("Could not extract Identity from generated token", err)
}
assert.Equal(t, identity.Username, ident.Username)
} | explode_data.jsonl/54985 | {
"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,
31115,
3323,
1155,
353,
8840,
836,
8,
341,
50346,
81288,
1155,
11,
5101,
25159,
2271,
692,
92272,
1669,
1855,
2043,
1155,
692,
197,
16912,
1669,
2692,
24423,
515,
197,
29580,
25,
981,
16040,
7121,
53,
19,
3148,
197,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIndexedVars(t *testing.T) {
c := make(testVarContainer, 4)
c[0] = NewDInt(3)
c[1] = NewDInt(5)
c[2] = NewDInt(6)
c[3] = NewDInt(0)
h := MakeIndexedVarHelper(c, 4)
// We use only the first three variables.
v0 := h.IndexedVar(0)
v1 := h.IndexedVar(1)
v2 := h.IndexedVar(2)
if !h.IndexedVarUsed(0) || !h.IndexedVarUsed(1) || !h.IndexedVarUsed(2) || h.IndexedVarUsed(3) {
t.Errorf("invalid IndexedVarUsed results %t %t %t %t (expected false false false true)",
h.IndexedVarUsed(0), h.IndexedVarUsed(1), h.IndexedVarUsed(2), h.IndexedVarUsed(3))
}
binary := func(op BinaryOperator, left, right Expr) Expr {
return &BinaryExpr{Operator: op, Left: left, Right: right}
}
expr := binary(Plus, v0, binary(Mult, v1, v2))
// Verify the expression evaluates correctly.
semaContext := &SemaContext{IVarContainer: c}
typedExpr, err := expr.TypeCheck(semaContext, types.Any)
if err != nil {
t.Fatal(err)
}
str := typedExpr.String()
expectedStr := "var0 + (var1 * var2)"
if str != expectedStr {
t.Errorf("invalid expression string '%s', expected '%s'", str, expectedStr)
}
// Test formatting using the indexed var format interceptor.
f := NewFmtCtx(FmtSimple)
f.WithIndexedVarFormat(
func(ctx *FmtCtx, idx int) {
ctx.Printf("customVar%d", idx)
},
)
f.FormatNode(typedExpr)
str = f.CloseAndGetString()
expectedStr = "customVar0 + (customVar1 * customVar2)"
if str != expectedStr {
t.Errorf("invalid expression string '%s', expected '%s'", str, expectedStr)
}
typ := typedExpr.ResolvedType()
if !typ.Equivalent(types.Int) {
t.Errorf("invalid expression type %s", typ)
}
evalCtx := NewTestingEvalContext(cluster.MakeTestingClusterSettings())
defer evalCtx.Stop(context.Background())
evalCtx.IVarContainer = c
d, err := typedExpr.Eval(evalCtx)
if err != nil {
t.Fatal(err)
}
if d.Compare(evalCtx, NewDInt(3+5*6)) != 0 {
t.Errorf("invalid result %s (expected %d)", d, 3+5*6)
}
} | explode_data.jsonl/72686 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 802
} | [
2830,
3393,
69941,
28305,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1281,
8623,
3962,
4502,
11,
220,
19,
340,
1444,
58,
15,
60,
284,
1532,
35,
1072,
7,
18,
340,
1444,
58,
16,
60,
284,
1532,
35,
1072,
7,
20,
340,
1444,
58,
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 TestInsertInsertOneOpt(t *testing.T) {
var bundle1 *OneBundle
bundle1 = bundle1.BypassDocumentValidation(true).BypassDocumentValidation(false)
testhelpers.RequireNotNil(t, bundle1, "created bundle was nil")
bundle1Opts := []option.Optioner{
BypassDocumentValidation(true).ConvertInsertOption(),
BypassDocumentValidation(false).ConvertInsertOption(),
}
bundle1DedupOpts := []option.Optioner{
BypassDocumentValidation(false).ConvertInsertOption(),
}
bundle2 := BundleOne(BypassDocumentValidation(true))
bundle2Opts := []option.Optioner{
BypassDocumentValidation(true).ConvertInsertOption(),
}
bundle3 := BundleOne().
BypassDocumentValidation(false).
BypassDocumentValidation(true)
bundle3Opts := []option.Optioner{
OptBypassDocumentValidation(false).ConvertInsertOption(),
OptBypassDocumentValidation(true).ConvertInsertOption(),
}
bundle3DedupOpts := []option.Optioner{
OptBypassDocumentValidation(true).ConvertInsertOption(),
}
nilBundle := BundleOne()
var nilBundleOpts []option.Optioner
nestedBundle1 := createNestedInsertOneBundle1(t)
nestedBundleOpts1 := []option.Optioner{
OptBypassDocumentValidation(true).ConvertInsertOption(),
OptWriteConcern{wc1}.ConvertInsertOption(),
OptBypassDocumentValidation(false).ConvertInsertOption(),
}
nestedBundleDedupOpts1 := []option.Optioner{
OptWriteConcern{wc1}.ConvertInsertOption(),
OptBypassDocumentValidation(false).ConvertInsertOption(),
}
nestedBundle2 := createNestedInsertOneBundle2(t)
nestedBundleOpts2 := []option.Optioner{
OptBypassDocumentValidation(true).ConvertInsertOption(),
OptWriteConcern{wc1}.ConvertInsertOption(),
OptWriteConcern{wc2}.ConvertInsertOption(),
OptBypassDocumentValidation(false).ConvertInsertOption(),
}
nestedBundleDedupOpts2 := []option.Optioner{
OptWriteConcern{wc2}.ConvertInsertOption(),
OptBypassDocumentValidation(false).ConvertInsertOption(),
}
nestedBundle3 := createNestedInsertOneBundle3(t)
nestedBundleOpts3 := []option.Optioner{
OptWriteConcern{wc2}.ConvertInsertOption(),
OptBypassDocumentValidation(true).ConvertInsertOption(),
OptWriteConcern{wc1}.ConvertInsertOption(),
OptWriteConcern{wc2}.ConvertInsertOption(),
OptBypassDocumentValidation(false).ConvertInsertOption(),
}
nestedBundleDedupOpts3 := []option.Optioner{
OptWriteConcern{wc2}.ConvertInsertOption(),
OptBypassDocumentValidation(false).ConvertInsertOption(),
}
t.Run("MakeOptions", func(t *testing.T) {
head := bundle1
bundleLen := 0
for head != nil && head.option != nil {
bundleLen++
head = head.next
}
if bundleLen != len(bundle1Opts) {
t.Errorf("expected bundle length %d. got: %d", len(bundle1Opts), bundleLen)
}
})
t.Run("TestAll", func(t *testing.T) {
wc := writeconcern.New(writeconcern.W(1))
opts := []One{
BypassDocumentValidation(true),
WriteConcern(wc),
}
bundle := BundleOne(opts...)
deleteOpts, err := bundle.Unbundle(true)
testhelpers.RequireNil(t, err, "got non-nill error from unbundle: %s", err)
if len(deleteOpts) != len(opts) {
t.Errorf("expected unbundled opts len %d. got %d", len(opts), len(deleteOpts))
}
for i, opt := range opts {
if !reflect.DeepEqual(opt.ConvertInsertOption(), deleteOpts[i]) {
t.Errorf("opt mismatch. expected %#v, got %#v", opt, deleteOpts[i])
}
}
})
t.Run("Unbundle", func(t *testing.T) {
var cases = []struct {
name string
dedup bool
bundle *OneBundle
expectedOpts []option.Optioner
}{
{"NilBundle", false, nilBundle, nilBundleOpts},
{"Bundle1", false, bundle1, bundle1Opts},
{"Bundle1Dedup", true, bundle1, bundle1DedupOpts},
{"Bundle2", false, bundle2, bundle2Opts},
{"Bundle2Dedup", true, bundle2, bundle2Opts},
{"Bundle3", false, bundle3, bundle3Opts},
{"Bundle3Dedup", true, bundle3, bundle3DedupOpts},
{"NestedBundle1_DedupFalse", false, nestedBundle1, nestedBundleOpts1},
{"NestedBundle1_DedupTrue", true, nestedBundle1, nestedBundleDedupOpts1},
{"NestedBundle2_DedupFalse", false, nestedBundle2, nestedBundleOpts2},
{"NestedBundle2_DedupTrue", true, nestedBundle2, nestedBundleDedupOpts2},
{"NestedBundle3_DedupFalse", false, nestedBundle3, nestedBundleOpts3},
{"NestedBundle3_DedupTrue", true, nestedBundle3, nestedBundleDedupOpts3},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
options, err := tc.bundle.Unbundle(tc.dedup)
testhelpers.RequireNil(t, err, "got non-nill error from unbundle: %s", err)
if len(options) != len(tc.expectedOpts) {
t.Errorf("options length does not match expected length. got %d expected %d", len(options),
len(tc.expectedOpts))
} else {
for i, opt := range options {
if !reflect.DeepEqual(opt, tc.expectedOpts[i]) {
t.Errorf("expected: %s\nreceived: %s", opt, tc.expectedOpts[i])
}
}
}
})
}
})
} | explode_data.jsonl/81177 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1929
} | [
2830,
3393,
13780,
13780,
3966,
21367,
1155,
353,
8840,
836,
8,
341,
2405,
12894,
16,
353,
3966,
8409,
198,
2233,
4206,
16,
284,
12894,
16,
1785,
49911,
7524,
13799,
3715,
568,
33,
49911,
7524,
13799,
3576,
340,
18185,
21723,
81288,
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 TestValidateResultsBlockFailsOnBadGenesis(t *testing.T) {
with.Context(func(ctx context.Context) {
with.Logging(t, func(harness *with.LoggingHarness) {
s := newHarness(harness.Logger, false)
s.management.Reset()
setManagementValues(s.management, 1, primitives.TimestampSeconds(time.Now().Unix()), primitives.TimestampSeconds(time.Now().Unix()+5000))
input := &services.ValidateResultsBlockInput{
CurrentBlockHeight: 1,
PrevBlockReferenceTime: primitives.TimestampSeconds(time.Now().Unix() - 1000),
}
_, err := s.service.ValidateResultsBlock(ctx, input)
require.Error(t, err, "validation should fail on bad genesis value for block height 1")
})
})
} | explode_data.jsonl/11018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
17926,
9801,
4713,
37,
6209,
1925,
17082,
84652,
1155,
353,
8840,
836,
8,
341,
46948,
9328,
18552,
7502,
2266,
9328,
8,
341,
197,
46948,
41945,
1155,
11,
2915,
3203,
23518,
353,
4197,
41945,
74248,
8,
341,
298,
1903,
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 TestData(t *testing.T) {
defer abtest.SetupDataDir(t)()
f := mbtest.NewReportingMetricSetV2(t, getConfig())
// Set lastState and add test process to cache so it will be reported as stopped.
f.(*MetricSet).lastState = time.Now()
s := testSocket()
f.(*MetricSet).cache.DiffAndUpdateCache(convertToCacheable([]*Socket{s}))
events, errs := mbtest.ReportingFetchV2(f)
if len(errs) > 0 {
t.Fatalf("received error: %+v", errs[0])
}
if len(events) == 0 {
t.Fatal("no events were generated")
}
// The first socket (events[0]) is usually something like rpcbind,
// the last one should be more interesting.
fullEvent := mbtest.StandardizeEvent(f, events[len(events)-1], core.AddDatasetToEvent)
mbtest.WriteEventToDataJSON(t, fullEvent, "")
} | explode_data.jsonl/37026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
93200,
1155,
353,
8840,
836,
8,
341,
16867,
668,
1944,
39820,
1043,
6184,
1155,
8,
2822,
1166,
1669,
10016,
1944,
7121,
70131,
54310,
1649,
53,
17,
1155,
11,
66763,
12367,
197,
322,
2573,
1537,
1397,
323,
912,
1273,
1882,
311,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGenerateManifests_K8SAPIResetCache(t *testing.T) {
service := newService("../..")
src := argoappv1.ApplicationSource{Path: "manifests/base"}
q := apiclient.ManifestRequest{
KubeVersion: "v1.16.0",
Repo: &argoappv1.Repository{}, ApplicationSource: &src,
}
cachedFakeResponse := &apiclient.ManifestResponse{Manifests: []string{"Fake"}}
err := service.cache.SetManifests(mock.Anything, &src, &q, "", "", "", "", &cache.CachedManifestResponse{ManifestResponse: cachedFakeResponse})
assert.NoError(t, err)
res, err := service.GenerateManifest(context.Background(), &q)
assert.NoError(t, err)
assert.Equal(t, cachedFakeResponse, res)
q.KubeVersion = "v1.17.0"
res, err = service.GenerateManifest(context.Background(), &q)
assert.NoError(t, err)
assert.NotEqual(t, cachedFakeResponse, res)
assert.True(t, len(res.Manifests) > 1)
} | explode_data.jsonl/5661 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
31115,
38495,
82,
10102,
23,
50,
7082,
14828,
8233,
1155,
353,
8840,
836,
8,
341,
52934,
1669,
501,
1860,
17409,
496,
5130,
41144,
1669,
1392,
78,
676,
85,
16,
17521,
3608,
90,
1820,
25,
330,
42315,
82,
26090,
16707,
18534... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddDependency(t *testing.T) {
w := &Workflow{}
a, _ := w.NewStep("a")
b, _ := w.NewStep("b")
otherW := &Workflow{}
c, _ := otherW.NewStep("c")
tests := []struct {
desc string
in1, in2 *Step
shouldErr bool
}{
{"good case", a, b, false},
{"idempotent good case", a, b, false},
{"bad case 1", a, c, true},
{"bad case 2", c, b, true},
}
for _, tt := range tests {
if err := w.AddDependency(tt.in1, tt.in2); err == nil && tt.shouldErr {
t.Errorf("%s: should have erred but didn't", tt.desc)
} else if err != nil && !tt.shouldErr {
t.Errorf("%s: unexpected error: %v", tt.desc, err)
}
}
wantDeps := map[string][]string{"a": {"b"}}
if diffRes := diff(w.Dependencies, wantDeps, 0); diffRes != "" {
t.Errorf("incorrect dependencies: (-got,+want)\n%s", diffRes)
}
} | explode_data.jsonl/3861 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
2212,
36387,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
609,
62768,
16094,
11323,
11,
716,
1669,
289,
7121,
8304,
445,
64,
1138,
2233,
11,
716,
1669,
289,
7121,
8304,
445,
65,
5130,
197,
1575,
54,
1669,
609,
62768,
16094,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGteField(t *testing.T) {
validate := New()
type TimeTest struct {
Start *time.Time `validate:"required,gte"`
End *time.Time `validate:"required,gte,gtefield=Start"`
}
now := time.Now()
start := now.Add(time.Hour * 24)
end := start.Add(time.Hour * 24)
timeTest := &TimeTest{
Start: &start,
End: &end,
}
errs := validate.Struct(timeTest)
Equal(t, errs, nil)
timeTest = &TimeTest{
Start: &end,
End: &start,
}
errs = validate.Struct(timeTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "TimeTest.End", "TimeTest.End", "End", "End", "gtefield")
errs = validate.VarWithValue(&end, &start, "gtefield")
Equal(t, errs, nil)
errs = validate.VarWithValue(&start, &end, "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
errs = validate.VarWithValue(&start, timeTest, "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
errs = validate.VarWithValue("test", "test", "gtefield")
Equal(t, errs, nil)
errs = validate.VarWithValue("test bigger", "test", "gtefield")
Equal(t, errs, nil)
type IntTest struct {
Val1 int `validate:"required"`
Val2 int `validate:"required,gtefield=Val1"`
}
intTest := &IntTest{
Val1: 1,
Val2: 5,
}
errs = validate.Struct(intTest)
Equal(t, errs, nil)
intTest = &IntTest{
Val1: 5,
Val2: 1,
}
errs = validate.Struct(intTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "IntTest.Val2", "IntTest.Val2", "Val2", "Val2", "gtefield")
errs = validate.VarWithValue(int(5), int(1), "gtefield")
Equal(t, errs, nil)
errs = validate.VarWithValue(int(1), int(5), "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
type UIntTest struct {
Val1 uint `validate:"required"`
Val2 uint `validate:"required,gtefield=Val1"`
}
uIntTest := &UIntTest{
Val1: 1,
Val2: 5,
}
errs = validate.Struct(uIntTest)
Equal(t, errs, nil)
uIntTest = &UIntTest{
Val1: 5,
Val2: 1,
}
errs = validate.Struct(uIntTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "UIntTest.Val2", "UIntTest.Val2", "Val2", "Val2", "gtefield")
errs = validate.VarWithValue(uint(5), uint(1), "gtefield")
Equal(t, errs, nil)
errs = validate.VarWithValue(uint(1), uint(5), "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
type FloatTest struct {
Val1 float64 `validate:"required"`
Val2 float64 `validate:"required,gtefield=Val1"`
}
floatTest := &FloatTest{
Val1: 1,
Val2: 5,
}
errs = validate.Struct(floatTest)
Equal(t, errs, nil)
floatTest = &FloatTest{
Val1: 5,
Val2: 1,
}
errs = validate.Struct(floatTest)
NotEqual(t, errs, nil)
AssertError(t, errs, "FloatTest.Val2", "FloatTest.Val2", "Val2", "Val2", "gtefield")
errs = validate.VarWithValue(float32(5), float32(1), "gtefield")
Equal(t, errs, nil)
errs = validate.VarWithValue(float32(1), float32(5), "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
errs = validate.VarWithValue(nil, 1, "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
errs = validate.VarWithValue(5, "T", "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
errs = validate.VarWithValue(5, start, "gtefield")
NotEqual(t, errs, nil)
AssertError(t, errs, "", "", "", "", "gtefield")
type TimeTest2 struct {
Start *time.Time `validate:"required"`
End *time.Time `validate:"required,gtefield=NonExistantField"`
}
timeTest2 := &TimeTest2{
Start: &start,
End: &end,
}
errs = validate.Struct(timeTest2)
NotEqual(t, errs, nil)
AssertError(t, errs, "TimeTest2.End", "TimeTest2.End", "End", "End", "gtefield")
} | explode_data.jsonl/77303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1653
} | [
2830,
3393,
38,
665,
1877,
1155,
353,
8840,
836,
8,
1476,
197,
7067,
1669,
1532,
2822,
13158,
4120,
2271,
2036,
341,
197,
65999,
353,
1678,
16299,
1565,
7067,
2974,
6279,
21644,
665,
8805,
197,
38407,
256,
353,
1678,
16299,
1565,
7067,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetOrderHistory(t *testing.T) {
b.SetDefaults()
TestSetup(t)
var getOrdersRequest = exchange.GetOrdersRequest{
OrderType: exchange.AnyOrderType,
Currencies: []currency.Pair{currency.NewPair(currency.LTC,
currency.BTC)},
}
_, err := b.GetOrderHistory(&getOrdersRequest)
if areTestAPIKeysSet() && err != nil {
t.Errorf("Could not get order history: %s", err)
} else if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
} | explode_data.jsonl/49005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
1949,
4431,
13424,
1155,
353,
8840,
836,
8,
341,
2233,
4202,
16273,
741,
73866,
21821,
1155,
692,
2405,
633,
24898,
1900,
284,
9289,
2234,
24898,
1900,
515,
197,
197,
4431,
929,
25,
9289,
13311,
4431,
929,
345,
197,
6258,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTwoLineFile(t *testing.T) {
_, err := newWithContents(t, `{"user":"scheduler", "readonly": true, "resource": "pods"}
{"user":"scheduler", "readonly": true, "resource": "services"}
`)
if err != nil {
t.Errorf("unable to read policy file: %v", err)
}
} | explode_data.jsonl/46826 | {
"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,
11613,
2460,
1703,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
501,
2354,
14803,
1155,
11,
1565,
4913,
872,
3252,
63122,
497,
220,
330,
22569,
788,
830,
11,
330,
9233,
788,
330,
79,
29697,
16707,
4913,
872,
3252,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetRepoNames(t *testing.T) {
b := bytes.NewBuffer(nil)
m := &Manager{
Out: b,
RepositoryConfig: repoConfig,
RepositoryCache: repoCache,
}
tests := []struct {
name string
req []*chart.Dependency
expect map[string]string
err bool
}{
{
name: "no repo definition, but references a url",
req: []*chart.Dependency{
{Name: "oedipus-rex", Repository: "http://example.com/test"},
},
expect: map[string]string{"http://example.com/test": "http://example.com/test"},
},
{
name: "no repo definition failure -- stable repo",
req: []*chart.Dependency{
{Name: "oedipus-rex", Repository: "stable"},
},
err: true,
},
{
name: "no repo definition failure",
req: []*chart.Dependency{
{Name: "oedipus-rex", Repository: "http://example.com"},
},
expect: map[string]string{"oedipus-rex": "testing"},
},
{
name: "repo from local path",
req: []*chart.Dependency{
{Name: "local-dep", Repository: "file://./testdata/signtest"},
},
expect: map[string]string{"local-dep": "file://./testdata/signtest"},
},
{
name: "repo alias (alias:)",
req: []*chart.Dependency{
{Name: "oedipus-rex", Repository: "alias:testing"},
},
expect: map[string]string{"oedipus-rex": "testing"},
},
{
name: "repo alias (@)",
req: []*chart.Dependency{
{Name: "oedipus-rex", Repository: "@testing"},
},
expect: map[string]string{"oedipus-rex": "testing"},
},
{
name: "repo from local chart under charts path",
req: []*chart.Dependency{
{Name: "local-subchart", Repository: ""},
},
expect: map[string]string{},
},
}
for _, tt := range tests {
l, err := m.resolveRepoNames(tt.req)
if err != nil {
if tt.err {
continue
}
t.Fatal(err)
}
if tt.err {
t.Fatalf("Expected error in test %q", tt.name)
}
// m1 and m2 are the maps we want to compare
eq := reflect.DeepEqual(l, tt.expect)
if !eq {
t.Errorf("%s: expected map %v, got %v", tt.name, l, tt.name)
}
}
} | explode_data.jsonl/24397 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 925
} | [
2830,
3393,
1949,
25243,
7980,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
5820,
7121,
4095,
27907,
340,
2109,
1669,
609,
2043,
515,
197,
197,
2662,
25,
1060,
293,
345,
197,
197,
4624,
2648,
25,
15867,
2648,
345,
197,
197,
4624,
8233,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseAny(t *testing.T) {
assert(t, Parse("100").Float() == 100)
assert(t, Parse("true").Bool())
assert(t, Parse("false").Bool() == false)
assert(t, Parse("yikes").Exists() == false)
} | explode_data.jsonl/43417 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
14463,
8610,
1155,
353,
8840,
836,
8,
341,
6948,
1155,
11,
14775,
445,
16,
15,
15,
1827,
5442,
368,
621,
220,
16,
15,
15,
340,
6948,
1155,
11,
14775,
445,
1866,
1827,
11233,
2398,
6948,
1155,
11,
14775,
445,
3849,
1827,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVariables_ListsAndNullability_DoesNotAllowUnknownTypesToBeUsedAsValues(t *testing.T) {
doc := `
query q($input: UnknownType!) {
fieldWithObjectInput(input: $input)
}
`
params := map[string]interface{}{
"input": "whoknows",
}
expected := &graphql.Result{
Data: nil,
Errors: []gqlerrors.FormattedError{
{
Message: `Variable "$input" expected value of type "UnknownType!" which cannot be used as an input type.`,
Locations: []location.SourceLocation{
{
Line: 2, Column: 17,
},
},
},
},
}
ast := testutil.TestParse(t, doc)
// execute
ep := graphql.ExecuteParams{
Schema: variablesTestSchema,
AST: ast,
Args: params,
}
result := testutil.TestExecute(t, ep)
if len(result.Errors) != len(expected.Errors) {
t.Fatalf("Unexpected errors, Diff: %v", testutil.Diff(expected.Errors, result.Errors))
}
if !reflect.DeepEqual(expected, result) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, result))
}
} | explode_data.jsonl/6465 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
22678,
27104,
82,
3036,
3280,
2897,
1557,
7072,
2623,
18605,
13790,
4173,
1249,
3430,
22743,
2121,
6227,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
22074,
286,
3239,
2804,
699,
1355,
25,
21693,
929,
16315,
341,
688,
2070,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDelete(t *testing.T) {
type want struct {
cr *v1beta1.SecurityGroup
err error
}
cases := map[string]struct {
args
want
}{
"Successful": {
args: args{
sg: &fake.MockSecurityGroupClient{
MockDelete: func(ctx context.Context, input *awsec2.DeleteSecurityGroupInput, opts []func(*awsec2.Options)) (*awsec2.DeleteSecurityGroupOutput, error) {
return &awsec2.DeleteSecurityGroupOutput{}, nil
},
},
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
})),
},
want: want{
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}), withConditions(xpv1.Deleting())),
},
},
"InvalidSgId": {
args: args{
sg: &fake.MockSecurityGroupClient{
MockDelete: func(ctx context.Context, input *awsec2.DeleteSecurityGroupInput, opts []func(*awsec2.Options)) (*awsec2.DeleteSecurityGroupOutput, error) {
return &awsec2.DeleteSecurityGroupOutput{}, nil
},
},
cr: sg(),
},
want: want{
cr: sg(withConditions(xpv1.Deleting())),
},
},
"DeleteFailure": {
args: args{
sg: &fake.MockSecurityGroupClient{
MockDelete: func(ctx context.Context, input *awsec2.DeleteSecurityGroupInput, opts []func(*awsec2.Options)) (*awsec2.DeleteSecurityGroupOutput, error) {
return nil, errBoom
},
},
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
})),
},
want: want{
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}), withConditions(xpv1.Deleting())),
err: awsclient.Wrap(errBoom, errDelete),
},
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
e := &external{kube: tc.kube, sg: tc.sg}
err := e.Delete(context.Background(), tc.args.cr)
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
if diff := cmp.Diff(tc.want.cr, tc.args.cr, test.EquateConditions()); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
})
}
} | explode_data.jsonl/79624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 935
} | [
2830,
3393,
6435,
1155,
353,
8840,
836,
8,
341,
13158,
1366,
2036,
341,
197,
91492,
220,
353,
85,
16,
19127,
16,
21567,
2808,
198,
197,
9859,
1465,
198,
197,
630,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
31215,
198,
197,
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... | 1 |
func TestNumberDataPoint_StartTimestamp(t *testing.T) {
ms := NewNumberDataPoint()
assert.EqualValues(t, Timestamp(0), ms.StartTimestamp())
testValStartTimestamp := Timestamp(1234567890)
ms.SetStartTimestamp(testValStartTimestamp)
assert.EqualValues(t, testValStartTimestamp, ms.StartTimestamp())
} | explode_data.jsonl/32723 | {
"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,
2833,
1043,
2609,
38056,
20812,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
2833,
1043,
2609,
741,
6948,
12808,
6227,
1155,
11,
32758,
7,
15,
701,
9829,
12101,
20812,
2398,
18185,
2208,
3479,
20812,
1669,
32758,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCombinedStatus(t *testing.T) {
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
t.Errorf("Bad method: %s", r.Method)
}
if r.URL.Path == "/repos/k8s/kuber/commits/SHA/status" {
statuses := CombinedStatus{
SHA: "SHA",
Statuses: []Status{{Context: "foo"}},
}
b, err := json.Marshal(statuses)
if err != nil {
t.Fatalf("Didn't expect error: %v", err)
}
w.Header().Set("Link", fmt.Sprintf(`<blorp>; rel="first", <https://%s/someotherpath>; rel="next"`, r.Host))
fmt.Fprint(w, string(b))
} else if r.URL.Path == "/someotherpath" {
statuses := CombinedStatus{
SHA: "SHA",
Statuses: []Status{{Context: "bar"}},
}
b, err := json.Marshal(statuses)
if err != nil {
t.Fatalf("Didn't expect error: %v", err)
}
fmt.Fprint(w, string(b))
} else {
t.Errorf("Bad request path: %s", r.URL.Path)
}
}))
defer ts.Close()
c := getClient(ts.URL)
combined, err := c.GetCombinedStatus("k8s", "kuber", "SHA")
if err != nil {
t.Errorf("Didn't expect error: %v", err)
} else if combined.SHA != "SHA" {
t.Errorf("Expected SHA 'SHA', found %s", combined.SHA)
} else if len(combined.Statuses) != 2 {
t.Errorf("Expected two statuses, found %d: %v", len(combined.Statuses), combined.Statuses)
} else if combined.Statuses[0].Context != "foo" || combined.Statuses[1].Context != "bar" {
t.Errorf("Wrong review IDs: %v", combined.Statuses)
}
} | explode_data.jsonl/6303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 653
} | [
2830,
3393,
94268,
2522,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
1758,
20798,
1949,
341,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestChannelClientRollsBackPvtDataIfMvccReadConflict(t *testing.T) {
orgsContext := setupMultiOrgContext(t, mainSDK)
require.NoError(t, integration.EnsureChannelCreatedAndPeersJoined(t, mainSDK, orgChannelID, "orgchannel.tx", orgsContext))
// private data collection used for test
const coll = "collection1"
// collection key used for test
const key = "collection_key"
ccID := integration.GenerateExamplePvtID(true)
collConfig, err := newCollectionConfig(coll, "OR('Org1MSP.member','Org2MSP.member','Org3MSP.member')", 0, 2, 1000)
require.NoError(t, err)
require.NoError(t, integration.InstallExamplePvtChaincode(orgsContext, ccID))
require.NoError(t, integration.InstantiateExamplePvtChaincode(orgsContext, orgChannelID, ccID, "OR('Org1MSP.member','Org2MSP.member','Org3MSP.member')", collConfig))
ctxProvider := mainSDK.ChannelContext(orgChannelID, fabsdk.WithUser(org1User), fabsdk.WithOrg(org1Name))
chClient, err := channel.New(ctxProvider)
require.NoError(t, err)
var errMtx sync.Mutex
errs := multi.Errors{}
var wg sync.WaitGroup
// test function; invokes a CC function that mutates the private data collection
changePvtData := func(amount int) {
defer wg.Done()
_, err := chClient.Execute(
channel.Request{
ChaincodeID: ccID,
Fcn: "addToInt",
Args: [][]byte{[]byte(coll), []byte(key), []byte(strconv.Itoa(amount))},
},
)
if err != nil {
errMtx.Lock()
errs = append(errs, err)
errMtx.Unlock()
return
}
}
// expected value at the end of the test
const expected = 10
wg.Add(2)
go changePvtData(expected)
go changePvtData(expected)
wg.Wait()
// ensure the MVCC_READ_CONFLICT was reproduced
require.Truef(t, len(errs) > 0 && strings.Contains(errs[0].Error(), "MVCC_READ_CONFLICT"), "could not reproduce MVCC_READ_CONFLICT")
// read current value of private data collection
//resp, err := chClient.Query(
// channel.Request{
// ChaincodeID: ccID,
// Fcn: "getprivate",
// Args: [][]byte{[]byte(coll), []byte(key)},
// },
// channel.WithRetry(retry.TestRetryOpts),
//)
resp, err := retry.NewInvoker(retry.New(retry.TestRetryOpts)).Invoke(
func() (interface{}, error) {
b, e := chClient.Query(
channel.Request{
ChaincodeID: ccID,
Fcn: "getprivate",
Args: [][]byte{[]byte(coll), []byte(key)},
},
channel.WithRetry(retry.TestRetryOpts),
)
if e != nil || strings.TrimSpace(string(b.Payload)) == "" {
return nil, status.New(status.TestStatus, status.GenericTransient.ToInt32(), fmt.Sprintf("getprivate data returned error: %v", e), nil)
}
return b, e
},
)
require.NoErrorf(t, err, "error attempting to read private data")
require.NotEmptyf(t, strings.TrimSpace(string(resp.(channel.Response).Payload)), "reading private data returned empty response")
actual, err := strconv.Atoi(string(resp.(channel.Response).Payload))
require.NoError(t, err)
assert.Truef(t, actual == expected, "Private data not rolled back during MVCC_READ_CONFLICT")
} | explode_data.jsonl/5048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1177
} | [
2830,
3393,
9629,
2959,
32355,
82,
3707,
47,
9708,
1043,
2679,
44,
85,
638,
4418,
57974,
1155,
353,
8840,
836,
8,
341,
87625,
82,
1972,
1669,
6505,
20358,
42437,
1972,
1155,
11,
1887,
31534,
340,
17957,
35699,
1155,
11,
17590,
22834,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPaginatedBase_Last(t *testing.T) {
b := PaginatedBase{
pagination: APIResponseMetadataPagination{
TotalPages: 10,
},
getFunc: func(parameters APIRequestParameters) (Paginated, error) {
assert.Equal(t, 10, parameters.Pagination.Page)
return &PaginatedBase{
parameters: parameters,
}, nil
},
}
lastPage, err := b.Last()
assert.Nil(t, err)
assert.Equal(t, 10, lastPage.CurrentPage())
} | explode_data.jsonl/44636 | {
"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,
47712,
15479,
3978,
84672,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
42355,
15479,
3978,
515,
197,
3223,
10353,
25,
5333,
2582,
14610,
44265,
515,
298,
197,
7595,
17713,
25,
220,
16,
15,
345,
197,
197,
1583,
197,
10366,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPlayer_HasDefuseKit(t *testing.T) {
pl := playerWithProperty("m_bHasDefuser", st.PropertyValue{IntVal: 0})
assert.False(t, pl.HasDefuseKit())
pl = playerWithProperty("m_bHasDefuser", st.PropertyValue{IntVal: 1})
assert.True(t, pl.HasDefuseKit())
} | explode_data.jsonl/12185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
4476,
2039,
300,
2620,
810,
7695,
1155,
353,
8840,
836,
8,
341,
72213,
1669,
2781,
2354,
3052,
445,
76,
880,
10281,
2620,
872,
497,
357,
15727,
1130,
90,
1072,
2208,
25,
220,
15,
8824,
6948,
50757,
1155,
11,
625,
16152,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdate(t *testing.T) {
storage := map[string]RESTStorage{}
simpleStorage := SimpleRESTStorage{}
ID := "id"
storage["simple"] = &simpleStorage
selfLinker := &setTestSelfLinker{
t: t,
expectedSet: "/prefix/version/simple/" + ID,
}
handler := Handle(storage, codec, "/prefix/version", selfLinker)
server := httptest.NewServer(handler)
item := &Simple{
Name: "bar",
}
body, err := codec.Encode(item)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
client := http.Client{}
request, err := http.NewRequest("PUT", server.URL+"/prefix/version/simple/"+ID, bytes.NewReader(body))
_, err = client.Do(request)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if simpleStorage.updated.Name != item.Name {
t.Errorf("Unexpected update value %#v, expected %#v.", simpleStorage.updated, item)
}
if !selfLinker.called {
t.Errorf("Never set self link")
}
} | explode_data.jsonl/71497 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 347
} | [
2830,
3393,
4289,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
2415,
14032,
60,
38307,
5793,
16094,
1903,
6456,
5793,
1669,
8993,
38307,
5793,
16094,
29580,
1669,
330,
307,
698,
197,
16172,
1183,
22944,
1341,
284,
609,
22944,
5793,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrdererAddresses(t *testing.T) {
cc := &ChannelConfig{protos: &ChannelProtos{OrdererAddresses: &cb.OrdererAddresses{}}}
assert.Error(t, cc.validateOrdererAddresses(), "Must supply orderer addresses")
cc = &ChannelConfig{protos: &ChannelProtos{OrdererAddresses: &cb.OrdererAddresses{Addresses: []string{"127.0.0.1:7050"}}}}
assert.NoError(t, cc.validateOrdererAddresses(), "Invalid orderer address supplied")
assert.Equal(t, "127.0.0.1:7050", cc.OrdererAddresses()[0], "Unexpected orderer address returned")
} | explode_data.jsonl/30624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
4431,
261,
52290,
1155,
353,
8840,
836,
8,
341,
63517,
1669,
609,
9629,
2648,
90,
4391,
436,
25,
609,
9629,
12423,
436,
90,
4431,
261,
52290,
25,
609,
7221,
19664,
261,
52290,
90,
3417,
532,
6948,
6141,
1155,
11,
12527,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Export_isExists(t *testing.T) {
tst := []string{"../testdata/voice.pcm", "../testdata/raw-http-post-json.txt"}
for _, fName := range tst {
assert.Equal(t, isExists(fName), true, fName)
}
notExists := []string{"a.txt", "b.txt"}
for _, fName := range notExists {
assert.Equal(t, isExists(fName), false, fName)
}
} | explode_data.jsonl/43932 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
62,
16894,
6892,
15575,
1155,
353,
8840,
836,
8,
341,
3244,
267,
1669,
3056,
917,
4913,
1244,
92425,
14,
9862,
556,
6226,
497,
7005,
92425,
75909,
71312,
24410,
56080,
3909,
63159,
2023,
8358,
92409,
1669,
2088,
71707,
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... | 3 |
func TestDeletePost(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Client := th.Client
_, resp := Client.DeletePost("")
CheckNotFoundStatus(t, resp)
_, resp = Client.DeletePost("junk")
CheckBadRequestStatus(t, resp)
_, resp = Client.DeletePost(th.BasicPost.Id)
CheckForbiddenStatus(t, resp)
Client.Login(th.TeamAdminUser.Email, th.TeamAdminUser.Password)
_, resp = Client.DeletePost(th.BasicPost.Id)
CheckNoError(t, resp)
post := th.CreatePost()
user := th.CreateUser()
Client.Logout()
Client.Login(user.Email, user.Password)
_, resp = Client.DeletePost(post.Id)
CheckForbiddenStatus(t, resp)
Client.Logout()
_, resp = Client.DeletePost(model.NewId())
CheckUnauthorizedStatus(t, resp)
status, resp := th.SystemAdminClient.DeletePost(post.Id)
require.True(t, status, "post should return status OK")
CheckNoError(t, resp)
} | explode_data.jsonl/5255 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
6435,
4133,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
197,
6878,
9039,
1669,
8423,
18872,
4133,
31764,
69472,
10372,
2522,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocalIP(t *testing.T) {
t.Parallel()
ip, err := LocalIP()
if err != nil {
t.Error(err)
}
if ip.String() == "" {
t.Error("expected IP address")
}
t.Log(ip)
} | explode_data.jsonl/58671 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
7319,
3298,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
46531,
11,
1848,
1669,
8774,
3298,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
630,
743,
5997,
6431,
368,
621,
1591,
341,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 3 |
func TestBrokerThreadSafety(t *testing.T) {
count := 100000
var handled int32
handler1 := func(msg interface{}) {
atomic.AddInt32(&handled, 1)
}
handler2 := func(msg interface{}) {
atomic.AddInt32(&handled, 1)
}
handler3 := func(msg interface{}) {
atomic.AddInt32(&handled, 1)
}
b := NewBroker()
sub1 := b.Subscribe("topic1", handler1)
sub2 := b.Subscribe("topic1", handler2)
sub3 := b.Subscribe("topic2", handler3)
defer sub1.Unsubscribe()
defer sub2.Unsubscribe()
defer sub3.Unsubscribe()
for i := 0; i < count; i++ {
b.Publish("topic1", i)
b.Publish("topic2", i)
}
time.Sleep(time.Millisecond * 100)
if int(handled) != count*3 {
t.Errorf("Expected %d results, got %d", count*3, handled)
}
} | explode_data.jsonl/37066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
65545,
6855,
73037,
1155,
353,
8840,
836,
8,
341,
18032,
1669,
220,
16,
15,
15,
15,
15,
15,
198,
2405,
17608,
526,
18,
17,
198,
53326,
16,
1669,
2915,
8119,
3749,
28875,
341,
197,
78739,
1904,
1072,
18,
17,
2099,
38821,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMatchIgnoreMissingBodyDefinition(t *testing.T) {
hreq := &definition.Request{}
hreq.Body = "HelloWorld"
mreq := &definition.Request{}
m := MockMatch{}
if m, err := m.Match(hreq, mreq); !m {
t.Error(err)
}
} | explode_data.jsonl/1096 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
8331,
12497,
25080,
5444,
10398,
1155,
353,
8840,
836,
8,
341,
9598,
2958,
1669,
609,
18375,
9659,
16094,
9598,
2958,
20934,
284,
330,
9707,
10134,
698,
2109,
2958,
1669,
609,
18375,
9659,
16094,
2109,
1669,
14563,
8331,
31483... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTx_CreateBucket(t *testing.T) {
db := MustOpenDB()
defer db.MustClose()
// Create a bucket.
if err := db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucket([]byte("widgets"))
if err != nil {
t.Fatal(err)
} else if b == nil {
t.Fatal("expected bucket")
}
return nil
}); err != nil {
t.Fatal(err)
}
// Read the bucket through a separate transaction.
if err := db.View(func(tx *bolt.Tx) error {
if tx.Bucket([]byte("widgets")) == nil {
t.Fatal("expected bucket")
}
return nil
}); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/1689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
31584,
34325,
36018,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
15465,
5002,
3506,
741,
16867,
2927,
50463,
7925,
2822,
197,
322,
4230,
264,
15621,
624,
743,
1848,
1669,
2927,
16689,
18552,
27301,
353,
52433,
81362,
8,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestReadFull(t *testing.T) {
var out [4]byte
b := bytes.NewBufferString("foo")
n, err := readFull(b, out[:3])
if n != 3 || err != nil {
t.Errorf("full read failed n:%d err:%s", n, err)
}
b = bytes.NewBufferString("foo")
n, err = readFull(b, out[:4])
if n != 3 || err != io.ErrUnexpectedEOF {
t.Errorf("partial read failed n:%d err:%s", n, err)
}
b = bytes.NewBuffer(nil)
n, err = readFull(b, out[:3])
if n != 0 || err != io.ErrUnexpectedEOF {
t.Errorf("empty read failed n:%d err:%s", n, err)
}
} | explode_data.jsonl/52942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
4418,
9432,
1155,
353,
8840,
836,
8,
341,
2405,
700,
508,
19,
90184,
271,
2233,
1669,
5820,
7121,
4095,
703,
445,
7975,
1138,
9038,
11,
1848,
1669,
1349,
9432,
1883,
11,
700,
3447,
18,
2546,
743,
308,
961,
220,
18,
1369,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPartitionActive(t *testing.T) {
tests := []struct {
lighthouseJobs []v1alpha1.LighthouseJob
pending sets.String
triggered sets.String
aborted sets.String
}{
{
lighthouseJobs: []v1alpha1.LighthouseJob{
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.TriggeredState,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "bar",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.PendingState,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "baz",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.SuccessState,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "error",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.ErrorState,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "bak",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.PendingState,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "aborted",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.AbortedState,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "aborted-and-completed",
},
Status: v1alpha1.LighthouseJobStatus{
State: v1alpha1.AbortedState,
CompletionTime: &[]metav1.Time{metav1.Now()}[0],
},
},
},
pending: sets.NewString("bar", "bak"),
triggered: sets.NewString("foo"),
aborted: sets.NewString("aborted"),
},
}
for i, test := range tests {
t.Logf("test run #%d", i)
pendingCh, triggeredCh, abortedCh := PartitionActive(test.lighthouseJobs)
for job := range pendingCh {
if !test.pending.Has(job.Name) {
t.Errorf("didn't find pending job %#v", job)
}
}
for job := range triggeredCh {
if !test.triggered.Has(job.Name) {
t.Errorf("didn't find triggered job %#v", job)
}
}
for job := range abortedCh {
if !test.aborted.Has(job.Name) {
t.Errorf("didn't find aborted job %#v", job)
}
}
}
} | explode_data.jsonl/51120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1061
} | [
2830,
3393,
49978,
5728,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
8810,
57909,
40667,
3056,
85,
16,
7141,
16,
1214,
57909,
12245,
271,
197,
3223,
2459,
256,
7289,
6431,
198,
197,
83228,
291,
7289,
6431,
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... | 8 |
func TestFormat_StringInterfaceMap(t *testing.T) {
str := "some test {abc} {{abc}} {key2}"
kwArgs := map[String]interface{}{"abc": "123"}
got := Format(str, kwArgs)
want := "some test 123 {abc} {key2}"
assert.Equal(t, want, got)
} | explode_data.jsonl/54325 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
4061,
31777,
5051,
2227,
1155,
353,
8840,
836,
8,
341,
11355,
1669,
330,
14689,
1273,
314,
13683,
92,
5867,
13683,
3417,
314,
792,
17,
11195,
16463,
86,
4117,
1669,
2415,
18498,
31344,
6257,
4913,
13683,
788,
330,
16,
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 TestDomainType(t *testing.T) {
testWithAndWithoutPreferSimpleProtocol(t, func(t *testing.T, conn *pgx.Conn) {
skipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)")
var n uint64
// Domain type uint64 is a PostgreSQL domain of underlying type numeric.
err := conn.QueryRow(context.Background(), "select $1::uint64", uint64(24)).Scan(&n)
require.NoError(t, err)
// A string can be used. But a string cannot be the result because the describe result from the PostgreSQL server gives
// the underlying type of numeric.
err = conn.QueryRow(context.Background(), "select $1::uint64", "42").Scan(&n)
if err != nil {
t.Fatal(err)
}
if n != 42 {
t.Fatalf("Expected n to be 42, but was %v", n)
}
var uint64OID uint32
err = conn.QueryRow(context.Background(), "select t.oid from pg_type t where t.typname='uint64';").Scan(&uint64OID)
if err != nil {
t.Fatalf("did not find uint64 OID, %v", err)
}
conn.ConnInfo().RegisterDataType(pgtype.DataType{Value: &pgtype.Numeric{}, Name: "uint64", OID: uint64OID})
// String is still an acceptable argument after registration
err = conn.QueryRow(context.Background(), "select $1::uint64", "7").Scan(&n)
if err != nil {
t.Fatal(err)
}
if n != 7 {
t.Fatalf("Expected n to be 7, but was %v", n)
}
// But a uint64 is acceptable
err = conn.QueryRow(context.Background(), "select $1::uint64", uint64(24)).Scan(&n)
if err != nil {
t.Fatal(err)
}
if n != 24 {
t.Fatalf("Expected n to be 24, but was %v", n)
}
})
} | explode_data.jsonl/40027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 603
} | [
2830,
3393,
13636,
929,
1155,
353,
8840,
836,
8,
341,
18185,
2354,
3036,
26040,
4703,
802,
16374,
20689,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
4534,
353,
3517,
87,
50422,
8,
341,
197,
1903,
13389,
34,
1176,
64500,
3506,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestRuleTimestampDefault(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
{
"CREATE TABLE tbl( `id` bigint not null, `create_time` timestamp) ENGINE=InnoDB DEFAULT CHARSET=utf8;",
"ALTER TABLE t1 MODIFY b timestamp NOT NULL;",
},
{
"CREATE TABLE tbl (`id` bigint not null, `update_time` timestamp default current_timestamp)",
"ALTER TABLE t1 MODIFY b timestamp NOT NULL default current_timestamp;",
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleTimestampDefault()
if rule.Item != "COL.013" {
t.Error("Rule not match:", rule.Item, "Expect : COL.013")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleTimestampDefault()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 453
} | [
2830,
3393,
11337,
20812,
3675,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
515,
298,
197,
1,
22599,
14363,
21173,
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... | 7 |
func TestStreamFlush(t *testing.T) {
var w bytes.Buffer
writer := NewWriter(&w)
reader := NewReader(&w)
payload := "cc" // keep the payload short to make sure it will not be automatically flushed by zstd
buf := make([]byte, len(payload))
for i := 0; i < 5; i++ {
_, err := writer.Write([]byte(payload))
failOnError(t, "Failed writing to compress object", err)
err = writer.Flush()
failOnError(t, "Failed flushing compress object", err)
_, err = io.ReadFull(reader, buf)
failOnError(t, "Failed reading uncompress object", err)
if string(buf) != payload {
debug.PrintStack()
log.Fatal("Uncompressed object mismatch")
}
}
failOnError(t, "Failed to close compress object", writer.Close())
failOnError(t, "Failed to close uncompress object", reader.Close())
} | explode_data.jsonl/70463 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
3027,
46874,
1155,
353,
8840,
836,
8,
341,
2405,
289,
5820,
22622,
198,
38959,
1669,
1532,
6492,
2099,
86,
340,
61477,
1669,
1532,
5062,
2099,
86,
692,
76272,
1669,
330,
638,
1,
442,
2506,
279,
7729,
2805,
311,
1281,
2704,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServerCloseTelemetryConnection(t *testing.T) {
// create server telemetrybuffer and start server
tb = NewTelemetryBuffer(hostAgentUrl)
err := tb.StartServer()
if err == nil {
go tb.BufferAndPushData(0)
}
// create client telemetrybuffer and connect to server
tb1 := NewTelemetryBuffer(hostAgentUrl)
if err := tb1.Connect(); err != nil {
t.Errorf("connection to telemetry server failed %v", err)
}
// Exit server thread and close server connection
tb.Cancel()
time.Sleep(300 * time.Millisecond)
b := []byte("tamil")
if _, err := tb1.Write(b); err == nil {
t.Errorf("Client couldn't recognise server close")
}
if len(tb.connections) != 0 {
t.Errorf("All connections not closed as expected")
}
// Close client connection
tb1.Close()
} | explode_data.jsonl/49198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
5475,
7925,
6639,
35958,
4526,
1155,
353,
8840,
836,
8,
341,
197,
322,
1855,
3538,
61037,
7573,
323,
1191,
3538,
198,
62842,
284,
1532,
6639,
35958,
4095,
19973,
16810,
2864,
340,
9859,
1669,
16363,
12101,
5475,
741,
743,
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... | 5 |
func TestPageWithShortCodeInSummary(t *testing.T) {
t.Parallel()
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
checkPageTitle(t, p, "Simple")
checkPageContent(t, p, normalizeExpected(ext, "<p>Summary Next Line. <figure> <img src=\"/not/real\"/> </figure> . More text here.</p><p>Some more text</p>"))
checkPageSummary(t, p, "Summary Next Line. . More text here. Some more text")
checkPageType(t, p, "page")
}
testAllMarkdownEnginesForPages(t, assertFunc, nil, simplePageWithShortcodeInSummary)
} | explode_data.jsonl/60613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
2665,
2354,
12472,
2078,
641,
19237,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
6948,
9626,
1669,
2915,
1155,
353,
8840,
836,
11,
1303,
914,
11,
6816,
2150,
68829,
8,
341,
197,
3223,
1669,
6816,
58,
15,
921,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateTeamWithUser(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
id := model.NewId()
team := &model.Team{
DisplayName: "dn_" + id,
Name: "name" + id,
Email: "success+" + id + "@simulator.amazonses.com",
Type: model.TEAM_OPEN,
}
_, err := th.App.CreateTeamWithUser(team, th.BasicUser.Id)
require.Nil(t, err, "Should create a new team with existing user")
_, err = th.App.CreateTeamWithUser(team, model.NewId())
require.NotNil(t, err, "Should not create a new team - user does not exist")
} | explode_data.jsonl/30268 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
4021,
14597,
2354,
1474,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
15710,
1669,
1614,
7121,
764,
741,
197,
9196,
1669,
609,
2528,
65842,
515,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFromError(t *testing.T) {
dummyErr := errors.New("dummy error")
err := FromError(http.StatusInternalServerError, dummyErr)
assert.Error(t, err)
assert.Equal(t, dummyErr.Error(), err.Error())
} | explode_data.jsonl/30242 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
3830,
1454,
1155,
353,
8840,
836,
8,
341,
2698,
8574,
7747,
1669,
5975,
7121,
445,
31390,
1465,
1138,
9859,
1669,
5542,
1454,
19886,
66760,
11,
17292,
7747,
340,
6948,
6141,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
17292,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStructPtrCallMethod(t *testing.T) {
foo := &contact{
Name: "bill",
}
out, err := starlight.Eval([]byte(`out = foo.GetName()`), map[string]interface{}{"foo": foo}, nil)
if err != nil {
t.Fatal(err)
}
o, ok := out["out"]
if !ok {
t.Fatal("out param not found")
}
s, ok := o.(string)
if !ok {
t.Fatalf("out param not string, was %T", o)
}
expected := "bill"
if s != expected {
t.Fatalf("expected %q, but was %q", expected, s)
}
} | explode_data.jsonl/47070 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
9422,
5348,
7220,
3523,
1155,
353,
8840,
836,
8,
341,
197,
7975,
1669,
609,
6287,
515,
197,
21297,
25,
330,
29642,
756,
197,
630,
13967,
11,
1848,
1669,
6774,
4145,
5142,
831,
10556,
3782,
5809,
411,
284,
15229,
60304,
542... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntDataPoint_Timestamp(t *testing.T) {
ms := NewIntDataPoint()
assert.EqualValues(t, Timestamp(0), ms.Timestamp())
testValTimestamp := Timestamp(1234567890)
ms.SetTimestamp(testValTimestamp)
assert.EqualValues(t, testValTimestamp, ms.Timestamp())
} | explode_data.jsonl/32714 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
1072,
1043,
2609,
1139,
4702,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
1072,
1043,
2609,
741,
6948,
12808,
6227,
1155,
11,
32758,
7,
15,
701,
9829,
49024,
2398,
18185,
2208,
20812,
1669,
32758,
7,
16,
17,
18,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFromURL(t *testing.T) {
endSystem, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("net.Listen failed: %v", err)
}
defer endSystem.Close()
gateway, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("net.Listen failed: %v", err)
}
defer gateway.Close()
var wg sync.WaitGroup
wg.Add(1)
go socks5Gateway(t, gateway, endSystem, socks5Domain, &wg)
url, err := url.Parse("socks5://user:password@" + gateway.Addr().String())
if err != nil {
t.Fatalf("url.Parse failed: %v", err)
}
proxy, err := FromURL(url, Direct)
if err != nil {
t.Fatalf("FromURL failed: %v", err)
}
_, port, err := net.SplitHostPort(endSystem.Addr().String())
if err != nil {
t.Fatalf("net.SplitHostPort failed: %v", err)
}
if c, err := proxy.Dial("tcp", "localhost:"+port); err != nil {
t.Fatalf("FromURL.Dial failed: %v", err)
} else {
c.Close()
}
wg.Wait()
} | explode_data.jsonl/72577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
3830,
3144,
1155,
353,
8840,
836,
8,
341,
6246,
2320,
11,
1848,
1669,
4179,
68334,
445,
27161,
497,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
15,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
4711,
68334,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTagsDirection(t *testing.T) {
assert.NoError(t, PrepareEngine())
type OnlyFromDBStruct struct {
Id int64
Name string
Uuid string `xorm:"<- default '1'"`
}
assertSync(t, new(OnlyFromDBStruct))
cnt, err := testEngine.Insert(&OnlyFromDBStruct{
Name: "test",
Uuid: "2",
})
assert.NoError(t, err)
assert.EqualValues(t, 1, cnt)
var s OnlyFromDBStruct
has, err := testEngine.ID(1).Get(&s)
assert.NoError(t, err)
assert.True(t, has)
assert.EqualValues(t, "1", s.Uuid)
assert.EqualValues(t, "test", s.Name)
cnt, err = testEngine.ID(1).Update(&OnlyFromDBStruct{
Uuid: "3",
Name: "test1",
})
assert.NoError(t, err)
assert.EqualValues(t, 1, cnt)
var s3 OnlyFromDBStruct
has, err = testEngine.ID(1).Get(&s3)
assert.NoError(t, err)
assert.True(t, has)
assert.EqualValues(t, "1", s3.Uuid)
assert.EqualValues(t, "test1", s3.Name)
type OnlyToDBStruct struct {
Id int64
Name string
Uuid string `xorm:"->"`
}
assertSync(t, new(OnlyToDBStruct))
cnt, err = testEngine.Insert(&OnlyToDBStruct{
Name: "test",
Uuid: "2",
})
assert.NoError(t, err)
assert.EqualValues(t, 1, cnt)
var s2 OnlyToDBStruct
has, err = testEngine.ID(1).Get(&s2)
assert.NoError(t, err)
assert.True(t, has)
assert.EqualValues(t, "", s2.Uuid)
assert.EqualValues(t, "test", s2.Name)
} | explode_data.jsonl/19216 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 580
} | [
2830,
3393,
15930,
9268,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
4571,
12367,
13158,
8278,
3830,
3506,
9422,
2036,
341,
197,
67211,
256,
526,
21,
19,
198,
197,
21297,
914,
198,
197,
15980,
2423,
914,
1565,
87,
493,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.