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 TestWriterErrors(t *testing.T) {
errorTests := []struct {
html string
n []int
}{
{`<!doctype>`, []int{0}},
{`text`, []int{0}},
{`<foo attr=val>`, []int{0, 1, 2, 3, 4, 5}},
{`</foo>`, []int{0}},
{`<style>x</style>`, []int{2}},
{`<textarea>x</textarea>`, []int{2}},
{`<code>x</code>`, []int{2}},
{`<pre>x</pre>`, []int{2}},
{`<svg>x</svg>`, []int{0}},
{`<math>x</math>`, []int{0}},
{`<!--[if IE 6]> text <![endif]-->`, []int{0, 1, 2}},
{`<![if IE 6]> text <![endif]>`, []int{0}},
}
m := minify.New()
m.Add("text/html", &Minifier{
KeepConditionalComments: true,
})
for _, tt := range errorTests {
for _, n := range tt.n {
t.Run(fmt.Sprint(tt.html, " ", tt.n), func(t *testing.T) {
r := bytes.NewBufferString(tt.html)
w := test.NewErrorWriter(n)
err := m.Minify("text/html", w, r)
test.T(t, err, test.ErrPlain)
})
}
}
} | explode_data.jsonl/59590 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 476
} | [
2830,
3393,
6492,
13877,
1155,
353,
8840,
836,
8,
341,
18290,
18200,
1669,
3056,
1235,
341,
197,
36126,
914,
198,
197,
9038,
262,
3056,
396,
198,
197,
59403,
197,
197,
90,
63,
13543,
50139,
29,
7808,
3056,
396,
90,
15,
22050,
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... | 1 |
func TestGetContext(t *testing.T) {
conf, cleanup := testutil.InitConfig(t)
defer cleanup(t)
context, err := conf.GetContext("def_ephemeral")
require.NoError(t, err)
// Test Positives
assert.EqualValues(t, context.NameInKubeconf, "def_ephemeral")
// Test Wrong Cluster
_, err = conf.GetContext("unknown")
assert.Error(t, err)
} | explode_data.jsonl/57902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
1949,
1972,
1155,
353,
8840,
836,
8,
341,
67850,
11,
21290,
1669,
1273,
1314,
26849,
2648,
1155,
340,
16867,
21290,
1155,
692,
28413,
11,
1848,
1669,
2335,
2234,
1972,
445,
750,
12476,
29032,
3253,
1138,
17957,
35699,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewRequestCloudfronting(t *testing.T) {
client := newClient()
client.Host = "www.x.org"
req, err := client.NewRequest(
context.Background(), "GET", "/", nil, nil,
)
if err != nil {
t.Fatal(err)
}
if req.Host != client.Host {
t.Fatal("expected different req.Host here")
}
} | explode_data.jsonl/60963 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
3564,
1900,
16055,
6951,
287,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
2959,
741,
25291,
29840,
284,
330,
2136,
1993,
2659,
698,
24395,
11,
1848,
1669,
2943,
75274,
1006,
197,
28413,
19047,
1507,
330,
3806,
497,
64657... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSnapshotNotExists(t *testing.T) {
if test.UpdateGoldenGlobal {
t.Skip()
}
a := struct {
A string
B int
C bool
D *string
}{
A: "foo",
B: 1,
C: true,
D: swag.String("bar"),
}
b := "Hello World!"
defer func() {
os.Remove(filepath.Join(test.DefaultSnapshotDirPathAbs, "TestSnapshotNotExists.golden"))
}()
tMock := new(mocks.TestingT)
tMock.On("Helper").Return()
tMock.On("Name").Return("TestSnapshotNotExists")
tMock.On("Fatalf", mock.Anything, mock.Anything).Return()
tMock.On("Fatal", mock.Anything).Return()
tMock.On("Error", mock.Anything).Return()
test.Snapshoter.Save(tMock, a, b)
tMock.AssertNotCalled(t, "Error")
tMock.AssertNotCalled(t, "Fatalf")
tMock.AssertCalled(t, "Fatalf", mock.Anything, mock.Anything)
} | explode_data.jsonl/17629 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
15009,
2623,
15575,
1155,
353,
8840,
836,
8,
341,
743,
1273,
16689,
59790,
11646,
341,
197,
3244,
57776,
741,
197,
532,
11323,
1669,
2036,
341,
197,
22985,
914,
198,
197,
12791,
526,
198,
197,
6258,
1807,
198,
197,
10957,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Hoverfly_PutSimulation_ImportsDelaysWithValidationError(t *testing.T) {
RegisterTestingT(t)
unit := NewHoverflyWithConfiguration(&Configuration{})
simulationToImport := v2.SimulationViewV5{
v2.DataViewV5{
GlobalActions: v2.GlobalActionsView{
Delays: []v1.ResponseDelayView{delayOne, invalidDelay},
},
},
v2.MetaView{},
}
err := unit.PutSimulation(simulationToImport)
Expect(err.GetError()).NotTo(BeNil())
delays := unit.Simulation.ResponseDelays.ConvertToResponseDelayPayloadView()
Expect(delays.Data).To(BeEmpty())
} | explode_data.jsonl/45379 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
2039,
1975,
21642,
1088,
332,
64554,
62,
31250,
16532,
942,
2354,
80553,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
692,
81189,
1669,
1532,
34379,
21642,
2354,
7688,
2099,
7688,
6257,
692,
1903,
60361,
1249,
11511,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBoolMarshal(t *testing.T) {
b := val.Boolean(true)
j, _ := b.MarshalJSON()
require.Equal(t, []byte("true"), j)
bin, _ := b.MarshalBinary()
require.Equal(t, []byte{0xc3}, bin)
b = val.Boolean(false)
j, _ = b.MarshalJSON()
require.Equal(t, []byte("false"), j)
bin, _ = b.MarshalBinary()
require.Equal(t, []byte{0xc2}, bin)
s := &testBoolStruct{val.Boolean(true)}
j, _ = json.Marshal(s)
require.Equal(t, "{\"B\":true}", string(j))
} | explode_data.jsonl/37955 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
11233,
55438,
1155,
353,
8840,
836,
8,
1476,
2233,
1669,
1044,
19162,
3715,
692,
12428,
11,
716,
1669,
293,
37271,
5370,
741,
17957,
12808,
1155,
11,
3056,
3782,
445,
1866,
3975,
502,
692,
2233,
258,
11,
716,
1669,
293,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListIngress(t *testing.T) {
a, _ := NewAdapter(testConfig, IngressAPIVersionNetworking, testIngressFilter, testIngressDefaultSecurityGroup, testSSLPolicy, aws.LoadBalancerTypeApplication, DefaultClusterLocalDomain, false)
client := &mockClient{}
a.kubeClient = client
ingresses, err := a.ListIngress()
if err != nil {
t.Error(err)
}
if len(ingresses) != 1 {
t.Fatal("unexpected count of ingress resources")
}
client.broken = true
_, err = a.ListIngress()
if err == nil {
t.Error("expected an error")
}
} | explode_data.jsonl/6731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
852,
641,
2483,
1155,
353,
8840,
836,
8,
341,
11323,
11,
716,
1669,
1532,
5940,
8623,
2648,
11,
758,
2483,
7082,
5637,
78007,
11,
1273,
641,
2483,
5632,
11,
1273,
641,
2483,
3675,
15352,
2808,
11,
1273,
1220,
12567,
8018,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDocumentExtraction(t *testing.T) {
for _, test := range []struct {
Name string
Document *birch.Document
EncoderShouldError bool
NumEncodedValues int
FirstEncodedValue int64
Types []bsontype.Type
}{
{
Name: "EmptyDocument",
Document: birch.NewDocument(),
NumEncodedValues: 0,
FirstEncodedValue: 0,
},
{
Name: "NilDocumentsDocument",
Document: (&birch.Document{IgnoreNilInsert: true}).Append(nil, nil),
NumEncodedValues: 0,
FirstEncodedValue: 0,
},
{
Name: "SingleMetricValue",
Document: birch.NewDocument(birch.EC.Int64("foo", 42)),
NumEncodedValues: 1,
FirstEncodedValue: 42,
Types: []bsontype.Type{bsontype.Int64},
},
{
Name: "MultiMetricValue",
Document: birch.NewDocument(birch.EC.Int64("foo", 7), birch.EC.Int32("foo", 72)),
NumEncodedValues: 2,
FirstEncodedValue: 7,
Types: []bsontype.Type{bsontype.Int64, bsontype.Int32},
},
{
Name: "MultiNonMetricValue",
Document: birch.NewDocument(birch.EC.String("foo", "var"), birch.EC.String("bar", "bar")),
NumEncodedValues: 0,
FirstEncodedValue: 0,
},
{
Name: "MixedArrayFirstMetrics",
Document: birch.NewDocument(birch.EC.Boolean("zp", true), birch.EC.String("foo", "var"), birch.EC.Int64("bar", 7)),
NumEncodedValues: 2,
FirstEncodedValue: 1,
Types: []bsontype.Type{bsontype.Boolean, bsontype.Int64},
},
} {
t.Run(test.Name, func(t *testing.T) {
metrics, err := extractMetricsFromDocument(test.Document)
assert.NoError(t, err)
assert.Equal(t, test.NumEncodedValues, len(metrics.values))
assert.False(t, metrics.ts.IsZero())
if len(metrics.values) > 0 {
assert.EqualValues(t, test.FirstEncodedValue, metrics.values[0].Interface())
}
require.Len(t, metrics.types, len(test.Types))
for i := range metrics.types {
assert.Equal(t, test.Types[i], metrics.types[i])
}
})
}
} | explode_data.jsonl/15278 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1027
} | [
2830,
3393,
7524,
840,
26425,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
21297,
2290,
914,
198,
197,
98887,
1843,
353,
43855,
331,
26256,
198,
197,
197,
19921,
14996,
1454,
1807,
198,
197,
197,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_GenerateMarkdown_Returns_Parse_Err(t *testing.T) {
eng := &goeditorjs.MarkdownEngine{BlockHandlers: make(map[string]goeditorjs.MarkdownBlockHandler)}
_, err := eng.GenerateMarkdown(``)
require.Error(t, err)
} | explode_data.jsonl/21334 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
2646,
13220,
68005,
53316,
82,
77337,
93623,
1155,
353,
8840,
836,
8,
341,
197,
826,
1669,
609,
3346,
8868,
2519,
75888,
2923,
4571,
90,
4713,
39949,
25,
1281,
9147,
14032,
60,
3346,
8868,
2519,
75888,
2923,
4713,
3050,
1056... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitConfigFromRawWithPem(t *testing.T) {
// get a config byte for testing
configPath := filepath.Join(getConfigPath(), configPemTestFile)
cBytes, err := loadConfigBytesFromFile(t, configPath)
if err != nil {
t.Fatalf("Failed to load sample bytes from File. Error: %s", err)
}
// test init config from bytes
backend, err := config.FromRaw(cBytes, configType)()
if err != nil {
t.Fatalf("Failed to initialize config from bytes array. Error: %s", err)
}
config1, err := ConfigFromBackend(backend...)
if err != nil {
t.Fatalf("Failed to initialize config from bytes array. Error: %s", err)
}
endpointConfig := config1.(*EndpointConfig)
o := endpointConfig.OrderersConfig()
if len(o) == 0 {
t.Fatal("orderer cannot be nil or empty")
}
oPem := `-----BEGIN CERTIFICATE-----
MIICNjCCAdygAwIBAgIRAILSPmMB3BzoLIQGsFxwZr8wCgYIKoZIzj0EAwIwbDEL
MAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG
cmFuY2lzY28xFDASBgNVBAoTC2V4YW1wbGUuY29tMRowGAYDVQQDExF0bHNjYS5l
eGFtcGxlLmNvbTAeFw0xNzA3MjgxNDI3MjBaFw0yNzA3MjYxNDI3MjBaMGwxCzAJ
BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJh
bmNpc2NvMRQwEgYDVQQKEwtleGFtcGxlLmNvbTEaMBgGA1UEAxMRdGxzY2EuZXhh
bXBsZS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQfgKb4db53odNzdMXn
P5FZTZTFztOO1yLvCHDofSNfTPq/guw+YYk7ZNmhlhj8JHFG6dTybc9Qb/HOh9hh
gYpXo18wXTAOBgNVHQ8BAf8EBAMCAaYwDwYDVR0lBAgwBgYEVR0lADAPBgNVHRMB
Af8EBTADAQH/MCkGA1UdDgQiBCBxaEP3nVHQx4r7tC+WO//vrPRM1t86SKN0s6XB
8LWbHTAKBggqhkjOPQQDAgNIADBFAiEA96HXwCsuMr7tti8lpcv1oVnXg0FlTxR/
SQtE5YgdxkUCIHReNWh/pluHTxeGu2jNCH1eh6o2ajSGeeizoapvdJbN
-----END CERTIFICATE-----`
oCert, err := tlsCertByBytes([]byte(oPem))
if err != nil {
t.Fatal("failed to cert from pem bytes")
}
if !reflect.DeepEqual(oCert.RawSubject, o[0].TLSCACert.RawSubject) {
t.Fatal("certs supposed to match")
}
pc, ok := endpointConfig.PeersConfig(org1)
if !ok {
t.Fatal("unexpected error while getting peerConfig")
}
if len(pc) == 0 {
t.Fatalf("peers list of %s cannot be nil or empty", org1)
}
checkPem(endpointConfig, t)
} | explode_data.jsonl/34087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1044
} | [
2830,
3393,
3803,
2648,
3830,
20015,
2354,
47,
336,
1155,
353,
8840,
836,
8,
341,
197,
322,
633,
264,
2193,
4922,
369,
7497,
198,
25873,
1820,
1669,
26054,
22363,
5433,
2648,
1820,
1507,
2193,
47,
336,
2271,
1703,
340,
1444,
7078,
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... | 9 |
func TestServerCustomNodeId(t *testing.T) {
idHex := "5a3ce1c14e7a08645677bbd1cfe7d8f956d53256"
idBytes, err := hex.DecodeString(idHex)
require.NoError(t, err)
var id [20]byte
n := copy(id[:], idBytes)
require.Equal(t, 20, n)
// How to test custom *secure* ID when tester computers will have
// different IDs? Generate custom ids for local IPs and use mini-ID?
s, err := NewServer(&ServerConfig{
NodeId: id,
Conn: mustListen(":0"),
})
require.NoError(t, err)
defer s.Close()
assert.Equal(t, id, s.ID())
} | explode_data.jsonl/35952 | {
"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,
5475,
10268,
79206,
1155,
353,
8840,
836,
8,
341,
15710,
20335,
1669,
330,
20,
64,
18,
346,
16,
66,
16,
19,
68,
22,
64,
15,
23,
21,
19,
20,
21,
22,
22,
6066,
67,
16,
66,
1859,
22,
67,
23,
69,
24,
20,
21,
67,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInvalidV2Configs(t *testing.T) {
for _, c := range []struct{ path, errorSubstring string }{
{"testdata/insecure-conflicts.conf", "registry 'registry.com' is defined multiple times with conflicting 'insecure' setting"},
{"testdata/blocked-conflicts.conf", "registry 'registry.com' is defined multiple times with conflicting 'blocked' setting"},
{"testdata/missing-mirror-location.conf", "invalid condition: mirror location is unset"},
{"testdata/invalid-prefix.conf", "invalid location"},
{"testdata/this-does-not-exist.conf", "no such file or directory"},
} {
_, err := GetRegistries(&types.SystemContext{SystemRegistriesConfPath: c.path})
assert.Error(t, err, c.path)
if c.errorSubstring != "" {
assert.Contains(t, err.Error(), c.errorSubstring, c.path)
}
}
} | explode_data.jsonl/62230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
7928,
53,
17,
84905,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
3056,
1235,
90,
1815,
11,
1465,
59075,
914,
335,
515,
197,
197,
4913,
92425,
17996,
25132,
50717,
56445,
13937,
497,
330,
29172,
364,
29172,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestHook_HasError(t *testing.T) {
hook := NewHook(nil, nil)
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
if !hook.HasError() {
t.Error("has error err")
}
} | explode_data.jsonl/40945 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
31679,
2039,
300,
1454,
1155,
353,
8840,
836,
8,
341,
9598,
1941,
1669,
1532,
31679,
27907,
11,
2092,
340,
9598,
1941,
27862,
38881,
7121,
445,
1944,
5455,
9598,
1941,
27862,
38881,
7121,
445,
1944,
5455,
9598,
1941,
27862,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadSequence(t *testing.T) {
// first create archive, that we will be able to read
updateTestDir, _ := ioutil.TempDir("", "update")
defer os.RemoveAll(updateTestDir)
archive, err := WriteRootfsImageArchive(updateTestDir, RootfsImageStructOK)
assert.NoError(t, err)
assert.NotEqual(t, "", archive)
// open archive file
f, err := os.Open(archive)
defer f.Close()
assert.NoError(t, err)
assert.NotNil(t, f)
aReader := NewReader(f)
defer aReader.Close()
rp := &parser.RootfsParser{}
aReader.Register(rp)
info, err := aReader.ReadInfo()
assert.NoError(t, err)
assert.NotNil(t, info)
hInfo, err := aReader.ReadHeaderInfo()
assert.NoError(t, err)
assert.NotNil(t, hInfo)
df, err := os.Create(filepath.Join(updateTestDir, "my_update"))
defer df.Close()
for cnt, update := range hInfo.Updates {
if update.Type == "rootfs-image" {
rp := &parser.RootfsParser{W: df}
aReader.PushWorker(rp, fmt.Sprintf("%04d", cnt))
}
}
hdr, err := aReader.ReadHeader()
assert.NoError(t, err)
assert.NotNil(t, hdr)
w, err := aReader.ReadData()
assert.NoError(t, err)
assert.Equal(t, "vexpress", aReader.GetCompatibleDevices()[0])
assert.NotNil(t, w)
data, err := ioutil.ReadFile(path.Join(updateTestDir, "my_update"))
assert.NoError(t, err)
assert.Equal(t, "my first update", string(data))
} | explode_data.jsonl/35300 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
4418,
14076,
1155,
353,
8840,
836,
8,
341,
197,
322,
1156,
1855,
18132,
11,
429,
582,
686,
387,
2952,
311,
1349,
198,
27175,
2271,
6184,
11,
716,
1669,
43144,
65009,
6184,
19814,
330,
2386,
1138,
16867,
2643,
84427,
31540,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUintBytesToBigInt(t *testing.T) {
res, err := UintBytesToBigInt(MustHexDecodeString("0x0004"))
assert.NoError(t, err)
assert.Equal(t, big.NewInt(4), res)
res, err = UintBytesToBigInt(MustHexDecodeString("0xfffc"))
assert.NoError(t, err)
assert.Equal(t, big.NewInt(65532), res)
_, err = UintBytesToBigInt([]byte{})
assert.EqualError(t, err, "cannot decode an empty byte slice")
} | explode_data.jsonl/18432 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
21570,
7078,
1249,
87474,
1155,
353,
8840,
836,
8,
341,
10202,
11,
1848,
1669,
27883,
7078,
1249,
87474,
3189,
590,
20335,
32564,
703,
445,
15,
87,
15,
15,
15,
19,
5455,
6948,
35699,
1155,
11,
1848,
340,
6948,
12808,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUpdateDocumentsKeepNullFalse(t *testing.T) {
ctx := context.Background()
c := createClientFromEnv(t, true)
db := ensureDatabase(ctx, c, "document_test", nil, t)
col := ensureCollection(ctx, db, "documents_test", nil, t)
docs := []Account{
Account{
ID: "1234",
User: &UserDoc{
"Mathilda",
45,
},
},
Account{
ID: "364",
User: &UserDoc{
"Jo",
42,
},
},
}
metas, errs, err := col.CreateDocuments(ctx, docs)
if err != nil {
t.Fatalf("Failed to create new documents: %s", describe(err))
} else if err := errs.FirstNonNil(); err != nil {
t.Fatalf("Expected no errors, got first: %s", describe(err))
}
// Update document
updates := []map[string]interface{}{
map[string]interface{}{
"id": "5678",
"user": nil,
},
map[string]interface{}{
"id": "753",
"user": nil,
},
}
if _, _, err := col.UpdateDocuments(driver.WithKeepNull(ctx, false), metas.Keys(), updates); err != nil {
t.Fatalf("Failed to update documents: %s", describe(err))
}
// Read updated documents
for i, meta := range metas {
readDoc := docs[i]
if _, err := col.ReadDocument(ctx, meta.Key, &readDoc); err != nil {
t.Fatalf("Failed to read document '%s': %s", meta.Key, describe(err))
}
if readDoc.User == nil {
t.Errorf("Expected user to be untouched, got %v", readDoc.User)
}
}
} | explode_data.jsonl/49558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 562
} | [
2830,
3393,
4289,
27143,
19434,
3280,
4049,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
1669,
1855,
2959,
3830,
14359,
1155,
11,
830,
340,
20939,
1669,
5978,
5988,
7502,
11,
272,
11,
330,
6062,
4452,
497,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestFilePoolSizes(t *testing.T) {
tests := []struct {
size int
err error
}{
{-1, ErrPoolSizeLessThanZero},
{0, ErrPoolSizeLessThanZero},
{4, nil},
{8, nil},
}
for _, tc := range tests {
t.Run(fmt.Sprintf("size %d", tc.size), func(t *testing.T) {
dir, err := ioutil.TempDir("", "fastzip-filepool")
require.NoError(t, err)
defer os.RemoveAll(dir)
fp, err := New(dir, tc.size, -1)
require.Equal(t, tc.err, err)
if tc.err != nil {
return
}
// writing should produce the temporary file
for i := 0; i < tc.size; i++ {
f := fp.Get()
_, err = f.Write([]byte("foobar"))
assert.NoError(t, err)
fp.Put(f)
_, err = os.Lstat(filepath.Join(dir, fmt.Sprintf("fastzip_%02d", i)))
assert.NoError(t, err, fmt.Sprintf("fastzip_%02d should exist", i))
}
// closing should cleanup temporary files
assert.NoError(t, fp.Close())
for i := 0; i < tc.size; i++ {
_, err = os.Lstat(filepath.Join(dir, fmt.Sprintf("fastzip_%02d", i)))
assert.Error(t, err, fmt.Sprintf("fastzip_%02d shouldn't exist", i))
}
})
}
} | explode_data.jsonl/60246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 508
} | [
2830,
3393,
1703,
10551,
34930,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
13832,
526,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,
197,
19999,
16,
11,
15495,
10551,
1695,
27451,
26067,
17999,
1583,
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... | 4 |
func TestNewMention(t *testing.T) {
msg := NewMention([]string{"user"}, nil, true)
data := msg.payload()
assert.NotNil(t, data.Text)
assert.Equal(t, data.MessageType, "text")
assert.Equal(t, msg.members, []string{"user"})
assert.Equal(t, msg.all, true)
} | explode_data.jsonl/57563 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
3564,
44,
2939,
1155,
353,
8840,
836,
8,
341,
21169,
1669,
1532,
44,
2939,
10556,
917,
4913,
872,
14345,
2092,
11,
830,
692,
8924,
1669,
3750,
17492,
741,
6948,
93882,
1155,
11,
821,
1979,
340,
6948,
12808,
1155,
11,
821,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDHCP(t *testing.T) {
t.Run("Put", testDHCPPutConfig)
t.Run("Get", testDHCPGetConfig)
t.Run("Lease", testDHCPLease)
t.Run("Renew", testDHCPRenew)
t.Run("Release", testDHCPRelease)
t.Run("Decline", testDHCPDecline)
t.Run("Expire", testDHCPLeaseExpiration)
t.Run("Race", testDHCPLeaseRace)
t.Run("Generate Dummy MAC", testDummyMAC)
} | explode_data.jsonl/73032 | {
"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,
51326,
7123,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
19103,
497,
1273,
51326,
15855,
332,
2648,
340,
3244,
16708,
445,
1949,
497,
1273,
51326,
7123,
1949,
2648,
340,
3244,
16708,
445,
2304,
519,
497,
1273,
51326,
712... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilepathREST_Update_SimultaneousUpdates(t *testing.T) {
f := newRESTFixture(t)
defer f.tearDown()
var obj runtime.Object
obj = &v1alpha1.Manifest{
ObjectMeta: metav1.ObjectMeta{
Name: "test-obj",
},
Spec: v1alpha1.ManifestSpec{
Message: "original",
},
}
f.mustCreate(obj)
type result struct {
inVersion string
outVersion string
message string
}
// create a bunch of workers that loop attempting to do updates and keep
// track of which are successful so that we can ensure that only one update
// per input resourceVersion is ever accepted by the server
const workerCount = 20
const workerIterations = 100
var results [workerCount][workerIterations]result
var wg sync.WaitGroup
for worker := 0; worker < workerCount; worker++ {
wg.Add(1)
go func(worker int) {
for i := 0; i < workerIterations; i++ {
var inVersion string
msg := fmt.Sprintf("worker-%d-iteration-%d", worker, i)
obj, err := f.update("test-obj", func(obj runtime.Object) {
m := obj.(*v1alpha1.Manifest)
m.Spec.Message = msg
inVersion = m.GetResourceVersion()
})
if err == nil {
m := obj.(*v1alpha1.Manifest)
// verify the version returned back to us has our data
require.Equal(t, msg, m.Spec.Message, "Incorrect updated object message")
results[worker][i] = result{
inVersion: inVersion,
outVersion: m.GetResourceVersion(),
message: m.Spec.Message,
}
}
}
wg.Done()
}(worker)
}
wg.Wait()
seen := make(map[string]string)
for worker := range results {
for i := range results[worker] {
r := results[worker][i]
if r.inVersion == "" {
continue
}
if v, ok := seen[r.inVersion]; ok {
// apiserver accepted > 1 update for the same inVersion
// NOTE: if this is failing and you see 2x identical outVersions, that's not a test issue! it means
// not only was the update accepted twice, but there are now two _different_ objects out there with
// the same resource version
t.Fatalf("Saw more than one update for inVersion=%s (outVersion=%s and outVersion=%s)",
r.inVersion, v, r.outVersion)
}
// it IS possible for a no-op update to result in no version change, but all the updates in this test
// mutate the object, so if the version doesn't change but apiserver accepts the update, that's a bug
require.NotEqualf(t, r.inVersion, r.outVersion,
"inVersion and outVersion are equal (apiserver changed object without changing version)")
seen[r.inVersion] = r.outVersion
require.Equal(t, fmt.Sprintf("worker-%d-iteration-%d", worker, i), r.message)
}
}
} | explode_data.jsonl/64544 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 986
} | [
2830,
3393,
1703,
2343,
38307,
47393,
1098,
318,
494,
17666,
37091,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
38307,
18930,
1155,
340,
16867,
282,
31853,
59342,
2822,
2405,
2839,
15592,
8348,
198,
22671,
284,
609,
85,
16,
7141,
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 TestRemoveComments(t *testing.T) {
// Leading ; comment.
input := "; Leading comment"
expected := ""
actual := removeComments(input)
if expected != actual {
t.Errorf("expected: %q, actual: %q", expected, actual)
}
// Leading # comment.
input = "# Leading comment"
expected = ""
actual = removeComments(input)
if expected != actual {
t.Errorf("expected: %q, actual: %q", expected, actual)
}
// Embedded comment.
input = "Some text # Leading comment"
expected = "Some text"
actual = removeComments(input)
if expected != actual {
t.Errorf("expected: %q, actual: %q", expected, actual)
}
// Comment within comment.
input = "Some text # Leading comment ; Another comment"
expected = "Some text"
actual = removeComments(input)
if expected != actual {
t.Errorf("expected: %q, actual: %q", expected, actual)
}
// Multiple comment characters.
input = "########################################################################"
expected = ""
actual = removeComments(input)
if expected != actual {
t.Errorf("expected: %q, actual: %q", expected, actual)
}
} | explode_data.jsonl/49349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
13021,
17373,
1155,
353,
8840,
836,
8,
341,
197,
322,
58043,
2587,
3980,
624,
22427,
1669,
18963,
58043,
3980,
698,
42400,
1669,
8389,
88814,
1669,
4057,
17373,
5384,
340,
743,
3601,
961,
5042,
341,
197,
3244,
13080,
445,
73... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestMaxDeltaSchemaCount(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
require.Equal(t, int64(variable.DefTiDBMaxDeltaSchemaCount), variable.GetMaxDeltaSchemaCount())
tk.MustExec("set @@global.tidb_max_delta_schema_count= -1")
tk.MustQuery("show warnings;").Check(testkit.Rows("Warning 1292 Truncated incorrect tidb_max_delta_schema_count value: '-1'"))
// Make sure a new session will load global variables.
tk.RefreshSession()
tk.MustExec("use test")
require.Equal(t, int64(100), variable.GetMaxDeltaSchemaCount())
tk.MustExec(fmt.Sprintf("set @@global.tidb_max_delta_schema_count= %v", uint64(math.MaxInt64)))
tk.MustQuery("show warnings;").Check(testkit.Rows(fmt.Sprintf("Warning 1292 Truncated incorrect tidb_max_delta_schema_count value: '%d'", uint64(math.MaxInt64))))
tk.RefreshSession()
tk.MustExec("use test")
require.Equal(t, int64(16384), variable.GetMaxDeltaSchemaCount())
_, err := tk.Exec("set @@global.tidb_max_delta_schema_count= invalid_val")
require.Truef(t, terror.ErrorEqual(err, variable.ErrWrongTypeForVar), "err %v", err)
tk.MustExec("set @@global.tidb_max_delta_schema_count= 2048")
tk.RefreshSession()
tk.MustExec("use test")
require.Equal(t, int64(2048), variable.GetMaxDeltaSchemaCount())
tk.MustQuery("select @@global.tidb_max_delta_schema_count").Check(testkit.Rows("2048"))
} | explode_data.jsonl/38153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 540
} | [
2830,
3393,
5974,
20277,
8632,
2507,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50463,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBucketOverflow(t *testing.T) {
t.Parallel()
b := NewBucket(10, 10*time.Millisecond)
defer b.Close()
n, err := b.Fill(func(remaining int64) (int64, error) {
return 11, nil
})
if err != nil {
t.Fatalf("Fill(): got %v, want no error", err)
}
n, err = b.Fill(func(int64) (int64, error) {
t.Fatal("Fill: executed func when full, want skipped")
return 0, nil
})
if err != ErrBucketOverflow {
t.Fatalf("Fill(): got %v, want ErrBucketOverflow", err)
}
if got, want := n, int64(0); got != want {
t.Fatalf("n: got %d, want %d", got, want)
}
} | explode_data.jsonl/74397 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
36018,
42124,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2233,
1669,
1532,
36018,
7,
16,
15,
11,
220,
16,
15,
77053,
71482,
340,
16867,
293,
10421,
2822,
9038,
11,
1848,
1669,
293,
19495,
18552,
7,
43436,
526,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTemporal(t *testing.T) {
conf := `
{
"start":"10:00",
"end": "19:30"
}
`
p, err := Temporal([]byte(conf), 13, 100)
if err != nil {
t.Error(err)
}
if p.ValueRange() != 87 {
t.Error("Expected 87, found:", p.ValueRange())
}
if p.TotalMinutes() != 570 {
t.Error("Expected 570, found:", p.TotalMinutes())
}
if n := p.PastMinutes(time.Now()); n == 0 {
t.Error("Expected non-zero, found:", n)
}
} | explode_data.jsonl/48672 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
92850,
1155,
353,
8840,
836,
8,
341,
67850,
1669,
22074,
515,
197,
1,
2468,
3252,
16,
15,
25,
15,
15,
756,
197,
1,
408,
788,
330,
16,
24,
25,
18,
15,
698,
532,
3989,
3223,
11,
1848,
1669,
19944,
9819,
10556,
3782,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGrantChannelsAndUUIDsFailureNotStubbed(t *testing.T) {
assert := assert.New(t)
pn := pubnub.NewPubNub(pamConfigCopy())
res, _, err := pn.Grant().Channels([]string{"ch1", "ch2"}).
Get(true).Update(true).Join(true).Read(true).
AuthKeys([]string{"uuid-key"}).UUIDs([]string{"ch1", "ch2"}).
Execute()
assert.NotNil(err)
assert.Nil(res)
} | explode_data.jsonl/43182 | {
"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,
67971,
35925,
3036,
24754,
82,
17507,
2623,
33838,
2721,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
3223,
77,
1669,
6675,
77,
392,
7121,
29162,
45,
392,
1295,
309,
2648,
12106,
12367,
10202,
11,
8358,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSubrace_QueryList_IT(t *testing.T) {
query := make(map[string]string, 1)
query["index"] = "high-elf"
resp, err := Client.QueryList(query)
r, _ := json.Marshal(resp)
log.Print(fmt.Sprintf("Response: %s", r))
assert.Nil(t, err, "Should not receive an error contacting API.")
assert.True(t, true, "Should complete successfully!")
} | explode_data.jsonl/57198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
3136,
41183,
48042,
852,
41681,
1155,
353,
8840,
836,
8,
341,
27274,
1669,
1281,
9147,
14032,
30953,
11,
220,
16,
340,
27274,
1183,
1252,
1341,
284,
330,
11892,
12,
490,
698,
34653,
11,
1848,
1669,
8423,
15685,
852,
10741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestACO(t *testing.T) {
settings := ACOSettings{}
pop := []Ant{
ant{true, true},
ant{true, true},
ant{true, true},
}
res, err := ACO(pop, settings)
if err == nil {
t.Error("ACO should fail when settings are invalid")
}
settings.Evaporation = 0.9
settings.MaxIterations = 10
settings.Verbose = 1
settings.KeepHistory = true
res, err = ACO(pop, settings)
if err != nil {
t.Errorf("ACO shoud not fail, got: %v", err)
}
if res.Iterations != settings.MaxIterations {
t.Errorf("result iterations unexpected, wanted %v got %v", settings.MaxIterations, res.Iterations)
}
if res.AveragePerformances[0] != pop[0].Performance() {
t.Error("all ants have the same performance, so average performance should be the same too")
}
if res.BestPerformances[0] != pop[0].Performance() {
t.Error("all ants have the same performance, so best performance should be the same too")
}
if res.BestAnts[res.Iterations-1].Performance() != pop[0].Performance() {
t.Error("best ant should have same performance as any other ant")
}
} | explode_data.jsonl/60133 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 367
} | [
2830,
3393,
1706,
46,
1155,
353,
8840,
836,
8,
341,
62930,
1669,
362,
8281,
6086,
16094,
74813,
1669,
3056,
17117,
515,
197,
197,
517,
90,
1866,
11,
830,
1583,
197,
197,
517,
90,
1866,
11,
830,
1583,
197,
197,
517,
90,
1866,
11,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestScaleUint64(t *testing.T) {
n1 := NewScalerUint64(0, 0)
require.Equal(t, uint32(0), n1.ScaleUint64(0))
require.Equal(t, uint32(math.MaxUint32), n1.ScaleUint64(1))
n2 := NewScalerUint64(0, 1<<32)
require.Equal(t, uint32(math.MaxUint32), n2.ScaleUint64(1<<32))
require.Equal(t, uint32(0x3fffffff), n2.ScaleUint64(1<<30))
} | explode_data.jsonl/30795 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
6947,
21570,
21,
19,
1155,
353,
8840,
836,
8,
341,
9038,
16,
1669,
1532,
59553,
21570,
21,
19,
7,
15,
11,
220,
15,
340,
17957,
12808,
1155,
11,
2622,
18,
17,
7,
15,
701,
308,
16,
51832,
21570,
21,
19,
7,
15,
1171,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetReturnsErrIfLocalFilePathDoesNotExist(t *testing.T) {
beforeTest(t)
conn := _getConnection(t)
defer conn.Close()
client := agaveproto.NewSftpRelayClient(conn)
// create a random directory name in our test dir
tmpTestFilePath, err := _createTempFile("", ".bin")
if err != nil {
assert.FailNowf(t, err.Error(), "Unable to create temp test file: %s", err.Error())
}
// this will be the path of FileName on the Get requet
resolvedRemoteTmpTestFilePath := _resolveTestPath(tmpTestFilePath, SFTP_SHARED_TEST_DIR)
// create a directory as the target of our get
missingDownloadTestDirPath := filepath.Join(CurrentBaseTestDirPath, uuid.New().String(), uuid.New().String())
resolvedMissingRemoteTestDirPath := _resolveTestPath(missingDownloadTestDirPath, LocalSharedTestDir)
req := &agaveproto.SrvGetRequest{
SystemConfig: _createRemoteSystemConfig(),
RemotePath: resolvedRemoteTmpTestFilePath,
LocalPath: resolvedMissingRemoteTestDirPath,
Force: false,
}
grpcResponse, err := client.Get(context.Background(), req)
if err != nil {
assert.Nilf(t, err, "Error while invoking remote service: %v", err)
} else {
_, err := os.Stat(resolvedMissingRemoteTestDirPath)
if err == nil {
assert.FailNowf(t, "Missing target dir should not be created", "Missing target directory, %s, should not be created on the local host after get", resolvedMissingRemoteTestDirPath)
}
// get the test directory stat in the local shared directory
assert.Contains(t, strings.ToLower(grpcResponse.Error), "no such file or directory", "Error message in response should state no such file or directory")
assert.Nil(t, grpcResponse.RemoteFileInfo, "Returned file info should be nil on error")
}
afterTest(t)
} | explode_data.jsonl/32562 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 566
} | [
2830,
3393,
1949,
16446,
7747,
2679,
7319,
19090,
21468,
45535,
1155,
353,
8840,
836,
8,
341,
63234,
2271,
1155,
692,
32917,
1669,
716,
52414,
1155,
340,
16867,
4534,
10421,
2822,
25291,
1669,
933,
523,
15110,
7121,
50,
25068,
6740,
352,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUseStrictDirectiveMinifyNoBundle(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
'use strict'
'use loose'
a
b
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
MangleSyntax: true,
RemoveWhitespace: true,
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38543 | {
"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,
10253,
41857,
62076,
6217,
1437,
2753,
8409,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPodOrphaningAndAdoptionWhenLabelsChange(t *testing.T) {
s, closeFn, rm, informers, c := rmSetup(t)
defer closeFn()
ns := framework.CreateTestingNamespace("test-pod-orphaning-and-adoption-when-labels-change", s, t)
defer framework.DeleteTestingNamespace(ns, s, t)
stopCh := runControllerAndInformers(t, rm, informers, 0)
defer close(stopCh)
rs := newRS("rs", ns.Name, 1)
rss, _ := createRSsPods(t, c, []*apps.ReplicaSet{rs}, []*v1.Pod{})
rs = rss[0]
waitRSStable(t, c, rs)
// Orphaning: RS should remove OwnerReference from a pod when the pod's labels change to not match its labels
podClient := c.CoreV1().Pods(ns.Name)
pods := getPods(t, podClient, labelMap())
if len(pods.Items) != 1 {
t.Fatalf("len(pods) = %d, want 1", len(pods.Items))
}
pod := &pods.Items[0]
// Start by verifying ControllerRef for the pod is not nil
if metav1.GetControllerOf(pod) == nil {
t.Fatalf("ControllerRef of pod %s is nil", pod.Name)
}
newLabelMap := map[string]string{"new-foo": "new-bar"}
updatePod(t, podClient, pod.Name, func(pod *v1.Pod) {
pod.Labels = newLabelMap
})
if err := wait.PollImmediate(interval, timeout, func() (bool, error) {
newPod, err := podClient.Get(pod.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
pod = newPod
return metav1.GetControllerOf(newPod) == nil, nil
}); err != nil {
t.Fatalf("Failed to verify ControllerRef for the pod %s is nil: %v", pod.Name, err)
}
// Adoption: RS should add ControllerRef to a pod when the pod's labels change to match its labels
updatePod(t, podClient, pod.Name, func(pod *v1.Pod) {
pod.Labels = labelMap()
})
if err := wait.PollImmediate(interval, timeout, func() (bool, error) {
newPod, err := podClient.Get(pod.Name, metav1.GetOptions{})
if err != nil {
// If the pod is not found, it means the RS picks the pod for deletion (it is extra)
// Verify there is only one pod in namespace and it has ControllerRef to the RS
if errors.IsNotFound(err) {
pods := getPods(t, podClient, labelMap())
if len(pods.Items) != 1 {
return false, fmt.Errorf("Expected 1 pod in current namespace, got %d", len(pods.Items))
}
// Set the pod accordingly
pod = &pods.Items[0]
return true, nil
}
return false, err
}
// Always update the pod so that we can save a GET call to API server later
pod = newPod
// If the pod is found, verify the pod has a ControllerRef
return metav1.GetControllerOf(newPod) != nil, nil
}); err != nil {
t.Fatalf("Failed to verify ControllerRef for pod %s is not nil: %v", pod.Name, err)
}
// Verify the pod has a ControllerRef to the RS
// Do nothing if the pod is nil (i.e., has been picked for deletion)
if pod != nil {
controllerRef := metav1.GetControllerOf(pod)
if controllerRef.UID != rs.UID {
t.Fatalf("RS owner of the pod %s has a different UID: Expected %v, got %v", pod.Name, rs.UID, controllerRef.UID)
}
}
} | explode_data.jsonl/40117 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1098
} | [
2830,
3393,
23527,
2195,
9943,
287,
3036,
2589,
2047,
4498,
23674,
4072,
1155,
353,
8840,
836,
8,
341,
1903,
11,
3265,
24911,
11,
18998,
11,
6051,
388,
11,
272,
1669,
18998,
21821,
1155,
340,
16867,
3265,
24911,
741,
84041,
1669,
12626,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProvisionURI(t *testing.T) {
otpconf := OTPConfig{
Secret: "x",
}
cases := []struct {
user, iss string
hotp bool
out string
}{
{"test", "", false, "otpauth://totp/test?secret=x"},
{"test", "", true, "otpauth://hotp/test?counter=1&secret=x"},
{"test", "Company", true, "otpauth://hotp/Company:test?counter=1&issuer=Company&secret=x"},
{"test", "Company", false, "otpauth://totp/Company:test?issuer=Company&secret=x"},
}
for i, c := range cases {
otpconf.HotpCounter = 0
if c.hotp {
otpconf.HotpCounter = 1
}
got := otpconf.ProvisionURIWithIssuer(c.user, c.iss)
if got != c.out {
t.Errorf("%d: want %q, got %q", i, c.out, got)
}
}
} | explode_data.jsonl/75092 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
1336,
13013,
10301,
1155,
353,
8840,
836,
8,
341,
197,
48708,
6135,
1669,
80868,
2648,
515,
197,
7568,
50856,
25,
330,
87,
756,
197,
630,
1444,
2264,
1669,
3056,
1235,
341,
197,
19060,
11,
2369,
914,
198,
197,
9598,
48708,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadConfig(t *testing.T) {
_, err := readConfig(nil)
if err == nil {
t.Errorf("Should fail when no config is provided: %s", err)
}
cfg, err := readConfig(strings.NewReader(`
[Global]
target = 0.0.0.0
project = project
overrideIP = true
vmID = vmid
authentication = false
`))
if err != nil {
t.Fatalf("Should succeed when a valid config is provided: %s", err)
}
if cfg.Global.CloudTarget != "0.0.0.0" {
t.Errorf("incorrect photon target ip: %s", cfg.Global.CloudTarget)
}
if cfg.Global.Project != "project" {
t.Errorf("incorrect project: %s", cfg.Global.Project)
}
if cfg.Global.VMID != "vmid" {
t.Errorf("incorrect vmid: %s", cfg.Global.VMID)
}
} | explode_data.jsonl/21915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
4418,
2648,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
1349,
2648,
27907,
340,
743,
1848,
621,
2092,
341,
197,
3244,
13080,
445,
14996,
3690,
979,
902,
2193,
374,
3897,
25,
1018,
82,
497,
1848,
340,
197,
630,
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... | 6 |
func TestErrorPageHasRequiredFields(t *testing.T) {
tests := []struct {
errorPage v1.ErrorPage
expected bool
}{
{
errorPage: v1.ErrorPage{
Codes: nil,
Return: nil,
Redirect: nil,
},
expected: false,
},
{
errorPage: v1.ErrorPage{
Codes: nil,
Return: &v1.ErrorPageReturn{},
Redirect: &v1.ErrorPageRedirect{},
},
expected: false,
},
{
errorPage: v1.ErrorPage{
Codes: nil,
Return: &v1.ErrorPageReturn{},
Redirect: nil,
},
expected: true,
},
{
errorPage: v1.ErrorPage{
Codes: nil,
Return: nil,
Redirect: &v1.ErrorPageRedirect{},
},
expected: true,
},
}
for _, test := range tests {
result := errorPageHasRequiredFields(test.errorPage)
if result != test.expected {
t.Errorf("errorPageHasRequiredFields(%v) returned %v but expected %v", test.errorPage, result, test.expected)
}
}
} | explode_data.jsonl/65914 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 431
} | [
2830,
3393,
1454,
2665,
10281,
8164,
8941,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
18290,
2665,
348,
16,
6141,
2665,
198,
197,
42400,
220,
1807,
198,
197,
59403,
197,
197,
515,
298,
18290,
2665,
25,
348,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestHypervisorDefaultsKernel(t *testing.T) {
assert := assert.New(t)
tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)
testKernelPath := filepath.Join(tmpdir, "kernel")
testKernelLinkPath := filepath.Join(tmpdir, "kernel-link")
err = createEmptyFile(testKernelPath)
assert.NoError(err)
err = syscall.Symlink(testKernelPath, testKernelLinkPath)
assert.NoError(err)
savedKernelPath := defaultKernelPath
defer func() {
defaultKernelPath = savedKernelPath
}()
defaultKernelPath = testKernelPath
h := hypervisor{}
p, err := h.kernel()
assert.NoError(err)
assert.Equal(p, defaultKernelPath, "default Kernel path wrong")
// test path resolution
defaultKernelPath = testKernelLinkPath
h = hypervisor{}
p, err = h.kernel()
assert.NoError(err)
assert.Equal(p, testKernelPath)
assert.Equal(h.kernelParams(), defaultKernelParams, "default hypervisor image wrong")
kernelParams := "foo=bar xyz"
h.KernelParams = kernelParams
assert.Equal(h.kernelParams(), kernelParams, "custom hypervisor kernel parameterms wrong")
} | explode_data.jsonl/5128 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 390
} | [
2830,
3393,
39,
1082,
31396,
16273,
26343,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
8623,
6184,
11,
14676,
6948,
35699,
3964,
340,
16867,
2643,
84427,
10368,
3741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStuff(t *testing.T) {
strings := []string{
"Come watch https://www.twitch.tv/lietu because I'm awesome",
"Come watch https://twitch.tv/lietu because I'm awesome",
"Come watch http://www.twitch.tv/lietu because I'm awesome",
"Come watch http://twitch.tv/lietu because I'm awesome",
"Come watch www.twitch.tv/lietu because I'm awesome",
"Come watch twitch.tv/lietu because I'm awesome",
"Come watch https://www.lietu.tv/live because I'm awesome",
"Come watch https://lietu.tv/live because I'm awesome",
"Come watch http://www.lietu.tv/live because I'm awesome",
"Come watch http://lietu.tv/live because I'm awesome",
"Come watch www.lietu.tv/live because I'm awesome",
"Come watch lietu.tv/live because I'm awesome",
"Come watch lietu.tv/live/ because I'm awesome",
"https://www.lietu.tv/live/",
"https://www.lietu.tv/live",
"https://lietu.tv/live",
"http://www.lietu.tv/live",
"http://lietu.tv/live",
"www.lietu.tv/live",
"lietu.tv/live",
"https://www.twitch.tv/lietu",
"https://twitch.tv/lietu",
"http://www.twitch.tv/lietu",
"http://twitch.tv/lietu",
"www.twitch.tv/lietu",
"twitch.tv/lietu",
}
for _, s := range strings {
stream := getStreamerAdvertised(s)
if stream != "lietu" {
t.Errorf("Did not match expected streamer: %s", s)
} else {
log.Printf("%s -> %s: OK!", s, stream)
}
}
strings = []string{
"Come watch me because I'm awesome",
"Test",
"Test,",
"lulz",
"http://youtube.com/aasdasd",
"https://stackoverflow.com/questions/24613271/golang-is-conversion-between-different-struct-types-possible",
"twitch.tv/directory/following/live",
}
for _, s := range strings {
stream := getStreamerAdvertised(s)
if stream != "" {
t.Errorf("False positive match %s: %s", stream, s)
} else {
log.Printf("%s -> %s: OK!", s, stream)
}
}
strings = []string{
"<Minin> blind playtrough of Fallout 2 https://www.twitch.tv/minin/",
}
for _, s := range strings {
stream := getStreamerAdvertised(s)
if stream != "minin" {
t.Errorf("Did not match expected streamer: %s", s)
} else {
log.Printf("%s -> %s: OK!", s, stream)
}
}
} | explode_data.jsonl/29886 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 891
} | [
2830,
3393,
86622,
1155,
353,
8840,
836,
8,
341,
11355,
819,
1669,
3056,
917,
515,
197,
197,
1,
28851,
3736,
3703,
1110,
2136,
90179,
14485,
88381,
94417,
1576,
358,
2776,
12456,
756,
197,
197,
1,
28851,
3736,
3703,
1110,
83,
5539,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSimpleList(t *testing.T) {
storage := map[string]RESTStorage{}
simpleStorage := SimpleRESTStorage{}
storage["simple"] = &simpleStorage
handler := New(storage, "/prefix/version")
server := httptest.NewServer(handler)
resp, err := http.Get(server.URL + "/prefix/version/simple")
expectNoError(t, err)
if resp.StatusCode != 200 {
t.Errorf("Unexpected status: %d, Expected: %d, %#v", resp.StatusCode, 200, resp)
}
} | explode_data.jsonl/30455 | {
"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,
16374,
852,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
2415,
14032,
60,
38307,
5793,
16094,
1903,
6456,
5793,
1669,
8993,
38307,
5793,
16094,
197,
16172,
1183,
22944,
1341,
284,
609,
22944,
5793,
198,
53326,
1669,
1532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNegativeInput(t *testing.T) {
ctx := createSweeperTestContext(t)
// Sweep an input large enough to cover fees, so in any case the tx
// output will be above the dust limit.
largeInput := createTestInput(100000, input.CommitmentNoDelay)
largeInputResult, err := ctx.sweeper.SweepInput(
&largeInput, defaultFeePref,
)
if err != nil {
t.Fatal(err)
}
// Sweep an additional input with a negative net yield. The weight of
// the HtlcAcceptedRemoteSuccess input type adds more in fees than its
// value at the current fee level.
negInput := createTestInput(2900, input.HtlcOfferedRemoteTimeout)
negInputResult, err := ctx.sweeper.SweepInput(&negInput, defaultFeePref)
if err != nil {
t.Fatal(err)
}
// Sweep a third input that has a smaller output than the previous one,
// but yields positively because of its lower weight.
positiveInput := createTestInput(2800, input.CommitmentNoDelay)
positiveInputResult, err := ctx.sweeper.SweepInput(
&positiveInput, defaultFeePref,
)
if err != nil {
t.Fatal(err)
}
ctx.tick()
// We expect that a sweep tx is published now, but it should only
// contain the large input. The negative input should stay out of sweeps
// until fees come down to get a positive net yield.
sweepTx1 := ctx.receiveTx()
assertTxSweepsInputs(t, &sweepTx1, &largeInput, &positiveInput)
ctx.backend.mine()
ctx.expectResult(largeInputResult, nil)
ctx.expectResult(positiveInputResult, nil)
// Lower fee rate so that the negative input is no longer negative.
ctx.estimator.updateFees(1000, 1000)
// Create another large input.
secondLargeInput := createTestInput(100000, input.CommitmentNoDelay)
secondLargeInputResult, err := ctx.sweeper.SweepInput(
&secondLargeInput, defaultFeePref,
)
if err != nil {
t.Fatal(err)
}
ctx.tick()
sweepTx2 := ctx.receiveTx()
assertTxSweepsInputs(t, &sweepTx2, &secondLargeInput, &negInput)
ctx.backend.mine()
ctx.expectResult(secondLargeInputResult, nil)
ctx.expectResult(negInputResult, nil)
ctx.finish(1)
} | explode_data.jsonl/34222 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 685
} | [
2830,
3393,
38489,
2505,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1855,
50,
896,
10436,
2271,
1972,
1155,
692,
197,
322,
85022,
458,
1946,
3460,
3322,
311,
3421,
12436,
11,
773,
304,
894,
1142,
279,
9854,
198,
197,
322,
2550,
686,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWatchWithCreatedNotificationDropConn(t *testing.T) {
integration2.BeforeTest(t)
cluster := integration2.NewClusterV3(t, &integration2.ClusterConfig{Size: 1, UseBridge: true})
defer cluster.Terminate(t)
client := cluster.RandClient()
wch := client.Watch(context.Background(), "a", clientv3.WithCreatedNotify())
resp := <-wch
if !resp.Created {
t.Fatalf("expected created event, got %v", resp)
}
cluster.Members[0].Bridge().DropConnections()
// check watch channel doesn't post another watch response.
select {
case wresp := <-wch:
t.Fatalf("got unexpected watch response: %+v\n", wresp)
case <-time.After(time.Second):
// watcher may not reconnect by the time it hits the select,
// so it wouldn't have a chance to filter out the second create event
}
} | explode_data.jsonl/28941 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
14247,
2354,
11694,
11196,
19871,
9701,
1155,
353,
8840,
836,
8,
341,
2084,
17376,
17,
31153,
2271,
1155,
692,
197,
18855,
1669,
17590,
17,
7121,
28678,
53,
18,
1155,
11,
609,
60168,
17,
72883,
2648,
90,
1695,
25,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDockerEnvWhitelist(t *testing.T) {
as := assert.New(t)
envTotalMatch := "TEST_REGION,TEST_ZONE"
envMatchWithPrefix := "TEST_"
envMatchWithPrefixEmpty := ""
rawCntConfig := container.Config{Env: []string{"TEST_REGION=FRA", "TEST_ZONE=A", "HELLO=WORLD"}}
newCntConfig := container.Config{Env: []string{"TEST_REGION=FRA", "TEST_ZONE=A", "TEST_POOL=TOOLING", "HELLO=WORLD"}}
rawExpected := map[string]string{
"test_region": "FRA",
"test_zone": "A",
}
newExpected := map[string]string{
"test_region": "FRA",
"test_zone": "A",
"test_pool": "TOOLING",
}
emptyExpected := map[string]string{}
rawEnvsTotalMatch := rawMetadataEnvMatch(envTotalMatch, rawCntConfig)
newEnvsTotalMatch := newMetadataEnvMatch(envTotalMatch, rawCntConfig)
// make sure total match does not change
as.Equal(rawEnvsTotalMatch, newEnvsTotalMatch)
as.Equal(rawEnvsTotalMatch, rawExpected)
rawEnvsTotalMatch2 := rawMetadataEnvMatch(envTotalMatch, newCntConfig)
newEnvsTotalMatch2 := newMetadataEnvMatch(envTotalMatch, newCntConfig)
// make sure total match does not change with more envs exposed
as.Equal(rawEnvsTotalMatch2, newEnvsTotalMatch2)
as.Equal(rawEnvsTotalMatch2, rawExpected)
newEnvsMatchWithPrefix := newMetadataEnvMatch(envMatchWithPrefix, rawCntConfig)
newEnvsMatchWithPrefix2 := newMetadataEnvMatch(envMatchWithPrefix, newCntConfig)
// make sure new method can return envs with prefix specified
as.Equal(newEnvsMatchWithPrefix, rawExpected)
as.Equal(newEnvsMatchWithPrefix2, newExpected)
newEnvsMatchWithEmptyPrefix := newMetadataEnvMatch(envMatchWithPrefixEmpty, newCntConfig)
rawEnvsMatchWithEmptyWhitelist := rawMetadataEnvMatch(envMatchWithPrefixEmpty, newCntConfig)
// make sure empty whitelist returns nothing
as.Equal(newEnvsMatchWithEmptyPrefix, emptyExpected)
as.Equal(rawEnvsMatchWithEmptyWhitelist, emptyExpected)
} | explode_data.jsonl/29970 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 696
} | [
2830,
3393,
35,
13659,
14359,
1639,
57645,
1155,
353,
8840,
836,
8,
341,
60451,
1669,
2060,
7121,
1155,
692,
57538,
7595,
8331,
1669,
330,
10033,
39179,
11,
10033,
60742,
698,
57538,
8331,
2354,
14335,
1669,
330,
10033,
62,
698,
57538,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHeadTracker_SwitchesToLongestChainWithHeadSamplingDisabled(t *testing.T) {
// Need separate db because ht.Stop() will cancel the ctx, causing a db connection
// close and go-txdb rollback.
config, _ := heavyweight.FullTestORM(t, "switches_longest_chain", true, true)
config.Overrides.GlobalEvmFinalityDepth = null.IntFrom(50)
// Need to set the buffer to something large since we inject a lot of heads at once and otherwise they will be dropped
config.Overrides.GlobalEvmHeadTrackerMaxBufferSize = null.IntFrom(42)
d := 0 * time.Second
config.Overrides.GlobalEvmHeadTrackerSamplingInterval = &d
store := cltest.NewStoreWithConfig(t, config)
ethClient, sub := cltest.NewEthClientAndSubMockWithDefaultChain(t)
checker := new(htmocks.HeadTrackable)
checker.Test(t)
orm := headtracker.NewORM(store.DB, cltest.FixtureChainID)
evmcfg := evmtest.NewChainScopedConfig(t, config)
ht := createHeadTrackerWithChecker(ethClient, evmcfg, orm, checker)
chchHeaders := make(chan chan<- *eth.Head, 1)
ethClient.On("SubscribeNewHead", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) { chchHeaders <- args.Get(1).(chan<- *eth.Head) }).
Return(sub, nil)
sub.On("Unsubscribe").Return()
sub.On("Err").Return(nil)
// ---------------------
lastHead := make(chan struct{})
blocks := cltest.NewBlocks(t, 10)
head0 := blocks.Head(0) // eth.Head{Number: 0, Hash: utils.NewHash(), ParentHash: utils.NewHash(), Timestamp: time.Unix(0, 0)}
// Initial query
ethClient.On("HeadByNumber", mock.Anything, (*big.Int)(nil)).Return(head0, nil)
headSeq := cltest.NewHeadBuffer(t)
headSeq.Append(blocks.Head(0))
headSeq.Append(blocks.Head(1))
// Blocks 2 and 3 are out of order
headSeq.Append(blocks.Head(3))
headSeq.Append(blocks.Head(2))
// Block 4 comes in
headSeq.Append(blocks.Head(4))
// Another block at level 4 comes in, that will be uncled
headSeq.Append(blocks.NewHead(4))
// Reorg happened forking from block 2
blocksForked := blocks.ForkAt(t, 2, 5)
headSeq.Append(blocksForked.Head(2))
headSeq.Append(blocksForked.Head(3))
headSeq.Append(blocksForked.Head(4))
headSeq.Append(blocksForked.Head(5)) // Now the new chain is longer
checker.On("OnNewLongestChain", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
h := args.Get(1).(eth.Head)
require.Equal(t, int64(0), h.Number)
require.Equal(t, blocks.Head(0).Hash, h.Hash)
}).Return().Once()
checker.On("OnNewLongestChain", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
h := args.Get(1).(eth.Head)
require.Equal(t, int64(1), h.Number)
require.Equal(t, blocks.Head(1).Hash, h.Hash)
}).Return().Once()
checker.On("OnNewLongestChain", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
h := args.Get(1).(eth.Head)
require.Equal(t, int64(3), h.Number)
require.Equal(t, blocks.Head(3).Hash, h.Hash)
}).Return().Once()
checker.On("OnNewLongestChain", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
h := args.Get(1).(eth.Head)
require.Equal(t, int64(4), h.Number)
require.Equal(t, blocks.Head(4).Hash, h.Hash)
// Check that the block came with its parents
require.NotNil(t, h.Parent)
require.Equal(t, h.Parent.Hash, blocks.Head(3).Hash)
require.NotNil(t, h.Parent.Parent.Hash)
require.Equal(t, h.Parent.Parent.Hash, blocks.Head(2).Hash)
require.NotNil(t, h.Parent.Parent.Parent)
require.Equal(t, h.Parent.Parent.Parent.Hash, blocks.Head(1).Hash)
}).Return().Once()
checker.On("OnNewLongestChain", mock.Anything, mock.Anything).
Run(func(args mock.Arguments) {
h := args.Get(1).(eth.Head)
require.Equal(t, int64(5), h.Number)
require.Equal(t, blocksForked.Head(5).Hash, h.Hash)
// This is the new longest chain, check that it came with its parents
require.NotNil(t, h.Parent)
require.Equal(t, h.Parent.Hash, blocksForked.Head(4).Hash)
require.NotNil(t, h.Parent.Parent)
require.Equal(t, h.Parent.Parent.Hash, blocksForked.Head(3).Hash)
require.NotNil(t, h.Parent.Parent.Parent)
require.Equal(t, h.Parent.Parent.Parent.Hash, blocksForked.Head(2).Hash)
require.NotNil(t, h.Parent.Parent.Parent.Parent)
require.Equal(t, h.Parent.Parent.Parent.Parent.Hash, blocksForked.Head(1).Hash)
close(lastHead)
}).Return().Once()
require.NoError(t, ht.Start())
headers := <-chchHeaders
// This grotesque construction is the only way to do dynamic return values using
// the mock package. We need dynamic returns because we're simulating reorgs.
latestHeadByNumber := make(map[int64]*eth.Head)
latestHeadByNumberMu := new(sync.Mutex)
fnCall := ethClient.On("HeadByNumber", mock.Anything, mock.Anything)
fnCall.RunFn = func(args mock.Arguments) {
latestHeadByNumberMu.Lock()
defer latestHeadByNumberMu.Unlock()
num := args.Get(1).(*big.Int)
head, exists := latestHeadByNumber[num.Int64()]
if !exists {
head = cltest.Head(num.Int64())
latestHeadByNumber[num.Int64()] = head
}
fnCall.ReturnArguments = mock.Arguments{head, nil}
}
for _, h := range headSeq.Heads {
latestHeadByNumberMu.Lock()
latestHeadByNumber[h.Number] = h
latestHeadByNumberMu.Unlock()
headers <- h
}
gomega.NewGomegaWithT(t).Eventually(lastHead).Should(gomega.BeClosed())
require.NoError(t, ht.Stop())
assert.Equal(t, int64(5), ht.headTracker.HighestSeenHead().Number)
for _, h := range headSeq.Heads {
c, err := orm.Chain(context.TODO(), h.Hash, 1)
require.NoError(t, err)
require.NotNil(t, c)
assert.Equal(t, c.ParentHash, h.ParentHash)
assert.Equal(t, c.Timestamp.Unix(), h.Timestamp.UTC().Unix())
assert.Equal(t, c.Number, h.Number)
}
checker.AssertExpectations(t)
} | explode_data.jsonl/63754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2229
} | [
2830,
3393,
12346,
31133,
1098,
5539,
288,
1249,
6583,
477,
18837,
2354,
12346,
98622,
25907,
1155,
353,
8840,
836,
8,
341,
197,
322,
14656,
8651,
2927,
1576,
34323,
30213,
368,
686,
9121,
279,
5635,
11,
14381,
264,
2927,
3633,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
content := `{"log-opts": {"max-size": "1k"}}`
tempFile := tempfile.NewTempFile(t, "config", content)
defer tempFile.Remove()
opts := defaultOptions(tempFile.Name())
opts.common.Debug = true
opts.common.LogLevel = "info"
assert.NilError(t, opts.flags.Set("selinux-enabled", "true"))
loadedConfig, err := loadDaemonCliConfig(opts)
assert.NilError(t, err)
assert.NotNil(t, loadedConfig)
assert.Equal(t, loadedConfig.Debug, true)
assert.Equal(t, loadedConfig.LogLevel, "info")
assert.Equal(t, loadedConfig.EnableSelinuxSupport, true)
assert.Equal(t, loadedConfig.LogConfig.Type, "json-file")
assert.Equal(t, loadedConfig.LogConfig.Config["max-size"], "1k")
} | explode_data.jsonl/12064 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
5879,
89177,
87014,
2648,
2354,
89177,
9195,
1155,
353,
8840,
836,
8,
341,
27751,
1669,
1565,
4913,
839,
12,
10518,
788,
5212,
2810,
7174,
788,
330,
16,
74,
30975,
3989,
16280,
1703,
1669,
54819,
7121,
12151,
1703,
1155,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDB_Get(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db := setup(t)
defer s.Stopper().Stop()
result, err := db.Get(context.TODO(), "aa")
if err != nil {
t.Fatal(err)
}
checkResult(t, []byte(""), result.ValueBytes())
} | explode_data.jsonl/20015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
3506,
13614,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1903,
11,
2927,
1669,
6505,
1155,
340,
16867,
274,
7758,
18487,
1005,
10674,
2822,
9559,
11,
1848,
1669,
2927,
2234,
5378,
90988,
1507... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemovedPropertyAndTagWithSameName(t *testing.T) {
t.Skipf("Not valid until use case is supported in SFx exporter")
dimension := types.Dimension{
Properties: map[string]string{
"shared_name": "",
},
Tags: map[string]bool{
"shared_name": false,
},
}
metadataUpdate := dimensionToMetadataUpdate(dimension)
assert.Empty(t, metadataUpdate.MetadataToAdd)
assert.Empty(t, metadataUpdate.MetadataToUpdate)
expectedMetadataToRemove := map[string]string{
"shared_name": "sf_delete_this_property",
}
assert.Equal(t, expectedMetadataToRemove, metadataUpdate.MetadataToRemove)
} | explode_data.jsonl/6189 | {
"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,
42642,
3052,
3036,
5668,
2354,
19198,
675,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
69,
445,
2623,
2697,
3080,
990,
1142,
374,
7248,
304,
23463,
87,
57378,
1138,
2698,
18161,
1669,
4494,
53234,
515,
197,
197,
7903,
25,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetCert(t *testing.T) {
tID := os.Getenv("TENANT_ID")
certID := os.Getenv("CERT_ID")
url := os.Getenv("URL")
token := os.Getenv("TOKEN")
c := NewClient(Config{
ClusterType: ClusterTypeSingleNode,
Token: token,
Environment: EnvironmentDev,
SamlTenant: "ycloud.accounts.ondemand.com",
URL: url,
}, logrus.StandardLogger())
signedCert, found, err := c.GetSignedCertificate(tID, certID)
t.Logf("Found: %v", found)
t.Logf(string(signedCert))
t.Log(err)
} | explode_data.jsonl/502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
1949,
36934,
1155,
353,
8840,
836,
8,
341,
3244,
915,
1669,
2643,
64883,
445,
51,
953,
2821,
3450,
1138,
1444,
529,
915,
1669,
2643,
64883,
445,
89431,
3450,
5130,
19320,
1669,
2643,
64883,
445,
3144,
1138,
43947,
1669,
2643... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQuestion(t *testing.T) {
tests := []struct {
desc string
given string
fallback string
expected string
}{
{"records interactive response", "hello\n", "", "hello"},
{"responds with default if response is empty", "\n", "Fine.", "Fine."},
}
for _, test := range tests {
q := &Question{
Reader: strings.NewReader(test.given),
Writer: ioutil.Discard,
Prompt: "Say something: ",
DefaultValue: test.fallback,
}
answer, err := q.Ask()
assert.NoError(t, err)
assert.Equal(t, answer, test.expected, test.desc)
}
} | explode_data.jsonl/16167 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
14582,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
3174,
2071,
262,
914,
198,
197,
1166,
3420,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
4913,
26203,
20753,
2033,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseOutpostAccessPointARNResource(t *testing.T) {
cases := map[string]struct {
ARN arn.ARN
ExpectErr string
ExpectARN OutpostAccessPointARN
}{
"region not set": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
AccountID: "012345678901",
Resource: "outpost/myoutpost/accesspoint/myendpoint",
},
ExpectErr: "region not set",
},
"account-id not set": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
Resource: "outpost/myoutpost/accesspoint/myendpoint",
},
ExpectErr: "account-id not set",
},
"resource-id not set": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
AccountID: "012345678901",
Resource: "myoutpost",
},
ExpectErr: "resource-id not set",
},
"resource-id empty": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
AccountID: "012345678901",
Resource: "outpost:",
},
ExpectErr: "resource-id not set",
},
"resource not supported": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
AccountID: "012345678901",
Resource: "outpost/myoutpost/accesspoint/endpoint/object/key",
},
ExpectErr: "sub resource not supported",
},
"access-point not defined": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
AccountID: "012345678901",
Resource: "outpost/myoutpost/endpoint/object/key",
},
ExpectErr: "unknown resource set for outpost ARN",
},
"valid resource-id": {
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
AccountID: "012345678901",
Resource: "outpost/myoutpost/accesspoint/myaccesspoint",
},
ExpectARN: OutpostAccessPointARN{
AccessPointARN: AccessPointARN{
ARN: arn.ARN{
Partition: "aws",
Service: "s3-outposts",
Region: "us-west-2",
AccountID: "012345678901",
Resource: "outpost/myoutpost/accesspoint/myaccesspoint",
},
AccessPointName: "myaccesspoint",
},
OutpostID: "myoutpost",
},
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
resParts := SplitResource(c.ARN.Resource)
a, err := ParseOutpostARNResource(c.ARN, resParts[1:])
if len(c.ExpectErr) == 0 && err != nil {
t.Fatalf("expect no error but got %v", err)
} else if len(c.ExpectErr) != 0 && err == nil {
t.Fatalf("expect error %q, but got nil", c.ExpectErr)
} else if len(c.ExpectErr) != 0 && err != nil {
if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) {
t.Fatalf("expect error %q, got %q", e, a)
}
return
}
if e, a := c.ExpectARN, a; !reflect.DeepEqual(e, a) {
t.Errorf("expect %v, got %v", e, a)
}
})
}
} | explode_data.jsonl/62370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1437
} | [
2830,
3393,
14463,
2662,
2203,
6054,
2609,
9051,
4783,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
9051,
981,
796,
77,
875,
50195,
198,
197,
35911,
7747,
914,
198,
197,
35911,
9051,
4371,
2203... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestEventSeriesf(t *testing.T) {
hostname, _ := os.Hostname()
testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
SelfLink: "/api/version/pods/foo",
Name: "foo",
Namespace: "baz",
UID: "bar",
},
}
regarding, err := ref.GetPartialReference(scheme.Scheme, testPod, ".spec.containers[1]")
if err != nil {
t.Fatal(err)
}
related, err := ref.GetPartialReference(scheme.Scheme, testPod, ".spec.containers[0]")
if err != nil {
t.Fatal(err)
}
expectedEvent := &v1beta1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "baz",
},
EventTime: metav1.MicroTime{time.Now()},
ReportingController: "eventTest",
ReportingInstance: "eventTest-" + hostname,
Action: "started",
Reason: "test",
Regarding: *regarding,
Related: related,
Note: "some verbose message: 1",
Type: v1.EventTypeNormal,
}
isomorphicEvent := expectedEvent.DeepCopy()
nonIsomorphicEvent := expectedEvent.DeepCopy()
nonIsomorphicEvent.Action = "stopped"
expectedEvent.Series = &v1beta1.EventSeries{Count: 1}
table := []struct {
regarding k8sruntime.Object
related k8sruntime.Object
actual *v1beta1.Event
elements []interface{}
expect *v1beta1.Event
expectUpdate bool
}{
{
regarding: regarding,
related: related,
actual: isomorphicEvent,
elements: []interface{}{1},
expect: expectedEvent,
expectUpdate: true,
},
{
regarding: regarding,
related: related,
actual: nonIsomorphicEvent,
elements: []interface{}{1},
expect: nonIsomorphicEvent,
expectUpdate: false,
},
}
stopCh := make(chan struct{})
createEvent := make(chan *v1beta1.Event)
updateEvent := make(chan *v1beta1.Event)
patchEvent := make(chan *v1beta1.Event)
testEvents := testEventSeriesSink{
OnCreate: func(event *v1beta1.Event) (*v1beta1.Event, error) {
createEvent <- event
return event, nil
},
OnUpdate: func(event *v1beta1.Event) (*v1beta1.Event, error) {
updateEvent <- event
return event, nil
},
OnPatch: func(event *v1beta1.Event, patch []byte) (*v1beta1.Event, error) {
// event we receive is already patched, usually the sink uses it only to retrieve the name and namespace, here
// we'll use it directly
patchEvent <- event
return event, nil
},
}
eventBroadcaster := newBroadcaster(&testEvents, 0, map[eventKey]*v1beta1.Event{})
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, "eventTest")
eventBroadcaster.StartRecordingToSink(stopCh)
recorder.Eventf(regarding, related, isomorphicEvent.Type, isomorphicEvent.Reason, isomorphicEvent.Action, isomorphicEvent.Note, []interface{}{1})
// read from the chan as this was needed only to populate the cache
<-createEvent
for index, item := range table {
actual := item.actual
recorder.Eventf(item.regarding, item.related, actual.Type, actual.Reason, actual.Action, actual.Note, item.elements)
// validate event
if item.expectUpdate {
actualEvent := <-patchEvent
t.Logf("%v - validating event affected by patch request", index)
validateEventSerie(strconv.Itoa(index), true, actualEvent, item.expect, t)
} else {
actualEvent := <-createEvent
t.Logf("%v - validating event affected by a create request", index)
validateEventSerie(strconv.Itoa(index), false, actualEvent, item.expect, t)
}
}
close(stopCh)
} | explode_data.jsonl/27773 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1417
} | [
2830,
3393,
1556,
25544,
69,
1155,
353,
8840,
836,
8,
341,
197,
27806,
11,
716,
1669,
2643,
29840,
606,
2822,
18185,
23527,
1669,
609,
85,
16,
88823,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
7568,
490,
3939,
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... | 1 |
func TestAccAWSS3BucketObject_storageClass(t *testing.T) {
var obj s3.GetObjectOutput
resourceName := "aws_s3_bucket_object.object"
rInt := acctest.RandInt()
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketObjectDestroy,
Steps: []resource.TestStep{
{
PreConfig: func() {},
Config: testAccAWSS3BucketObjectConfigContent(rInt, "some_bucket_content"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj),
resource.TestCheckResourceAttr(resourceName, "storage_class", "STANDARD"),
testAccCheckAWSS3BucketObjectStorageClass(resourceName, "STANDARD"),
),
},
{
Config: testAccAWSS3BucketObjectConfig_storageClass(rInt, "REDUCED_REDUNDANCY"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj),
resource.TestCheckResourceAttr(resourceName, "storage_class", "REDUCED_REDUNDANCY"),
testAccCheckAWSS3BucketObjectStorageClass(resourceName, "REDUCED_REDUNDANCY"),
),
},
{
Config: testAccAWSS3BucketObjectConfig_storageClass(rInt, "GLACIER"),
Check: resource.ComposeTestCheckFunc(
// Can't GetObject on an object in Glacier without restoring it.
resource.TestCheckResourceAttr(resourceName, "storage_class", "GLACIER"),
testAccCheckAWSS3BucketObjectStorageClass(resourceName, "GLACIER"),
),
},
{
Config: testAccAWSS3BucketObjectConfig_storageClass(rInt, "INTELLIGENT_TIERING"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSS3BucketObjectExists(resourceName, &obj),
resource.TestCheckResourceAttr(resourceName, "storage_class", "INTELLIGENT_TIERING"),
testAccCheckAWSS3BucketObjectStorageClass(resourceName, "INTELLIGENT_TIERING"),
),
},
{
Config: testAccAWSS3BucketObjectConfig_storageClass(rInt, "DEEP_ARCHIVE"),
Check: resource.ComposeTestCheckFunc(
// Can't GetObject on an object in DEEP_ARCHIVE without restoring it.
resource.TestCheckResourceAttr(resourceName, "storage_class", "DEEP_ARCHIVE"),
testAccCheckAWSS3BucketObjectStorageClass(resourceName, "DEEP_ARCHIVE"),
),
},
},
})
} | explode_data.jsonl/64968 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 889
} | [
2830,
3393,
14603,
14419,
1220,
18,
36018,
1190,
23310,
1957,
1155,
353,
8840,
836,
8,
341,
2405,
2839,
274,
18,
25618,
5097,
198,
50346,
675,
1669,
330,
8635,
643,
18,
38749,
5314,
6035,
698,
7000,
1072,
1669,
1613,
67880,
2013,
437,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransactionPendingMinimumAllowance(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{statedb, 1000000, new(notify.Feed)}
config := testTxPoolConfig
config.GlobalSlots = 1
pool := NewTxPool(config, params.TestChainConfig, blockchain)
defer pool.Stop()
// Create a number of test accounts and fund them
keys := make([]*ecdsa.PrivateKey, 5)
for i := 0; i < len(keys); i++ {
keys[i], _ = crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(1000000))
}
// Generate and queue a batch of transactions
nonces := make(map[common.Address]uint64)
txs := types.Transactions{}
for _, key := range keys {
addr := crypto.PubkeyToAddress(key.PublicKey)
for j := 0; j < int(config.AccountSlots)*2; j++ {
txs = append(txs, transaction(nonces[addr], 100000, key))
nonces[addr]++
}
}
// Import the batch and verify that limits have been enforced
pool.AddRemotesSync(txs)
for addr, list := range pool.pending {
if list.Len() != int(config.AccountSlots) {
t.Errorf("addr %x: total pending transactions mismatch: have %d, want %d", addr, list.Len(), config.AccountSlots)
}
}
if err := validateTxPoolInternals(pool); err != nil {
t.Fatalf("pool internal state corrupted: %v", err)
}
} | explode_data.jsonl/7875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 499
} | [
2830,
3393,
8070,
32027,
28695,
18605,
681,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
4230,
279,
7314,
311,
1273,
279,
3930,
13324,
448,
198,
18388,
657,
65,
11,
716,
1669,
1584,
7121,
57802,
15103,
22655,
1584,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBlockedDiscardStats(t *testing.T) {
dir, err := ioutil.TempDir("", "badger-test")
require.NoError(t, err)
defer os.Remove(dir)
db, err := Open(getTestOptions(dir))
require.NoError(t, err)
// Set discard stats.
db.vlog.lfDiscardStats.m = map[uint32]int64{0: 0}
db.blockWrite()
// Push discard stats more than the capacity of flushChan. This ensures at least one flush
// operation completes successfully after the writes were blocked.
for i := 0; i < cap(db.vlog.lfDiscardStats.flushChan)+2; i++ {
db.vlog.lfDiscardStats.flushChan <- db.vlog.lfDiscardStats.m
}
db.unblockWrite()
require.NoError(t, db.Close())
} | explode_data.jsonl/39105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
95847,
23477,
567,
16635,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
13855,
1389,
16839,
1138,
17957,
35699,
1155,
11,
1848,
340,
16867,
2643,
13270,
14161,
340,
20939,
11,
1848,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestProxyDirectorURL(t *testing.T) {
for i, c := range []struct {
requestURL string
targetURL string
without string
expectURL string
}{
{
requestURL: `http://localhost:2020/test`,
targetURL: `https://localhost:2021`,
expectURL: `https://localhost:2021/test`,
},
{
requestURL: `http://localhost:2020/test`,
targetURL: `https://localhost:2021/t`,
expectURL: `https://localhost:2021/t/test`,
},
{
requestURL: `http://localhost:2020/test?t=w`,
targetURL: `https://localhost:2021/t`,
expectURL: `https://localhost:2021/t/test?t=w`,
},
{
requestURL: `http://localhost:2020/test`,
targetURL: `https://localhost:2021/t?foo=bar`,
expectURL: `https://localhost:2021/t/test?foo=bar`,
},
{
requestURL: `http://localhost:2020/test?t=w`,
targetURL: `https://localhost:2021/t?foo=bar`,
expectURL: `https://localhost:2021/t/test?foo=bar&t=w`,
},
{
requestURL: `http://localhost:2020/test?t=w`,
targetURL: `https://localhost:2021/t?foo=bar`,
expectURL: `https://localhost:2021/t?foo=bar&t=w`,
without: "/test",
},
{
requestURL: `http://localhost:2020/test?t%3dw`,
targetURL: `https://localhost:2021/t?foo%3dbar`,
expectURL: `https://localhost:2021/t?foo%3dbar&t%3dw`,
without: "/test",
},
{
requestURL: `http://localhost:2020/test/`,
targetURL: `https://localhost:2021/t/`,
expectURL: `https://localhost:2021/t/test/`,
},
{
requestURL: `http://localhost:2020/test/mypath`,
targetURL: `https://localhost:2021/t/`,
expectURL: `https://localhost:2021/t/mypath`,
without: "/test",
},
{
requestURL: `http://localhost:2020/%2C`,
targetURL: `https://localhost:2021/t/`,
expectURL: `https://localhost:2021/t/%2C`,
},
{
requestURL: `http://localhost:2020/%2C/`,
targetURL: `https://localhost:2021/t/`,
expectURL: `https://localhost:2021/t/%2C/`,
},
{
requestURL: `http://localhost:2020/test`,
targetURL: `https://localhost:2021/%2C`,
expectURL: `https://localhost:2021/%2C/test`,
},
{
requestURL: `http://localhost:2020/%2C`,
targetURL: `https://localhost:2021/%2C`,
expectURL: `https://localhost:2021/%2C/%2C`,
},
{
requestURL: `http://localhost:2020/%2F/test`,
targetURL: `https://localhost:2021/`,
expectURL: `https://localhost:2021/%2F/test`,
},
{
requestURL: `http://localhost:2020/test/%2F/mypath`,
targetURL: `https://localhost:2021/t/`,
expectURL: `https://localhost:2021/t/%2F/mypath`,
without: "/test",
},
} {
targetURL, err := url.Parse(c.targetURL)
if err != nil {
t.Errorf("case %d failed to parse target URL: %s", i, err)
continue
}
req, err := http.NewRequest("GET", c.requestURL, nil)
if err != nil {
t.Errorf("case %d failed to create request: %s", i, err)
continue
}
NewSingleHostReverseProxy(targetURL, c.without, 0, 30*time.Second).Director(req)
if expect, got := c.expectURL, req.URL.String(); expect != got {
t.Errorf("case %d url not equal: expect %q, but got %q",
i, expect, got)
}
}
} | explode_data.jsonl/64243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1388
} | [
2830,
3393,
16219,
37194,
3144,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
272,
1669,
2088,
3056,
1235,
341,
197,
23555,
3144,
914,
198,
197,
28861,
3144,
220,
914,
198,
197,
197,
28996,
262,
914,
198,
197,
24952,
3144,
220,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestServiceRoleInvalid(t *testing.T) {
assert := assert.New(t)
conf := config.NewConfig()
config.Set(conf)
sr := data.AddServicesToServiceRole([]string{"service3"}, data.CreateEmptyServiceRole("sr1", "test"))
sc := ServiceChecker{
ServiceRole: sr,
Services: getFourServices(),
}
checks, valid := sc.Check()
assert.False(valid)
assert.NotEmpty(checks)
assert.Equal(models.CheckMessage("servicerole.invalid.services"), checks[0].Message)
} | explode_data.jsonl/8820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
1860,
9030,
7928,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
67850,
1669,
2193,
7121,
2648,
741,
25873,
4202,
29879,
692,
1903,
81,
1669,
821,
1904,
11025,
1249,
1860,
9030,
10556,
917,
4913,
7936,
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... | 1 |
func TestKubelessTestsJobPostsubmit(t *testing.T) {
// WHEN
jobConfig, err := tester.ReadJobConfig("./../../../../prow/jobs/kyma/tests/kubeless/kubeless.yaml")
// THEN
require.NoError(t, err)
assert.Len(t, jobConfig.Postsubmits, 1)
kymaPost, ex := jobConfig.Postsubmits["kyma-project/kyma"]
assert.True(t, ex)
assert.Len(t, kymaPost, 1)
actualPost := kymaPost[0]
expName := "kyma-tests-kubeless"
assert.Equal(t, expName, actualPost.Name)
assert.Equal(t, []string{"master"}, actualPost.Branches)
assert.Equal(t, 10, actualPost.MaxConcurrency)
assert.True(t, actualPost.Decorate)
assert.Equal(t, "github.com/kyma-project/kyma", actualPost.PathAlias)
tester.AssertThatHasExtraRefTestInfra(t, actualPost.JobBase.UtilityConfig, "master")
tester.AssertThatHasPresets(t, actualPost.JobBase, tester.PresetDindEnabled, tester.PresetDockerPushRepo, tester.PresetGcrPush, tester.PresetBuildMaster)
assert.Equal(t, "^tests/kubeless/", actualPost.RunIfChanged)
assert.Equal(t, tester.ImageGolangBuildpackLatest, actualPost.Spec.Containers[0].Image)
assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/test-infra/prow/scripts/build.sh"}, actualPost.Spec.Containers[0].Command)
assert.Equal(t, []string{"/home/prow/go/src/github.com/kyma-project/kyma/tests/kubeless"}, actualPost.Spec.Containers[0].Args)
} | explode_data.jsonl/33132 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 522
} | [
2830,
3393,
42,
3760,
1717,
18200,
12245,
4133,
5955,
1155,
353,
8840,
836,
8,
341,
197,
322,
33633,
198,
68577,
2648,
11,
1848,
1669,
37111,
6503,
12245,
2648,
13988,
84257,
79,
651,
4437,
5481,
14109,
1600,
64,
62468,
14109,
3760,
171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestV4DMagnitude(t *testing.T) {
ctx := assert.Context(t)
for _, test := range []struct {
v f32.Vec4
r float32
}{
{f32.Vec4{0, 0, 0, 0}, 0},
{f32.Vec4{1, 0, 0, 0}, 1},
{f32.Vec4{0, 2, 0, 0}, 2},
{f32.Vec4{0, 0, -3, 0}, 3},
{f32.Vec4{0, 0, 0, -4}, 4},
{f32.Vec4{1, 1, 1, 1}, 2},
} {
assert.For(ctx, "%v.Magnitude", test.v).That(test.v.Magnitude()).Equals(test.r)
}
} | explode_data.jsonl/8028 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
53,
19,
8395,
34715,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2060,
9328,
1155,
340,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
5195,
282,
18,
17,
5058,
757,
19,
198,
197,
7000,
2224,
18,
17,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/v2.0/fw/firewalls", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, `
{
"firewalls":[
{
"status": "ACTIVE",
"name": "fw1",
"admin_state_up": false,
"tenant_id": "b4eedccc6fb74fa8a7ad6b08382b852b",
"firewall_policy_id": "34be8c83-4d42-4dca-a74e-b77fffb8e28a",
"id": "fb5b5315-64f6-4ea3-8e58-981cc37c6f61",
"description": "OpenStack firewall 1"
},
{
"status": "PENDING_UPDATE",
"name": "fw2",
"admin_state_up": true,
"tenant_id": "b4eedccc6fb74fa8a7ad6b08382b852b",
"firewall_policy_id": "34be8c83-4d42-4dca-a74e-b77fffb8e299",
"id": "fb5b5315-64f6-4ea3-8e58-981cc37c6f99",
"description": "OpenStack firewall 2"
}
]
}
`)
})
count := 0
firewalls.List(fake.ServiceClient(), firewalls.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := firewalls.ExtractFirewalls(page)
if err != nil {
t.Errorf("Failed to extract members: %v", err)
return false, err
}
expected := []firewalls.Firewall{
{
Status: "ACTIVE",
Name: "fw1",
AdminStateUp: false,
TenantID: "b4eedccc6fb74fa8a7ad6b08382b852b",
PolicyID: "34be8c83-4d42-4dca-a74e-b77fffb8e28a",
ID: "fb5b5315-64f6-4ea3-8e58-981cc37c6f61",
Description: "OpenStack firewall 1",
},
{
Status: "PENDING_UPDATE",
Name: "fw2",
AdminStateUp: true,
TenantID: "b4eedccc6fb74fa8a7ad6b08382b852b",
PolicyID: "34be8c83-4d42-4dca-a74e-b77fffb8e299",
ID: "fb5b5315-64f6-4ea3-8e58-981cc37c6f99",
Description: "OpenStack firewall 2",
},
}
th.CheckDeepEquals(t, expected, actual)
return true, nil
})
if count != 1 {
t.Errorf("Expected 1 page, got %d", count)
}
} | explode_data.jsonl/36151 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1193
} | [
2830,
3393,
852,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
70479,
1321,
2200,
63623,
4283,
85,
17,
13,
15,
60193,
53010,
86296,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPublicKeyIsEqual(t *testing.T) {
pubKey1, err := ParsePubKey(
[]byte{0x03, 0x26, 0x89, 0xc7, 0xc2, 0xda, 0xb1, 0x33,
0x09, 0xfb, 0x14, 0x3e, 0x0e, 0x8f, 0xe3, 0x96, 0x34,
0x25, 0x21, 0x88, 0x7e, 0x97, 0x66, 0x90, 0xb6, 0xb4,
0x7f, 0x5b, 0x2a, 0x4b, 0x7d, 0x44, 0x8e,
},
S256(),
)
if err != nil {
t.Fatalf("failed to parse raw bytes for pubKey1: %v", err)
}
pubKey2, err := ParsePubKey(
[]byte{0x02, 0xce, 0x0b, 0x14, 0xfb, 0x84, 0x2b, 0x1b,
0xa5, 0x49, 0xfd, 0xd6, 0x75, 0xc9, 0x80, 0x75, 0xf1,
0x2e, 0x9c, 0x51, 0x0f, 0x8e, 0xf5, 0x2b, 0xd0, 0x21,
0xa9, 0xa1, 0xf4, 0x80, 0x9d, 0x3b, 0x4d,
},
S256(),
)
if err != nil {
t.Fatalf("failed to parse raw bytes for pubKey2: %v", err)
}
if !pubKey1.IsEqual(pubKey1) {
t.Fatalf("value of IsEqual is incorrect, %v is "+
"equal to %v", pubKey1, pubKey1)
}
if pubKey1.IsEqual(pubKey2) {
t.Fatalf("value of IsEqual is incorrect, %v is not "+
"equal to %v", pubKey1, pubKey2)
}
} | explode_data.jsonl/71132 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 572
} | [
2830,
3393,
61822,
3872,
2993,
1155,
353,
8840,
836,
8,
341,
62529,
1592,
16,
11,
1848,
1669,
14775,
29162,
1592,
1006,
197,
197,
1294,
3782,
90,
15,
87,
15,
18,
11,
220,
15,
87,
17,
21,
11,
220,
15,
87,
23,
24,
11,
220,
15,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGracefulShutdown(t *testing.T) {
// Create context that listns for the interrupt signal.
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
// load config
config.AppConfig()
logrus.Infof("API route mounted on port %s\n", viper.GetString("SERVER_PORT"))
logrus.Infof("creating http Server")
//go singleton.singleton.GetDealerInstance()
go singleton.GetDealer()
go asyncWebWorker()
httpServer := &http.Server{
// viper config .env get server address
Addr: viper.GetViper().GetString("SERVER_ADDR") + ":" + viper.GetViper().GetString("SERVER_PORT"),
Handler: service(),
ReadTimeout: viper.GetViper().GetDuration("SERVER_READ_TIMEOUT"),
WriteTimeout: viper.GetViper().GetDuration("SERVER_WRITE_TIMEOUT"),
MaxHeaderBytes: 1 << 20,
}
// initializing the server in a goroutine so that
// it won't block the graceful shutdown handling below
go func() {
if err := httpServer.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
logrus.Errorf("error starting http server: %s\n", err)
}
logrus.Printf("server stopped serving new connections")
}()
// Listen for the interrupt signal
<-ctx.Done()
// Restore default behavior on interrupt signal and notify user of shutdown.
stop()
logrus.Infof("shutting downserver gracefully, press Ctrl+C again to force")
// The context is used to inform the server it has 5 seconds to finish
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := httpServer.Shutdown(ctx); err != nil {
logrus.Errorf("error shutting down http server: %s\n", err)
}
logrus.Infof("server exiting")
time.Sleep(11 * time.Second)
// Attempt the graceful shutdown by closing the listener
if err := httpServer.Shutdown(ctx); err != nil {
logrus.Fatalf("failed to shutdown: %v", err)
}
// Check for closed server connection
if err := httpServer.Shutdown(ctx); err != nil {
logrus.Fatalf("failed to shutdown: %v", err)
t.Fatalf("failed to shutdown: %v", err)
}
logrus.Printf("server gracefully stopped")
} | explode_data.jsonl/3955 | {
"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,
86543,
1262,
62004,
1155,
353,
8840,
836,
8,
1476,
197,
322,
4230,
2266,
429,
1140,
4412,
369,
279,
12667,
8286,
624,
20985,
11,
2936,
1669,
8286,
80435,
1972,
5378,
19047,
1507,
49345,
85086,
3221,
11,
49345,
85086,
49349,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientSniffSuccess(t *testing.T) {
client, err := NewClient(SetURL("http://127.0.0.1:19200", "http://127.0.0.1:9200"))
if err != nil {
t.Fatal(err)
}
// The client should sniff both URLs, but only 127.0.0.1:9200 should return nodes.
if len(client.conns) != 1 {
t.Fatalf("expected exactly 1 node in the local cluster, got: %d (%v)", len(client.conns), client.conns)
}
} | explode_data.jsonl/37995 | {
"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,
2959,
20720,
3092,
7188,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
1532,
2959,
52474,
3144,
445,
1254,
1110,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
16,
24,
17,
15,
15,
497,
330,
1254,
1110,
16,
17,
22,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestStepPrepareTools(t *testing.T) {
tf, err := ioutil.TempFile("", "packer")
if err != nil {
t.Fatalf("err: %s", err)
}
tf.Close()
defer os.Remove(tf.Name())
state := testState(t)
step := &StepPrepareTools{
RemoteType: "",
ToolsUploadFlavor: "foo",
}
driver := state.Get("driver").(*DriverMock)
// Mock results
driver.ToolsIsoPathResult = tf.Name()
// Test the run
if action := step.Run(state); action != multistep.ActionContinue {
t.Fatalf("bad action: %#v", action)
}
if _, ok := state.GetOk("error"); ok {
t.Fatal("should NOT have error")
}
// Test the driver
if !driver.ToolsIsoPathCalled {
t.Fatal("tools iso path should be called")
}
if driver.ToolsIsoPathFlavor != "foo" {
t.Fatalf("bad: %#v", driver.ToolsIsoPathFlavor)
}
// Test the resulting state
path, ok := state.GetOk("tools_upload_source")
if !ok {
t.Fatal("should have tools_upload_source")
}
if path != tf.Name() {
t.Fatalf("bad: %#v", path)
}
} | explode_data.jsonl/77416 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 394
} | [
2830,
3393,
8304,
50590,
16583,
1155,
353,
8840,
836,
8,
341,
3244,
69,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
4748,
261,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
615,
25,
1018,
82,
497,
1848,
340,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestManyMigrations(t *testing.T) {
defer func(v []migration, s string) {
schemaMigrations = v
DbSchemaCurrent = s
}(schemaMigrations, DbSchemaCurrent)
DbSchemaCurrent = DbSchemaCode
shouldNotRun := false
executionOrder := []int{-1, -1, -1, -1}
schemaMigrations = []migration{
{name: DbSchemaCode, fn: func(db *DB) error {
shouldNotRun = true // this should not be executed
return nil
}},
{name: "keju", fn: func(db *DB) error {
executionOrder[0] = 0
return nil
}},
{name: "coconut", fn: func(db *DB) error {
executionOrder[1] = 1
return nil
}},
{name: "mango", fn: func(db *DB) error {
executionOrder[2] = 2
return nil
}},
{name: "salvation", fn: func(db *DB) error {
executionOrder[3] = 3
return nil
}},
}
dir, err := ioutil.TempDir("", "localstore-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
baseKey := make([]byte, 32)
if _, err := rand.Read(baseKey); err != nil {
t.Fatal(err)
}
logger := logging.New(ioutil.Discard, 0)
// start the fresh localstore with the sanctuary schema name
db, err := New(dir, baseKey, nil, logger)
if err != nil {
t.Fatal(err)
}
err = db.Close()
if err != nil {
t.Fatal(err)
}
DbSchemaCurrent = "salvation"
// start the existing localstore and expect the migration to run
db, err = New(dir, baseKey, nil, logger)
if err != nil {
t.Fatal(err)
}
schemaName, err := db.schemaName.Get()
if err != nil {
t.Fatal(err)
}
if schemaName != "salvation" {
t.Errorf("schema name mismatch. got '%s', want '%s'", schemaName, "salvation")
}
if shouldNotRun {
t.Errorf("migration ran but shouldnt have")
}
for i, v := range executionOrder {
if i != v && i != len(executionOrder)-1 {
t.Errorf("migration did not run in sequence, slot %d value %d", i, v)
}
}
err = db.Close()
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/79612 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 792
} | [
2830,
3393,
8441,
44,
17824,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
3747,
3056,
80227,
11,
274,
914,
8,
341,
197,
1903,
3416,
44,
17824,
284,
348,
198,
197,
197,
7994,
8632,
5405,
284,
274,
198,
197,
25547,
17349,
44,
17824,
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 TestRestore(t *testing.T) {
fs, cleanup := defaultFSStoreBackend(t)
defer cleanup()
id1, err := fs.Set([]byte(`{"comment": "abc", "rootfs": {"type": "layers"}}`))
assert.NilError(t, err)
_, err = fs.Set([]byte(`invalid`))
assert.NilError(t, err)
id2, err := fs.Set([]byte(`{"comment": "def", "rootfs": {"type": "layers", "diff_ids": ["2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"]}}`))
assert.NilError(t, err)
err = fs.SetMetadata(id2, "parent", []byte(id1))
assert.NilError(t, err)
mlgrMap := make(map[string]LayerGetReleaser)
mlgrMap[runtime.GOOS] = &mockLayerGetReleaser{}
is, err := NewImageStore(fs, mlgrMap)
assert.NilError(t, err)
assert.Check(t, cmp.Len(is.Map(), 2))
img1, err := is.Get(ID(id1))
assert.NilError(t, err)
assert.Check(t, cmp.Equal(ID(id1), img1.computedID))
assert.Check(t, cmp.Equal(string(id1), img1.computedID.String()))
img2, err := is.Get(ID(id2))
assert.NilError(t, err)
assert.Check(t, cmp.Equal("abc", img1.Comment))
assert.Check(t, cmp.Equal("def", img2.Comment))
_, err = is.GetParent(ID(id1))
assert.ErrorContains(t, err, "failed to read metadata")
p, err := is.GetParent(ID(id2))
assert.NilError(t, err)
assert.Check(t, cmp.Equal(ID(id1), p))
children := is.Children(ID(id1))
assert.Check(t, cmp.Len(children, 1))
assert.Check(t, cmp.Equal(ID(id2), children[0]))
assert.Check(t, cmp.Len(is.Heads(), 1))
sid1, err := is.Search(string(id1)[:10])
assert.NilError(t, err)
assert.Check(t, cmp.Equal(ID(id1), sid1))
sid1, err = is.Search(digest.Digest(id1).Hex()[:6])
assert.NilError(t, err)
assert.Check(t, cmp.Equal(ID(id1), sid1))
invalidPattern := digest.Digest(id1).Hex()[1:6]
_, err = is.Search(invalidPattern)
assert.ErrorContains(t, err, "No such image")
} | explode_data.jsonl/45447 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 801
} | [
2830,
3393,
56284,
1155,
353,
8840,
836,
8,
341,
53584,
11,
21290,
1669,
1638,
8485,
6093,
29699,
1155,
340,
16867,
21290,
2822,
15710,
16,
11,
1848,
1669,
8619,
4202,
10556,
3782,
5809,
4913,
6182,
788,
330,
13683,
497,
330,
2888,
3848... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateSSGenVotes(t *testing.T) {
var tests = []struct {
votebits uint16
expected []byte
}{
{65535, hexToBytes("6a02ffff")},
{256, hexToBytes("6a020001")},
{127, hexToBytes("6a027f00")},
{0, hexToBytes("6a020000")},
}
for _, test := range tests {
s, err := GenerateSSGenVotes(test.votebits)
if err != nil {
t.Errorf("GenerateSSGenVotes failed: %v", err)
continue
}
if !bytes.Equal(s, test.expected) {
t.Errorf("GenerateSSGenVotes: unexpected script:\n "+
"got %x\nwant %x", s, test.expected)
}
}
} | explode_data.jsonl/29690 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
31115,
1220,
9967,
75535,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
5195,
1272,
11516,
2622,
16,
21,
198,
197,
42400,
3056,
3782,
198,
197,
59403,
197,
197,
90,
21,
20,
20,
18,
20,
11,
12371,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkingKey(t *testing.T) {
var workingKeyFields ebs_fields.WorkingKeyFields
workingKeyFields.ClientID = "noebs"
workingKeyFields.TerminalID = "12345678"
workingKeyFields.TranDateTime = time.Now().UTC().String()
workingKeyFields.SystemTraceAuditNumber = rand.Intn(99999)
payload, err := json.Marshal(workingKeyFields)
if err != nil {
t.Fatal()
}
w := httptest.NewRecorder()
route := GetMainEngine()
fmt.Println(w.Body.String(), "Why is it.")
// well, assuming that the server is running. Eh?
// Mock data BTW...
req := httptest.NewRequest("POST", "/test", bytes.NewBuffer(payload))
route.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
// I'm really not sure why this would ever work.
// suddenly, things starting to make sense.
} | explode_data.jsonl/27397 | {
"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,
33978,
1592,
1155,
353,
8840,
836,
8,
341,
2405,
3238,
1592,
8941,
384,
1279,
12132,
28748,
287,
1592,
8941,
198,
197,
21152,
1592,
8941,
11716,
915,
284,
330,
2152,
68,
1279,
698,
197,
21152,
1592,
8941,
80671,
977,
915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWalletNew2(t *testing.T) {
address.CurrentNetwork = address.Mainnet
ki, addr, err := WalletNew(types.KTSecp256k1)
if err != nil {
t.Error(err)
}
t.Log(hex.EncodeToString(ki.PrivateKey))
t.Log(addr.String())
// 3e91d9dfb6a98f224745177e1c670fee00f7cf4f55f1576c34b6a0fae7b83c2c
// f1yfi4yslez2hz3ori5grvv3xdo3xkibc4v6xjusy
} | explode_data.jsonl/17781 | {
"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,
38259,
3564,
17,
1155,
353,
8840,
836,
8,
1476,
63202,
11517,
12320,
284,
2621,
23873,
4711,
271,
197,
6642,
11,
10789,
11,
1848,
1669,
36483,
3564,
52613,
11352,
51,
8430,
79,
17,
20,
21,
74,
16,
340,
743,
1848,
961,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestHealthStates(t *testing.T) {
// set up environment: events, task, container ....
e := events.New()
_, l, _ := e.Subscribe()
defer e.Evict(l)
task := &api.Task{
ID: "id",
ServiceID: "sid",
Spec: api.TaskSpec{
Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Image: "image_name",
Labels: map[string]string{
"com.docker.swarm.task.id": "id",
},
},
},
},
Annotations: api.Annotations{Name: "name"},
}
c := &container.Container{
ID: "id",
Name: "name",
Config: &containertypes.Config{
Image: "image_name",
Labels: map[string]string{
"com.docker.swarm.task.id": "id",
},
},
}
daemon := &daemon.Daemon{
EventsService: e,
}
controller, err := newController(daemon, nil, task, nil, nil)
if err != nil {
t.Fatalf("create controller fail %v", err)
}
errChan := make(chan error, 1)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// fire checkHealth
go func() {
err := controller.checkHealth(ctx)
select {
case errChan <- err:
case <-ctx.Done():
}
}()
// send an event and expect to get expectedErr
// if expectedErr is nil, shouldn't get any error
logAndExpect := func(msg string, expectedErr error) {
daemon.LogContainerEvent(c, msg)
timer := time.NewTimer(1 * time.Second)
defer timer.Stop()
select {
case err := <-errChan:
if err != expectedErr {
t.Fatalf("expect error %v, but get %v", expectedErr, err)
}
case <-timer.C:
if expectedErr != nil {
t.Fatal("time limit exceeded, didn't get expected error")
}
}
}
// events that are ignored by checkHealth
logAndExpect("health_status: running", nil)
logAndExpect("health_status: healthy", nil)
logAndExpect("die", nil)
// unhealthy event will be caught by checkHealth
logAndExpect("health_status: unhealthy", ErrContainerUnhealthy)
} | explode_data.jsonl/71483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 746
} | [
2830,
3393,
14542,
23256,
1155,
353,
8840,
836,
8,
1476,
197,
322,
738,
705,
4573,
25,
4357,
11,
3383,
11,
5476,
21903,
198,
7727,
1669,
4357,
7121,
741,
197,
6878,
326,
11,
716,
1669,
384,
82628,
741,
16867,
384,
5142,
85,
849,
233... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreUpdateDirTTL(t *testing.T) {
s := newStore()
fc := newFakeClock()
s.clock = fc
var eidx uint64 = 3
s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent})
s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent})
e, err := s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)})
testutil.AssertNil(t, err)
testutil.AssertEqual(t, e.Node.Dir, true)
testutil.AssertEqual(t, e.EtcdIndex, eidx)
e, _ = s.Get("/foo/bar", false, false)
testutil.AssertEqual(t, *e.Node.Value, "baz")
testutil.AssertEqual(t, e.EtcdIndex, eidx)
fc.Advance(600 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
e, err = s.Get("/foo/bar", false, false)
testutil.AssertNil(t, e)
testutil.AssertEqual(t, err.(*v2error.Error).ErrorCode, v2error.EcodeKeyNotFound)
} | explode_data.jsonl/44121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 360
} | [
2830,
3393,
6093,
4289,
6184,
51,
13470,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
6093,
741,
1166,
66,
1669,
501,
52317,
26104,
741,
1903,
50546,
284,
25563,
271,
2405,
384,
6361,
2622,
21,
19,
284,
220,
18,
198,
1903,
7251,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTransportNoBodyMeansNoDATA(t *testing.T) {
ct := newClientTester(t)
unblockClient := make(chan bool)
ct.client = func() error {
req, _ := http.NewRequest("GET", "https://dummy.tld/", http.NoBody)
ct.tr.RoundTrip(req)
<-unblockClient
return nil
}
ct.server = func() error {
defer close(unblockClient)
defer ct.cc.(*net.TCPConn).Close()
ct.greet()
for {
f, err := ct.fr.ReadFrame()
if err != nil {
return fmt.Errorf("ReadFrame while waiting for Headers: %v", err)
}
switch f := f.(type) {
default:
return fmt.Errorf("Got %T; want HeadersFrame", f)
case *WindowUpdateFrame, *SettingsFrame:
continue
case *HeadersFrame:
if !f.StreamEnded() {
return fmt.Errorf("got headers frame without END_STREAM")
}
return nil
}
}
}
ct.run()
} | explode_data.jsonl/16144 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
27560,
2753,
5444,
83402,
2753,
17777,
1155,
353,
8840,
836,
8,
341,
89216,
1669,
501,
2959,
58699,
1155,
692,
20479,
4574,
2959,
1669,
1281,
35190,
1807,
692,
89216,
6581,
284,
2915,
368,
1465,
341,
197,
24395,
11,
716,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMinSyncIntervalClose(t *testing.T) {
const minSyncInterval = 100 * time.Millisecond
f := &syncFile{}
w := NewLogWriter(f, 0)
w.SetMinSyncInterval(func() time.Duration {
return minSyncInterval
})
var timer fakeTimer
w.afterFunc = func(d time.Duration, f func()) syncTimer {
if d != minSyncInterval {
t.Fatalf("expected minSyncInterval %s, but found %s", minSyncInterval, d)
}
timer.f = f
timer.Reset(d)
return &timer
}
syncRecord := func(n int) *sync.WaitGroup {
wg := &sync.WaitGroup{}
wg.Add(1)
_, err := w.SyncRecord(bytes.Repeat([]byte{'a'}, n), wg, new(error))
if err != nil {
t.Fatal(err)
}
return wg
}
// Sync one record which will cause the sync timer to kick in.
syncRecord(1).Wait()
// Syncing another record will not complete until the timer is fired OR the
// writer is closed.
wg := syncRecord(1)
if err := w.Close(); err != nil {
t.Fatal(err)
}
wg.Wait()
} | explode_data.jsonl/58758 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
6217,
12154,
10256,
7925,
1155,
353,
8840,
836,
8,
341,
4777,
1308,
12154,
10256,
284,
220,
16,
15,
15,
353,
882,
71482,
271,
1166,
1669,
609,
12996,
1703,
16094,
6692,
1669,
1532,
2201,
6492,
955,
11,
220,
15,
340,
6692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseAttributes(t *testing.T) {
line := "TEST-ID=\"Help\",URI=\"http://test\",ID=33\n"
mapAttr := m3u8.ParseAttributes(line)
assert.NotNil(t, mapAttr)
assert.Equal(t, "Help", mapAttr["TEST-ID"])
assert.Equal(t, "http://test", mapAttr["URI"])
assert.Equal(t, "33", mapAttr["ID"])
} | explode_data.jsonl/4031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
14463,
10516,
1155,
353,
8840,
836,
8,
341,
27109,
1669,
330,
10033,
53365,
4070,
12689,
16215,
10301,
4070,
1254,
1110,
1944,
16215,
915,
28,
18,
18,
1699,
698,
19567,
13371,
1669,
296,
18,
84,
23,
8937,
10516,
8797,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindSingleEvent(t *testing.T) {
contractAddress := common.HexToAddress("abcd")
from := common.HexToAddress("00")
to := common.HexToAddress("01")
value := big.NewInt(0)
t.Run("ok", func(t *testing.T) {
var event transferEvent
err := transaction.FindSingleEvent(
&erc20ABI,
&types.Receipt{
Logs: []*types.Log{
newTransferLog(from, to, from, value), // event from different contract
{Topics: []common.Hash{{}}, Address: contractAddress}, // different event from same contract
newTransferLog(contractAddress, from, to, value),
},
Status: 1,
},
contractAddress,
erc20ABI.Events["Transfer"],
&event,
)
if err != nil {
t.Fatal(err)
}
if event.From != from {
t.Fatalf("parsed wrong from. wanted %x, got %x", from, event.From)
}
if event.To != to {
t.Fatalf("parsed wrong to. wanted %x, got %x", to, event.To)
}
if value.Cmp(event.Value) != 0 {
t.Fatalf("parsed wrong value. wanted %d, got %d", value, event.Value)
}
})
t.Run("not found", func(t *testing.T) {
var event transferEvent
err := transaction.FindSingleEvent(
&erc20ABI,
&types.Receipt{
Logs: []*types.Log{
newTransferLog(from, to, from, value), // event from different contract
{Topics: []common.Hash{{}}, Address: contractAddress}, // different event from same contract
},
Status: 1,
},
contractAddress,
erc20ABI.Events["Transfer"],
&event,
)
if !errors.Is(err, transaction.ErrEventNotFound) {
t.Fatalf("wanted error %v, got %v", transaction.ErrEventNotFound, err)
}
})
t.Run("Reverted", func(t *testing.T) {
var event transferEvent
err := transaction.FindSingleEvent(
&erc20ABI,
&types.Receipt{Status: 0},
contractAddress,
erc20ABI.Events["Transfer"],
&event,
)
if !errors.Is(err, transaction.ErrTransactionReverted) {
t.Fatalf("wanted error %v, got %v", transaction.ErrTransactionReverted, err)
}
})
} | explode_data.jsonl/24536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 829
} | [
2830,
3393,
9885,
10888,
1556,
1155,
353,
8840,
836,
8,
341,
197,
20257,
4286,
1669,
4185,
91538,
1249,
4286,
445,
68644,
1138,
42727,
1669,
4185,
91538,
1249,
4286,
445,
15,
15,
1138,
31709,
1669,
4185,
91538,
1249,
4286,
445,
15,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestAddKeyCommand(t *testing.T) {
err := ioutil.WriteFile("testkey.pub", []byte("ssh-rsa aaaaawhartevervAsde fake key"), 0600)
if err != nil {
t.Error(err)
}
err = ioutil.WriteFile("testkey", []byte("-----BEGIN RSA PRIVATE KEY-----\nfake key\n-----END RSA PRIVATE KEY-----"), 0600)
if err != nil {
t.Error(err)
}
t.Run("Key in command line", func(t *testing.T) {
defer func() {
if err := recover(); err != nil {
t.Error(err)
}
}()
_, c, app := testutil.BaseTestAuthSetup(t, false, commands)
c.When("GetUser", "test-user").Return(brain.User{Username: "test-user"}).Times(1)
c.MockRequest = &mocks.Request{
T: t,
StatusCode: 200,
}
err = app.Run(strings.Split("bytemark add key --user test-user ssh-rsa aaaaawhartevervAsde fake key", " "))
if err != nil {
t.Error(err)
}
c.MockRequest.AssertRequestObjectEqual(brain.User{
Username: "test-user",
AuthorizedKeys: brain.Keys{brain.Key{Key: "ssh-rsa aaaaawhartevervAsde fake key"}},
})
if ok, vErr := c.Verify(); !ok {
t.Fatal(vErr)
}
})
t.Run("Key in file", func(t *testing.T) {
defer func() {
if err := recover(); err != nil {
t.Error(err)
}
}()
_, c, app := testutil.BaseTestAuthSetup(t, false, commands)
c.When("GetUser", "test-user").Return(brain.User{Username: "test-user"}).Times(1)
c.MockRequest = &mocks.Request{
T: t,
StatusCode: 200,
}
err = app.Run([]string{"bytemark", "add", "key", "--user", "test-user", "testkey.pub"})
if err != nil {
t.Error(err)
}
c.MockRequest.AssertRequestObjectEqual(brain.User{
Username: "test-user",
AuthorizedKeys: brain.Keys{brain.Key{Key: "ssh-rsa aaaaawhartevervAsde fake key"}},
})
if ok, vErr := c.Verify(); !ok {
t.Fatal(vErr)
}
})
t.Run("Key in file using flag", func(t *testing.T) {
defer func() {
if err := recover(); err != nil {
t.Error(err)
}
}()
_, c, app := testutil.BaseTestAuthSetup(t, false, commands)
c.When("GetUser", "test-user").Return(brain.User{Username: "test-user"}).Times(1)
c.MockRequest = &mocks.Request{
T: t,
StatusCode: 200,
}
err = app.Run([]string{"bytemark", "add", "key", "--user", "test-user", "--public-key-file", "testkey.pub"})
if err != nil {
t.Error(err)
}
c.MockRequest.AssertRequestObjectEqual(brain.User{
Username: "test-user",
AuthorizedKeys: brain.Keys{brain.Key{Key: "ssh-rsa aaaaawhartevervAsde fake key"}},
})
if ok, vErr := c.Verify(); !ok {
t.Fatal(vErr)
}
})
t.Run("dont allow private key", func(t *testing.T) {
defer func() {
if err := recover(); err != nil {
t.Error(err)
}
}()
_, c, app := testutil.BaseTestAuthSetup(t, false, commands)
err = app.Run([]string{"bytemark", "add", "key", "--user", "test-user", "--public-key-file", "testkey"})
if err == nil {
t.Error("Expected an error")
}
if ok, err := c.Verify(); !ok {
t.Fatal(err)
}
})
_ = os.Remove("testkey.pub")
_ = os.Remove("testkey")
} | explode_data.jsonl/26278 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1375
} | [
2830,
3393,
2212,
1592,
4062,
1155,
353,
8840,
836,
8,
1476,
9859,
1669,
43144,
4073,
1703,
445,
1944,
792,
47773,
497,
3056,
3782,
445,
25537,
3795,
9081,
264,
32646,
672,
46389,
2054,
85,
2121,
450,
12418,
1376,
3975,
220,
15,
21,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnableRPCFlagDeprecation(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
rpcPort := randomPort()
out, err := skaffold.Build("--enable-rpc", "--rpc-port", rpcPort).InDir("testdata/build").RunWithCombinedOutput(t)
testutil.CheckError(t, false, err)
testutil.CheckContains(t, "Flag --enable-rpc has been deprecated", string(out))
rpcPort = randomPort()
out, err = skaffold.Build("--rpc-port", rpcPort).InDir("testdata/build").RunWithCombinedOutput(t)
testutil.CheckError(t, false, err)
testutil.CheckNotContains(t, "Flag --enable-rpc has been deprecated", string(out))
} | explode_data.jsonl/22966 | {
"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,
11084,
29528,
12135,
7839,
2758,
367,
1155,
353,
8840,
836,
8,
341,
197,
8949,
52464,
2271,
1155,
11,
2980,
6727,
26040,
38,
4672,
340,
7000,
3992,
7084,
1669,
4194,
7084,
741,
13967,
11,
1848,
1669,
1901,
2649,
813,
25212,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsMember(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 != "/orgs/k8s/members/person" {
t.Errorf("Bad request path: %s", r.URL.Path)
}
http.Error(w, "204 No Content", http.StatusNoContent)
}))
defer ts.Close()
c := getClient(ts.URL)
mem, err := c.IsMember("k8s", "person")
if err != nil {
t.Errorf("Didn't expect error: %v", err)
} else if !mem {
t.Errorf("Should be member.")
}
} | explode_data.jsonl/6248 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
3872,
9366,
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... | 3 |
func TestClusterCreate(t *testing.T) {
t.Parallel()
withNamespace(t, func(namespace func() string) {
t.Run("create cluster", func(t *testing.T) {
t.Run("creates a workflow", func(t *testing.T) {
output, err := pgo("create", "cluster", "mycluster", "-n", namespace()).Exec(t)
defer teardownCluster(t, namespace(), "mycluster", time.Now())
require.NoError(t, err)
require.Contains(t, output, "workflow id")
workflow := regexp.MustCompile(`\S+$`).FindString(strings.TrimSpace(output))
require.NotEmpty(t, workflow)
_, err = pgo("show", "workflow", workflow, "-n", namespace()).Exec(t)
require.NoError(t, err)
})
})
withCluster(t, namespace, func(cluster func() string) {
t.Run("show cluster", func(t *testing.T) {
t.Run("shows something", func(t *testing.T) {
output, err := pgo("show", "cluster", cluster(), "-n", namespace()).Exec(t)
require.NoError(t, err)
require.NotEmpty(t, output)
})
})
t.Run("show user", func(t *testing.T) {
t.Run("shows something", func(t *testing.T) {
output, err := pgo("show", "user", cluster(), "-n", namespace()).Exec(t)
require.NoError(t, err)
require.NotEmpty(t, output)
})
})
})
})
} | explode_data.jsonl/54309 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 524
} | [
2830,
3393,
28678,
4021,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
46948,
22699,
1155,
11,
2915,
52397,
2915,
368,
914,
8,
341,
197,
3244,
16708,
445,
3182,
10652,
497,
2915,
1155,
353,
8840,
836,
8,
341,
298,
3244,
16708... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScanHexInt(t *testing.T) {
t.Parallel()
const in = "hi 0x123 bye"
var a, b string
var i Int
_, err := fmt.Sscanf(in, "%s %x %s", &a, &i, &b)
if err != nil {
t.Fatal(err)
}
if i.Int64() != 291 {
t.Fatal(i.Int64(), 291)
}
} | explode_data.jsonl/80653 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
26570,
20335,
1072,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
4777,
304,
284,
330,
6023,
220,
15,
87,
16,
17,
18,
53041,
698,
2405,
264,
11,
293,
914,
198,
2405,
600,
1333,
198,
197,
6878,
1848,
1669,
8879,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHasVoted(t *testing.T) {
p1 := &poll.Poll{Question: "Question",
AnswerOptions: []*poll.AnswerOption{
{Answer: "Answer 1",
Voter: []string{"a"}},
{Answer: "Answer 2"},
},
}
assert.True(t, p1.HasVoted("a"))
assert.False(t, p1.HasVoted("b"))
} | explode_data.jsonl/30289 | {
"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,
10281,
53,
9253,
1155,
353,
8840,
836,
8,
341,
3223,
16,
1669,
609,
30141,
1069,
965,
90,
14582,
25,
330,
14582,
756,
197,
197,
16141,
3798,
25,
29838,
30141,
8624,
3559,
5341,
515,
298,
197,
90,
16141,
25,
330,
16141,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWriteKeyFilesIfNotExist(t *testing.T) {
setupKey, _ := NewServiceAccountSigningKey()
key, _ := NewServiceAccountSigningKey()
var tests = []struct {
setupFunc func(pkiDir string) error
expectedError bool
expectedKey *rsa.PrivateKey
}{
{ // key does not exists > key written
expectedKey: key,
},
{ // key exists > existing key used
setupFunc: func(pkiDir string) error {
return writeKeyFilesIfNotExist(pkiDir, "dummy", setupKey)
},
expectedKey: setupKey,
},
{ // some file exists, but it is not a valid key > err
setupFunc: func(pkiDir string) error {
testutil.SetupEmptyFiles(t, pkiDir, "dummy.key")
return nil
},
expectedError: true,
},
}
for _, test := range tests {
// Create temp folder for the test case
tmpdir := testutil.SetupTempDir(t)
defer os.RemoveAll(tmpdir)
// executes setup func (if necessary)
if test.setupFunc != nil {
if err := test.setupFunc(tmpdir); err != nil {
t.Errorf("error executing setupFunc: %v", err)
continue
}
}
// executes create func
err := writeKeyFilesIfNotExist(tmpdir, "dummy", key)
if !test.expectedError && err != nil {
t.Errorf("error writeKeyFilesIfNotExist failed when not expected to fail: %v", err)
continue
} else if test.expectedError && err == nil {
t.Error("error writeKeyFilesIfNotExist didn't failed when expected")
continue
} else if test.expectedError {
continue
}
// asserts expected files are there
testutil.AssertFileExists(t, tmpdir, "dummy.key", "dummy.pub")
// check created key
resultingKey, err := pkiutil.TryLoadKeyFromDisk(tmpdir, "dummy")
if err != nil {
t.Errorf("failure reading created key: %v", err)
continue
}
//TODO: check if there is a better method to compare keys
if resultingKey.D == key.D {
t.Error("created key does not match expected key")
}
}
} | explode_data.jsonl/58622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 707
} | [
2830,
3393,
7985,
1592,
10809,
2679,
45535,
1155,
353,
8840,
836,
8,
1476,
84571,
1592,
11,
716,
1669,
1532,
1860,
7365,
93358,
1592,
741,
23634,
11,
716,
1669,
1532,
1860,
7365,
93358,
1592,
2822,
2405,
7032,
284,
3056,
1235,
341,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCatalog_Register_ForwardDC(t *testing.T) {
t.Parallel()
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
defer s1.Shutdown()
codec := rpcClient(t, s1)
defer codec.Close()
dir2, s2 := testServerDC(t, "dc2")
defer os.RemoveAll(dir2)
defer s2.Shutdown()
// Try to join
joinWAN(t, s2, s1)
testrpc.WaitForLeader(t, s1.RPC, "dc2")
arg := structs.RegisterRequest{
Datacenter: "dc2", // Should forward through s1
Node: "foo",
Address: "127.0.0.1",
Service: &structs.NodeService{
Service: "db",
Tags: []string{"master"},
Port: 8000,
},
}
var out struct{}
if err := msgpackrpc.CallWithCodec(codec, "Catalog.Register", &arg, &out); err != nil {
t.Fatalf("err: %v", err)
}
} | explode_data.jsonl/49211 | {
"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,
41606,
73124,
84368,
1606,
5626,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
1155,
340,
16867,
2643,
84427,
14161,
16,
340,
16867,
274,
16,
10849,
18452,
741,
43343,
66,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIsValidBranchName(t *testing.T) {
tests := []struct {
name string
input string
want bool
}{
{name: "simple", input: "branch", want: true},
{name: "empty", input: "", want: false},
{name: "short", input: "a", want: true},
{name: "space", input: "got space", want: false},
{name: "special", input: "/branch", want: false},
{name: "dash", input: "a-branch", want: true},
{name: "leading-dash", input: "-branch", want: false},
{name: "underscores", input: "__", want: true},
{name: "backslash", input: "a\\branch", want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := IsValidBranchName(tt.input)
if got != tt.want {
t.Errorf("IsValidBranchName() got = %t, want %t", got, tt.want)
}
})
}
} | explode_data.jsonl/13871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
55470,
18197,
675,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
914,
198,
197,
50780,
220,
1807,
198,
197,
59403,
197,
197,
47006,
25,
330,
22944,
497,
1946,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFormat_Struct(t *testing.T) {
str := "some test {Field1:%s} and {Field2:08d}"
got := Format(str, &testObject{Field1: "abc", Field2: 123})
want := "some test abc and 00000123"
assert.Equal(t, want, got)
} | explode_data.jsonl/54322 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
4061,
72246,
1155,
353,
8840,
836,
8,
341,
11355,
1669,
330,
14689,
1273,
314,
1877,
16,
7533,
82,
92,
323,
314,
1877,
17,
25,
15,
23,
67,
11195,
3174,
354,
1669,
15042,
4199,
11,
609,
1944,
1190,
90,
1877,
16,
25,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStorageLastIndex(t *testing.T) {
ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
s := &MemoryStorage{ents: ents}
last, err := s.LastIndex()
if err != nil {
t.Errorf("err = %v, want nil", err)
}
if last != 5 {
t.Errorf("term = %d, want %d", last, 5)
}
s.Append([]pb.Entry{{Index: 6, Term: 5}})
last, err = s.LastIndex()
if err != nil {
t.Errorf("err = %v, want nil", err)
}
if last != 6 {
t.Errorf("last = %d, want %d", last, 5)
}
} | explode_data.jsonl/66753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
5793,
5842,
1552,
1155,
353,
8840,
836,
8,
341,
197,
805,
1669,
3056,
16650,
22330,
2979,
1552,
25,
220,
18,
11,
17519,
25,
220,
18,
2137,
314,
1552,
25,
220,
19,
11,
17519,
25,
220,
19,
2137,
314,
1552,
25,
220,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestMapSliceToBool(t *testing.T) {
assert := assert.New(t)
g := &Group{
People: []*Person{
{0, "George", 42.42, true},
{1, "Jeff", 0, true},
{2, "Ted", 50, true},
{3, "Luda", 100, false},
},
}
s, err := slices.ToBools(g.People, "Male")
assert.Nil(err)
assert.NotEmpty(s)
assert.Equal(s[0], true)
assert.Equal(s[1], true)
assert.Equal(s[2], true)
assert.Equal(s[3], false)
s, err = slices.ToBools(g.People, "Name")
assert.Equal(slices.ErrNotBool, err)
} | explode_data.jsonl/18826 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 237
} | [
2830,
3393,
2227,
33236,
1249,
11233,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
3174,
1669,
609,
2808,
515,
197,
10025,
68,
1164,
25,
29838,
10680,
515,
298,
197,
90,
15,
11,
330,
38952,
497,
220,
19,
17,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestObserve(t *testing.T) {
type args struct {
mg resource.Managed
}
type want struct {
mg resource.Managed
obs managed.ExternalObservation
err error
}
cases := map[string]struct {
handler http.Handler
kube client.Client
args args
want want
}{
"NotFound": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusNotFound)
_ = json.NewEncoder(w).Encode(&container.Cluster{})
}),
args: args{
mg: cluster(),
},
want: want{
mg: cluster(),
err: nil,
},
},
"GetFailed": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusBadRequest)
_ = json.NewEncoder(w).Encode(&container.Cluster{})
}),
args: args{
mg: cluster(),
},
want: want{
mg: cluster(),
err: errors.Wrap(gError(http.StatusBadRequest, ""), errGetCluster),
},
},
"NotUpToDateSpecUpdateFailed": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusOK)
gc := &container.Cluster{}
gke.GenerateCluster(name, cluster().Spec.ForProvider, gc)
gc.Locations = []string{"loc-1"}
_ = json.NewEncoder(w).Encode(gc)
}),
kube: &test.MockClient{
MockUpdate: test.NewMockUpdateFn(errBoom),
},
args: args{
mg: cluster(),
},
want: want{
mg: cluster(withLocations([]string{"loc-1"})),
err: errors.Wrap(errBoom, errManagedUpdateFailed),
},
},
"Creating": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusOK)
c := &container.Cluster{}
gke.GenerateCluster(name, cluster().Spec.ForProvider, c)
c.Status = v1beta2.ClusterStateProvisioning
c.MasterAuth = &container.MasterAuth{
Username: "admin",
Password: "admin",
}
_ = json.NewEncoder(w).Encode(c)
}),
args: args{
mg: cluster(withUsername("admin")),
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ConnectionDetails: connectionDetails(&container.Cluster{
Name: name,
MasterAuth: &container.MasterAuth{
Username: "admin",
Password: "admin",
},
}),
},
mg: cluster(withUsername("admin"), withProviderStatus(v1beta2.ClusterStateProvisioning), withConditions(xpv1.Creating())),
},
},
"Unavailable": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusOK)
c := &container.Cluster{}
gke.GenerateCluster(name, cluster().Spec.ForProvider, c)
c.Status = v1beta2.ClusterStateError
_ = json.NewEncoder(w).Encode(c)
}),
args: args{
mg: cluster(),
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ConnectionDetails: connectionDetails(&container.Cluster{}),
},
mg: cluster(withProviderStatus(v1beta2.ClusterStateError), withConditions(xpv1.Unavailable())),
},
},
"RunnableUnbound": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusOK)
c := &container.Cluster{}
gke.GenerateCluster(name, cluster().Spec.ForProvider, c)
c.Status = v1beta2.ClusterStateRunning
_ = json.NewEncoder(w).Encode(c)
}),
kube: &test.MockClient{
MockGet: test.NewMockGetFn(nil),
},
args: args{
mg: cluster(),
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ConnectionDetails: connectionDetails(&container.Cluster{}),
},
mg: cluster(
withProviderStatus(v1beta2.ClusterStateRunning),
withConditions(xpv1.Available())),
},
},
"BoundUnavailable": {
handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = r.Body.Close()
if diff := cmp.Diff(http.MethodGet, r.Method); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
w.WriteHeader(http.StatusOK)
c := &container.Cluster{}
gke.GenerateCluster(name, cluster().Spec.ForProvider, c)
c.Status = v1beta2.ClusterStateError
_ = json.NewEncoder(w).Encode(c)
}),
kube: &test.MockClient{
MockGet: test.NewMockGetFn(nil),
},
args: args{
mg: cluster(
withProviderStatus(v1beta2.ClusterStateRunning),
withConditions(xpv1.Available()),
),
},
want: want{
obs: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
ConnectionDetails: connectionDetails(&container.Cluster{}),
},
mg: cluster(
withProviderStatus(v1beta2.ClusterStateError),
withConditions(xpv1.Unavailable())),
},
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
server := httptest.NewServer(tc.handler)
defer server.Close()
s, _ := container.NewService(context.Background(), option.WithEndpoint(server.URL), option.WithoutAuthentication())
e := clusterExternal{
kube: tc.kube,
projectID: projectID,
cluster: s,
}
obs, err := e.Observe(context.Background(), tc.args.mg)
if tc.want.err != nil && err != nil {
// the case where our mock server returns error.
if diff := cmp.Diff(tc.want.err.Error(), err.Error()); diff != "" {
t.Errorf("Observe(...): want error string != got error string:\n%s", diff)
}
} else {
if diff := cmp.Diff(tc.want.err, err); diff != "" {
t.Errorf("Observe(...): want error != got error:\n%s", diff)
}
}
if diff := cmp.Diff(tc.want.obs, obs); diff != "" {
t.Errorf("Observe(...): -want, +got:\n%s", diff)
}
if diff := cmp.Diff(tc.want.mg, tc.args.mg); diff != "" {
t.Errorf("Observe(...): -want, +got:\n%s", diff)
}
})
}
} | explode_data.jsonl/69613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2987
} | [
2830,
3393,
4121,
13267,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
2109,
70,
5101,
29902,
3279,
198,
197,
532,
13158,
1366,
2036,
341,
197,
2109,
70,
220,
5101,
29902,
3279,
198,
197,
197,
5481,
8975,
5121,
15342,
377... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintInput(t *testing.T) {
name := Input{"Lala"}
want := true
result := PrintInput(name)
if result != want {
t.Fatalf(`Want %v get %v`, want, result)
}
} | explode_data.jsonl/8694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 67
} | [
2830,
3393,
8994,
2505,
1155,
353,
8840,
836,
8,
341,
11609,
1669,
5571,
4913,
43,
6053,
16707,
50780,
1669,
830,
198,
9559,
1669,
8213,
2505,
3153,
340,
743,
1102,
961,
1366,
341,
197,
3244,
30762,
5809,
28823,
1018,
85,
633,
1018,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestHistogram(t *testing.T) {
for i, test := range []struct {
x []float64
weights []float64
dividers []float64
ans []float64
}{
{
x: []float64{1, 3, 5, 6, 7, 8},
dividers: []float64{0, 2, 4, 6, 7, 9},
ans: []float64{1, 1, 1, 1, 2},
},
{
x: []float64{1, 3, 5, 6, 7, 8},
dividers: []float64{1, 2, 4, 6, 7, 9},
weights: []float64{1, 2, 1, 1, 1, 2},
ans: []float64{1, 2, 1, 1, 3},
},
{
x: []float64{1, 8},
dividers: []float64{0, 2, 4, 6, 7, 9},
weights: []float64{1, 2},
ans: []float64{1, 0, 0, 0, 2},
},
{
x: []float64{1, 8},
dividers: []float64{0, 2, 4, 6, 7, 9},
ans: []float64{1, 0, 0, 0, 1},
},
{
x: []float64{},
dividers: []float64{1, 3},
ans: []float64{0},
},
} {
hist := Histogram(nil, test.dividers, test.x, test.weights)
if !floats.Equal(hist, test.ans) {
t.Errorf("Hist mismatch case %d. Expected %v, Found %v", i, test.ans, hist)
}
// Test with non-zero values
Histogram(hist, test.dividers, test.x, test.weights)
if !floats.Equal(hist, test.ans) {
t.Errorf("Hist mismatch case %d. Expected %v, Found %v", i, test.ans, hist)
}
}
// panic cases
for _, test := range []struct {
name string
x []float64
weights []float64
dividers []float64
count []float64
}{
{
name: "len(x) != len(weights)",
x: []float64{1, 3, 5, 6, 7, 8},
weights: []float64{1, 1, 1, 1},
},
{
name: "len(count) != len(dividers) - 1",
x: []float64{1, 3, 5, 6, 7, 8},
dividers: []float64{1, 4, 9},
count: make([]float64, 6),
},
{
name: "dividers not sorted",
x: []float64{1, 3, 5, 6, 7, 8},
dividers: []float64{0, -1, 0},
},
{
name: "x not sorted",
x: []float64{1, 5, 2, 9, 7, 8},
dividers: []float64{1, 4, 9},
},
{
name: "fewer than 2 dividers",
x: []float64{1, 2, 3},
dividers: []float64{5},
},
{
name: "x too large",
x: []float64{1, 2, 3},
dividers: []float64{1, 3},
},
{
name: "x too small",
x: []float64{1, 2, 3},
dividers: []float64{2, 3},
},
} {
if !panics(func() { Histogram(test.count, test.dividers, test.x, test.weights) }) {
t.Errorf("Histogram did not panic when %s", test.name)
}
}
} | explode_data.jsonl/1767 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1303
} | [
2830,
3393,
77210,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
10225,
286,
3056,
3649,
21,
19,
198,
197,
197,
13327,
220,
3056,
3649,
21,
19,
198,
197,
63278,
13269,
3056,
3649,
21,
19,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMappingRuleMarkTombstoned(t *testing.T) {
proto := &rulepb.MappingRule{
Uuid: "12669817-13ae-40e6-ba2f-33087b262c68",
Snapshots: []*rulepb.MappingRuleSnapshot{
testMappingRuleSnapshot3V2Proto,
},
}
rr, err := newMappingRuleFromProto(proto, testTagsFilterOptions())
require.NoError(t, err)
meta := UpdateMetadata{
cutoverNanos: 67890000000,
updatedAtNanos: 10000,
updatedBy: "john",
}
require.NoError(t, rr.markTombstoned(meta))
require.Equal(t, 2, len(rr.snapshots))
require.True(t, cmp.Equal(testMappingRuleSnapshot3, rr.snapshots[0], testMappingRuleSnapshotCmpOpts...))
expected := &mappingRuleSnapshot{
name: "foo",
tombstoned: true,
cutoverNanos: 67890000000,
rawFilter: "tag1:value1 tag2:value2",
lastUpdatedAtNanos: 10000,
lastUpdatedBy: "john",
tags: []models.Tag{},
}
require.True(t, cmp.Equal(expected, rr.snapshots[1], testMappingRuleSnapshotCmpOpts...))
} | explode_data.jsonl/64583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 451
} | [
2830,
3393,
6807,
11337,
8949,
51,
2855,
7720,
291,
1155,
353,
8840,
836,
8,
341,
197,
15110,
1669,
609,
12937,
16650,
76455,
11337,
515,
197,
15980,
2423,
25,
330,
16,
17,
21,
21,
24,
23,
16,
22,
12,
16,
18,
5918,
12,
19,
15,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPicturesService_Upsert(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
tcs := map[string]struct {
id string
Image *bytes.Buffer
want *Picture
}{
"ok": {"1", bytes.NewBuffer(make([]byte, 0, 10)), getPicture("1")},
}
for n, tc := range tcs {
t.Run(n, func(t *testing.T) {
mux.HandleFunc(fmt.Sprintf("/type/%s/%s", tc.id, picturesPath), func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, fmt.Sprintf(getPictureJSON(tc.id)))
})
got, err := client.Picture.Upsert(context.Background(), tc.id, &UpsertPictureRequest{
tc.Image,
})
if err != nil {
t.Fatalf("Failed: %v", err)
}
if diff := cmp.Diff(got, tc.want); diff != "" {
t.Fatalf("Diff: %s(-got +want)", diff)
}
})
}
} | explode_data.jsonl/53570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 351
} | [
2830,
3393,
76646,
1860,
6665,
1690,
529,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
3244,
4837,
1669,
2415,
14032,
60,
1235,
341,
197,
15710,
262,
914,
198,
197,
53397,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCustomDisplay(t *testing.T) {
tests := []struct {
node *Node
level int
expected string
}{
{
newNodeWithSize("hello", 3*1024*1024),
3,
" hello | 3.00 MiB \n",
},
{
newNodeWithDisplay("hashAAAA", displayAsBlob),
2,
" Blob ID hashAAAA (0 reuses):\n",
},
{
newNodeWithDisplay("something_not_a_meta", displayAsMeta),
2,
" something_not_a_meta\n",
},
{
newNodeWithDisplay("/some/path/a_package.meta/something_else", displayAsMeta),
2,
" a_package\n",
},
{
withSetChildren(
newNodeWithDisplay("hashAAAA", displayAsBlob),
map[string]*Node{
"1": newNodeWithDisplay("metaBBBB", displayAsMeta),
}),
2,
" Blob ID hashAAAA (1 reuses):\n metaBBBB\n",
},
}
for _, test := range tests {
test := test
t.Run(test.expected, func(t *testing.T) {
t.Parallel()
actual := test.node.storageBreakdown(test.level)
if test.expected != actual {
t.Errorf("custom display mismatch:\nexpected: '%v'\n(bytes): %v\nactual: '%v'\n(bytes): %v",
test.expected,
[]byte(test.expected),
actual,
[]byte(actual),
)
}
})
}
} | explode_data.jsonl/12625 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 634
} | [
2830,
3393,
10268,
7020,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
20831,
257,
353,
1955,
198,
197,
53743,
262,
526,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
8638,
1955,
2354,
1695,
445,
14990,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCouchdbRedoLogger(t *testing.T) {
testEnv := NewTestVDBEnv(t)
defer testEnv.Cleanup()
// commitToRedologAndRestart - a helper function that commits directly to redologs and restart the statedb
commitToRedologAndRestart := func(newVal string, version *version.Height) {
batch := statedb.NewUpdateBatch()
batch.Put("ns1", "key1", []byte(newVal), version)
db, err := testEnv.DBProvider.GetDBHandle("testcouchdbredologger")
assert.NoError(t, err)
vdb := db.(*VersionedDB)
assert.NoError(t,
vdb.redoLogger.persist(
&redoRecord{
UpdateBatch: batch,
Version: version,
},
),
)
testEnv.CloseAndReopen()
}
// verifyExpectedVal - a helper function that verifies the statedb contents
verifyExpectedVal := func(expectedVal string, expectedSavepoint *version.Height) {
db, err := testEnv.DBProvider.GetDBHandle("testcouchdbredologger")
assert.NoError(t, err)
vdb := db.(*VersionedDB)
vv, err := vdb.GetState("ns1", "key1")
assert.NoError(t, err)
assert.Equal(t, expectedVal, string(vv.Value))
savepoint, err := vdb.GetLatestSavePoint()
assert.NoError(t, err)
assert.Equal(t, expectedSavepoint, savepoint)
}
// initialize statedb with initial set of writes
db, err := testEnv.DBProvider.GetDBHandle("testcouchdbredologger")
if err != nil {
t.Fatalf("Failed to get database handle: %s", err)
}
vdb := db.(*VersionedDB)
batch1 := statedb.NewUpdateBatch()
batch1.Put("ns1", "key1", []byte("value1"), version.NewHeight(1, 1))
vdb.ApplyUpdates(batch1, version.NewHeight(1, 1))
// make redolog one block ahead than statedb - upon restart the redolog should get applied
commitToRedologAndRestart("value2", version.NewHeight(2, 1))
verifyExpectedVal("value2", version.NewHeight(2, 1))
// make redolog two blocks ahead than statedb - upon restart the redolog should be ignored
commitToRedologAndRestart("value3", version.NewHeight(4, 1))
verifyExpectedVal("value2", version.NewHeight(2, 1))
// make redolog one block behind than statedb - upon restart the redolog should be ignored
commitToRedologAndRestart("value3", version.NewHeight(1, 5))
verifyExpectedVal("value2", version.NewHeight(2, 1))
// A nil height should cause skipping the writing of redo-record
db, _ = testEnv.DBProvider.GetDBHandle("testcouchdbredologger")
vdb = db.(*VersionedDB)
vdb.ApplyUpdates(batch1, nil)
record, err := vdb.redoLogger.load()
assert.NoError(t, err)
assert.Equal(t, version.NewHeight(1, 5), record.Version)
assert.Equal(t, []byte("value3"), record.UpdateBatch.Get("ns1", "key1").Value)
// A batch that does not contain PostOrderWrites should cause skipping the writing of redo-record
db, _ = testEnv.DBProvider.GetDBHandle("testcouchdbredologger")
vdb = db.(*VersionedDB)
batchWithNoGeneratedWrites := batch1
batchWithNoGeneratedWrites.ContainsPostOrderWrites = false
vdb.ApplyUpdates(batchWithNoGeneratedWrites, version.NewHeight(2, 5))
record, err = vdb.redoLogger.load()
assert.NoError(t, err)
assert.Equal(t, version.NewHeight(1, 5), record.Version)
assert.Equal(t, []byte("value3"), record.UpdateBatch.Get("ns1", "key1").Value)
// A batch that contains PostOrderWrites should cause writing of redo-record
db, _ = testEnv.DBProvider.GetDBHandle("testcouchdbredologger")
vdb = db.(*VersionedDB)
batchWithGeneratedWrites := batch1
batchWithGeneratedWrites.ContainsPostOrderWrites = true
vdb.ApplyUpdates(batchWithNoGeneratedWrites, version.NewHeight(3, 4))
record, err = vdb.redoLogger.load()
assert.NoError(t, err)
assert.Equal(t, version.NewHeight(3, 4), record.Version)
assert.Equal(t, []byte("value1"), record.UpdateBatch.Get("ns1", "key1").Value)
} | explode_data.jsonl/2698 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1319
} | [
2830,
3393,
34,
3026,
1999,
6033,
78,
7395,
1155,
353,
8840,
836,
8,
341,
18185,
14359,
1669,
1532,
2271,
53,
3506,
14359,
1155,
340,
16867,
1273,
14359,
727,
60639,
2822,
197,
322,
5266,
1249,
6033,
1609,
3036,
59354,
481,
264,
13137,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue_SearchIssueIDsByKeyword(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
total, ids, err := SearchIssueIDsByKeyword("issue2", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{2}, ids)
total, ids, err = SearchIssueIDsByKeyword("first", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{1}, ids)
total, ids, err = SearchIssueIDsByKeyword("for", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 5, total)
assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids)
// issue1's comment id 2
total, ids, err = SearchIssueIDsByKeyword("good", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{1}, ids)
} | explode_data.jsonl/46845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
42006,
65913,
42006,
30466,
1359,
34481,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
19905,
28770,
3380,
2271,
5988,
2398,
34493,
11,
14151,
11,
1848,
1669,
7542,
42006,
30466,
1359,
34481,
445,
11159,
17,
497,
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 TestEth_GetFilterChanges_BlockFilter(t *testing.T) {
rpcRes := call(t, "eth_newBlockFilter", []string{})
var ID string
err := json.Unmarshal(rpcRes.Result, &ID)
require.NoError(t, err)
time.Sleep(5 * time.Second)
changesRes := call(t, "eth_getFilterChanges", []string{ID})
var hashes []common.Hash
err = json.Unmarshal(changesRes.Result, &hashes)
require.NoError(t, err)
require.GreaterOrEqual(t, len(hashes), 1)
} | explode_data.jsonl/852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
65390,
13614,
5632,
11317,
51779,
5632,
1155,
353,
8840,
836,
8,
341,
7000,
3992,
1061,
1669,
1618,
1155,
11,
330,
769,
5921,
4713,
5632,
497,
3056,
917,
6257,
692,
2405,
3034,
914,
198,
9859,
1669,
2951,
38097,
2601,
3992,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEntry_OnKeyDown_BackspaceBeyondTextAndNewLine(t *testing.T) {
entry := widget.NewMultiLineEntry()
entry.SetText("H\ni")
down := &fyne.KeyEvent{Name: fyne.KeyDown}
entry.TypedKey(down)
right := &fyne.KeyEvent{Name: fyne.KeyRight}
entry.TypedKey(right)
key := &fyne.KeyEvent{Name: fyne.KeyBackspace}
entry.TypedKey(key)
assert.Equal(t, 1, entry.CursorRow)
assert.Equal(t, 0, entry.CursorColumn)
entry.TypedKey(key)
assert.Equal(t, 0, entry.CursorRow)
assert.Equal(t, 1, entry.CursorColumn)
assert.Equal(t, "H", entry.Text)
} | explode_data.jsonl/12338 | {
"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,
5874,
35482,
24173,
1668,
7821,
1306,
55341,
1178,
3036,
3564,
2460,
1155,
353,
8840,
836,
8,
341,
48344,
1669,
9086,
7121,
20358,
2460,
5874,
741,
48344,
92259,
445,
39,
1699,
72,
5130,
2698,
779,
1669,
609,
30595,
811,
588... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMinifiedDynamicImportWithExpressionCJS(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/a.js": `
import('foo')
import(foo())
`,
},
entryPaths: []string{"/a.js"},
options: config.Options{
Mode: config.ModeConvertFormat,
OutputFormat: config.FormatCommonJS,
AbsOutputFile: "/out.js",
RemoveWhitespace: true,
},
})
} | explode_data.jsonl/38472 | {
"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,
6217,
1870,
21752,
11511,
2354,
9595,
34,
12545,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
64,
2857,
788,
22074,
571,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Execution_CheckHealthy_Never_Healthy_ELB(t *testing.T) {
// Should end in Alert Bad Thing Happened State
release := models.MockRelease(t)
maws := models.MockAwsClients(release)
maws.ELB.DescribeInstanceHealthResp["web-elb"] = &mocks.DescribeInstanceHealthResponse{}
stateMachine := createTestStateMachine(t, maws)
exec, err := stateMachine.Execute(release)
assert.Error(t, err)
ep := exec.Path()
assert.Equal(t, []string{
"Validate",
"Lock",
"ValidateResources",
"Deploy",
"WaitForDeploy",
"WaitForHealthy",
"CheckHealthy"}, ep[0:7])
assert.Equal(t, []string{
"DetachForFailure",
"WaitDetachForFailure",
"CleanUpFailure",
"ReleaseLockFailure",
"FailureClean",
}, ep[len(ep)-5:len(ep)])
assert.Regexp(t, "Timeout", exec.LastOutputJSON)
assert.Regexp(t, "success\": false", exec.LastOutputJSON)
} | explode_data.jsonl/3586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
62,
20294,
28188,
96113,
1604,
2054,
62,
96113,
2089,
34068,
1155,
353,
8840,
836,
8,
341,
197,
322,
12260,
835,
304,
13975,
11461,
37200,
34700,
6758,
3234,
198,
17200,
1623,
1669,
4119,
24664,
16077,
1155,
692,
2109,
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 |
func TestMsgFilter_NotByBot(t *testing.T) {
var botID disgord.Snowflake = 123
messageFromBot := &disgord.Message{
Author: &disgord.User{Bot: true},
}
messageNotFromBot := &disgord.Message{
Author: &disgord.User{Bot: false},
}
testCases := []struct {
name string
evt interface{}
shouldPassThrough bool
}{
{"MessageCreate_FromBot", &disgord.MessageCreate{Message: messageFromBot}, false},
{"MessageUpdate_FromBot", &disgord.MessageUpdate{Message: messageFromBot}, false},
{"MessageCreate_NotBot", &disgord.MessageCreate{Message: messageNotFromBot}, true},
{"MessageUpdate_NotBot", &disgord.MessageUpdate{Message: messageNotFromBot}, true},
}
filter, _ := newMsgFilter(context.Background(), &clientRESTMock{id: botID})
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := filter.NotByBot(tc.evt)
if tc.shouldPassThrough && result == nil {
t.Error("expected to passthrough")
}
if !tc.shouldPassThrough && result != nil {
t.Error("expected a filter match")
}
})
}
} | explode_data.jsonl/1327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
6611,
5632,
60816,
1359,
23502,
1155,
353,
8840,
836,
8,
341,
2405,
10924,
915,
32183,
539,
808,
3328,
63456,
284,
220,
16,
17,
18,
271,
24753,
3830,
23502,
1669,
609,
4243,
70,
539,
8472,
515,
197,
197,
7133,
25,
609,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDeleteFinalStateUnknown(t *testing.T) {
for _, strategy := range updateStrategies() {
manager, _, _, err := newTestController()
if err != nil {
t.Fatalf("error creating DaemonSets controller: %v", err)
}
addNodes(manager.nodeStore, 0, 1, nil)
ds := newDaemonSet("foo")
ds.Spec.UpdateStrategy = *strategy
// DeletedFinalStateUnknown should queue the embedded DS if found.
manager.deleteDaemonset(cache.DeletedFinalStateUnknown{Key: "foo", Obj: ds})
enqueuedKey, _ := manager.queue.Get()
if enqueuedKey.(string) != "default/foo" {
t.Errorf("expected delete of DeletedFinalStateUnknown to enqueue the daemonset but found: %#v", enqueuedKey)
}
}
} | explode_data.jsonl/50302 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
6435,
19357,
1397,
13790,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
8282,
1669,
2088,
2647,
2580,
69388,
368,
341,
197,
92272,
11,
8358,
8358,
1848,
1669,
501,
2271,
2051,
741,
197,
743,
1848,
961,
2092,
341,
298,
3244,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAtCharset(t *testing.T) {
expectPrinted(t, "@charset \"UTF-8\";", "@charset \"UTF-8\";\n")
expectPrinted(t, "@charset 'UTF-8';", "@charset \"UTF-8\";\n")
expectParseError(t, "@charset \"US-ASCII\";", "<stdin>: warning: \"UTF-8\" will be used instead of unsupported charset \"US-ASCII\"\n")
expectParseError(t, "@charset;", "<stdin>: warning: Expected whitespace but found \";\"\n")
expectParseError(t, "@charset ;", "<stdin>: warning: Expected string token but found \";\"\n")
expectParseError(t, "@charset\"UTF-8\";", "<stdin>: warning: Expected whitespace but found \"\\\"UTF-8\\\"\"\n")
expectParseError(t, "@charset \"UTF-8\"", "<stdin>: warning: Expected \";\" but found end of file\n")
expectParseError(t, "@charset url(UTF-8);", "<stdin>: warning: Expected string token but found \"url(UTF-8)\"\n")
expectParseError(t, "@charset url(\"UTF-8\");", "<stdin>: warning: Expected string token but found \"url(\"\n")
expectParseError(t, "@charset \"UTF-8\" ", "<stdin>: warning: Expected \";\" but found whitespace\n")
expectParseError(t, "@charset \"UTF-8\"{}", "<stdin>: warning: Expected \";\" but found \"{\"\n")
} | explode_data.jsonl/32626 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 448
} | [
2830,
3393,
1655,
78172,
1155,
353,
8840,
836,
8,
341,
24952,
8994,
291,
1155,
11,
8428,
25327,
7245,
8561,
12,
23,
2105,
32503,
8428,
25327,
7245,
8561,
12,
23,
2105,
17882,
77,
1138,
24952,
8994,
291,
1155,
11,
8428,
25327,
364,
856... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSingleMapLiteralReturnStatement(t *testing.T) {
p := createParser(`return map[string]int{"one":2, "two":3}`)
bvmUtils.Assert(t, isReturnStatement(p), "should detect return statement")
parseReturnStatement(p)
u := p.scope.Next()
bvmUtils.AssertNow(t, u.Type() == ast.ReturnStatement, "wrong return type")
r := u.(*ast.ReturnStatementNode)
bvmUtils.AssertNow(t, len(r.Results) == 1, "wrong result length")
bvmUtils.AssertNow(t, r.Results[0].Type() == ast.MapLiteral, "wrong result 0 type")
} | explode_data.jsonl/49734 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
10888,
2227,
17350,
5598,
8636,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1855,
6570,
5809,
689,
2415,
14032,
63025,
4913,
603,
788,
17,
11,
330,
19789,
788,
18,
27085,
2233,
7338,
4209,
11711,
1155,
11,
374,
5598,
8636,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkerAddFunction(t *testing.T) {
if !runIntegrationTests {
t.Skip("To run this test, use: go test -integration")
}
if err := worker.AddFunc("foobar", foobar, 0); err != nil {
t.Error(err)
}
if err := worker.AddFunc("timeout", foobar, 5); err != nil {
t.Error(err)
}
if l := len(worker.funcs); l != 2 {
t.Log(worker.funcs)
t.Errorf("The length of function map should be %d.", 2)
}
} | explode_data.jsonl/43513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
21936,
2212,
5152,
1155,
353,
8840,
836,
8,
341,
743,
753,
6108,
52464,
18200,
341,
197,
3244,
57776,
445,
1249,
1598,
419,
1273,
11,
990,
25,
728,
1273,
481,
60168,
1138,
197,
532,
743,
1848,
1669,
11864,
1904,
9626,
445,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.