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 TestNoAuth(t *testing.T) {
req := bytes.NewBuffer(nil)
req.Write([]byte{1, NoAuth})
var resp bytes.Buffer
s, _ := New(&Config{})
ctx, err := s.authenticate(&resp, req)
if err != nil {
t.Fatalf("err: %v", err)
}
if ctx.Method != NoAuth {
t.Fatal("Invalid Context Method")
}
out := resp.Bytes()
if !bytes.Equal(out, []byte{socks5Version, NoAuth}) {
t.Fatalf("bad: %v", out)
}
} | explode_data.jsonl/18558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
2753,
5087,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
5820,
7121,
4095,
27907,
340,
24395,
4073,
10556,
3782,
90,
16,
11,
2308,
5087,
3518,
2405,
9039,
5820,
22622,
271,
1903,
11,
716,
1669,
1532,
2099,
2648,
37790,
20985,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQueueHappy(t *testing.T) {
tf.UnitTest(t)
testQ := dispatcher.NewTargetQueue()
// Add syncRequests out of order
sR0 := dispatcher.Target{ChainInfo: *(chainInfoFromHeight(t, 0))}
sR1 := dispatcher.Target{ChainInfo: *(chainInfoFromHeight(t, 1))}
sR2 := dispatcher.Target{ChainInfo: *(chainInfoFromHeight(t, 2))}
sR47 := dispatcher.Target{ChainInfo: *(chainInfoFromHeight(t, 47))}
testQ.Push(sR2)
testQ.Push(sR47)
testQ.Push(sR0)
testQ.Push(sR1)
assert.Equal(t, 4, testQ.Len())
// Pop in order
out0 := requirePop(t, testQ)
out1 := requirePop(t, testQ)
out2 := requirePop(t, testQ)
out3 := requirePop(t, testQ)
assert.Equal(t, uint64(47), out0.ChainInfo.Height)
assert.Equal(t, uint64(2), out1.ChainInfo.Height)
assert.Equal(t, uint64(1), out2.ChainInfo.Height)
assert.Equal(t, uint64(0), out3.ChainInfo.Height)
assert.Equal(t, 0, testQ.Len())
} | explode_data.jsonl/82040 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
7554,
32847,
1155,
353,
8840,
836,
8,
341,
3244,
69,
25159,
2271,
1155,
340,
18185,
48,
1669,
38799,
7121,
6397,
7554,
2822,
197,
322,
2691,
12811,
35295,
700,
315,
1973,
198,
1903,
49,
15,
1669,
38799,
35016,
90,
18837,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilter_Out(t *testing.T) {
out := &TestPrinter{T: t}
filter := &Filter{Type: FilterOut}
filter.Chain(out)
DoFilterPrints(filter)
out.ExpectOrdered(
"<a> x",
"<a.b> x",
"<a.c> x",
"<a.b.c> x",
"<a.c.b> x",
"<b> x",
"<b.a> x",
"<b.c> x",
"<b.a.c> x",
"<b.c.a> x",
"<c> x",
"<c.a> x",
"<c.b> x",
"<c.a.b> x",
"<c.b.a> x",
)
filter.Add("a.b.c")
filter.Add("c.b.a")
filter.Add("d")
filter.AddPrefix("b")
filter.AddPrefix("d")
filter.AddSuffix("c")
filter.AddSuffix("d")
WaitForPropagation()
DoFilterPrints(filter)
out.ExpectOrdered(
"<a> x",
"<a.b> x",
"<a.c.b> x",
"<c.a> x",
"<c.b> x",
"<c.a.b> x",
)
filter.Remove("a.b.c")
filter.Remove("c.b.a")
filter.Remove("e")
filter.AddPrefix("c")
filter.RemovePrefix("b")
filter.RemovePrefix("e")
filter.AddSuffix("b")
filter.RemoveSuffix("c")
filter.RemoveSuffix("e")
WaitForPropagation()
DoFilterPrints(filter)
out.ExpectOrdered(
"<a> x",
"<a.c> x",
"<a.b.c> x",
"<b.a> x",
"<b.c> x",
"<b.a.c> x",
"<b.c.a> x",
)
} | explode_data.jsonl/44646 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 616
} | [
2830,
3393,
5632,
36675,
1155,
353,
8840,
836,
8,
341,
13967,
1669,
609,
2271,
45660,
76025,
25,
259,
532,
50108,
1669,
609,
5632,
90,
929,
25,
12339,
2662,
532,
50108,
98269,
9828,
692,
197,
5404,
5632,
8994,
82,
19704,
340,
13967,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSeedPhrase(t *testing.T) {
// make the storage with reasonable defaults
cstore := NewInMemory()
algo := Secp256k1
n1, n2 := "lost-key", "found-again"
p1, p2 := nums, foobar
// make sure key works with initial password
info, mnemonic, err := cstore.CreateMnemonic(n1, English, p1, algo)
require.Nil(t, err, "%+v", err)
require.Equal(t, n1, info.GetName())
assert.NotEmpty(t, mnemonic)
// now, let us delete this key
err = cstore.Delete(n1, p1, false)
require.Nil(t, err, "%+v", err)
_, err = cstore.Get(n1)
require.NotNil(t, err)
// let us re-create it from the mnemonic-phrase
params := *hd.NewFundraiserParams(0, sdk.CoinType, 0)
newInfo, err := cstore.Derive(n2, mnemonic, DefaultBIP39Passphrase, p2, params)
require.NoError(t, err)
require.Equal(t, n2, newInfo.GetName())
require.Equal(t, info.GetPubKey().Address(), newInfo.GetPubKey().Address())
require.Equal(t, info.GetPubKey(), newInfo.GetPubKey())
} | explode_data.jsonl/10674 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
41471,
46806,
1155,
353,
8840,
836,
8,
1476,
197,
322,
1281,
279,
5819,
448,
13276,
16674,
198,
1444,
4314,
1669,
1532,
641,
10642,
2822,
69571,
3346,
1669,
4520,
79,
17,
20,
21,
74,
16,
198,
9038,
16,
11,
308,
17,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDirect_DoubleStop(t *testing.T) {
g := NewGomegaWithT(t)
xform, src, acc := setup(g)
xform.Start()
src.Handlers.Handle(event.FullSyncFor(basicmeta.K8SCollection1))
src.Handlers.Handle(event.AddFor(basicmeta.K8SCollection1, data.EntryN1I1V1))
fixtures.ExpectEventsEventually(t, acc,
event.FullSyncFor(basicmeta.Collection2),
event.AddFor(basicmeta.Collection2, data.EntryN1I1V1), // XForm to Collection2
)
acc.Clear()
xform.Stop()
xform.Stop()
g.Consistently(acc.Events).Should(BeEmpty())
} | explode_data.jsonl/37561 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
16027,
84390,
10674,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
692,
10225,
627,
11,
2286,
11,
1029,
1669,
6505,
3268,
692,
10225,
627,
12101,
2822,
41144,
35308,
9254,
31421,
6235,
32038,
121... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_yamlConfigAnalyzer_Required(t *testing.T) {
tests := []struct {
name string
filePattern *regexp.Regexp
filePath string
want bool
}{
{
name: "yaml",
filePath: "deployment.yaml",
want: true,
},
{
name: "yml",
filePath: "deployment.yml",
want: true,
},
{
name: "json",
filePath: "deployment.json",
want: false,
},
{
name: "file pattern",
filePattern: regexp.MustCompile(`foo*`),
filePath: "foo_file",
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := yaml.NewConfigAnalyzer(tt.filePattern)
got := s.Required(tt.filePath, nil)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/63941 | {
"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,
64380,
2648,
54911,
62,
8164,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
17661,
15760,
353,
55796,
8989,
4580,
198,
197,
17661,
1820,
262,
914,
198,
197,
50780,
286,
1807,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEtcdListEndpoints(t *testing.T) {
ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t)
key := makeServiceEndpointsListKey(ctx)
fakeClient.Data[key] = tools.EtcdResponseWithError{
R: &etcd.Response{
Node: &etcd.Node{
Nodes: []*etcd.Node{
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "foo"}, Endpoints: []string{"127.0.0.1:8345"}}),
},
{
Value: runtime.EncodeOrDie(latest.Codec, &api.Endpoints{TypeMeta: api.TypeMeta{ID: "bar"}}),
},
},
},
},
E: nil,
}
registry := NewTestEtcdRegistry(fakeClient)
services, err := registry.ListEndpoints(ctx)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(services.Items) != 2 || services.Items[0].ID != "foo" || services.Items[1].ID != "bar" {
t.Errorf("Unexpected endpoints list: %#v", services)
}
} | explode_data.jsonl/8172 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 384
} | [
2830,
3393,
31860,
4385,
852,
80786,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6330,
7121,
3675,
1972,
741,
1166,
726,
2959,
1669,
7375,
7121,
52317,
31860,
4385,
2959,
1155,
340,
23634,
1669,
1281,
1860,
80786,
852,
1592,
7502,
340,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestSendOnResetConnection(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.CreateConnected(789, 30000, nil)
// Send RST segment.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagRst,
SeqNum: 790,
RcvWnd: 30000,
})
// Wait for the RST to be received.
time.Sleep(1 * time.Second)
// Try to write.
view := buffer.NewView(10)
if _, _, err := c.EP.Write(tcpip.SlicePayload(view), tcpip.WriteOptions{}); err != tcpip.ErrConnectionReset {
t.Fatalf("got c.EP.Write(...) = %v, want = %v", err, tcpip.ErrConnectionReset)
}
} | explode_data.jsonl/22308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 268
} | [
2830,
3393,
11505,
1925,
14828,
4526,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
1444,
7251,
21146,
7,
22,
23,
24,
11,
220,
18,
15,
15,
15,
15,
11,
2092,
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... | 2 |
func TestCheckAuthorization_NoPolicyDefined(t *testing.T) {
auth := setupAuthorizationTest(t)
auth.cfg.Resources[auth.resource].Views[auth.view].Roles[auth.role].Policies = nil
id, err := auth.dam.populateIdentityVisas(auth.ctx, auth.id, auth.cfg)
if err != nil {
t.Fatalf("unable to obtain passport identity: %v", err)
}
err = checkAuthorization(auth.ctx, id, auth.ttl, auth.resource, auth.view, auth.role, auth.cfg, test.TestClientID, auth.dam.ValidateCfgOpts(storage.DefaultRealm, nil))
if status.Code(err) != codes.PermissionDenied {
t.Errorf("checkAuthorization(ctx, id, %v, %q, %q, %q, cfg, %q) failed, expected %d, got: %v", auth.ttl, auth.resource, auth.view, auth.role, test.TestClientID, codes.PermissionDenied, err)
}
if errutil.ErrorReason(err) != errNoPolicyDefined {
t.Errorf("errutil.ErrorReason() = %s want %s", errutil.ErrorReason(err), errNoPolicyDefined)
}
} | explode_data.jsonl/18488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 334
} | [
2830,
3393,
3973,
18124,
36989,
13825,
29361,
1155,
353,
8840,
836,
8,
341,
78011,
1669,
6505,
18124,
2271,
1155,
340,
78011,
30481,
21703,
58,
3242,
24013,
936,
23217,
58,
3242,
3792,
936,
25116,
58,
3242,
26006,
936,
47,
42038,
284,
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... | 4 |
func TestGetProviderByName(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
"should return ATS provider",
ATS,
ATS,
},
{
"should return Istio provider",
Istio,
Istio,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
p := helper.GetProviderByName(test.input)
if assert.NotNil(t, p, "provider is nil: "+test.name) {
assert.Equal(t, p.Name(), test.expected, test.name)
}
})
}
} | explode_data.jsonl/15641 | {
"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,
1949,
5179,
16898,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
1,
5445,
470,
95375,
9109,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_Transaction(t *testing.T) {
var db = DB()
// 一键事务, 自动回滚和提交, 我们只需要关注业务即可
err := db.Transaction(
func(db IOrm) error {
//db.Table("users").Limit(2).SharedLock().Get()
//fmt.Println(db.LastSql())
_, err := db.Table("users").Where("uid", 2).Update(Data{"name": "gorose2"})
fmt.Println(db.LastSql())
if err != nil {
return err
}
_, err = db.Insert(&UsersMap{"name": "gorose2", "age": 0})
fmt.Println(db.LastSql())
if err != nil {
return err
}
return nil
},
func(db IOrm) error {
_, err := db.Table("users").Where("uid", 3).Update(Data{"name": "gorose3"})
fmt.Println(db.LastSql())
if err != nil {
return err
}
_, err = db.Insert(&UsersMap{"name": "gorose2", "age": 0})
fmt.Println(db.LastSql())
if err != nil {
return err
}
return nil
},
)
if err != nil {
t.Error(err.Error())
}
t.Log("事务测试通过")
} | explode_data.jsonl/60041 | {
"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,
34932,
1311,
1155,
353,
8840,
836,
8,
341,
2405,
2927,
284,
5952,
741,
197,
322,
220,
111471,
101436,
11,
61991,
27733,
18397,
100301,
33108,
71971,
11,
49434,
239,
79478,
107525,
100020,
103923,
104180,
198,
9859,
1669,
2927,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRestrictPrefix(t *testing.T) {
handler := http.StripPrefix("/static/",
RestrictPrefix(".", http.FileServer(http.Dir("../files/"))),
)
testCases := []struct {
path string
code int
}{
{"http://test/static/sage.svg", http.StatusOK},
{"http://test/static/.secret", http.StatusNotFound},
{"http://test/static/.dir/secret", http.StatusNotFound},
}
for i, c := range testCases {
r := httptest.NewRequest(http.MethodGet, c.path, nil)
w := httptest.NewRecorder()
handler.ServeHTTP(w, r)
actual := w.Result().StatusCode
if c.code != actual {
t.Errorf("%d: expected %d; actual %d", i, c.code, actual)
}
}
} | explode_data.jsonl/48736 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
50360,
849,
14335,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
1758,
27318,
573,
14335,
4283,
1978,
35075,
197,
11143,
15111,
849,
14335,
64217,
1758,
8576,
5475,
19886,
83757,
17409,
7198,
14,
2761,
1326,
197,
692,
18185,
3730... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAdmin_DeleteUser(t *testing.T) {
srv, ts := prep(t)
assert.NotNil(t, srv)
defer cleanup(ts)
c1 := store.Comment{Text: "test test #1", Orig: "o test test #1", User: store.User{ID: "id1", Name: "name"},
Locator: store.Locator{SiteID: "radio-t", URL: "https://radio-t.com/blah"}}
c2 := store.Comment{Text: "test test #2", Orig: "o test test #2", User: store.User{ID: "id2", Name: "name"}, ParentID: "p1",
Locator: store.Locator{SiteID: "radio-t", URL: "https://radio-t.com/blah"}}
c3 := store.Comment{Text: "test test #3", Orig: "o test test #3", User: store.User{ID: "id2", Name: "name"}, ParentID: "",
Locator: store.Locator{SiteID: "radio-t", URL: "https://radio-t.com/blah"}}
// write comments directly to store to keep user id
id1, err := srv.DataService.Create(c1)
assert.NoError(t, err)
_, err = srv.DataService.Create(c2)
assert.NoError(t, err)
_, err = srv.DataService.Create(c3)
assert.NoError(t, err)
client := http.Client{}
req, err := http.NewRequest(http.MethodDelete, fmt.Sprintf("%s/api/v1/admin/user/%s?site=radio-t", ts.URL, "id2"), nil)
assert.Nil(t, err)
req.SetBasicAuth("dev", "password")
resp, err := client.Do(req)
assert.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
// all 3 comments here, but for id2 they deleted
res, code := get(t, ts.URL+"/api/v1/find?site=radio-t&url=https://radio-t.com/blah&sort=+time")
assert.Equal(t, 200, code)
commentsWithInfo := commentsWithInfo{}
err = json.Unmarshal([]byte(res), &commentsWithInfo)
assert.Nil(t, err)
assert.Equal(t, 3, len(commentsWithInfo.Comments), "should have 3 comment")
// id1 comment untouched
assert.Equal(t, id1, commentsWithInfo.Comments[0].ID)
assert.Equal(t, "o test test #1", commentsWithInfo.Comments[0].Orig)
assert.False(t, commentsWithInfo.Comments[0].Deleted)
t.Logf("%+v", commentsWithInfo.Comments[0].User)
// id2 comments fully deleted
assert.Equal(t, "", commentsWithInfo.Comments[1].Text)
assert.Equal(t, "", commentsWithInfo.Comments[1].Orig)
assert.Equal(t, store.User{Name: "deleted", ID: "deleted", Picture: "", Admin: false, Blocked: false, IP: ""}, commentsWithInfo.Comments[1].User)
assert.True(t, commentsWithInfo.Comments[1].Deleted)
assert.Equal(t, "", commentsWithInfo.Comments[2].Text)
assert.Equal(t, "", commentsWithInfo.Comments[2].Orig)
assert.Equal(t, store.User{Name: "deleted", ID: "deleted", Picture: "", Admin: false, Blocked: false, IP: ""}, commentsWithInfo.Comments[1].User)
assert.True(t, commentsWithInfo.Comments[2].Deleted)
} | explode_data.jsonl/70317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 983
} | [
2830,
3393,
7210,
57418,
1474,
1155,
353,
8840,
836,
8,
341,
1903,
10553,
11,
10591,
1669,
21327,
1155,
340,
6948,
93882,
1155,
11,
43578,
340,
16867,
21290,
35864,
692,
1444,
16,
1669,
3553,
56730,
90,
1178,
25,
330,
1944,
1273,
671,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLogsPathMatcher_InvalidSource4(t *testing.T) {
cfgLogsPath := "/var/lib/kubelet/pods/"
cfgResourceType := "pod"
source := fmt.Sprintf("/invalid/dir/%s/volumes/kubernetes.io~empty-dir/applogs/server.log", puid)
expectedResult := ""
executeTestWithResourceType(t, cfgLogsPath, cfgResourceType, source, expectedResult)
} | explode_data.jsonl/34421 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
51053,
1820,
37554,
62,
7928,
3608,
19,
1155,
353,
8840,
836,
8,
341,
50286,
51053,
1820,
1669,
3521,
947,
8194,
14109,
3760,
1149,
4322,
29697,
29555,
50286,
4783,
929,
1669,
330,
39073,
698,
47418,
1669,
8879,
17305,
4283,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreExists(t *testing.T) {
testWithPostgresStoreV2(t, func(s storev2.Interface) {
fixture := corev3.FixtureEntityState("foo")
ctx := context.Background()
req := storev2.NewResourceRequestFromResource(ctx, fixture)
req.UsePostgres = true
// Exists should return false
got, err := s.Exists(req)
if err != nil {
t.Fatal(err)
}
if want := false; got != want {
t.Errorf("got true, want false")
}
// Create a resource under the default namespace
wrapper := WrapEntityState(fixture)
// CreateIfNotExists should succeed
if err := s.CreateIfNotExists(req, wrapper); err != nil {
t.Fatal(err)
}
got, err = s.Exists(req)
if err != nil {
t.Fatal(err)
}
if want := true; got != want {
t.Errorf("got false, want true")
}
})
} | explode_data.jsonl/73385 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
6093,
15575,
1155,
353,
8840,
836,
8,
341,
18185,
2354,
4133,
17818,
6093,
53,
17,
1155,
11,
2915,
1141,
3553,
85,
17,
41065,
8,
341,
197,
1166,
12735,
1669,
6200,
85,
18,
991,
12735,
3030,
1397,
445,
7975,
1138,
197,
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... | 6 |
func TestJolokia2_ObjectValues(t *testing.T) {
config := `
[jolokia2_agent]
urls = ["%s"]
[[jolokia2_agent.metric]]
name = "object_without_attribute"
mbean = "object_without_attribute"
tag_keys = ["foo"]
[[jolokia2_agent.metric]]
name = "object_with_attribute"
mbean = "object_with_attribute"
paths = ["biz"]
[[jolokia2_agent.metric]]
name = "object_with_attribute_and_path"
mbean = "object_with_attribute_and_path"
paths = ["biz/baz"]
# This will generate two separate request objects.
[[jolokia2_agent.metric]]
name = "object_with_branching_paths"
mbean = "object_with_branching_paths"
paths = ["foo/fiz", "foo/faz"]
# This should return multiple series with different test tags.
[[jolokia2_agent.metric]]
name = "object_with_key_pattern"
mbean = "object_with_key_pattern:test=*"
tag_keys = ["test"]
[[jolokia2_agent.metric]]
name = "ColumnFamily"
mbean = "org.apache.cassandra.metrics:keyspace=*,name=EstimatedRowSizeHistogram,scope=schema_columns,type=ColumnFamily"
tag_keys = ["keyspace", "name", "scope"]`
response := `[{
"request": {
"mbean": "object_without_attribute",
"type": "read"
},
"value": {
"biz": 123,
"baz": 456
},
"status": 200
}, {
"request": {
"mbean": "object_with_attribute",
"attribute": "biz",
"type": "read"
},
"value": {
"fiz": 123,
"faz": 456
},
"status": 200
}, {
"request": {
"mbean": "object_with_branching_paths",
"attribute": "foo",
"path": "fiz",
"type": "read"
},
"value": {
"bing": 123
},
"status": 200
}, {
"request": {
"mbean": "object_with_branching_paths",
"attribute": "foo",
"path": "faz",
"type": "read"
},
"value": {
"bang": 456
},
"status": 200
}, {
"request": {
"mbean": "object_with_attribute_and_path",
"attribute": "biz",
"path": "baz",
"type": "read"
},
"value": {
"bing": 123,
"bang": 456
},
"status": 200
}, {
"request": {
"mbean": "object_with_key_pattern:test=*",
"type": "read"
},
"value": {
"object_with_key_pattern:test=foo": {
"fiz": 123
},
"object_with_key_pattern:test=bar": {
"biz": 456
}
},
"status": 200
}, {
"request": {
"mbean": "org.apache.cassandra.metrics:keyspace=*,name=EstimatedRowSizeHistogram,scope=schema_columns,type=ColumnFamily",
"type": "read"
},
"value": {
"org.apache.cassandra.metrics:keyspace=system,name=EstimatedRowSizeHistogram,scope=schema_columns,type=ColumnFamily": {
"Value": [
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
]
}
},
"status": 200
}]`
server := setupServer(http.StatusOK, response)
defer server.Close()
plugin := setupPlugin(t, fmt.Sprintf(config, server.URL))
var acc testutil.Accumulator
assert.NoError(t, plugin.Gather(&acc))
acc.AssertContainsTaggedFields(t, "object_without_attribute", map[string]interface{}{
"biz": 123.0,
"baz": 456.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "object_with_attribute", map[string]interface{}{
"biz.fiz": 123.0,
"biz.faz": 456.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "object_with_attribute_and_path", map[string]interface{}{
"biz.baz.bing": 123.0,
"biz.baz.bang": 456.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "object_with_branching_paths", map[string]interface{}{
"foo.fiz.bing": 123.0,
"foo.faz.bang": 456.0,
}, map[string]string{
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "object_with_key_pattern", map[string]interface{}{
"fiz": 123.0,
}, map[string]string{
"test": "foo",
"jolokia_agent_url": server.URL,
})
acc.AssertContainsTaggedFields(t, "object_with_key_pattern", map[string]interface{}{
"biz": 456.0,
}, map[string]string{
"test": "bar",
"jolokia_agent_url": server.URL,
})
} | explode_data.jsonl/5354 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2092
} | [
2830,
3393,
41,
337,
27552,
17,
27839,
6227,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
22074,
197,
3809,
337,
27552,
17,
25730,
921,
197,
19320,
82,
284,
4383,
4,
82,
25912,
197,
15505,
73,
337,
27552,
17,
25730,
85816,
14288,
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 TestNewMOfNRedeemScript(t *testing.T) {
testPublicKeyStrings := []string{
"0446f1c8de232a065da428bf76e44b41f59a46620dec0aedfc9b5ab651e91f2051d610fddc78b8eba38a634bfe9a74bb015a88c52b9b844c74997035e08a695ce9",
"04704e19d4fc234a42d707d41053c87011f990b564949532d72cab009e136bd60d7d0602f925fce79da77c0dfef4a49c6f44bd0540faef548e37557d74b36da124",
"04b75a8cb10fd3f1785addbafdb41b409ecd6ffd50d5ad71d8a3cdc5503bcb35d3d13cdf23f6d0eb6ab88446276e2ba5b92d8786da7e5c0fb63aafb62f87443d28",
}
testM := 2
testN := 3
testRedeemScriptHex := "52410446f1c8de232a065da428bf76e44b41f59a46620dec0aedfc9b5ab651e91f2051d610fddc78b8eba38a634bfe9a74bb015a88c52b9b844c74997035e08a695ce94104704e19d4fc234a42d707d41053c87011f990b564949532d72cab009e136bd60d7d0602f925fce79da77c0dfef4a49c6f44bd0540faef548e37557d74b36da1244104b75a8cb10fd3f1785addbafdb41b409ecd6ffd50d5ad71d8a3cdc5503bcb35d3d13cdf23f6d0eb6ab88446276e2ba5b92d8786da7e5c0fb63aafb62f87443d2853ae"
publicKeys := make([][]byte, len(testPublicKeyStrings))
for i, publicKeyString := range testPublicKeyStrings {
publicKeys[i], _ = hex.DecodeString(publicKeyString) //Get private keys as slice of raw bytes
}
redeemScript, err := NewMOfNRedeemScript(testM, testN, publicKeys)
if err != nil {
t.Error(err)
}
redeemScriptHex := hex.EncodeToString(redeemScript)
if redeemScriptHex != testRedeemScriptHex {
testutils.CompareError(t, "M-of-N redeem script different from expected script.", testRedeemScriptHex, redeemScriptHex)
}
} | explode_data.jsonl/67115 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 725
} | [
2830,
3393,
3564,
44,
2124,
45,
6033,
68,
336,
5910,
1155,
353,
8840,
836,
8,
341,
18185,
61822,
20859,
1669,
3056,
917,
515,
197,
197,
1,
15,
19,
19,
21,
69,
16,
66,
23,
450,
17,
18,
17,
64,
15,
21,
20,
3235,
19,
17,
23,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGetDimensionsAndOptionsReturnsInternalError(t *testing.T) {
t.Parallel()
Convey("Given an internal error is returned from mongo, then response returns an internal error", t, func() {
r, err := createRequestWithToken("GET", "http://localhost:21800/instances/123/dimensions", nil)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
mockedDataStore, isLocked := storeMockWithLock(false)
mockedDataStore.GetInstanceFunc = func(ctx context.Context, ID string, eTagSelector string) (*models.Instance, error) {
So(*isLocked, ShouldBeTrue)
return nil, errs.ErrInternalServer
}
datasetAPI := getAPIWithCMDMocks(testContext, mockedDataStore, &mocks.DownloadsGeneratorMock{})
datasetAPI.Router.ServeHTTP(w, r)
So(w.Code, ShouldEqual, http.StatusInternalServerError)
So(w.Body.String(), ShouldContainSubstring, errs.ErrInternalServer.Error())
So(mockedDataStore.GetInstanceCalls(), ShouldHaveLength, 1)
So(mockedDataStore.GetInstanceCalls()[0].ID, ShouldEqual, "123")
validateLock(mockedDataStore, "123")
So(*isLocked, ShouldBeFalse)
})
Convey("Given instance state is invalid, then response returns an internal error", t, func() {
r, err := createRequestWithToken("GET", "http://localhost:21800/instances/123/dimensions", nil)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
mockedDataStore, isLocked := storeMockWithLock(true)
mockedDataStore.GetInstanceFunc = func(ctx context.Context, ID string, eTagSelector string) (*models.Instance, error) {
So(*isLocked, ShouldBeTrue)
return &models.Instance{State: "gobbly gook"}, nil
}
datasetAPI := getAPIWithCMDMocks(testContext, mockedDataStore, &mocks.DownloadsGeneratorMock{})
datasetAPI.Router.ServeHTTP(w, r)
So(w.Code, ShouldEqual, http.StatusInternalServerError)
So(w.Body.String(), ShouldContainSubstring, errs.ErrInternalServer.Error())
So(mockedDataStore.GetInstanceCalls(), ShouldHaveLength, 1)
So(mockedDataStore.GetInstanceCalls()[0].ID, ShouldEqual, "123")
validateLock(mockedDataStore, "123")
So(*isLocked, ShouldBeFalse)
})
} | explode_data.jsonl/20842 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 735
} | [
2830,
3393,
1949,
21351,
3036,
3798,
16446,
11569,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
93070,
5617,
445,
22043,
458,
5306,
1465,
374,
5927,
504,
33814,
11,
1221,
2033,
4675,
458,
5306,
1465,
497,
259,
11,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_newBitString(t *testing.T) {
bs1 := e2sm_kpm_ies.BitString{
Value: 0x9ABCD4,
Len: 22,
}
xer1, err := xerEncodeBitString(&bs1)
assert.NilError(t, err)
//t.Logf("XER Bit String \n%s", xer1)
per1, err := perEncodeBitString(&bs1)
assert.NilError(t, err)
//t.Logf("PER Bit String \n%v", per1)
cBitString := newBitString(&bs1)
assert.Equal(t, 3, int(cBitString.size), "unexpected number of bits")
assert.Equal(t, 2, int(cBitString.bits_unused), "unexpected number of bits_unused")
// Can't do any further analysis as we can't have C in tests
// Now reverse it to get proto back out
bs2, err := decodeBitString(cBitString)
assert.NilError(t, err)
assert.Equal(t, uint32(22), bs2.Len)
assert.Equal(t, uint64(0x9ABCD4), bs2.Value)
xer2, err := xerEncodeBitString(bs2)
assert.NilError(t, err)
assert.DeepEqual(t, xer1, xer2)
t.Logf("XER Bit String \n%s", xer1)
per2, err := perEncodeBitString(bs2)
assert.NilError(t, err)
assert.DeepEqual(t, per1, per2)
t.Logf("PER Bit String \n%v", per2)
} | explode_data.jsonl/66717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 456
} | [
2830,
3393,
5921,
8344,
703,
1155,
353,
8840,
836,
8,
341,
93801,
16,
1669,
384,
17,
3563,
4698,
5187,
62,
550,
68866,
703,
515,
197,
47399,
25,
220,
15,
87,
24,
1867,
6484,
19,
345,
197,
197,
11271,
25,
256,
220,
17,
17,
345,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDefault(t *testing.T) {
for i, this := range []struct {
input interface{}
tpl string
expected string
ok bool
}{
{map[string]string{"foo": "bar"}, `{{ index . "foo" | default "nope" }}`, `bar`, true},
{map[string]string{"foo": "pop"}, `{{ index . "bar" | default "nada" }}`, `nada`, true},
{map[string]string{"foo": "cat"}, `{{ default "nope" .foo }}`, `cat`, true},
{map[string]string{"foo": "dog"}, `{{ default "nope" .foo "extra" }}`, ``, false},
{map[string]interface{}{"images": []string{}}, `{{ default "default.jpg" (index .images 0) }}`, `default.jpg`, true},
} {
tmpl, err := New().New("test").Parse(this.tpl)
if err != nil {
t.Errorf("[%d] unable to create new html template %q: %s", i, this.tpl, err)
continue
}
buf := new(bytes.Buffer)
err = tmpl.Execute(buf, this.input)
if (err == nil) != this.ok {
t.Errorf("[%d] execute template returned unexpected error: %s", i, err)
continue
}
if buf.String() != this.expected {
t.Errorf("[%d] execute template got %v, but expected %v", i, buf.String(), this.expected)
}
}
} | explode_data.jsonl/9247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 450
} | [
2830,
3393,
3675,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
419,
1669,
2088,
3056,
1235,
341,
197,
22427,
262,
3749,
16094,
197,
3244,
500,
414,
914,
198,
197,
42400,
914,
198,
197,
59268,
981,
1807,
198,
197,
59403,
197,
197,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_BatchKinds_Authorization(t *testing.T) {
type testCase struct {
methodName string
additionalArgs []interface{}
expectedVerb string
expectedResource string
}
tests := []testCase{
// testCase{
// methodName: "AddActions",
// additionalArgs: []interface{}{[]*models.Object{}, []*string{}},
// expectedVerb: "create",
// expectedResource: "batch/actions",
// },
{
methodName: "AddObjects",
additionalArgs: []interface{}{[]*models.Object{}, []*string{}},
expectedVerb: "create",
expectedResource: "batch/objects",
},
{
methodName: "AddReferences",
additionalArgs: []interface{}{[]*models.BatchReference{}},
expectedVerb: "update",
expectedResource: "batch/*",
},
}
t.Run("verify that a test for every public method exists", func(t *testing.T) {
testedMethods := make([]string, len(tests))
for i, test := range tests {
testedMethods[i] = test.methodName
}
for _, method := range allExportedMethods(&BatchManager{}) {
assert.Contains(t, testedMethods, method)
}
})
t.Run("verify the tested methods require correct permissions from the authorizer", func(t *testing.T) {
principal := &models.Principal{}
logger, _ := test.NewNullLogger()
for _, test := range tests {
schemaManager := &fakeSchemaManager{}
locks := &fakeLocks{}
cfg := &config.WeaviateConfig{}
authorizer := &authDenier{}
vectorRepo := &fakeVectorRepo{}
vectorizer := &fakeVectorizer{}
vecProvider := &fakeVectorizerProvider{vectorizer}
manager := NewBatchManager(vectorRepo, vecProvider, locks, schemaManager, cfg, logger, authorizer)
args := append([]interface{}{context.Background(), principal}, test.additionalArgs...)
out, _ := callFuncByName(manager, test.methodName, args...)
require.Len(t, authorizer.calls, 1, "authorizer must be called")
assert.Equal(t, errors.New("just a test fake"), out[len(out)-1].Interface(),
"execution must abort with authorizer error")
assert.Equal(t, authorizeCall{principal, test.expectedVerb, test.expectedResource},
authorizer.calls[0], "correct paramteres must have been used on authorizer")
}
})
} | explode_data.jsonl/43858 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 819
} | [
2830,
3393,
1668,
754,
42,
8673,
1566,
1553,
2022,
1155,
353,
8840,
836,
8,
341,
13158,
54452,
2036,
341,
197,
42257,
675,
981,
914,
198,
197,
12718,
3005,
4117,
256,
3056,
4970,
16094,
197,
42400,
66946,
257,
914,
198,
197,
42400,
47... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNamespaceAggregateTilesSkipIfNoShardsOwned(t *testing.T) {
ctrl := xtest.NewController(t)
defer ctrl.Finish()
ctx := context.NewBackground()
defer ctx.Close()
start := xtime.Now().Truncate(targetBlockSize)
opts, err := NewAggregateTilesOptions(
start, start.Add(targetBlockSize), time.Second, targetNsID, AggregateTilesRegular,
false, false, nil, insOpts)
require.NoError(t, err)
sourceNs, sourceCloser := newTestNamespaceWithIDOpts(t, sourceNsID, namespace.NewOptions())
defer sourceCloser()
sourceNs.bootstrapState = Bootstrapped
sourceRetentionOpts := sourceNs.nopts.RetentionOptions().SetBlockSize(sourceBlockSize)
sourceNs.nopts = sourceNs.nopts.SetRetentionOptions(sourceRetentionOpts)
targetNs, targetCloser := newTestNamespaceWithIDOpts(t, targetNsID, namespace.NewOptions())
defer targetCloser()
targetNs.bootstrapState = Bootstrapped
targetNs.createEmptyWarmIndexIfNotExistsFn = func(blockStart xtime.UnixNano) error {
return nil
}
targetRetentionOpts := targetNs.nopts.RetentionOptions().SetBlockSize(targetBlockSize)
targetNs.nopts = targetNs.nopts.SetColdWritesEnabled(true).SetRetentionOptions(targetRetentionOpts)
noShards := sharding.NewEmptyShardSet(sharding.DefaultHashFn(1))
targetNs.AssignShardSet(noShards)
processedTileCount, err := targetNs.AggregateTiles(ctx, sourceNs, opts)
require.NoError(t, err)
assert.Zero(t, processedTileCount)
} | explode_data.jsonl/35387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 489
} | [
2830,
3393,
22699,
64580,
58365,
35134,
2679,
2753,
2016,
2347,
57641,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
856,
1944,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
20985,
1669,
2266,
7121,
8706,
741,
16867,
5635,
10421,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTx_Commit_ErrTxNotWritable(t *testing.T) {
db := MustOpenDB()
defer db.MustClose()
tx, err := db.Begin(false)
if err != nil {
t.Fatal(err)
}
if err := tx.Commit(); err != bolt.ErrTxNotWritable {
t.Fatal(err)
}
// Close the view transaction
tx.Rollback()
} | explode_data.jsonl/1683 | {
"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,
31584,
16946,
1763,
93623,
31584,
2623,
39623,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
15465,
5002,
3506,
741,
16867,
2927,
50463,
7925,
741,
46237,
11,
1848,
1669,
2927,
28467,
3576,
340,
743,
1848,
961,
2092,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestReceiveIgnoreMissingFalse(t *testing.T) {
p := New().(*processor)
ctx := testutils.NewProcessorContext()
p.Configure(
ctx,
map[string]interface{}{
"Compare_Field": "toto",
"Ignore_missing": false,
},
)
p.Receive(testutils.NewPacketOld("test", map[string]interface{}{"toto": "A"}))
assert.Equal(t, 0, ctx.SentPacketsCount(0), "changed ! 1")
p.Receive(testutils.NewPacketOld("test", nil))
assert.Equal(t, 1, ctx.SentPacketsCount(0), "changed ! 2")
p.Receive(testutils.NewPacketOld("test", nil))
assert.Equal(t, 1, ctx.SentPacketsCount(0), "changed ! 3")
p.Receive(testutils.NewPacketOld("test", map[string]interface{}{"toto": "A"}))
assert.Equal(t, 2, ctx.SentPacketsCount(0), "changed ! 4")
p.Receive(testutils.NewPacketOld("test", map[string]interface{}{"toto": "A"}))
assert.Equal(t, 2, ctx.SentPacketsCount(0), "changed ! 5")
p.Receive(testutils.NewPacketOld("test", map[string]interface{}{"toto": "B"}))
assert.Equal(t, 3, ctx.SentPacketsCount(0), "changed ! 6")
p.Receive(testutils.NewPacketOld("test", nil))
assert.Equal(t, 4, ctx.SentPacketsCount(0), "changed ! 7")
} | explode_data.jsonl/74197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 461
} | [
2830,
3393,
14742,
12497,
25080,
4049,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1532,
1005,
4071,
29474,
340,
20985,
1669,
1273,
6031,
7121,
22946,
1972,
741,
3223,
78281,
1006,
197,
20985,
345,
197,
19567,
14032,
31344,
67066,
298,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNilEventName(t *testing.T) {
stub := ChaincodeStub{}
if err := stub.SetEvent("", []byte("event payload")); err == nil {
t.Error("Event name can not be nil string.")
}
} | explode_data.jsonl/10293 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
19064,
1556,
675,
1155,
353,
8840,
836,
8,
341,
18388,
392,
1669,
28525,
1851,
33838,
16094,
743,
1848,
1669,
13633,
4202,
1556,
19814,
3056,
3782,
445,
3087,
7729,
32596,
1848,
621,
2092,
341,
197,
3244,
6141,
445,
1556,
82... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestIterFn(t *testing.T) {
err := Newf("%v", "Turtles").WithContext(" all the way down.").WithTrace()
for i := 0; i < 1000; i++ {
err = Wrap(err).WithContext(" %d ", i)
}
et := err.(ErrMadNet)
fmt.Printf("%s\n", et)
} | explode_data.jsonl/54724 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
8537,
24911,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
1532,
69,
4430,
85,
497,
330,
51,
51114,
1827,
91101,
445,
678,
279,
1616,
1495,
98401,
2354,
6550,
741,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
15,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetSRVService(t *testing.T) {
tests := []struct {
scheme string
serviceName string
expected string
}{
{
"https",
"",
"etcd-client-ssl",
},
{
"http",
"",
"etcd-client",
},
{
"https",
"foo",
"etcd-client-ssl-foo",
},
{
"http",
"bar",
"etcd-client-bar",
},
}
for i, tt := range tests {
service := GetSRVService("etcd-client", tt.serviceName, tt.scheme)
if strings.Compare(service, tt.expected) != 0 {
t.Errorf("#%d: service = %s, want %s", i, service, tt.expected)
}
}
} | explode_data.jsonl/26138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
1949,
14557,
53,
1860,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
1903,
8058,
414,
914,
198,
197,
52934,
675,
914,
271,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
57557,
756,
298,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFailedUserRebaseRequestDueToValidations(t *testing.T) {
ctxOuter, cancel := testhelper.Context()
defer cancel()
server, serverSocketPath := runFullServer(t)
defer server.Stop()
client, conn := operations.NewOperationClient(t, serverSocketPath)
defer conn.Close()
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
testRepoCopy, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
user := &gitalypb.User{
Name: []byte("Ahmad Sherif"),
Email: []byte("ahmad@gitlab.com"),
GlId: "user-123",
}
testCases := []struct {
desc string
request *gitalypb.UserRebaseRequest
code codes.Code
}{
{
desc: "empty repository",
request: &gitalypb.UserRebaseRequest{
Repository: nil,
User: user,
RebaseId: "1",
Branch: []byte("some-branch"),
BranchSha: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e",
RemoteRepository: testRepoCopy,
RemoteBranch: []byte("master"),
},
code: codes.InvalidArgument,
},
{
desc: "empty user",
request: &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: nil,
RebaseId: "1",
Branch: []byte("some-branch"),
BranchSha: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e",
RemoteRepository: testRepoCopy,
RemoteBranch: []byte("master"),
},
code: codes.InvalidArgument,
},
{
desc: "empty rebase id",
request: &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: user,
RebaseId: "",
Branch: []byte("some-branch"),
BranchSha: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e",
RemoteRepository: testRepoCopy,
RemoteBranch: []byte("master"),
},
code: codes.InvalidArgument,
},
{
desc: "empty branch",
request: &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: user,
RebaseId: "1",
Branch: nil,
BranchSha: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e",
RemoteRepository: testRepoCopy,
RemoteBranch: []byte("master"),
},
code: codes.InvalidArgument,
},
{
desc: "empty branch sha",
request: &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: user,
RebaseId: "1",
Branch: []byte("some-branch"),
BranchSha: "",
RemoteRepository: testRepoCopy,
RemoteBranch: []byte("master"),
},
code: codes.InvalidArgument,
},
{
desc: "empty remote repository",
request: &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: user,
RebaseId: "1",
Branch: []byte("some-branch"),
BranchSha: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e",
RemoteRepository: nil,
RemoteBranch: []byte("master"),
},
code: codes.InvalidArgument,
},
{
desc: "empty remote branch",
request: &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: user,
RebaseId: "1",
Branch: []byte("some-branch"),
BranchSha: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e",
RemoteRepository: testRepoCopy,
RemoteBranch: nil,
},
code: codes.InvalidArgument,
},
}
for _, testCase := range testCases {
t.Run(testCase.desc, func(t *testing.T) {
md := testhelper.GitalyServersMetadata(t, serverSocketPath)
ctx := metadata.NewOutgoingContext(ctxOuter, md)
_, err := client.UserRebase(ctx, testCase.request)
testhelper.RequireGrpcError(t, err, testCase.code)
})
}
} | explode_data.jsonl/65109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1834
} | [
2830,
3393,
9408,
1474,
693,
3152,
1900,
33060,
1249,
4088,
804,
1155,
353,
8840,
836,
8,
341,
20985,
51322,
11,
9121,
1669,
1273,
18764,
9328,
741,
16867,
9121,
2822,
41057,
11,
3538,
10286,
1820,
1669,
1598,
9432,
5475,
1155,
340,
168... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMongo_Verified(t *testing.T) {
m, skip := prepMongo(t, true) // adds two comments
if skip {
return
}
assert.False(t, m.IsVerified("radio-t", "u1"), "nothing verified")
assert.NoError(t, m.SetVerified("radio-t", "u1", true))
assert.True(t, m.IsVerified("radio-t", "u1"), "u1 verified")
assert.False(t, m.IsVerified("radio-t", "u2"), "u2 still not verified")
assert.NoError(t, m.SetVerified("radio-t", "u1", false))
assert.False(t, m.IsVerified("radio-t", "u1"), "u1 not verified anymore")
assert.NotNil(t, m.SetVerified("bad", "u1", true), `site "bad" not found`)
assert.NoError(t, m.SetVerified("radio-t", "u1xyz", false))
assert.False(t, m.IsVerified("radio-t-bad", "u1"), "nothing verified on wrong site")
assert.NoError(t, m.SetVerified("radio-t", "u1", true))
assert.NoError(t, m.SetVerified("radio-t", "u2", true))
assert.NoError(t, m.SetVerified("radio-t", "u3", false))
ids, err := m.Verified("radio-t")
assert.NoError(t, err)
assert.Equal(t, []string{"u1", "u2"}, ids, "verified 2 ids")
ids, err = m.Verified("radio-t-bad")
assert.NoError(t, err)
assert.Equal(t, 0, len(ids))
} | explode_data.jsonl/54202 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 471
} | [
2830,
3393,
54998,
2334,
261,
1870,
1155,
353,
8840,
836,
8,
341,
2109,
11,
10706,
1669,
21327,
54998,
1155,
11,
830,
8,
442,
11367,
1378,
6042,
198,
743,
10706,
341,
197,
853,
198,
197,
532,
6948,
50757,
1155,
11,
296,
4506,
54558,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileServiceInstanceNonExistentClusterServicePlan(t *testing.T) {
_, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, noFakeActions())
sharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())
sharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())
sharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())
instance := &v1beta1.ServiceInstance{
ObjectMeta: metav1.ObjectMeta{
Name: testServiceInstanceName,
Generation: 1,
},
Spec: v1beta1.ServiceInstanceSpec{
PlanReference: v1beta1.PlanReference{
ClusterServiceClassExternalName: testClusterServiceClassName,
ClusterServicePlanExternalName: "nothere",
},
ClusterServiceClassRef: &v1beta1.ClusterObjectReference{
Name: testClusterServiceClassGUID,
},
ExternalID: testServiceInstanceGUID,
},
}
if err := reconcileServiceInstance(t, testController, instance); err == nil {
t.Fatal("The service plan nothere should not exist to be referenced.")
}
brokerActions := fakeClusterServiceBrokerClient.Actions()
assertNumberOfBrokerActions(t, brokerActions, 0)
// ensure that there are two actions, one to list plans and an action
// to set the condition on the instance to indicate that the service
// plan doesn't exist
actions := fakeCatalogClient.Actions()
assertNumberOfActions(t, actions, 2)
listRestrictions := clientgotesting.ListRestrictions{
Labels: labels.Everything(),
Fields: fields.ParseSelectorOrDie("spec.externalName=nothere,spec.clusterServiceBrokerName=test-clusterservicebroker,spec.clusterServiceClassRef.name=cscguid"),
}
assertList(t, actions[0], &v1beta1.ClusterServicePlan{}, listRestrictions)
updatedServiceInstance := assertUpdateStatus(t, actions[1], instance)
assertServiceInstanceErrorBeforeRequest(t, updatedServiceInstance, errorNonexistentClusterServicePlanReason, instance)
// check to make sure the only event sent indicated that the instance references a non-existent
// service plan
events := getRecordedEvents(testController)
expectedEvent := warningEventBuilder(errorNonexistentClusterServicePlanReason).msgf(
`References a non-existent ClusterServicePlan %b on ClusterServiceClass %s %c or there is more than one (found: 0)`,
instance.Spec.PlanReference, instance.Spec.ClusterServiceClassRef.Name, instance.Spec.PlanReference,
)
if err := checkEvents(events, expectedEvent.stringArr()); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/58131 | {
"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,
693,
40446,
457,
1860,
2523,
8121,
840,
18128,
28678,
1860,
20485,
1155,
353,
8840,
836,
8,
341,
197,
6878,
12418,
41606,
2959,
11,
12418,
28678,
1860,
65545,
2959,
11,
1273,
2051,
11,
6094,
37891,
388,
1669,
501,
2271,
2051... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCPUProfile(t *testing.T) {
testCPUProfile(t, []string{"runtime/pprof.cpuHog1"}, func(dur time.Duration) {
cpuHogger(cpuHog1, dur)
})
} | explode_data.jsonl/13648 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
31615,
8526,
1155,
353,
8840,
836,
8,
341,
18185,
31615,
8526,
1155,
11,
3056,
917,
4913,
22255,
87146,
299,
69,
42387,
39,
538,
16,
14345,
2915,
1500,
324,
882,
33795,
8,
341,
197,
80335,
39,
538,
1389,
48814,
39,
538,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFuncStateCheckpoint(t *testing.T) {
common.IsTesting = true
streamList := []string{"text"}
handleStream(false, streamList, t)
var tests = []ruleCheckpointTest{
{
ruleTest: ruleTest{
name: `TestFuncStateCheckpointRule1`,
sql: `SELECT accumulateWordCount(slogan, " ") as wc FROM text`,
r: [][]map[string]interface{}{
{{
"wc": float64(3),
}},
{{
"wc": float64(6),
}},
{{
"wc": float64(8),
}},
{{
"wc": float64(8),
}},
{{
"wc": float64(16),
}},
{{
"wc": float64(20),
}},
{{
"wc": float64(25),
}},
{{
"wc": float64(27),
}},
{{
"wc": float64(30),
}},
},
m: map[string]interface{}{
"op_preprocessor_text_0_exceptions_total": int64(0),
"op_preprocessor_text_0_process_latency_us": int64(0),
"op_preprocessor_text_0_records_in_total": int64(6),
"op_preprocessor_text_0_records_out_total": int64(6),
"op_project_0_exceptions_total": int64(0),
"op_project_0_process_latency_us": int64(0),
"op_project_0_records_in_total": int64(6),
"op_project_0_records_out_total": int64(6),
"sink_mockSink_0_exceptions_total": int64(0),
"sink_mockSink_0_records_in_total": int64(6),
"sink_mockSink_0_records_out_total": int64(6),
"source_text_0_exceptions_total": int64(0),
"source_text_0_records_in_total": int64(6),
"source_text_0_records_out_total": int64(6),
},
},
pauseSize: 3,
cc: 1,
pauseMetric: map[string]interface{}{
"op_preprocessor_text_0_exceptions_total": int64(0),
"op_preprocessor_text_0_process_latency_us": int64(0),
"op_preprocessor_text_0_records_in_total": int64(3),
"op_preprocessor_text_0_records_out_total": int64(3),
"op_project_0_exceptions_total": int64(0),
"op_project_0_process_latency_us": int64(0),
"op_project_0_records_in_total": int64(3),
"op_project_0_records_out_total": int64(3),
"sink_mockSink_0_exceptions_total": int64(0),
"sink_mockSink_0_records_in_total": int64(3),
"sink_mockSink_0_records_out_total": int64(3),
"source_text_0_exceptions_total": int64(0),
"source_text_0_records_in_total": int64(3),
"source_text_0_records_out_total": int64(3),
},
},
}
handleStream(true, streamList, t)
doCheckpointRuleTest(t, tests, 0, &api.RuleOption{
BufferLength: 100,
Qos: api.AtLeastOnce,
CheckpointInterval: 2000,
})
} | explode_data.jsonl/47455 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1327
} | [
2830,
3393,
9626,
1397,
92688,
1155,
353,
8840,
836,
8,
341,
83825,
4506,
16451,
284,
830,
198,
44440,
852,
1669,
3056,
917,
4913,
1318,
16707,
53822,
3027,
3576,
11,
4269,
852,
11,
259,
340,
2405,
7032,
284,
3056,
12937,
92688,
2271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRSAPSSVerify(t *testing.T) {
var err error
key, _ := ioutil.ReadFile("test/sample_key.pub")
var rsaPSSKey *rsa.PublicKey
if rsaPSSKey, err = jwt.ParseRSAPublicKeyFromPEM(key); err != nil {
t.Errorf("Unable to parse RSA public key: %v", err)
}
for _, data := range rsaPSSTestData {
parts := strings.Split(data.tokenString, ".")
method := jwt.GetSigningMethod(data.alg)
err := method.Verify(strings.Join(parts[0:2], "."), parts[2], rsaPSSKey)
if data.valid && err != nil {
t.Errorf("[%v] Error while verifying key: %v", data.name, err)
}
if !data.valid && err == nil {
t.Errorf("[%v] Invalid key passed validation", data.name)
}
}
} | explode_data.jsonl/10572 | {
"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,
11451,
2537,
1220,
32627,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
271,
23634,
11,
716,
1669,
43144,
78976,
445,
1944,
69851,
3097,
47773,
1138,
2405,
68570,
47,
1220,
1592,
353,
60869,
49139,
1592,
198,
743,
68570,
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... | 7 |
func TestExp(t *testing.T) {
tests := []struct{ base, exponent, result *big.Int }{
{base: big.NewInt(0), exponent: big.NewInt(0), result: big.NewInt(1)},
{base: big.NewInt(1), exponent: big.NewInt(0), result: big.NewInt(1)},
{base: big.NewInt(1), exponent: big.NewInt(1), result: big.NewInt(1)},
{base: big.NewInt(1), exponent: big.NewInt(2), result: big.NewInt(1)},
{base: big.NewInt(3), exponent: big.NewInt(144), result: MustParseBig256("507528786056415600719754159741696356908742250191663887263627442114881")},
{base: big.NewInt(2), exponent: big.NewInt(255), result: MustParseBig256("57896044618658097711785492504343953926634992332820282019728792003956564819968")},
}
for _, test := range tests {
if result := Exp(test.base, test.exponent); result.Cmp(test.result) != 0 {
t.Errorf("Exp(%d, %d) = %d, want %d", test.base, test.exponent, result, test.result)
}
}
} | explode_data.jsonl/35400 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
8033,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
90,
2331,
11,
27690,
11,
1102,
353,
16154,
7371,
335,
515,
197,
197,
90,
3152,
25,
2409,
7121,
1072,
7,
15,
701,
27690,
25,
2409,
7121,
1072,
7,
15,
701,
110... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDependencyOutputOptimizationSkipInit(t *testing.T) {
expectOutputLogs := []string{
`Detected module .*nested-optimization/dep/terragrunt.hcl is already init-ed. Retrieving outputs directly from working directory. prefix=\[.*fixture-get-output/nested-optimization/dep\]`,
}
dependencyOutputOptimizationTest(t, "nested-optimization", false, expectOutputLogs)
} | explode_data.jsonl/10126 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
36387,
5097,
21367,
65964,
35134,
3803,
1155,
353,
8840,
836,
8,
341,
24952,
5097,
51053,
1669,
3056,
917,
515,
197,
197,
63,
17076,
1569,
4688,
47409,
59271,
12,
19133,
2022,
14,
14891,
14,
465,
4101,
81,
3850,
860,
564,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTokensApprovedSucceedWithRetries(t *testing.T) {
em, cancel := newTestEventManagerWithMetrics(t)
defer cancel()
mdi := em.database.(*databasemocks.Plugin)
mti := &tokenmocks.Plugin{}
approval := newApproval()
approval.TX = fftypes.TransactionRef{}
pool := &fftypes.TokenPool{
Namespace: "ns1",
}
mdi.On("GetTokenPoolByProtocolID", em.ctx, "erc1155", "F1").Return(nil, fmt.Errorf("pop")).Once()
mdi.On("GetTokenPoolByProtocolID", em.ctx, "erc1155", "F1").Return(pool, nil).Times(2)
mdi.On("InsertBlockchainEvent", em.ctx, mock.MatchedBy(func(e *fftypes.BlockchainEvent) bool {
return e.Namespace == pool.Namespace && e.Name == approval.Event.Name
})).Return(nil).Times(2)
mdi.On("InsertEvent", em.ctx, mock.MatchedBy(func(ev *fftypes.Event) bool {
return ev.Type == fftypes.EventTypeBlockchainEvent && ev.Namespace == pool.Namespace
})).Return(nil).Times(2)
mdi.On("UpsertTokenApproval", em.ctx, &approval.TokenApproval).Return(fmt.Errorf("pop")).Once()
mdi.On("UpsertTokenApproval", em.ctx, &approval.TokenApproval).Return(nil).Times(1)
mdi.On("InsertEvent", em.ctx, mock.MatchedBy(func(ev *fftypes.Event) bool {
return ev.Type == fftypes.EventTypeApprovalConfirmed && ev.Reference == approval.LocalID && ev.Namespace == pool.Namespace
})).Return(nil).Once()
err := em.TokensApproved(mti, approval)
assert.NoError(t, err)
mdi.AssertExpectations(t)
mti.AssertExpectations(t)
} | explode_data.jsonl/15916 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 553
} | [
2830,
3393,
29300,
59651,
50,
29264,
2354,
12020,
4019,
1155,
353,
8840,
836,
8,
341,
66204,
11,
9121,
1669,
501,
2271,
83694,
2354,
27328,
1155,
340,
16867,
9121,
2822,
2109,
8579,
1669,
976,
15062,
41399,
67,
2096,
300,
336,
25183,
64... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileHelper_IsPathString_01(t *testing.T) {
fh := FileHelper{}
pathFile := fh.AdjustPathSlash("..\\..\\..\\")
expectedPathStr := fh.AdjustPathSlash("..\\..\\..\\")
isPath, cannotDetermine, testPathStr, err := fh.IsPathString(pathFile)
if err != nil {
t.Errorf("Error returned from fh.IsPathString(pathFile). "+
"pathFile='%v' Error='%v' ", pathFile, err.Error())
}
if true != isPath {
t.Errorf("Expected isPath='%v'. Instead, isPath='%v' "+
"testPathStr='%v' ", true, isPath, testPathStr)
}
if expectedPathStr != testPathStr {
t.Errorf("Error: Expected 'expectedPathStr'='%v'. Instead, 'expectedPathStr='%v'.",
expectedPathStr, testPathStr)
}
if false != cannotDetermine {
t.Errorf("Error: Expected 'cannotDetermine'='%v'. Instead, 'cannotDetermine'='%v' ",
false, cannotDetermine)
}
} | explode_data.jsonl/14506 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
1703,
5511,
31879,
1820,
703,
62,
15,
16,
1155,
353,
8840,
836,
8,
1476,
220,
36075,
1669,
2887,
5511,
16094,
220,
1815,
1703,
1669,
36075,
17865,
4250,
1820,
88004,
95032,
3422,
496,
3422,
496,
3422,
1138,
220,
3601,
1820,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestChunkedNoContent(t *testing.T) {
defer afterTest(t)
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
w.WriteHeader(StatusNoContent)
}))
defer ts.Close()
c := ts.Client()
for _, closeBody := range []bool{true, false} {
const n = 4
for i := 1; i <= n; i++ {
res, err := c.Get(ts.URL)
if err != nil {
t.Errorf("closingBody=%v, req %d/%d: %v", closeBody, i, n, err)
} else {
if closeBody {
res.Body.Close()
}
}
}
}
} | explode_data.jsonl/14101 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
28304,
291,
2753,
2762,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
57441,
1669,
54320,
70334,
7121,
5475,
7,
3050,
9626,
18552,
3622,
5949,
6492,
11,
435,
353,
1900,
8,
341,
197,
6692,
69794,
38866,
2753,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserLoginMFAFlow(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(c *model.Config) {
*c.ServiceSettings.EnableMultifactorAuthentication = true
})
t.Run("WithoutMFA", func(t *testing.T) {
_, _, err := th.Client.Login(th.BasicUser.Email, th.BasicUser.Password)
require.NoError(t, err)
})
t.Run("WithInvalidMFA", func(t *testing.T) {
secret, appErr := th.App.GenerateMfaSecret(th.BasicUser.Id)
assert.Nil(t, appErr)
// Fake user has MFA enabled
err := th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
require.NoError(t, err)
err = th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
require.NoError(t, err)
err = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
require.NoError(t, err)
user, _, err := th.Client.Login(th.BasicUser.Email, th.BasicUser.Password)
CheckErrorID(t, err, "mfa.validate_token.authenticate.app_error")
assert.Nil(t, user)
user, _, err = th.Client.LoginWithMFA(th.BasicUser.Email, th.BasicUser.Password, "")
CheckErrorID(t, err, "mfa.validate_token.authenticate.app_error")
assert.Nil(t, user)
user, _, err = th.Client.LoginWithMFA(th.BasicUser.Email, th.BasicUser.Password, "abcdefgh")
CheckErrorID(t, err, "mfa.validate_token.authenticate.app_error")
assert.Nil(t, user)
secret2, appErr := th.App.GenerateMfaSecret(th.BasicUser2.Id)
assert.Nil(t, appErr)
user, _, err = th.Client.LoginWithMFA(th.BasicUser.Email, th.BasicUser.Password, secret2.Secret)
CheckErrorID(t, err, "mfa.validate_token.authenticate.app_error")
assert.Nil(t, user)
})
t.Run("WithCorrectMFA", func(t *testing.T) {
secret, appErr := th.App.GenerateMfaSecret(th.BasicUser.Id)
assert.Nil(t, appErr)
// Fake user has MFA enabled
err := th.Server.Store.User().UpdateMfaActive(th.BasicUser.Id, true)
require.NoError(t, err)
err = th.Server.Store.User().UpdateMfaSecret(th.BasicUser.Id, secret.Secret)
require.NoError(t, err)
code := dgoogauth.ComputeCode(secret.Secret, time.Now().UTC().Unix()/30)
user, _, err := th.Client.LoginWithMFA(th.BasicUser.Email, th.BasicUser.Password, fmt.Sprintf("%06d", code))
require.NoError(t, err)
assert.NotNil(t, user)
})
} | explode_data.jsonl/47525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 916
} | [
2830,
3393,
1474,
6231,
44,
3627,
18878,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
70479,
5105,
16689,
2648,
18552,
1337,
353,
2528,
10753,
8,
341,
197,
197,
39091,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRangeCoalesce(t *testing.T) {
for _, test := range []struct {
rs Ranges
i int
want Ranges
}{
{
rs: Ranges{},
want: Ranges{},
},
{
rs: Ranges{
{Pos: 1, Size: 1},
},
want: Ranges{
{Pos: 1, Size: 1},
},
i: 0,
},
{
rs: Ranges{
{Pos: 1, Size: 1},
{Pos: 2, Size: 1},
{Pos: 3, Size: 1},
},
want: Ranges{
{Pos: 1, Size: 3},
},
i: 0,
},
{
rs: Ranges{
{Pos: 1, Size: 1},
{Pos: 3, Size: 1},
{Pos: 4, Size: 1},
{Pos: 5, Size: 1},
},
want: Ranges{
{Pos: 1, Size: 1},
{Pos: 3, Size: 3},
},
i: 2,
},
{
rs: Ranges{{38, 8}, {51, 10}, {60, 3}},
want: Ranges{{38, 8}, {51, 12}},
i: 1,
},
} {
got := append(Ranges{}, test.rs...)
got.coalesce(test.i)
what := fmt.Sprintf("test rs=%v, i=%d", test.rs, test.i)
assert.Equal(t, test.want, got, what)
checkRanges(t, got, what)
}
} | explode_data.jsonl/2638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 541
} | [
2830,
3393,
6046,
7339,
73250,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
41231,
256,
431,
5520,
198,
197,
8230,
262,
526,
198,
197,
50780,
431,
5520,
198,
197,
59403,
197,
197,
515,
298,
41231,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSumInt(t *testing.T) {
sum := SumInt(1, 2, 3, 4, 5)
if sum != 15 {
t.Errorf("Expected 15 got %d", sum)
}
} | explode_data.jsonl/75161 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
9190,
1072,
1155,
353,
8840,
836,
8,
341,
31479,
1669,
8116,
1072,
7,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
340,
743,
2629,
961,
220,
16,
20,
341,
197,
3244,
13080,
445,
18896,
220,
16,
20,
2684,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue28106(t *testing.T) {
testenv.NeedsGoPackages(t)
// In go1.10, go/packages loads all packages from source, not
// export data, but does not type check function bodies of
// imported packages. This test ensures that we do not attempt
// to run the SSA builder on functions without type information.
cfg := &packages.Config{Mode: packages.LoadSyntax}
pkgs, err := packages.Load(cfg, "runtime")
if err != nil {
t.Fatal(err)
}
prog, _ := ssautil.Packages(pkgs, ssa.BuilderMode(0))
prog.Build() // no crash
} | explode_data.jsonl/14824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
42006,
17,
23,
16,
15,
21,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
2067,
68,
6767,
10850,
69513,
1155,
692,
197,
322,
758,
728,
16,
13,
16,
15,
11,
728,
72919,
20907,
678,
14185,
504,
2530,
11,
537,
198,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestValidateVirtualServerRouteHost(t *testing.T) {
virtualServerHost := "example.com"
validHost := "example.com"
allErrs := validateVirtualServerRouteHost(validHost, virtualServerHost, field.NewPath("host"))
if len(allErrs) > 0 {
t.Errorf("validateVirtualServerRouteHost() returned errors %v for valid input", allErrs)
}
invalidHost := "foo.example.com"
allErrs = validateVirtualServerRouteHost(invalidHost, virtualServerHost, field.NewPath("host"))
if len(allErrs) == 0 {
t.Errorf("validateVirtualServerRouteHost() returned no errors for invalid input")
}
} | explode_data.jsonl/65856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
17926,
33026,
5475,
4899,
9296,
1155,
353,
8840,
836,
8,
341,
9558,
5475,
9296,
1669,
330,
8687,
905,
1837,
56322,
9296,
1669,
330,
8687,
905,
1837,
50960,
7747,
82,
1669,
9593,
33026,
5475,
4899,
9296,
41529,
9296,
11,
4108... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSet(t *testing.T) {
for _, a := range sumNN {
z := nat(nil).set(a.z)
if z.cmp(a.z) != 0 {
t.Errorf("got z = %v; want %v", z, a.z)
}
}
} | explode_data.jsonl/2181 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
1649,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
264,
1669,
2088,
2629,
9745,
341,
197,
20832,
1669,
17588,
27907,
568,
746,
2877,
3938,
340,
197,
743,
1147,
520,
1307,
2877,
3938,
8,
961,
220,
15,
341,
298,
3244,
13080,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStats(t *testing.T) {
t.Run("Test Stats with empty bitmap", func(t *testing.T) {
expectedStats := roaring.Statistics{}
rr := NewBitmap()
assert.EqualValues(t, expectedStats, rr.Stats())
})
t.Run("Test Stats with bitmap Container", func(t *testing.T) {
// Given a bitmap that should have a single bitmap container
expectedStats := roaring.Statistics{
Cardinality: 60000,
Containers: 1,
BitmapContainers: 1,
BitmapContainerValues: 60000,
BitmapContainerBytes: 8192,
RunContainers: 0,
RunContainerBytes: 0,
RunContainerValues: 0,
}
rr := NewBitmap()
for i := uint64(0); i < 60000; i++ {
rr.Add(i)
}
assert.EqualValues(t, expectedStats, rr.Stats())
})
t.Run("Test Stats with Array Container", func(t *testing.T) {
// Given a bitmap that should have a single array container
expectedStats := roaring.Statistics{
Cardinality: 2,
Containers: 1,
ArrayContainers: 1,
ArrayContainerValues: 2,
ArrayContainerBytes: 4,
}
rr := NewBitmap()
rr.Add(2)
rr.Add(4)
assert.EqualValues(t, expectedStats, rr.Stats())
})
} | explode_data.jsonl/20347 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 446
} | [
2830,
3393,
16635,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2271,
29927,
448,
4287,
19746,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
42400,
16635,
1669,
92756,
53419,
5589,
16094,
197,
197,
634,
1669,
1532,
16773,
2822,
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 TestCephPoolName(t *testing.T) {
t.Run("spec not set", func(t *testing.T) {
p := cephv1.CephBlockPool{ObjectMeta: metav1.ObjectMeta{Name: "metapool"}}
name := getCephName(p)
assert.Equal(t, "metapool", name)
})
t.Run("same name already set", func(t *testing.T) {
p := cephv1.CephBlockPool{ObjectMeta: metav1.ObjectMeta{Name: "metapool"}, Spec: cephv1.NamedBlockPoolSpec{Name: "metapool"}}
name := getCephName(p)
assert.Equal(t, "metapool", name)
})
t.Run("override device metrics", func(t *testing.T) {
p := cephv1.CephBlockPool{ObjectMeta: metav1.ObjectMeta{Name: "device-metrics"}, Spec: cephv1.NamedBlockPoolSpec{Name: "device_health_metrics"}}
name := getCephName(p)
assert.Equal(t, "device_health_metrics", name)
})
t.Run("override nfs", func(t *testing.T) {
p := cephv1.CephBlockPool{ObjectMeta: metav1.ObjectMeta{Name: "default-nfs"}, Spec: cephv1.NamedBlockPoolSpec{Name: ".nfs"}}
name := getCephName(p)
assert.Equal(t, ".nfs", name)
})
} | explode_data.jsonl/62474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
34,
23544,
10551,
675,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
9535,
537,
738,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3223,
1669,
272,
23544,
85,
16,
727,
23544,
4713,
10551,
90,
1190,
12175,
25,
77520,
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 TestClient_secureConfigAndReattach(t *testing.T) {
config := &ClientConfig{
SecureConfig: &SecureConfig{},
Reattach: &ReattachConfig{},
}
c := NewClient(config)
defer c.Kill()
_, err := c.Start()
if err != ErrSecureConfigAndReattach {
t.Fatalf("err should not be %s, got %s", ErrSecureConfigAndReattach, err)
}
} | explode_data.jsonl/57854 | {
"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,
2959,
73088,
2648,
3036,
693,
16330,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
609,
2959,
2648,
515,
197,
7568,
76108,
2648,
25,
609,
49813,
2648,
38837,
197,
197,
693,
16330,
25,
257,
609,
693,
16330,
2648,
38837,
197,
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... | 2 |
func TestBadStructs(t *testing.T) {
val := "i_am_not_a_struct"
wantErr := errNotStruct(val)
if _, gotErr := InsertStruct("t_test", val); !reflect.DeepEqual(gotErr, wantErr) {
t.Errorf("InsertStruct(%q) returns error %v, want %v", val, gotErr, wantErr)
}
if _, gotErr := InsertOrUpdateStruct("t_test", val); !reflect.DeepEqual(gotErr, wantErr) {
t.Errorf("InsertOrUpdateStruct(%q) returns error %v, want %v", val, gotErr, wantErr)
}
if _, gotErr := UpdateStruct("t_test", val); !reflect.DeepEqual(gotErr, wantErr) {
t.Errorf("UpdateStruct(%q) returns error %v, want %v", val, gotErr, wantErr)
}
if _, gotErr := ReplaceStruct("t_test", val); !reflect.DeepEqual(gotErr, wantErr) {
t.Errorf("ReplaceStruct(%q) returns error %v, want %v", val, gotErr, wantErr)
}
} | explode_data.jsonl/50036 | {
"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,
17082,
9422,
82,
1155,
353,
8840,
836,
8,
341,
19302,
1669,
330,
72,
22880,
7913,
4306,
15126,
698,
50780,
7747,
1669,
1848,
2623,
9422,
9098,
340,
743,
8358,
2684,
7747,
1669,
17101,
9422,
445,
83,
4452,
497,
1044,
1215,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDashboardID(t *testing.T) {
testData := []struct {
Input string
Error bool
Expected *DashboardId
}{
{
// empty
Input: "",
Error: true,
},
{
// missing SubscriptionId
Input: "/",
Error: true,
},
{
// missing value for SubscriptionId
Input: "/subscriptions/",
Error: true,
},
{
// missing ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/",
Error: true,
},
{
// missing value for ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/",
Error: true,
},
{
// missing Name
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Portal/",
Error: true,
},
{
// missing value for Name
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Portal/dashboards/",
Error: true,
},
{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Portal/dashboards/dashboard1",
Expected: &DashboardId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "group1",
Name: "dashboard1",
},
},
{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/GROUP1/PROVIDERS/MICROSOFT.PORTAL/DASHBOARDS/DASHBOARD1",
Error: true,
},
}
for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)
actual, err := DashboardID(v.Input)
if err != nil {
if v.Error {
continue
}
t.Fatalf("Expect a value but got an error: %s", err)
}
if v.Error {
t.Fatal("Expect an error but didn't get one")
}
if actual.SubscriptionId != v.Expected.SubscriptionId {
t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId)
}
if actual.ResourceGroup != v.Expected.ResourceGroup {
t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup)
}
if actual.Name != v.Expected.Name {
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name)
}
}
} | explode_data.jsonl/40731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 951
} | [
2830,
3393,
26947,
915,
1155,
353,
8840,
836,
8,
341,
18185,
1043,
1669,
3056,
1235,
341,
197,
66588,
262,
914,
198,
197,
58421,
262,
1807,
198,
197,
197,
18896,
353,
26947,
764,
198,
197,
92,
4257,
197,
197,
515,
298,
197,
322,
428... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateV1Beta1ValidWithMinimalChart(t *testing.T) {
manifest := `---
apiVersion: manifests/v1beta1
metadata:
name: test-manifest
spec:
charts:
- name: chart1
namespace: default
version: 0.0.1
`
_, err := Validate(manifest)
if err != nil {
t.Errorf("Got unexpected error from manifest.TestValidateV1Beta1ValidWithMinimalChart(): %s", err)
}
} | explode_data.jsonl/80472 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
17926,
53,
16,
64811,
16,
4088,
2354,
88328,
14488,
1155,
353,
8840,
836,
8,
341,
197,
42315,
1669,
1565,
10952,
2068,
5637,
25,
83232,
5457,
16,
19127,
16,
198,
17637,
510,
220,
829,
25,
1273,
20477,
6962,
198,
9535,
510,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestArray_Pad(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []interface{}{0}
array1 := garray.NewArrayFrom(a1)
t.Assert(array1.Pad(3, 1).Slice(), []interface{}{0, 1, 1})
t.Assert(array1.Pad(-4, 1).Slice(), []interface{}{1, 0, 1, 1})
t.Assert(array1.Pad(3, 1).Slice(), []interface{}{1, 0, 1, 1})
})
} | explode_data.jsonl/13902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
1857,
1088,
329,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
4970,
6257,
90,
15,
532,
197,
11923,
16,
1669,
342,
1653,
7121,
1857,
3830,
2877,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLastIndexRune(t *testing.T) {
cs := []struct {
w int
s string
b rune
}{
{3, "aabbcc", 'b'},
{9, "一一二二うう", '二'},
}
for i, c := range cs {
a := LastIndexRune(c.s, c.b)
if a != c.w {
t.Errorf("[%d] LastIndexRune(%q, %q) = %v, want %v", i, c.s, c.b, a, c.w)
}
}
} | explode_data.jsonl/80916 | {
"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,
5842,
1552,
49,
2886,
1155,
353,
8840,
836,
8,
341,
71899,
1669,
3056,
1235,
341,
197,
6692,
526,
198,
197,
1903,
914,
198,
197,
2233,
63499,
198,
197,
59403,
197,
197,
90,
18,
11,
330,
64,
12523,
638,
497,
364,
65,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRootParseExecutable(t *testing.T) {
root := setupSchema(t)
for src, expect := range map[string]string{
"{ title }": `query {
title
}
`,
"\xef\xbb\xbf{ title }": `query {
title
}
`,
"query getTitle { title }": `query getTitle {
title
}
`,
"{ alien: title }": `query {
alien: title
}
`,
"{artists{name}}": `query {
artists {
name
}
}
`,
`{artist(name:"Frazerdaze"){name}}`: `query {
artist(name: "Frazerdaze") {
name
}
}
`,
`query artistName($id: String = "Who"){artist(name:$id){name}}`: `query artistName($id: String = "Who") {
artist(name: $id) {
name
}
}
`,
`query artistName($id:String="Who"@example){artist(name:$id){name}}`: `query artistName($id: String = "Who" @example) {
artist(name: $id) {
name
}
}
`,
`{artists{name, ...{songs}}}`: `query {
artists {
name
... {
songs
}
}
}
`,
`{artists{name, ...on Artist{songs}}}`: `query {
artists {
name
... on Artist {
songs
}
}
}
`,
`{artists{name, ...sung}} fragment sung on Artist {songs}`: `query {
artists {
name
...sung
}
}
fragment sung on Artist {
songs
}
`,
`fragment sung on Artist {songs} {artists{name, ...sung}}`: `query {
artists {
name
...sung
}
}
fragment sung on Artist {
songs
}
`,
`{artists{name, ...sung}} fragment sung on Artist {songs} fragment where on Artist {origin}`: `query {
artists {
name
...sung
}
}
fragment sung on Artist {
songs
}
fragment where on Artist {
origin
}
`,
`{artists{name, ...sung ...where}} fragment sung on Artist {songs} fragment where on Artist {origin}`: `query {
artists {
name
...sung
...where
}
}
fragment sung on Artist {
songs
}
fragment where on Artist {
origin
}
`,
} {
exe, err := root.ParseExecutableString(src)
checkNil(t, err, "ParseExecutableString(%s) failed. %s", src, err)
checkEqual(t, expect, exe.String(), "result mismatch for %s", src)
}
} | explode_data.jsonl/48187 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 827
} | [
2830,
3393,
8439,
14463,
94772,
1155,
353,
8840,
836,
8,
341,
33698,
1669,
6505,
8632,
1155,
692,
2023,
2286,
11,
1720,
1669,
2088,
2415,
14032,
30953,
515,
197,
197,
14129,
2265,
335,
788,
1565,
1631,
341,
220,
2265,
198,
532,
12892,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateBuilderIncludeExplicitInfoIfEnabled(t *testing.T) {
var tests = map[string]struct {
IncludeInfo map[types.IncludeInfoKey]bool
expectedExplicitCount int
}{
"include all": {
IncludeInfo: map[types.IncludeInfoKey]bool{
types.IncludeAllInfo: true,
},
expectedExplicitCount: 1,
},
"exclude all": {
IncludeInfo: map[types.IncludeInfoKey]bool{
types.IncludeAllInfo: false,
},
expectedExplicitCount: 0,
},
"include *": {
IncludeInfo: map[types.IncludeInfoKey]bool{
"*": true,
},
expectedExplicitCount: 1,
},
"exclude *": {
IncludeInfo: map[types.IncludeInfoKey]bool{
"*": false,
},
expectedExplicitCount: 0,
},
"include none": {
IncludeInfo: map[types.IncludeInfoKey]bool{},
expectedExplicitCount: 0,
},
"include nil": {
expectedExplicitCount: 0,
},
"include explicit": {
IncludeInfo: map[types.IncludeInfoKey]bool{
types.IncludeExplicitInfo: true,
},
expectedExplicitCount: 1,
},
"exclude explicit": {
IncludeInfo: map[types.IncludeInfoKey]bool{
types.IncludeExplicitInfo: false,
},
expectedExplicitCount: 0,
},
}
for name, mock := range tests {
name := name
mock := mock
t.Run(name, func(t *testing.T) {
b := &UpdateStatesBuilder{
Request: UpdateRequest{
IncludeInfo: mock.IncludeInfo,
},
Result: &types.Result{},
}
b.includeExplicitInfoIfEnabled(&unstructured.Unstructured{
Object: map[string]interface{}{
"kind": "Pod",
"apiVersion": "v1",
"metadata": map[string]interface{}{
"name": "my-pod",
"namespace": "my-ns",
},
},
}, "Explicit info")
if mock.expectedExplicitCount != len(b.Result.ExplicitResourcesInfo) {
t.Fatalf(
"Expected explicit count %d got %d",
mock.expectedExplicitCount,
len(b.Result.ExplicitResourcesInfo),
)
}
})
}
} | explode_data.jsonl/54335 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 855
} | [
2830,
3393,
4289,
3297,
22283,
98923,
1731,
2679,
5462,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
2415,
14032,
60,
1235,
341,
197,
197,
22283,
1731,
1843,
2415,
58,
9242,
55528,
1731,
1592,
96436,
198,
197,
42400,
98923,
2507,
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... | 2 |
func TestCollectorAutoscalersSetMaxReplicas(t *testing.T) {
// prepare
maxReplicas := int32(2)
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.Collector.MaxReplicas = &maxReplicas
c := NewCollector(jaeger)
// test
a := c.Autoscalers()
// verify
assert.Len(t, a, 1)
assert.Equal(t, maxReplicas, a[0].Spec.MaxReplicas)
} | explode_data.jsonl/59537 | {
"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,
53694,
19602,
436,
5416,
388,
1649,
5974,
18327,
52210,
1155,
353,
8840,
836,
8,
341,
197,
322,
10549,
198,
22543,
18327,
52210,
1669,
526,
18,
17,
7,
17,
340,
197,
5580,
1878,
1669,
348,
16,
7121,
52445,
1878,
52613,
9893... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExecUpdateNode(t *testing.T) {
db, mock, err := sqlmock.New()
require.NoError(t, err)
mock.ExpectBegin()
mock.ExpectExec(escape("UPDATE `users` SET `age` = ?, `name` = ? WHERE `id` = ?")).
WithArgs(30, "Ariel", 1).
WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectCommit()
err = UpdateNode(context.Background(), sql.OpenDB("", db), &UpdateSpec{
Node: &NodeSpec{
Table: "users",
Columns: []string{"id", "name", "age"},
ID: &FieldSpec{Column: "id", Type: field.TypeInt, Value: 1},
},
Fields: FieldMut{
Set: []*FieldSpec{
{Column: "age", Type: field.TypeInt, Value: 30},
{Column: "name", Type: field.TypeString, Value: "Ariel"},
},
},
})
require.NoError(t, err)
} | explode_data.jsonl/41709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
10216,
4289,
1955,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
1848,
1669,
5704,
16712,
7121,
741,
17957,
35699,
1155,
11,
1848,
340,
77333,
81893,
11135,
741,
77333,
81893,
10216,
7,
12998,
445,
9239,
1565,
4218,
63,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAnalyze(t *testing.T) {
testCases := []analyzeTestCase{
analyzeTestCase{},
}
for _, testCase := range testCases {
kubeClient := &fakekube.Client{
Client: fake.NewSimpleClientset(),
}
analyzer := NewAnalyzer(kubeClient, log.Discard)
err := analyzer.Analyze(testCase.namespace, Options{Wait: testCase.noWait})
if testCase.expectedErr == "" {
assert.NilError(t, err, "Error in testCase %s", testCase.name)
} else {
assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name)
}
}
} | explode_data.jsonl/45354 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
2082,
55856,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
93221,
16458,
515,
197,
197,
93221,
16458,
38837,
197,
630,
2023,
8358,
54452,
1669,
2088,
1273,
37302,
341,
197,
16463,
3760,
2959,
1669,
609,
30570,
97717,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDisallowOnEmptyConsent(t *testing.T) {
perms := permissionsImpl{
cfg: config.GDPR{
HostVendorID: 3,
DefaultValue: "0",
},
gdprDefaultValue: SignalNo,
vendorIDs: nil,
fetchVendorList: map[uint8]func(ctx context.Context, id uint16) (vendorlist.VendorList, error){
tcf2SpecVersion: failedListFetcher,
},
}
allowSync, err := perms.BidderSyncAllowed(context.Background(), openrtb_ext.BidderAppnexus, SignalYes, "")
assertBoolsEqual(t, false, allowSync)
assertNilErr(t, err)
allowSync, err = perms.HostCookiesAllowed(context.Background(), SignalYes, "")
assertBoolsEqual(t, false, allowSync)
assertNilErr(t, err)
} | explode_data.jsonl/31087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
87854,
1925,
3522,
15220,
306,
1155,
353,
8840,
836,
8,
341,
197,
87772,
1669,
8541,
9673,
515,
197,
50286,
25,
2193,
1224,
35,
6480,
515,
298,
197,
9296,
44691,
915,
25,
220,
18,
345,
298,
197,
41533,
25,
330,
15,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_packetConn_handleStats(t *testing.T) {
tests := []struct {
name string
noCumulative bool
stats []unix.TpacketStats
out []Stats
}{
{
name: "no cumulative",
noCumulative: true,
stats: []unix.TpacketStats{
// Expect these exact outputs.
{Packets: 1, Drops: 1},
{Packets: 2, Drops: 2},
},
out: []Stats{
{Packets: 1, Drops: 1},
{Packets: 2, Drops: 2},
},
},
{
name: "cumulative",
stats: []unix.TpacketStats{
// Expect accumulation of structures.
{Packets: 1, Drops: 1},
{Packets: 2, Drops: 2},
},
out: []Stats{
{Packets: 1, Drops: 1},
{Packets: 3, Drops: 3},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := &packetConn{noCumulativeStats: tt.noCumulative}
if diff := cmp.Diff(len(tt.stats), len(tt.out)); diff != "" {
t.Fatalf("unexpected number of test cases (-want +got):\n%s", diff)
}
for i := 0; i < len(tt.stats); i++ {
out := *p.handleStats(&tt.stats[i])
if diff := cmp.Diff(tt.out[i], out); diff != "" {
t.Fatalf("unexpected Stats[%02d] (-want +got):\n%s", i, diff)
}
}
})
}
} | explode_data.jsonl/35216 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 584
} | [
2830,
3393,
21078,
9701,
10630,
16635,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
72104,
85805,
22160,
1807,
198,
197,
79659,
286,
3056,
56646,
836,
24829,
16635,
198,
197,
13967,
688,
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 TestOutbreakEventsForTimeRange(t *testing.T) {
db, mock, _ := sqlmock.New(sqlmock.QueryMatcherOption(sqlmock.QueryMatcherEqual))
defer db.Close()
locationID := "ABCDEFGH"
startTime := time.Unix(1613238163, 0)
endTime := time.Unix(1613324563, 0)
severity := uint32(1)
query := `SELECT location_id, start_time, end_time, severity FROM qr_outbreak_events
WHERE created >= ?
AND created < ?
ORDER BY location_id
`
row := sqlmock.NewRows([]string{"location_id", "start_time", "end_time", "severity"}).AddRow(locationID, startTime, endTime, severity)
mock.ExpectQuery(query).WithArgs(
startTime,
endTime).WillReturnRows(row)
expectedResult := locationID
rows, _ := outbreakEventsForTimeRange(db, startTime, endTime)
var receivedResult string
for rows.Next() {
rows.Scan(&receivedResult, nil, nil, nil)
}
assert.Equal(t, expectedResult, receivedResult, "Expected rows for the query")
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled expectations: %s", err)
}
} | explode_data.jsonl/64737 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
2662,
8960,
7900,
2461,
1462,
6046,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
716,
1669,
5704,
16712,
7121,
13148,
16712,
15685,
37554,
5341,
13148,
16712,
15685,
37554,
2993,
1171,
16867,
2927,
10421,
2822,
53761,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestManagerImpl(t *testing.T) {
lf, rl := NewRAMLedgerAndFactory(10)
consenters := make(map[string]consensus.Consenter)
consenters[conf.Orderer.OrdererType] = &mockConsenter{}
manager := NewRegistrar(lf, consenters, mockCrypto())
_, ok := manager.GetChain("Fake")
assert.False(t, ok, "Should not have found a chain that was not created")
chainSupport, ok := manager.GetChain(genesisconfig.TestChainID)
assert.True(t, ok, "Should have gotten chain which was initialized by ramledger")
messages := make([]*cb.Envelope, conf.Orderer.BatchSize.MaxMessageCount)
for i := 0; i < int(conf.Orderer.BatchSize.MaxMessageCount); i++ {
messages[i] = makeNormalTx(genesisconfig.TestChainID, i)
}
for _, message := range messages {
chainSupport.Order(message, 0)
}
it, _ := rl.Iterator(&ab.SeekPosition{Type: &ab.SeekPosition_Specified{Specified: &ab.SeekSpecified{Number: 1}}})
defer it.Close()
block, status := it.Next()
assert.Equal(t, cb.Status_SUCCESS, status, "Could not retrieve block")
for i := 0; i < int(conf.Orderer.BatchSize.MaxMessageCount); i++ {
assert.True(t, proto.Equal(messages[i], utils.ExtractEnvelopeOrPanic(block, i)), "Block contents wrong at index %d", i)
}
} | explode_data.jsonl/71399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 438
} | [
2830,
3393,
2043,
9673,
1155,
353,
8840,
836,
8,
341,
8810,
69,
11,
38877,
1669,
1532,
49,
31102,
291,
1389,
3036,
4153,
7,
16,
15,
692,
197,
6254,
306,
388,
1669,
1281,
9147,
14032,
60,
6254,
13626,
94594,
1950,
340,
197,
6254,
306... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateRegisteredAttributes(t *testing.T) {
origAttributes := []*ecs.Attribute{
{Name: aws.String("foo"), Value: aws.String("bar")},
{Name: aws.String("baz"), Value: aws.String("quux")},
{Name: aws.String("no_value"), Value: aws.String("")},
}
actualAttributes := []*ecs.Attribute{
{Name: aws.String("baz"), Value: aws.String("quux")},
{Name: aws.String("foo"), Value: aws.String("bar")},
{Name: aws.String("no_value"), Value: aws.String("")},
{Name: aws.String("ecs.internal-attribute"), Value: aws.String("some text")},
}
assert.NoError(t, validateRegisteredAttributes(origAttributes, actualAttributes))
origAttributes = append(origAttributes, &ecs.Attribute{Name: aws.String("abc"), Value: aws.String("xyz")})
assert.Error(t, validateRegisteredAttributes(origAttributes, actualAttributes))
} | explode_data.jsonl/61447 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
17926,
41430,
10516,
1155,
353,
8840,
836,
8,
341,
197,
4670,
10516,
1669,
29838,
53717,
33775,
515,
197,
197,
63121,
25,
31521,
6431,
445,
7975,
3975,
5162,
25,
31521,
6431,
445,
2257,
79583,
197,
197,
63121,
25,
31521,
643... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCases(t *testing.T) {
names, err := filepath.Glob("testdata/*.xsd")
if err != nil {
t.Fatal(err)
}
for _, filename := range names {
base := filename[:len(filename)-len(".xsd")]
schema, docs := parseFragment(t, base+".xsd")
answer := parseAnswer(t, base+".json")
testCase := test{schema, answer}
if !t.Run(filepath.Base(base), testCase.Test) {
t.Logf("subtest in %s.json failed", base)
t.Logf("normalized XSDs:")
for _, doc := range docs {
if doc.Attr("", "targetNamespace") == "tns" {
t.Logf("\n%s", xmltree.MarshalIndent(doc, "", " "))
}
}
}
}
} | explode_data.jsonl/22718 | {
"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,
37302,
1155,
353,
8840,
836,
8,
341,
93940,
11,
1848,
1669,
26054,
1224,
1684,
445,
92425,
23540,
82370,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
2023,
8358,
3899,
1669,
2088,
5036,
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... | 6 |
func TestNotGitRepoStatus(t *testing.T) {
output := "fatal: Not a git repository (or any of the parent directories): .git"
mockRunner := NewMockRunner(output)
git := NewCustomGit(mockRunner)
repo := &Repo{Path: "/test/"}
status := git.Status(repo)
if status != "error" {
t.Errorf("Should be error status")
}
} | explode_data.jsonl/14061 | {
"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,
2623,
46562,
25243,
2522,
1155,
353,
8840,
836,
8,
341,
21170,
1669,
330,
74394,
25,
2806,
264,
16345,
12542,
320,
269,
894,
315,
279,
2681,
28625,
1648,
659,
12882,
1837,
77333,
19486,
1669,
1532,
11571,
19486,
11057,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFailedUserRebaseRequestDueToPreReceiveError(t *testing.T) {
ctxOuter, cancel := testhelper.Context()
defer cancel()
server, serverSocketPath := runFullServer(t)
defer server.Stop()
client, conn := operations.NewOperationClient(t, serverSocketPath)
defer conn.Close()
testRepo, testRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
testRepoCopy, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
branchName := "many_files"
branchSha := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "rev-parse", branchName))
branchSha = strings.TrimSpace(branchSha)
user := &gitalypb.User{
Name: []byte("Ahmad Sherif"),
Email: []byte("ahmad@gitlab.com"),
GlId: "user-123",
}
request := &gitalypb.UserRebaseRequest{
Repository: testRepo,
User: user,
RebaseId: "1",
Branch: []byte(branchName),
BranchSha: branchSha,
RemoteRepository: testRepoCopy,
RemoteBranch: []byte("master"),
}
hookContent := []byte("#!/bin/sh\necho GL_ID=$GL_ID\nexit 1")
for _, hookName := range operations.GitlabPreHooks {
t.Run(hookName, func(t *testing.T) {
remove, err := operations.OverrideHooks(hookName, hookContent)
require.NoError(t, err)
defer remove()
md := testhelper.GitalyServersMetadata(t, serverSocketPath)
ctx := metadata.NewOutgoingContext(ctxOuter, md)
response, err := client.UserRebase(ctx, request)
require.NoError(t, err)
require.Contains(t, response.PreReceiveError, "GL_ID="+user.GlId)
})
}
} | explode_data.jsonl/65107 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 633
} | [
2830,
3393,
9408,
1474,
693,
3152,
1900,
33060,
1249,
4703,
14742,
1454,
1155,
353,
8840,
836,
8,
341,
20985,
51322,
11,
9121,
1669,
1273,
18764,
9328,
741,
16867,
9121,
2822,
41057,
11,
3538,
10286,
1820,
1669,
1598,
9432,
5475,
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 TestSvcStatus_Execute(t *testing.T) {
mockError := errors.New("some error")
mockServiceStatus := &describe.ServiceStatusDesc{}
testCases := map[string]struct {
shouldOutputJSON bool
mockStatusDescriber func(m *mocks.MockstatusDescriber)
wantedError error
}{
"errors if failed to describe the status of the service": {
mockStatusDescriber: func(m *mocks.MockstatusDescriber) {
m.EXPECT().Describe().Return(nil, mockError)
},
wantedError: fmt.Errorf("describe status of service mockSvc: some error"),
},
"success with JSON output": {
shouldOutputJSON: true,
mockStatusDescriber: func(m *mocks.MockstatusDescriber) {
m.EXPECT().Describe().Return(mockServiceStatus, nil)
},
},
"success with HumanString": {
mockStatusDescriber: func(m *mocks.MockstatusDescriber) {
m.EXPECT().Describe().Return(mockServiceStatus, nil)
},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
b := &bytes.Buffer{}
mockStatusDescriber := mocks.NewMockstatusDescriber(ctrl)
tc.mockStatusDescriber(mockStatusDescriber)
svcStatus := &svcStatusOpts{
svcStatusVars: svcStatusVars{
svcName: "mockSvc",
envName: "mockEnv",
shouldOutputJSON: tc.shouldOutputJSON,
appName: "mockApp",
},
statusDescriber: mockStatusDescriber,
initStatusDescriber: func(*svcStatusOpts) error { return nil },
w: b,
}
// WHEN
err := svcStatus.Execute()
// THEN
if tc.wantedError != nil {
require.EqualError(t, err, tc.wantedError.Error())
} else {
require.NoError(t, err)
require.NotEmpty(t, b.String(), "expected output content to not be empty")
}
})
}
} | explode_data.jsonl/47142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 771
} | [
2830,
3393,
92766,
2522,
83453,
1155,
353,
8840,
836,
8,
341,
77333,
1454,
1669,
5975,
7121,
445,
14689,
1465,
1138,
77333,
1860,
2522,
1669,
609,
12332,
13860,
2522,
11065,
16094,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNumber(t *testing.T) {
input := "123.7"
lex := lexer.NewLexer(input)
tokens, _ := lex.GetTokens()
parser := NewParser(tokens)
expressions, _ := parser.GetExpressions()
assertNumber(t, 123.7, expressions[0].(expr.Atom).Value.(float64))
} | explode_data.jsonl/43718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
2833,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
330,
16,
17,
18,
13,
22,
698,
197,
2571,
1669,
53259,
7121,
92847,
5384,
340,
3244,
9713,
11,
716,
1669,
22429,
2234,
29300,
741,
55804,
1669,
1532,
6570,
34052,
340,
8122,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKMSProviderTimeout(t *testing.T) {
timeoutField := field.NewPath("Resource").Index(0).Child("Provider").Index(0).Child("KMS").Child("Timeout")
negativeTimeout := &metav1.Duration{Duration: -1 * time.Minute}
zeroTimeout := &metav1.Duration{Duration: 0 * time.Minute}
testCases := []struct {
desc string
in *config.KMSConfiguration
want field.ErrorList
}{
{
desc: "valid timeout",
in: &config.KMSConfiguration{Timeout: &metav1.Duration{Duration: 1 * time.Minute}},
want: field.ErrorList{},
},
{
desc: "negative timeout",
in: &config.KMSConfiguration{Timeout: negativeTimeout},
want: field.ErrorList{
field.Invalid(timeoutField, negativeTimeout, fmt.Sprintf(zeroOrNegativeErrFmt, "timeout")),
},
},
{
desc: "zero timeout",
in: &config.KMSConfiguration{Timeout: zeroTimeout},
want: field.ErrorList{
field.Invalid(timeoutField, zeroTimeout, fmt.Sprintf(zeroOrNegativeErrFmt, "timeout")),
},
},
}
for _, tt := range testCases {
t.Run(tt.desc, func(t *testing.T) {
got := validateKMSTimeout(tt.in, timeoutField)
if d := cmp.Diff(tt.want, got); d != "" {
t.Fatalf("KMS Provider validation mismatch (-want +got):\n%s", d)
}
})
}
} | explode_data.jsonl/75102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 484
} | [
2830,
3393,
42,
4826,
5179,
7636,
1155,
353,
8840,
836,
8,
341,
78395,
1877,
1669,
2070,
7121,
1820,
445,
4783,
1827,
1552,
7,
15,
568,
3652,
445,
5179,
1827,
1552,
7,
15,
568,
3652,
445,
42,
4826,
1827,
3652,
445,
7636,
1138,
9038,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPingWire(t *testing.T) {
tests := []struct {
in wire.MsgPing // Message to encode
out wire.MsgPing // Expected decoded message
buf []byte // Wire encoding
pver uint32 // Protocol version for wire encoding
}{
// Latest protocol version.
{
wire.MsgPing{Nonce: 123123}, // 0x1e0f3
wire.MsgPing{Nonce: 123123}, // 0x1e0f3
[]byte{0xf3, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00},
wire.ProtocolVersion,
},
// Protocol version BIP0031Version+1
{
wire.MsgPing{Nonce: 456456}, // 0x6f708
wire.MsgPing{Nonce: 456456}, // 0x6f708
[]byte{0x08, 0xf7, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00},
wire.BIP0031Version + 1,
},
// Protocol version BIP0031Version
{
wire.MsgPing{Nonce: 789789}, // 0xc0d1d
wire.MsgPing{Nonce: 0}, // No nonce for pver
[]byte{}, // No nonce for pver
wire.BIP0031Version,
},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
// Encode the message to wire format.
var buf bytes.Buffer
err := test.in.BtcEncode(&buf, test.pver)
if err != nil {
t.Errorf("BtcEncode #%d error %v", i, err)
continue
}
if !bytes.Equal(buf.Bytes(), test.buf) {
t.Errorf("BtcEncode #%d\n got: %s want: %s", i,
spew.Sdump(buf.Bytes()), spew.Sdump(test.buf))
continue
}
// Decode the message from wire format.
var msg wire.MsgPing
rbuf := bytes.NewReader(test.buf)
err = msg.BtcDecode(rbuf, test.pver)
if err != nil {
t.Errorf("BtcDecode #%d error %v", i, err)
continue
}
if !reflect.DeepEqual(msg, test.out) {
t.Errorf("BtcDecode #%d\n got: %s want: %s", i,
spew.Sdump(msg), spew.Sdump(test.out))
continue
}
}
} | explode_data.jsonl/1146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 800
} | [
2830,
3393,
69883,
37845,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
9067,
30365,
69883,
442,
4856,
311,
16164,
198,
197,
13967,
220,
9067,
30365,
69883,
442,
31021,
29213,
1943,
198,
197,
26398,
220,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestCustomParserBasicUnsupported(t *testing.T) {
type ConstT int32
type config struct {
Const ConstT `env:"CONST_VAL"`
}
exp := ConstT(123)
os.Setenv("CONST_VAL", fmt.Sprintf("%d", exp))
cfg := &config{}
err := env.Parse(cfg)
assert.Zero(t, cfg.Const)
assert.Error(t, err)
assert.Equal(t, env.ErrUnsupportedType, err)
} | explode_data.jsonl/7500 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
10268,
6570,
15944,
41884,
1155,
353,
8840,
836,
8,
341,
13158,
24522,
51,
526,
18,
17,
271,
13158,
2193,
2036,
341,
197,
197,
19167,
24522,
51,
1565,
3160,
2974,
41795,
6096,
8805,
197,
630,
48558,
1669,
24522,
51,
7,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIsSignatureContractGood(t *testing.T) {
prog := make([]byte, 35)
prog[0] = byte(PUSHBYTES33)
prog[34] = byte(CHECKSIG)
assert.Equal(t, true, IsSignatureContract(prog))
assert.Equal(t, true, IsStandardContract(prog))
} | explode_data.jsonl/40581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
3872,
25088,
14067,
15216,
1155,
353,
8840,
836,
8,
341,
197,
32992,
1669,
1281,
10556,
3782,
11,
220,
18,
20,
340,
197,
32992,
58,
15,
60,
284,
4922,
5304,
19518,
97849,
18,
18,
340,
197,
32992,
58,
18,
19,
60,
284,
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 TestParseNetBackend(t *testing.T) {
val := ParseNetBackend("halide")
if val != NetBackendHalide {
t.Errorf("ParseNetBackend invalid")
}
val = ParseNetBackend("openvino")
if val != NetBackendOpenVINO {
t.Errorf("ParseNetBackend invalid")
}
val = ParseNetBackend("opencv")
if val != NetBackendOpenCV {
t.Errorf("ParseNetBackend invalid")
}
val = ParseNetBackend("crazytrain")
if val != NetBackendDefault {
t.Errorf("ParseNetBackend invalid")
}
} | explode_data.jsonl/31271 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
14463,
6954,
29699,
1155,
353,
8840,
836,
8,
341,
19302,
1669,
14775,
6954,
29699,
445,
11866,
577,
1138,
743,
1044,
961,
9374,
29699,
55941,
577,
341,
197,
3244,
13080,
445,
14463,
6954,
29699,
8318,
1138,
197,
532,
19302,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExecInContainerNoSuchPod(t *testing.T) {
testKubelet := newTestKubelet(t)
kubelet := testKubelet.kubelet
fakeRuntime := testKubelet.fakeRuntime
fakeCommandRunner := fakeContainerCommandRunner{}
kubelet.runner = &fakeCommandRunner
fakeRuntime.PodList = []*kubecontainer.Pod{}
podName := "podFoo"
podNamespace := "nsFoo"
containerID := "containerFoo"
err := kubelet.ExecInContainer(
kubecontainer.GetPodFullName(&api.Pod{ObjectMeta: api.ObjectMeta{Name: podName, Namespace: podNamespace}}),
"",
containerID,
[]string{"ls"},
nil,
nil,
nil,
false,
)
if err == nil {
t.Fatal("unexpected non-error")
}
if !fakeCommandRunner.ID.IsEmpty() {
t.Fatal("unexpected invocation of runner.ExecInContainer")
}
} | explode_data.jsonl/43319 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
10216,
641,
4502,
65531,
23527,
1155,
353,
8840,
836,
8,
341,
18185,
42,
3760,
1149,
1669,
501,
2271,
42,
3760,
1149,
1155,
340,
16463,
3760,
1149,
1669,
1273,
42,
3760,
1149,
5202,
3760,
1149,
198,
1166,
726,
15123,
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... | 3 |
func TestFulltextSearchModifier(t *testing.T) {
require.False(t, FulltextSearchModifier(FulltextSearchModifierNaturalLanguageMode).IsBooleanMode())
require.True(t, FulltextSearchModifier(FulltextSearchModifierNaturalLanguageMode).IsNaturalLanguageMode())
require.False(t, FulltextSearchModifier(FulltextSearchModifierNaturalLanguageMode).WithQueryExpansion())
} | explode_data.jsonl/27587 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
9432,
1318,
5890,
34405,
1155,
353,
8840,
836,
8,
341,
17957,
50757,
1155,
11,
8627,
1318,
5890,
34405,
7832,
617,
1318,
5890,
34405,
54281,
13806,
3636,
568,
3872,
6890,
3636,
2398,
17957,
32443,
1155,
11,
8627,
1318,
5890,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidate_url(t *testing.T) {
assert := assert.New(t)
type Model struct {
U1 *string `validate:"url=http https"`
U2 string `validate:"url"`
U3 string `validate:"url=scp"`
}
assert.EqualError(
v.Validate(&Model{}, valis.EachFields(tagrule.Validate)),
"(invalid_scheme) .U3 which scheme is not included in [scp]",
)
assert.NoError(
v.Validate(&Model{
U1: henge.ToStringPtr("https://example.com/path?q=1"),
U2: "http://example.com:1234/path?q=1",
U3: "scp://example.com:8888",
}, valis.EachFields(tagrule.Validate)),
)
assert.EqualError(
v.Validate(&Model{
U1: henge.ToStringPtr("rtmp://example.com/path?q=1"),
U2: "http://example.com:1234/path?q=1",
U3: "http://example.com:8888",
}, valis.EachFields(tagrule.Validate)),
`(invalid_scheme) .U1 which scheme is not included in [http https]
(invalid_scheme) .U3 which scheme is not included in [scp]`,
)
} | explode_data.jsonl/17257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
17926,
2903,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
13158,
4903,
2036,
341,
197,
15980,
16,
353,
917,
1565,
7067,
2974,
1085,
34717,
3703,
8805,
197,
15980,
17,
914,
220,
1565,
7067,
2974,
1085,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetChannel(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
Client := th.Client
channel, resp := Client.GetChannel(th.BasicChannel.Id, "")
CheckNoError(t, resp)
if channel.Id != th.BasicChannel.Id {
t.Fatal("ids did not match")
}
Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id)
_, resp = Client.GetChannel(th.BasicChannel.Id, "")
CheckNoError(t, resp)
channel, resp = Client.GetChannel(th.BasicPrivateChannel.Id, "")
CheckNoError(t, resp)
if channel.Id != th.BasicPrivateChannel.Id {
t.Fatal("ids did not match")
}
Client.RemoveUserFromChannel(th.BasicPrivateChannel.Id, th.BasicUser.Id)
_, resp = Client.GetChannel(th.BasicPrivateChannel.Id, "")
CheckForbiddenStatus(t, resp)
_, resp = Client.GetChannel(model.NewId(), "")
CheckNotFoundStatus(t, resp)
Client.Logout()
_, resp = Client.GetChannel(th.BasicChannel.Id, "")
CheckUnauthorizedStatus(t, resp)
user := th.CreateUser()
Client.Login(user.Email, user.Password)
_, resp = Client.GetChannel(th.BasicChannel.Id, "")
CheckForbiddenStatus(t, resp)
_, resp = th.SystemAdminClient.GetChannel(th.BasicChannel.Id, "")
CheckNoError(t, resp)
_, resp = th.SystemAdminClient.GetChannel(th.BasicPrivateChannel.Id, "")
CheckNoError(t, resp)
_, resp = th.SystemAdminClient.GetChannel(th.BasicUser.Id, "")
CheckNotFoundStatus(t, resp)
} | explode_data.jsonl/65647 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 502
} | [
2830,
3393,
1949,
9629,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
71550,
11,
9039,
1669,
8423,
2234,
9629,
24365,
488... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCompareConfigValue(t *testing.T) {
// Normal equality
assert.True(t, comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("bar"),
}}.equals(comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("bar"),
}}), "Should have found identical config values to be identical")
// Different Mod Policy
assert.False(t, comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("bar"),
}}.equals(comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "bar",
Value: []byte("bar"),
}}), "Should have detected different mod policy")
// Different Value
assert.False(t, comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("bar"),
}}.equals(comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("foo"),
}}), "Should have detected different value")
// Different Version
assert.False(t, comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("bar"),
}}.equals(comparable{
ConfigValue: &cb.ConfigValue{
Version: 1,
ModPolicy: "foo",
Value: []byte("bar"),
}}), "Should have detected different version")
// One nil value
assert.False(t, comparable{
ConfigValue: &cb.ConfigValue{
Version: 0,
ModPolicy: "foo",
Value: []byte("bar"),
}}.equals(comparable{}), "Should have detected nil other value")
} | explode_data.jsonl/40497 | {
"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,
27374,
2648,
1130,
1155,
353,
8840,
836,
8,
341,
197,
322,
18437,
21777,
198,
6948,
32443,
1155,
11,
29039,
515,
197,
66156,
1130,
25,
609,
7221,
10753,
1130,
515,
298,
77847,
25,
256,
220,
15,
345,
298,
197,
4459,
13825,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLeastWaste(t *testing.T) {
cpuPerPod := int64(500)
memoryPerPod := int64(1000 * 1024 * 1024)
e := NewStrategy()
balancedNodeInfo := makeNodeInfo(16*cpuPerPod, 16*memoryPerPod, 100)
nodeMap := map[string]*schedulercache.NodeInfo{"balanced": balancedNodeInfo}
balancedOption := expander.Option{NodeGroup: &FakeNodeGroup{"balanced"}, NodeCount: 1}
// Test without any pods, one node info
ret := e.BestOption([]expander.Option{balancedOption}, nodeMap)
assert.Equal(t, *ret, balancedOption)
pod := &apiv1.Pod{
Spec: apiv1.PodSpec{
Containers: []apiv1.Container{
{
Resources: apiv1.ResourceRequirements{
Requests: apiv1.ResourceList{
apiv1.ResourceCPU: *resource.NewMilliQuantity(cpuPerPod, resource.DecimalSI),
apiv1.ResourceMemory: *resource.NewQuantity(memoryPerPod, resource.DecimalSI),
},
},
},
},
},
}
// Test with one pod, one node info
balancedOption.Pods = []*apiv1.Pod{pod}
ret = e.BestOption([]expander.Option{balancedOption}, nodeMap)
assert.Equal(t, *ret, balancedOption)
// Test with one pod, two node infos, one that has lots of RAM one that has less
highmemNodeInfo := makeNodeInfo(16*cpuPerPod, 32*memoryPerPod, 100)
nodeMap["highmem"] = highmemNodeInfo
highmemOption := expander.Option{NodeGroup: &FakeNodeGroup{"highmem"}, NodeCount: 1, Pods: []*apiv1.Pod{pod}}
ret = e.BestOption([]expander.Option{balancedOption, highmemOption}, nodeMap)
assert.Equal(t, *ret, balancedOption)
// Test with one pod, three node infos, one that has lots of RAM one that has less, and one that has less CPU
lowcpuNodeInfo := makeNodeInfo(8*cpuPerPod, 16*memoryPerPod, 100)
nodeMap["lowcpu"] = lowcpuNodeInfo
lowcpuOption := expander.Option{NodeGroup: &FakeNodeGroup{"lowcpu"}, NodeCount: 1, Pods: []*apiv1.Pod{pod}}
ret = e.BestOption([]expander.Option{balancedOption, highmemOption, lowcpuOption}, nodeMap)
assert.Equal(t, *ret, lowcpuOption)
} | explode_data.jsonl/37334 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 705
} | [
2830,
3393,
81816,
54,
5525,
1155,
353,
8840,
836,
8,
341,
80335,
3889,
23527,
1669,
526,
21,
19,
7,
20,
15,
15,
340,
2109,
4731,
3889,
23527,
1669,
526,
21,
19,
7,
16,
15,
15,
15,
353,
220,
16,
15,
17,
19,
353,
220,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPopulateAccountEntryMasterMissingInSigners(t *testing.T) {
tt := assert.New(t)
ctx, _ := test.ContextWithLogBuffer()
hAccount := Account{}
account.MasterWeight = 0
signers = []history.AccountSigner{
{
Account: accountID.Address(),
Signer: "GCMQBJWOLTCSSMWNVDJAXL6E42SADH563IL5MN5B6RBBP4XP7TBRLJKE",
Weight: int32(3),
},
}
err := PopulateAccountEntry(ctx, &hAccount, account, data, signers, trustLines, nil)
tt.NoError(err)
tt.Len(hAccount.Signers, 2)
signer := hAccount.Signers[1]
tt.Equal(account.AccountID, signer.Key)
tt.Equal(int32(account.MasterWeight), signer.Weight)
tt.Equal(protocol.MustKeyTypeFromAddress(account.AccountID), signer.Type)
tt.Nil(hAccount.LastModifiedTime)
} | explode_data.jsonl/9835 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
11598,
6334,
7365,
5874,
18041,
25080,
641,
7264,
388,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
2060,
7121,
1155,
340,
20985,
11,
716,
1669,
1273,
9328,
2354,
2201,
4095,
741,
9598,
7365,
1669,
8615,
31483,
86866,
71202... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResourceAWSElastiCacheClusterIdValidation(t *testing.T) {
cases := []struct {
Value string
ErrCount int
}{
{
Value: "tEsting",
ErrCount: 1,
},
{
Value: "t.sting",
ErrCount: 1,
},
{
Value: "t--sting",
ErrCount: 1,
},
{
Value: "1testing",
ErrCount: 1,
},
{
Value: "testing-",
ErrCount: 1,
},
{
Value: randomString(65),
ErrCount: 1,
},
}
for _, tc := range cases {
_, errors := validateElastiCacheClusterId(tc.Value, "aws_elasticache_cluster_cluster_id")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected the ElastiCache Cluster cluster_id to trigger a validation error")
}
}
} | explode_data.jsonl/78582 | {
"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,
4783,
14419,
925,
4259,
72,
8233,
28678,
764,
13799,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
47399,
262,
914,
198,
197,
197,
7747,
2507,
526,
198,
197,
59403,
197,
197,
515,
298,
47399,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_Proxying(t *testing.T) {
builder := NewMockBuilder()
runner := NewMockRunner()
proxy := gin.NewProxy(builder, runner)
// create a test server and see if we can proxy a request
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello world")
}))
defer ts.Close()
config := &gin.Config{
Port: 5678,
ProxyTo: ts.URL,
}
err := proxy.Run(config)
defer proxy.Close()
expect(t, err, nil)
res, err := http.Get("http://localhost:5678")
expect(t, err, nil)
expect(t, res == nil, false)
greeting, err := ioutil.ReadAll(res.Body)
res.Body.Close()
expect(t, fmt.Sprintf("%s", greeting), "Hello world\n")
expect(t, runner.DidRun, true)
} | explode_data.jsonl/38856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
16670,
4130,
287,
1155,
353,
8840,
836,
8,
341,
44546,
1669,
1532,
11571,
3297,
741,
197,
41736,
1669,
1532,
11571,
19486,
741,
197,
22803,
1669,
46183,
7121,
16219,
30750,
11,
22259,
692,
197,
322,
1855,
264,
1273,
3538,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMethodUsageFlags(t *testing.T) {
t.Parallel()
tests := []struct {
name string
method string
err error
flags btcjson.UsageFlag
}{
{
name: "unregistered type",
method: "bogusmethod",
err: btcjson.Error{ErrorCode: btcjson.ErrUnregisteredMethod},
},
{
name: "getblock",
method: "getblock",
flags: 0,
},
{
name: "walletpassphrase",
method: "walletpassphrase",
flags: btcjson.UFWalletOnly,
},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
flags, err := btcjson.MethodUsageFlags(test.method)
if reflect.TypeOf(err) != reflect.TypeOf(test.err) {
t.Errorf("Test #%d (%s) wrong error - got %T (%[3]v), "+
"want %T", i, test.name, err, test.err)
continue
}
if err != nil {
gotErrorCode := err.(btcjson.Error).ErrorCode
if gotErrorCode != test.err.(btcjson.Error).ErrorCode {
t.Errorf("Test #%d (%s) mismatched error code "+
"- got %v (%v), want %v", i, test.name,
gotErrorCode, err,
test.err.(btcjson.Error).ErrorCode)
continue
}
continue
}
// Ensure flags match the expected value.
if flags != test.flags {
t.Errorf("Test #%d (%s) mismatched flags - got %v, "+
"want %v", i, test.name, flags, test.flags)
continue
}
}
} | explode_data.jsonl/27518 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 564
} | [
2830,
3393,
3523,
14783,
9195,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
42257,
914,
198,
197,
9859,
262,
1465,
198,
197,
59516,
220,
86037,
2236,
85900,
12135,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfig_WrongFieldType(t *testing.T) {
c := NewConfig()
err := c.LoadConfig("./testdata/wrong_field_type.toml")
require.Error(t, err, "invalid field type")
assert.Equal(t, "Error loading config file ./testdata/wrong_field_type.toml: error parsing http_listener_v2, line 2: (http_listener_v2.HTTPListenerV2.Port) cannot unmarshal TOML string into int", err.Error())
c = NewConfig()
err = c.LoadConfig("./testdata/wrong_field_type2.toml")
require.Error(t, err, "invalid field type2")
assert.Equal(t, "Error loading config file ./testdata/wrong_field_type2.toml: error parsing http_listener_v2, line 2: (http_listener_v2.HTTPListenerV2.Methods) cannot unmarshal TOML string into []string", err.Error())
} | explode_data.jsonl/67106 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
2648,
2763,
14347,
63733,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
2648,
741,
9859,
1669,
272,
13969,
2648,
13988,
92425,
6324,
14347,
5013,
1819,
73494,
75,
1138,
17957,
6141,
1155,
11,
1848,
11,
330,
11808,
2070,
94... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOperationOrSwaggerSecurity(t *testing.T) {
// Create the security schemes
securitySchemes := []ExampleSecurityScheme{
{
Name: "apikey",
Scheme: &openapi3.SecurityScheme{
Type: "apiKey",
Name: "apikey",
In: "cookie",
},
},
{
Name: "http-basic",
Scheme: &openapi3.SecurityScheme{
Type: "http",
Scheme: "basic",
},
},
}
// Create the test cases
tc := []struct {
name string
schemes *[]ExampleSecurityScheme
expectedSchemes *[]ExampleSecurityScheme
}{
{
name: "/inherited-security",
schemes: nil,
expectedSchemes: &[]ExampleSecurityScheme{
securitySchemes[1],
},
},
{
name: "/overwrite-without-security",
schemes: &[]ExampleSecurityScheme{},
expectedSchemes: &[]ExampleSecurityScheme{},
},
{
name: "/overwrite-with-security",
schemes: &[]ExampleSecurityScheme{
securitySchemes[0],
},
expectedSchemes: &[]ExampleSecurityScheme{
securitySchemes[0],
},
},
}
// Create the swagger
swagger := &openapi3.Swagger{
OpenAPI: "3.0.0",
Info: &openapi3.Info{
Title: "MyAPI",
Version: "0.1",
},
Paths: map[string]*openapi3.PathItem{},
Security: openapi3.SecurityRequirements{
{
securitySchemes[1].Name: {},
},
},
Components: openapi3.Components{
SecuritySchemes: map[string]*openapi3.SecuritySchemeRef{},
},
}
// Add the security schemes to the components
for _, scheme := range securitySchemes {
swagger.Components.SecuritySchemes[scheme.Name] = &openapi3.SecuritySchemeRef{
Value: scheme.Scheme,
}
}
// Add the paths from the test cases to the swagger's paths
for _, tc := range tc {
var securityRequirements *openapi3.SecurityRequirements = nil
if tc.schemes != nil {
tempS := make(openapi3.SecurityRequirements, 0)
for _, scheme := range *tc.schemes {
tempS = append(
tempS,
openapi3.SecurityRequirement{
scheme.Name: {},
},
)
}
securityRequirements = &tempS
}
swagger.Paths[tc.name] = &openapi3.PathItem{
Get: &openapi3.Operation{
Security: securityRequirements,
Responses: make(openapi3.Responses),
},
}
}
// Declare the router
router := openapi3filter.NewRouter().WithSwagger(swagger)
// Test each case
for _, path := range tc {
// Make a map of the schemes and whether they're
var schemesValidated *map[*openapi3.SecurityScheme]bool = nil
if path.expectedSchemes != nil {
temp := make(map[*openapi3.SecurityScheme]bool)
schemesValidated = &temp
for _, scheme := range *path.expectedSchemes {
(*schemesValidated)[scheme.Scheme] = false
}
}
// Create the request
emptyBody := bytes.NewReader(make([]byte, 0))
pathUrl, err := url.Parse(path.name)
require.NoError(t, err)
route, _, err := router.FindRoute(http.MethodGet, pathUrl)
require.NoError(t, err)
req := openapi3filter.RequestValidationInput{
Request: httptest.NewRequest(http.MethodGet, path.name, emptyBody),
Route: route,
Options: &openapi3filter.Options{
AuthenticationFunc: func(c context.Context, input *openapi3filter.AuthenticationInput) error {
if schemesValidated != nil {
if validated, ok := (*schemesValidated)[input.SecurityScheme]; ok {
if validated {
t.Fatalf("The path \"%s\" had the schemes %v named \"%s\" validated more than once",
path.name, input.SecurityScheme, input.SecuritySchemeName)
}
(*schemesValidated)[input.SecurityScheme] = true
return nil
}
}
t.Fatalf("The path \"%s\" had the schemes %v named \"%s\"",
path.name, input.SecurityScheme, input.SecuritySchemeName)
return nil
},
},
}
// Validate the request
err = openapi3filter.ValidateRequest(context.TODO(), &req)
require.NoError(t, err)
for securityRequirement, validated := range *schemesValidated {
if !validated {
t.Fatalf("The security requirement %v was exepected to be validated but wasn't",
securityRequirement)
}
}
}
} | explode_data.jsonl/41696 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1671
} | [
2830,
3393,
8432,
2195,
67714,
15352,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
279,
4763,
30856,
198,
197,
17039,
50,
66346,
1669,
3056,
13314,
15352,
28906,
515,
197,
197,
515,
298,
21297,
25,
330,
72174,
756,
298,
7568,
8058,
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... | 4 |
func TestNoDuplicatedAddress(t *testing.T) {
tokens := getTokenInTestDirectory()
coins := make(map[string]bool)
for _, coin := range *tokens {
coins[coin.Address] = true
}
if len(*tokens) != len(coins) {
log.Fatal("Length are not equal")
}
} | explode_data.jsonl/51123 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
2753,
35,
98984,
4286,
1155,
353,
8840,
836,
8,
341,
3244,
9713,
1669,
54111,
641,
2271,
9310,
2822,
197,
29609,
1669,
1281,
9147,
14032,
96436,
692,
2023,
8358,
16254,
1669,
2088,
353,
30566,
341,
197,
197,
29609,
58,
7160,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormat(t *testing.T) {
converter := lines(10)
for _, test := range tests {
for ti, text := range test[:2] {
spn := span.Parse(text)
if ti <= 1 {
// we can check %v produces the same as the input
expect := toPath(test[ti])
if got := fmt.Sprintf("%v", spn); got != expect {
t.Errorf("printing %q got %q expected %q", text, got, expect)
}
}
complete, err := spn.WithAll(converter)
if err != nil {
t.Error(err)
}
for fi, format := range []string{"%v", "%#v", "%+v"} {
expect := toPath(test[fi])
if got := fmt.Sprintf(format, complete); got != expect {
t.Errorf("printing completed %q as %q got %q expected %q [%+v]", text, format, got, expect, spn)
}
}
}
}
} | explode_data.jsonl/35897 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
4061,
1155,
353,
8840,
836,
8,
341,
37203,
8721,
1669,
5128,
7,
16,
15,
340,
2023,
8358,
1273,
1669,
2088,
7032,
341,
197,
2023,
8988,
11,
1467,
1669,
2088,
1273,
3447,
17,
60,
341,
298,
1903,
19958,
1669,
9390,
8937,
72... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCache_parseCredentialHeader(t *testing.T) {
if u, p, ok := parseCredentialHeader(newTestCredReq(NewSecret(10), NewSecret(10))); ok {
t.Fatal(u, p)
}
} | explode_data.jsonl/43691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
8233,
21039,
48265,
4047,
1155,
353,
8840,
836,
8,
341,
743,
575,
11,
281,
11,
5394,
1669,
4715,
48265,
4047,
1755,
2271,
34,
1151,
27234,
35063,
19773,
7,
16,
15,
701,
1532,
19773,
7,
16,
15,
47563,
5394,
341,
197,
3244... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestMulWithMULXADxX(t *testing.T) {
defer resetCpuFeatures()
if !HasADXandBMI2 {
t.Skip("MULX, ADCX and ADOX not supported by the platform")
}
testMul(t, kUse_MULXandADxX, kUse_MUL)
} | explode_data.jsonl/20917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
59155,
2354,
44,
1094,
55,
1808,
87,
55,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
34,
5584,
21336,
741,
743,
753,
10281,
83172,
437,
95526,
17,
341,
197,
3244,
57776,
445,
44,
1094,
55,
11,
22083,
55,
323,
362,
5865,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMethods(t *testing.T) {
tests := []testRun{{
Name: "options",
URL: "",
Method: "OPTIONS",
Status: http.StatusOK,
Expected: "",
Headers: map[string]string{
"Access-Control-Allow-Origin": "http://localhost:5572/",
"Access-Control-Request-Method": "POST, OPTIONS, GET, HEAD",
"Access-Control-Allow-Headers": "authorization, Content-Type",
},
}, {
Name: "bad",
URL: "",
Method: "POTATO",
Status: http.StatusMethodNotAllowed,
Expected: `{
"error": "method \"POTATO\" not allowed",
"input": null,
"path": "",
"status": 405
}
`,
}}
opt := newTestOpt()
opt.Serve = true
opt.Files = testFs
testServer(t, tests, &opt)
} | explode_data.jsonl/12963 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
17856,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1944,
6727,
90,
515,
197,
21297,
25,
257,
330,
2875,
756,
197,
79055,
25,
414,
8324,
197,
84589,
25,
256,
330,
56929,
756,
197,
58321,
25,
256,
1758,
52989,
345,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApp_Header(t *testing.T) {
tests := []struct {
name string
path string
wantErr error
}{
{
name: "Empty",
path: filepath.Join(corpus, "empty.sif"),
},
{
name: "OneGroup",
path: filepath.Join(corpus, "one-group.sif"),
},
{
name: "OneGroupSigned",
path: filepath.Join(corpus, "one-group-signed.sif"),
},
{
name: "OneGroupSignedLegacy",
path: filepath.Join(corpus, "one-group-signed-legacy.sif"),
},
{
name: "OneGroupSignedLegacyAll",
path: filepath.Join(corpus, "one-group-signed-legacy-all.sif"),
},
{
name: "OneGroupSignedLegacyGroup",
path: filepath.Join(corpus, "one-group-signed-legacy-group.sif"),
},
{
name: "TwoGroups",
path: filepath.Join(corpus, "two-groups.sif"),
},
{
name: "TwoGroupsSigned",
path: filepath.Join(corpus, "two-groups-signed.sif"),
},
{
name: "TwoGroupsSignedLegacy",
path: filepath.Join(corpus, "two-groups-signed-legacy.sif"),
},
{
name: "TwoGroupsSignedLegacyAll",
path: filepath.Join(corpus, "two-groups-signed-legacy-all.sif"),
},
{
name: "TwoGroupsSignedLegacyGroup",
path: filepath.Join(corpus, "two-groups-signed-legacy-group.sif"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var b bytes.Buffer
a, err := New(OptAppOutput(&b))
if err != nil {
t.Fatalf("failed to create app: %v", err)
}
if got, want := a.Header(tt.path), tt.wantErr; !errors.Is(got, want) {
t.Fatalf("got error %v, want %v", got, want)
}
g := goldie.New(t, goldie.WithTestNameForDir(true))
g.Assert(t, tt.name, b.Bytes())
})
}
} | explode_data.jsonl/26370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 781
} | [
2830,
3393,
2164,
71353,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
26781,
262,
914,
198,
197,
50780,
7747,
1465,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
3522,
756,
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 TestIrisStream(t *testing.T) {
e := irisTester(t)
e.GET("/stream").
Expect().
Status(http.StatusOK).
TransferEncoding("chunked"). // ensure server sent chunks
Body().Equal("0123456789")
// send chunks to server
e.POST("/stream").WithChunked(strings.NewReader("<long text>")).
Expect().
Status(http.StatusOK).Body().Equal("<long text>")
} | explode_data.jsonl/66293 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
40,
5963,
3027,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
63942,
58699,
1155,
692,
7727,
17410,
4283,
4027,
38609,
197,
35911,
25829,
197,
58321,
19886,
52989,
4292,
197,
197,
21970,
14690,
445,
25979,
291,
1827,
442,
5978,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListMyFilmCMD(t *testing.T) {
testTelegramClientInst, answerChan, _ := NewTestMovieBot("./test_data/test_data.sql")
updates := make(chan tgbotapi.Update)
go testTelegramClientInst.GetMyFilm(updates)
updates <- tgbotapi.Update{Message: &tgbotapi.Message{Text: "", Chat: &tgbotapi.Chat{ID: 100}}}
answer := <-answerChan
expectedAnswer := "Список ваших фильмов на очереди:\nFilm1\n"
if answer != expectedAnswer {
t.Errorf(fmt.Sprintf("Not expected bot answer: %s, expected: %s", answer, expectedAnswer))
return
}
t.Logf("TestListMyFilmCMD complete")
} | explode_data.jsonl/19227 | {
"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,
852,
5050,
51487,
38680,
1155,
353,
8840,
836,
8,
341,
18185,
72244,
2959,
8724,
11,
4226,
46019,
11,
716,
1669,
1532,
2271,
19668,
23502,
13988,
1944,
1769,
12697,
1769,
10045,
1138,
197,
49661,
1669,
1281,
35190,
53188,
6331... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecorder_ResponseStatus_RecordsFinalResponseStatus(t *testing.T) {
status, err := NewTestRecorder().
AddHttpRequest(HttpRequest{}).
AddHttpResponse(HttpResponse{Value: &http.Response{StatusCode: http.StatusAccepted}}).
AddHttpRequest(HttpRequest{}).
AddHttpResponse(HttpResponse{Value: &http.Response{StatusCode: http.StatusBadRequest}}).
ResponseStatus()
assert.Equal(t, true, err == nil)
assert.Equal(t, http.StatusBadRequest, status)
} | explode_data.jsonl/76378 | {
"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,
47023,
65873,
2522,
62,
25876,
19357,
92663,
1155,
353,
8840,
836,
8,
341,
23847,
11,
1848,
1669,
1532,
2271,
47023,
25829,
197,
37972,
26362,
12286,
1900,
6257,
4292,
197,
37972,
43342,
12286,
2582,
90,
1130,
25,
609,
1254,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateBigQueryInput(t *testing.T) {
for _, testcase := range []struct {
name string
cmd *bigquery.UpdateCommand
api mock.API
want *fastly.UpdateBigQueryInput
wantError string
}{
{
name: "no updates",
cmd: updateCommandNoUpdates(),
api: mock.API{
ListVersionsFn: testutil.ListVersions,
CloneVersionFn: testutil.CloneVersionResult(4),
GetBigQueryFn: getBigQueryOK,
},
want: &fastly.UpdateBigQueryInput{
ServiceID: "123",
ServiceVersion: 4,
Name: "log",
},
},
{
name: "all values set flag serviceID",
cmd: updateCommandAll(),
api: mock.API{
ListVersionsFn: testutil.ListVersions,
CloneVersionFn: testutil.CloneVersionResult(4),
GetBigQueryFn: getBigQueryOK,
},
want: &fastly.UpdateBigQueryInput{
ServiceID: "123",
ServiceVersion: 4,
Name: "log",
NewName: fastly.String("new1"),
ProjectID: fastly.String("new2"),
Dataset: fastly.String("new3"),
Table: fastly.String("new4"),
User: fastly.String("new5"),
SecretKey: fastly.String("new6"),
Template: fastly.String("new7"),
ResponseCondition: fastly.String("new8"),
Placement: fastly.String("new9"),
Format: fastly.String("new10"),
FormatVersion: fastly.Uint(3),
},
},
{
name: "error missing serviceID",
cmd: updateCommandMissingServiceID(),
want: nil,
wantError: errors.ErrNoServiceID.Error(),
},
} {
t.Run(testcase.name, func(t *testing.T) {
testcase.cmd.Base.Globals.Client = testcase.api
var bs []byte
out := bytes.NewBuffer(bs)
verboseMode := true
serviceID, serviceVersion, err := cmd.ServiceDetails(cmd.ServiceDetailsOpts{
AutoCloneFlag: testcase.cmd.AutoClone,
Client: testcase.api,
Manifest: testcase.cmd.Manifest,
Out: out,
ServiceVersionFlag: testcase.cmd.ServiceVersion,
VerboseMode: verboseMode,
})
if err != nil {
if testcase.wantError == "" {
t.Fatalf("unexpected error getting service details: %v", err)
}
testutil.AssertErrorContains(t, err, testcase.wantError)
return
}
if err == nil {
if testcase.wantError != "" {
t.Fatalf("expected error, have nil (service details: %s, %d)", serviceID, serviceVersion.Number)
}
}
have, err := testcase.cmd.ConstructInput(serviceID, serviceVersion.Number)
testutil.AssertErrorContains(t, err, testcase.wantError)
testutil.AssertEqual(t, testcase.want, have)
})
}
} | explode_data.jsonl/67598 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1247
} | [
2830,
3393,
4289,
15636,
2859,
2505,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
70080,
1669,
2088,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
25920,
981,
353,
16154,
1631,
16689,
4062,
198,
197,
54299,
981,
7860,
24922,
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... | 5 |
func TestPgpass(t *testing.T) {
if os.Getenv("TRAVIS") != "true" {
t.Skip("not running under Travis, skipping pgpass tests")
}
testAssert := func(conninfo string, expected string, reason string) {
conn, err := openTestConnConninfo(conninfo)
if err != nil {
t.Fatal(err)
}
defer conn.Close()
txn, err := conn.Begin()
if err != nil {
if expected != "fail" {
t.Fatalf(reason, err)
}
return
}
rows, err := txn.Query("SELECT USER")
if err != nil {
txn.Rollback()
if expected != "fail" {
t.Fatalf(reason, err)
}
} else {
rows.Close()
if expected != "ok" {
t.Fatalf(reason, err)
}
}
txn.Rollback()
}
testAssert("", "ok", "missing .pgpass, unexpected error %#v")
os.Setenv("PGPASSFILE", pgpassFile)
testAssert("host=/tmp", "fail", ", unexpected error %#v")
os.Remove(pgpassFile)
pgpass, err := os.OpenFile(pgpassFile, os.O_RDWR|os.O_CREATE, 0644)
if err != nil {
t.Fatalf("Unexpected error writing pgpass file %#v", err)
}
_, err = pgpass.WriteString(`# comment
server:5432:some_db:some_user:pass_A
*:5432:some_db:some_user:pass_B
localhost:*:*:*:pass_C
*:*:*:*:pass_fallback
`)
if err != nil {
t.Fatalf("Unexpected error writing pgpass file %#v", err)
}
pgpass.Close()
assertPassword := func(extra values, expected string) {
o := values{
"host": "localhost",
"sslmode": "disable",
"connect_timeout": "20",
"user": "majid",
"port": "5432",
"extra_float_digits": "2",
"dbname": "pqgotest",
"client_encoding": "UTF8",
"datestyle": "ISO, MDY",
}
for k, v := range extra {
o[k] = v
}
(&conn{}).handlePgpass(o)
if pw := o["password"]; pw != expected {
t.Fatalf("For %v expected %s got %s", extra, expected, pw)
}
}
// wrong permissions for the pgpass file means it should be ignored
assertPassword(values{"host": "example.com", "user": "foo"}, "")
// fix the permissions and check if it has taken effect
os.Chmod(pgpassFile, 0600)
assertPassword(values{"host": "server", "dbname": "some_db", "user": "some_user"}, "pass_A")
assertPassword(values{"host": "example.com", "user": "foo"}, "pass_fallback")
assertPassword(values{"host": "example.com", "dbname": "some_db", "user": "some_user"}, "pass_B")
// localhost also matches the default "" and UNIX sockets
assertPassword(values{"host": "", "user": "some_user"}, "pass_C")
assertPassword(values{"host": "/tmp", "user": "some_user"}, "pass_C")
// cleanup
os.Remove(pgpassFile)
os.Setenv("PGPASSFILE", "")
} | explode_data.jsonl/73472 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1096
} | [
2830,
3393,
82540,
6385,
1155,
353,
8840,
836,
8,
341,
743,
2643,
64883,
445,
2378,
98716,
899,
961,
330,
1866,
1,
341,
197,
3244,
57776,
445,
1921,
4303,
1212,
40710,
11,
42659,
17495,
6385,
7032,
1138,
197,
630,
18185,
8534,
1669,
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... | 7 |
func TestDataChannelBufferedAmount(t *testing.T) {
t.Run("set before datachannel becomes open", func(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
var nCbs int
buf := make([]byte, 1000)
offerPC, answerPC, err := newPair()
if err != nil {
t.Fatalf("Failed to create a PC pair for testing")
}
done := make(chan bool)
answerPC.OnDataChannel(func(d *DataChannel) {
// Make sure this is the data channel we were looking for. (Not the one
// created in signalPair).
if d.Label() != expectedLabel {
return
}
var nPacketsReceived int
d.OnMessage(func(msg DataChannelMessage) {
nPacketsReceived++
if nPacketsReceived == 10 {
go func() {
time.Sleep(time.Second)
done <- true
}()
}
})
assert.True(t, d.Ordered(), "Ordered should be set to true")
})
dc, err := offerPC.CreateDataChannel(expectedLabel, nil)
if err != nil {
t.Fatalf("Failed to create a PC pair for testing")
}
assert.True(t, dc.Ordered(), "Ordered should be set to true")
dc.OnOpen(func() {
for i := 0; i < 10; i++ {
e := dc.Send(buf)
if e != nil {
t.Fatalf("Failed to send string on data channel")
}
assert.Equal(t, uint64(1500), dc.BufferedAmountLowThreshold(), "value mismatch")
//assert.Equal(t, (i+1)*len(buf), int(dc.BufferedAmount()), "unexpected bufferedAmount")
}
})
dc.OnMessage(func(msg DataChannelMessage) {
})
// The value is temporarily stored in the dc object
// until the dc gets opened
dc.SetBufferedAmountLowThreshold(1500)
// The callback function is temporarily stored in the dc object
// until the dc gets opened
dc.OnBufferedAmountLow(func() {
nCbs++
})
err = signalPair(offerPC, answerPC)
if err != nil {
t.Fatalf("Failed to signal our PC pair for testing")
}
closePair(t, offerPC, answerPC, done)
assert.True(t, nCbs > 0, "callback should be made at least once")
})
t.Run("set after datachannel becomes open", func(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
var nCbs int
buf := make([]byte, 1000)
offerPC, answerPC, err := newPair()
if err != nil {
t.Fatalf("Failed to create a PC pair for testing")
}
done := make(chan bool)
answerPC.OnDataChannel(func(d *DataChannel) {
// Make sure this is the data channel we were looking for. (Not the one
// created in signalPair).
if d.Label() != expectedLabel {
return
}
var nPacketsReceived int
d.OnMessage(func(msg DataChannelMessage) {
nPacketsReceived++
if nPacketsReceived == 10 {
go func() {
time.Sleep(time.Second)
done <- true
}()
}
})
assert.True(t, d.Ordered(), "Ordered should be set to true")
})
dc, err := offerPC.CreateDataChannel(expectedLabel, nil)
if err != nil {
t.Fatalf("Failed to create a PC pair for testing")
}
assert.True(t, dc.Ordered(), "Ordered should be set to true")
dc.OnOpen(func() {
// The value should directly be passed to sctp
dc.SetBufferedAmountLowThreshold(1500)
// The callback function should directly be passed to sctp
dc.OnBufferedAmountLow(func() {
nCbs++
})
for i := 0; i < 10; i++ {
e := dc.Send(buf)
if e != nil {
t.Fatalf("Failed to send string on data channel")
}
assert.Equal(t, uint64(1500), dc.BufferedAmountLowThreshold(), "value mismatch")
//assert.Equal(t, (i+1)*len(buf), int(dc.BufferedAmount()), "unexpected bufferedAmount")
}
})
dc.OnMessage(func(msg DataChannelMessage) {
})
err = signalPair(offerPC, answerPC)
if err != nil {
t.Fatalf("Failed to signal our PC pair for testing")
}
closePair(t, offerPC, answerPC, done)
assert.True(t, nCbs > 0, "callback should be made at least once")
})
} | explode_data.jsonl/68048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1509
} | [
2830,
93200,
9629,
4095,
291,
10093,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
746,
1573,
821,
10119,
9044,
1787,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
69931,
1669,
1273,
10600,
49,
28628,
1155,
340,
197,
16867,
1895,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNodePublishVolumeBlock(t *testing.T) {
// Skipping for now - issues with symlink
t.Skip()
// Create server and client connection
s := newTestServer(t)
defer s.Stop()
// Make a call
c := csi.NewNodeClient(s.Conn())
name := "myvol"
size := uint64(10)
// create devicepath/targetpath
devicePath := fmt.Sprintf("/tmp/csi-devicePath.%d", time.Now().Unix())
targetPath := fmt.Sprintf("/tmp/csi-targetPath.%d", time.Now().Unix())
// Create the devicePath
f, err := os.Create(devicePath)
assert.NoError(t, err)
f.Close()
// cleanup devicepath and targetpath
defer os.Remove(devicePath)
defer os.Remove(targetPath)
gomock.InOrder(
s.MockDriver().
EXPECT().
Type().
Return(api.DriverType_DRIVER_TYPE_BLOCK).
Times(1),
s.MockDriver().
EXPECT().
Inspect([]string{name}).
Return([]*api.Volume{
&api.Volume{
Id: name,
Locator: &api.VolumeLocator{
Name: name,
},
Spec: &api.VolumeSpec{
Size: size,
},
},
}, nil).
Times(1),
s.MockDriver().
EXPECT().
Type().
Return(api.DriverType_DRIVER_TYPE_BLOCK).
Times(1),
s.MockDriver().
EXPECT().
Attach(name, gomock.Any()).
Return(devicePath, nil).
Times(1),
)
req := &csi.NodePublishVolumeRequest{
VolumeId: name,
TargetPath: targetPath,
VolumeCapability: &csi.VolumeCapability{
AccessMode: &csi.VolumeCapability_AccessMode{},
AccessType: &csi.VolumeCapability_Block{
Block: &csi.VolumeCapability_BlockVolume{},
},
},
Secrets: map[string]string{authsecrets.SecretTokenKey: systemUserToken},
}
r, err := c.NodePublishVolume(context.Background(), req)
assert.Nil(t, err)
assert.NotNil(t, r)
// Check that the symlink was created
fileInfo, err := os.Lstat(targetPath)
assert.NoError(t, err)
assert.Equal(t, fileInfo.Mode()&os.ModeSymlink, os.ModeSymlink)
} | explode_data.jsonl/51448 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 787
} | [
2830,
3393,
1955,
50145,
18902,
4713,
1155,
353,
8840,
836,
8,
341,
197,
322,
96118,
369,
1431,
481,
4714,
448,
83221,
198,
3244,
57776,
2822,
197,
322,
4230,
3538,
323,
2943,
3633,
198,
1903,
1669,
501,
2271,
5475,
1155,
340,
16867,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewRequestNewRequestFailure(t *testing.T) {
client := newClient()
req, err := client.NewRequest(
context.Background(), "\t\t\t", "/", nil, nil,
)
if err == nil || !strings.HasPrefix(err.Error(), "net/http: invalid method") {
t.Fatal("not the error we expected")
}
if req != nil {
t.Fatal("expected nil request here")
}
} | explode_data.jsonl/60962 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
3564,
1900,
3564,
1900,
17507,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
2959,
741,
24395,
11,
1848,
1669,
2943,
75274,
1006,
197,
28413,
19047,
1507,
2917,
83,
4955,
4955,
497,
64657,
2092,
11,
2092,
345,
197,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFillInPostProps(t *testing.T) {
t.Run("should not add disable group highlight to post props for user with group mention permissions", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
user1 := th.BasicUser
channel := th.CreateChannel(th.BasicTeam)
post1, err := th.App.CreatePost(th.Context, &model.Post{
UserId: user1.Id,
ChannelId: channel.Id,
Message: "test123123 @group1 @group2 blah blah blah",
}, channel, false, true)
require.Nil(t, err)
err = th.App.FillInPostProps(post1, channel)
assert.Nil(t, err)
assert.Equal(t, post1.Props, model.StringInterface{})
})
t.Run("should not add disable group highlight to post props for app without license", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
id := model.NewId()
guest := &model.User{
Email: "success+" + id + "@simulator.amazonses.com",
Username: "un_" + id,
Nickname: "nn_" + id,
Password: "Password1",
EmailVerified: true,
}
guest, err := th.App.CreateGuest(th.Context, guest)
require.Nil(t, err)
th.LinkUserToTeam(guest, th.BasicTeam)
channel := th.CreateChannel(th.BasicTeam)
th.AddUserToChannel(guest, channel)
post1, err := th.App.CreatePost(th.Context, &model.Post{
UserId: guest.Id,
ChannelId: channel.Id,
Message: "test123123 @group1 @group2 blah blah blah",
}, channel, false, true)
require.Nil(t, err)
err = th.App.FillInPostProps(post1, channel)
assert.Nil(t, err)
assert.Equal(t, post1.Props, model.StringInterface{})
})
t.Run("should add disable group highlight to post props for guest user", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.Srv().SetLicense(model.NewTestLicense("ldap"))
id := model.NewId()
guest := &model.User{
Email: "success+" + id + "@simulator.amazonses.com",
Username: "un_" + id,
Nickname: "nn_" + id,
Password: "Password1",
EmailVerified: true,
}
guest, err := th.App.CreateGuest(th.Context, guest)
require.Nil(t, err)
th.LinkUserToTeam(guest, th.BasicTeam)
channel := th.CreateChannel(th.BasicTeam)
th.AddUserToChannel(guest, channel)
post1, err := th.App.CreatePost(th.Context, &model.Post{
UserId: guest.Id,
ChannelId: channel.Id,
Message: "test123123 @group1 @group2 blah blah blah",
}, channel, false, true)
require.Nil(t, err)
err = th.App.FillInPostProps(post1, channel)
assert.Nil(t, err)
assert.Equal(t, post1.Props, model.StringInterface{"disable_group_highlight": true})
})
} | explode_data.jsonl/26442 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1103
} | [
2830,
3393,
14449,
641,
4133,
5992,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5445,
537,
912,
11156,
1874,
11167,
311,
1736,
6914,
369,
1196,
448,
1874,
6286,
8541,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
70479,
1669,
1862... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTopDownSets(t *testing.T) {
tests := []struct {
note string
rules []string
expected interface{}
}{
{"set_diff", []string{`p = x { s1 = {1, 2, 3, 4}; s2 = {1, 3}; x = s1 - s2 }`}, `[2,4]`},
{"set_diff: refs", []string{`p = x { s1 = {a[2], a[1], a[0]}; s2 = {a[0], 2}; set_diff(s1, s2, x) }`}, "[3]"},
{"set_diff: ground output", []string{`p = true { {1} = {1, 2, 3} - {2, 3} }`}, "true"},
{"set_diff: virt docs", []string{`p = x { x = s1 - s2 }`, `s1[1] { true }`, `s1[2] { true }`, `s1["c"] { true }`, `s2 = {"c", 1} { true }`}, "[2]"},
{"intersect", []string{`p = x { x = {a[1], a[2], 3} & {a[2], 4, 3} }`}, "[3]"},
{"union", []string{`p = true { {2, 3, 4} = {a[1], a[2], 3} | {a[2], 4, 3} }`}, "true"},
}
data := loadSmallTestData()
for _, tc := range tests {
runTopDownTestCase(t, data, tc.note, tc.rules, tc.expected)
}
} | explode_data.jsonl/25212 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 432
} | [
2830,
3393,
5366,
4454,
30175,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
9038,
1272,
257,
914,
198,
197,
7000,
2425,
262,
3056,
917,
198,
197,
42400,
3749,
16094,
197,
59403,
197,
197,
4913,
746,
15850,
497,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.