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 TestQuickQueueValue(t *testing.T) {
q := NewQuickQueue()
q.Add(15)
q.Add(11)
q.Add(19)
q.Add(12)
q.Add(8)
q.Add(1)
// len
require.Equal(t, 6, q.Len())
// Peek
require.Equal(t, 15, q.Peek())
require.Equal(t, 6, q.Len())
// Contains
require.True(t, q.Contains(19))
require.False(t, q.Contains(10000))
// Poll
require.Equal(t, 15, q.Poll())
require.Nil(t, q.head[0])
require.Equal(t, 5, q.Len())
// add new to tail
q.Add(23)
q.Add(3)
q.Add(17)
q.Add(7)
require.Equal(t, 9, q.Len())
// Contains (again)
require.True(t, q.Contains(19))
require.False(t, q.Contains(10000))
// Remove
q.Remove(19)
require.False(t, q.Contains(19))
require.Nil(t, q.head[1])
require.Equal(t, 4, len(q.head)-q.headPos)
// Remove
q.Remove(8)
require.False(t, q.Contains(8))
require.Equal(t, 3, len(q.head)-q.headPos)
q.Remove(17)
require.False(t, q.Contains(17))
require.Equal(t, 3, len(q.tail))
require.Equal(t, 6, q.Len())
} | explode_data.jsonl/42914 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
24318,
7554,
1130,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1532,
24318,
7554,
741,
18534,
1904,
7,
16,
20,
340,
18534,
1904,
7,
16,
16,
340,
18534,
1904,
7,
16,
24,
340,
18534,
1904,
7,
16,
17,
340,
18534,
1904,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSignEEATransaction_Execute(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockKeyManagerClient := qkmmock.NewMockKeyManagerClient(ctrl)
ctx := context.Background()
usecase := NewSignEEATransactionUseCase(mockKeyManagerClient)
signedRaw := utils.StringToHexBytes("0xf8d501822710825208944fed1fc4144c223ae3c1553be203cdfcbd38c58182c35080820713a09a0a890215ea6e79d06f9665297996ab967db117f36c2090d6d6ead5a2d32d52a065bc4bc766b5a833cb58b3319e44e952487559b9b939cb5268c0409398214c8ba0035695b4cc4b0941e60551d7a19cf30603db5bfc23e5ac43a56f57f25f75486af842a0035695b4cc4b0941e60551d7a19cf30603db5bfc23e5ac43a56f57f25f75486aa0075695b4cc4b0941e60551d7a19cf30603db5bfc23e5ac43a56f57f25f75486a8a72657374726963746564")
t.Run("should execute use case successfully", func(t *testing.T) {
job := testdata.FakeJob()
mockKeyManagerClient.EXPECT().SignEEATransaction(gomock.Any(), job.InternalData.StoreID, job.Transaction.From.String(),
gomock.AssignableToTypeOf(&types.SignEEATransactionRequest{})).Return(signedRaw.String(), nil)
raw, txHash, err := usecase.Execute(ctx, job)
require.NoError(t, err)
assert.Equal(t, signedRaw.String(), raw.String())
assert.Empty(t, txHash)
})
t.Run("should execute use case successfully for deployment transactions", func(t *testing.T) {
job := testdata.FakeJob()
job.Transaction.To = nil
mockKeyManagerClient.EXPECT().SignEEATransaction(gomock.Any(), job.InternalData.StoreID, job.Transaction.From.String(),
gomock.AssignableToTypeOf(&types.SignEEATransactionRequest{})).Return(signedRaw.String(), nil)
raw, txHash, err := usecase.Execute(ctx, job)
assert.NoError(t, err)
assert.Equal(t, signedRaw.String(), raw.String())
assert.Empty(t, txHash)
})
t.Run("should execute use case successfully for one time key transactions", func(t *testing.T) {
job := testdata.FakeJob()
job.InternalData.OneTimeKey = true
job.Transaction.PrivateFrom = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="
job.Transaction.PrivateFor = []string{"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="}
job.Transaction.TransactionType = types.LegacyTxType
raw, txHash, err := usecase.Execute(ctx, job)
assert.NoError(t, err)
assert.NotEmpty(t, raw)
assert.Empty(t, txHash)
})
t.Run("should fail with same error if ETHSignEEATransaction fails", func(t *testing.T) {
job := testdata.FakeJob()
mockKeyManagerClient.EXPECT().SignEEATransaction(gomock.Any(), job.InternalData.StoreID, job.Transaction.From.String(), gomock.Any()).
Return("", errors.InvalidFormatError("error"))
raw, txHash, err := usecase.Execute(ctx, job)
assert.True(t, errors.IsDependencyFailureError(err))
assert.Empty(t, raw)
assert.Empty(t, txHash)
})
} | explode_data.jsonl/52084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1114
} | [
2830,
3393,
7264,
7099,
828,
33389,
1311,
83453,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
77333,
1592,
2043,
2959,
1669,
2804,
74,
3821,
1176,
7121,
11571,
1592,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPanicOnError(t *testing.T) {
// Set the address to an invalid value to induce a panic.
if err := os.Setenv("DB_INSTANCE_PROVIDER_ADDRESS", "invalid"); err != nil {
t.Fatal(err)
}
// This function detects whether the database instantiation panicked or not.
func() {
defer func() {
if r := recover(); r == nil {
t.Fatal("Did not panic, want panic")
}
}()
database.NewFromEnv(context.Background())
}()
} | explode_data.jsonl/71935 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
47,
31270,
74945,
1155,
353,
8840,
836,
8,
341,
197,
322,
2573,
279,
2621,
311,
458,
8318,
897,
311,
48753,
264,
21975,
624,
743,
1848,
1669,
2643,
4202,
3160,
445,
3506,
42587,
62542,
20135,
497,
330,
11808,
5038,
1848,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMustGetFullPath(ot *testing.T) {
wd := MustGetWd()
udwTest.Equal(MustGetFullPath("/tmp"), "/tmp")
udwTest.Equal(MustGetFullPath("tmp"), filepath.Join(wd, "tmp"))
udwTest.Equal(MustGetFullPath("."), wd)
udwTest.Equal(MustGetFullPath(".."), filepath.Dir(wd))
} | explode_data.jsonl/41480 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
31776,
1949,
73220,
7,
354,
353,
8840,
836,
8,
341,
197,
6377,
1669,
15465,
1949,
54,
67,
741,
197,
661,
86,
2271,
12808,
3189,
590,
1949,
73220,
4283,
5173,
3975,
3521,
5173,
1138,
197,
661,
86,
2271,
12808,
3189,
590,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSteps(t *testing.T) {
var (
echo string
mockErr = errors.New("mock error")
)
wfCtx := newWorkflowContextForTest(t)
discover := providers.NewProviders()
discover.Register("test", map[string]providers.Handler{
"ok": func(ctx wfContext.Context, v *value.Value, act types.Action) error {
echo = echo + "ok"
return nil
},
"error": func(ctx wfContext.Context, v *value.Value, act types.Action) error {
return mockErr
},
})
exec := &executor{
handlers: discover,
}
testCases := []struct {
base string
expected string
hasErr bool
}{
{
base: `
process: {
#provider: "test"
#do: "ok"
}
#up: [process]
`,
expected: "okok",
},
{
base: `
process: {
#provider: "test"
#do: "ok"
}
#up: [process,{
#do: "steps"
p1: process
#up: [process]
}]
`,
expected: "okokokok",
},
{
base: `
process: {
#provider: "test"
#do: "ok"
}
#up: [process,{
p1: process
#up: [process]
}]
`,
expected: "okok",
},
{
base: `
process: {
#provider: "test"
#do: "ok"
}
#up: [process,{
#do: "steps"
err: {
#provider: "test"
#do: "error"
} @step(1)
#up: [{},process] @step(2)
}]
`,
expected: "okok",
hasErr: true,
},
{
base: `
#provider: "test"
#do: "ok"
`,
expected: "ok",
},
{
base: `
process: {
#provider: "test"
#do: "ok"
err: true
}
if process.err {
err: {
#provider: "test"
#do: "error"
}
}
apply: {
#provider: "test"
#do: "ok"
}
#up: [process,{}]
`,
expected: "ok",
hasErr: true,
},
}
for _, tc := range testCases {
echo = ""
v, err := value.NewValue(tc.base, nil, "", value.TagFieldOrder)
assert.NilError(t, err)
err = exec.doSteps(wfCtx, v)
assert.Equal(t, err != nil, tc.hasErr)
assert.Equal(t, echo, tc.expected)
}
} | explode_data.jsonl/29834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 886
} | [
2830,
3393,
33951,
1155,
353,
8840,
836,
8,
1476,
2405,
2399,
197,
5346,
262,
914,
198,
197,
77333,
7747,
284,
5975,
7121,
445,
16712,
1465,
1138,
197,
692,
6692,
69,
23684,
1669,
501,
62768,
1972,
2461,
2271,
1155,
340,
34597,
3688,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJWX(t *testing.T) {
e := echo.New()
handler := func(c echo.Context) error {
return c.String(http.StatusOK, "test")
}
token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"
validRawKey := []byte("secret")
invalidRawKey := []byte("invalid-key")
validKey, err := jwk.New(validRawKey)
if !assert.NoError(t, err, `jwk.New should succeed`) {
return
}
invalidKey, err := jwk.New(invalidRawKey)
if !assert.NoError(t, err, `jwk.New should succeed`) {
return
}
validAuth := jwx.DefaultConfig.AuthScheme + " " + token
for _, tc := range []struct {
expPanic bool
expErrCode int // 0 for Success
config jwx.Config
reqURL string // "/" if empty
hdrAuth string
hdrCookie string // test.Request doesn't provide SetCookie(); use name=val
formValues map[string]string
info string
}{
{
expErrCode: http.StatusBadRequest,
config: jwx.Config{
Key: validKey,
SignatureAlgorithm: "RS256",
},
info: "Unexpected signing method",
},
{
expErrCode: http.StatusUnauthorized,
hdrAuth: validAuth,
config: jwx.Config{Key: invalidKey},
info: "Invalid key",
},
{
hdrAuth: validAuth,
config: jwx.Config{Key: validKey},
info: "Valid JWT",
},
{
hdrAuth: "Token" + " " + token,
config: jwx.Config{AuthScheme: "Token", Key: validKey},
info: "Valid JWT with custom AuthScheme",
},
{
hdrAuth: validAuth,
config: jwx.Config{
Key: validKey,
},
info: "Valid JWT with custom claims",
},
{
hdrAuth: "invalid-auth",
expErrCode: http.StatusBadRequest,
config: jwx.Config{Key: validKey},
info: "Invalid Authorization header",
},
{
config: jwx.Config{Key: validKey},
expErrCode: http.StatusBadRequest,
info: "Empty header auth field",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "query:jwt",
},
reqURL: "/?a=b&jwt=" + token,
info: "Valid query method",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "query:jwt",
},
reqURL: "/?a=b&jwtxyz=" + token,
expErrCode: http.StatusBadRequest,
info: "Invalid query param name",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "query:jwt",
},
reqURL: "/?a=b&jwt=invalid-token",
expErrCode: http.StatusUnauthorized,
info: "Invalid query param value",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "query:jwt",
},
reqURL: "/?a=b",
expErrCode: http.StatusBadRequest,
info: "Empty query",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "param:jwt",
},
reqURL: "/" + token,
info: "Valid param method",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "cookie:jwt",
},
hdrCookie: "jwt=" + token,
info: "Valid cookie method",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "query:jwt,cookie:jwt",
},
hdrCookie: "jwt=" + token,
info: "Multiple jwt lookuop",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "cookie:jwt",
},
expErrCode: http.StatusUnauthorized,
hdrCookie: "jwt=invalid",
info: "Invalid token with cookie method",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "cookie:jwt",
},
expErrCode: http.StatusBadRequest,
info: "Empty cookie",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "form:jwt",
},
formValues: map[string]string{"jwt": token},
info: "Valid form method",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "form:jwt",
},
expErrCode: http.StatusUnauthorized,
formValues: map[string]string{"jwt": "invalid"},
info: "Invalid token with form method",
},
{
config: jwx.Config{
Key: validKey,
TokenLookup: "form:jwt",
},
expErrCode: http.StatusBadRequest,
info: "Empty form field",
},
{
hdrAuth: validAuth,
config: jwx.Config{
KeyFunc: func(echo.Context) (interface{}, error) {
return validKey, nil
},
},
info: "Valid JWT with a valid key using a user-defined KeyFunc",
},
{
hdrAuth: validAuth,
config: jwx.Config{
KeyFunc: func(echo.Context) (interface{}, error) {
return invalidKey, nil
},
},
expErrCode: http.StatusUnauthorized,
info: "Valid JWT with an invalid key using a user-defined KeyFunc",
},
{
hdrAuth: validAuth,
config: jwx.Config{
KeyFunc: func(echo.Context) (interface{}, error) {
return nil, errors.New("faulty KeyFunc")
},
},
expErrCode: http.StatusUnauthorized,
info: "Token verification does not pass using a user-defined KeyFunc",
},
} {
if tc.reqURL == "" {
tc.reqURL = "/"
}
var req *http.Request
if len(tc.formValues) > 0 {
form := url.Values{}
for k, v := range tc.formValues {
form.Set(k, v)
}
req = httptest.NewRequest(http.MethodPost, tc.reqURL, strings.NewReader(form.Encode()))
req.Header.Set(echo.HeaderContentType, "application/x-www-form-urlencoded")
req.ParseForm()
} else {
req = httptest.NewRequest(http.MethodGet, tc.reqURL, nil)
}
res := httptest.NewRecorder()
req.Header.Set(echo.HeaderAuthorization, tc.hdrAuth)
req.Header.Set(echo.HeaderCookie, tc.hdrCookie)
c := e.NewContext(req, res)
if tc.reqURL == "/"+token {
c.SetParamNames("jwt")
c.SetParamValues(token)
}
if tc.expPanic {
assert.Panics(t, func() {
jwx.WithConfig(tc.config)
}, tc.info)
continue
}
if tc.expErrCode != 0 {
h := jwx.WithConfig(tc.config)(handler)
he := h(c).(*echo.HTTPError)
assert.Equal(t, tc.expErrCode, he.Code, tc.info)
continue
}
h := jwx.WithConfig(tc.config)(handler)
if assert.NoError(t, h(c), tc.info) {
user := c.Get("user").(jwt.Token)
{
v, ok := user.Get("name")
if !assert.True(t, ok, `'name' field should exist`) {
return
}
if !assert.Equal(t, v, "John Doe", tc.info) {
return
}
}
{
v, ok := user.Get("admin")
if ok {
if !assert.Equal(t, v, true, tc.info) {
return
}
}
}
}
}
} | explode_data.jsonl/55414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3140
} | [
2830,
3393,
41,
65376,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
1687,
7121,
741,
53326,
1669,
2915,
1337,
1687,
9328,
8,
1465,
341,
197,
853,
272,
6431,
19886,
52989,
11,
330,
1944,
1138,
197,
532,
43947,
1669,
330,
84609,
49039,
38,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFillConfig(t *testing.T) {
c := Config{}
c.Fill()
assert.Equal(t, uint64(0), c.DeploymentID)
assert.Equal(t, defaultDataDir, c.DataDir)
assert.Equal(t, defaultServiceAddress, c.ServiceAddress)
assert.Equal(t, defaultServiceAddress, c.ServiceListenAddress)
assert.Equal(t, defaultRaftAddress, c.RaftAddress)
assert.Equal(t, defaultRaftAddress, c.RaftListenAddress)
assert.Equal(t, defaultGossipAddress, c.GossipAddress)
assert.Equal(t, defaultGossipAddress, c.GossipListenAddress)
assert.Equal(t, 0, len(c.GossipSeedAddresses))
} | explode_data.jsonl/50731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
14449,
2648,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
5532,
16094,
1444,
19495,
2822,
6948,
12808,
1155,
11,
2622,
21,
19,
7,
15,
701,
272,
34848,
39130,
915,
340,
6948,
12808,
1155,
11,
1638,
1043,
6184,
11,
272,
3336,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgRmPoolCreator_ValidateBasic(t *testing.T) {
tests := []struct {
name string
msg MsgRmPoolCreator
err error
}{
{
name: "invalid address",
msg: MsgRmPoolCreator{
Creator: "invalid_address",
},
err: sdkerrors.ErrInvalidAddress,
}, {
name: "valid address",
msg: MsgRmPoolCreator{
Creator: sample.AccAddress(),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.msg.ValidateBasic()
if tt.err != nil {
require.ErrorIs(t, err, tt.err)
return
}
require.NoError(t, err)
})
}
} | explode_data.jsonl/2716 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
6611,
49,
76,
10551,
31865,
62,
17926,
15944,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
21169,
220,
24205,
49,
76,
10551,
31865,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetKeyById(t *testing.T) {
kring, _ := ReadKeyRing(readerFromHex(testKeys1And2Hex))
keys := kring.KeysById(0xa34d7e18c20c31bb)
if len(keys) != 1 || keys[0].Entity != kring[0] {
t.Errorf("bad result for 0xa34d7e18c20c31bb: %#v", keys)
}
keys = kring.KeysById(0xfd94408d4543314f)
if len(keys) != 1 || keys[0].Entity != kring[0] {
t.Errorf("bad result for 0xa34d7e18c20c31bb: %#v", keys)
}
} | explode_data.jsonl/2276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
1949,
1592,
2720,
1155,
353,
8840,
836,
8,
341,
197,
9855,
287,
11,
716,
1669,
4457,
1592,
43466,
21987,
3830,
20335,
8623,
8850,
16,
3036,
17,
20335,
4390,
80112,
1669,
595,
12640,
37863,
2720,
7,
15,
9591,
18,
19,
67,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParseStandardInformation(t *testing.T) {
input := decodeHex(t, "8d07703c89d7d5018d07703c89d6d5018d07703c89d6d5018d07703c89d6d501200000000000A30005000000010000000070000001100000000010000000000028820f4b05000000")
out, err := mft.ParseStandardInformation(input)
require.Nilf(t, err, "could not parse attribute: %v", err)
expected := mft.StandardInformation{
Creation: time.Date(2020, time.January, 30, 16, 20, 50, 176398100, time.UTC),
FileLastModified: time.Date(2020, time.January, 29, 9, 48, 19, 13620500, time.UTC),
MftLastModified: time.Date(2020, time.January, 29, 9, 48, 19, 13620500, time.UTC),
LastAccess: time.Date(2020, time.January, 29, 9, 48, 19, 13620500, time.UTC),
FileAttributes: mft.FileAttribute(32),
MaximumNumberOfVersions: 10682368,
VersionNumber: 5,
ClassId: 1,
OwnerId: 28672,
SecurityId: 4097,
QuotaCharged: 1048576,
UpdateSequenceNumber: 22734144040,
}
assert.Equal(t, expected, out)
} | explode_data.jsonl/8272 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 497
} | [
2830,
3393,
14463,
19781,
14873,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
16895,
20335,
1155,
11,
330,
23,
67,
15,
22,
22,
15,
18,
66,
23,
24,
67,
22,
67,
20,
15,
16,
23,
67,
15,
22,
22,
15,
18,
66,
23,
24,
67,
21,
67,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSignedEncryptedMessage(t *testing.T) {
for i, test := range signedEncryptedMessageTests {
expected := "Signed and encrypted message\n"
kring, _ := ReadKeyRing(readerFromHex(test.keyRingHex))
prompt := func(keys []Key, symmetric bool) ([]byte, error) {
if symmetric {
t.Errorf("prompt: message was marked as symmetrically encrypted")
return nil, errors.ErrKeyIncorrect
}
if len(keys) == 0 {
t.Error("prompt: no keys requested")
return nil, errors.ErrKeyIncorrect
}
err := keys[0].PrivateKey.Decrypt([]byte("passphrase"))
if err != nil {
t.Errorf("prompt: error decrypting key: %s", err)
return nil, errors.ErrKeyIncorrect
}
return nil, nil
}
md, err := ReadMessage(readerFromHex(test.messageHex), kring, prompt, nil)
if err != nil {
t.Errorf("#%d: error reading message: %s", i, err)
return
}
if !md.IsSigned || md.SignedByKeyId != test.signedByKeyId || md.SignedBy == nil || !md.IsEncrypted || md.IsSymmetricallyEncrypted || len(md.EncryptedToKeyIds) == 0 || md.EncryptedToKeyIds[0] != test.encryptedToKeyId {
t.Errorf("#%d: bad MessageDetails: %#v", i, md)
}
contents, err := ioutil.ReadAll(md.UnverifiedBody)
if err != nil {
t.Errorf("#%d: error reading UnverifiedBody: %s", i, err)
}
if string(contents) != expected {
t.Errorf("#%d: bad UnverifiedBody got:%s want:%s", i, string(contents), expected)
}
if md.SignatureError != nil || md.Signature == nil {
t.Errorf("#%d: failed to validate: %s", i, md.SignatureError)
}
}
} | explode_data.jsonl/2280 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 623
} | [
2830,
3393,
49312,
7408,
14026,
2052,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
8499,
7408,
14026,
2052,
18200,
341,
197,
42400,
1669,
330,
49312,
323,
24455,
1943,
1699,
698,
197,
197,
9855,
287,
11,
716,
1669,
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... | 4 |
func TestSkipLargeReplicaSnapshot(t *testing.T) {
defer leaktest.AfterTest(t)()
sCtx := TestStoreContext()
sCtx.TestingKnobs.DisableSplitQueue = true
store, _, stopper := createTestStoreWithContext(t, &sCtx)
defer stopper.Stop()
const snapSize = 1 << 20 // 1 MiB
cfg := config.DefaultZoneConfig()
cfg.RangeMaxBytes = snapSize
defer config.TestingSetDefaultZoneConfig(cfg)()
rep, err := store.GetReplica(rangeID)
if err != nil {
t.Fatal(err)
}
rep.SetMaxBytes(snapSize)
if pErr := rep.redirectOnOrAcquireLease(context.Background()); pErr != nil {
t.Fatal(pErr)
}
fillTestRange(t, rep, snapSize)
if _, err := rep.GetSnapshot(context.Background()); err != nil {
t.Fatal(err)
}
fillTestRange(t, rep, snapSize*2)
if _, err := rep.Snapshot(); err != raft.ErrSnapshotTemporarilyUnavailable {
rep.mu.Lock()
after := rep.mu.state.Stats.Total()
rep.mu.Unlock()
t.Fatalf(
"snapshot of a very large range (%d / %d, needsSplit: %v, exceeds snap limit: %v) should fail but got %v",
after, rep.GetMaxBytes(),
rep.needsSplitBySize(), rep.exceedsDoubleSplitSizeLocked(), err,
)
}
} | explode_data.jsonl/44389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 435
} | [
2830,
3393,
35134,
34253,
18327,
15317,
15009,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1903,
23684,
1669,
3393,
6093,
1972,
741,
1903,
23684,
8787,
287,
36253,
5481,
10166,
480,
20193,
7554,
284,
830,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetYamlValuesContentLabels(t *testing.T) {
for _, tt := range []struct {
name string
deploymentLabelCMDFlags DeploymentLabelFlags
expectedResult string
}{{
name: "Knative Eventing",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
DeployName: "network",
},
expectedResult: `#@data/values
---
namespace: test-eventing
deployName: network
value: test-value`,
}, {
name: "Knative Eventing with service name",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
ServiceName: "network",
},
expectedResult: `#@data/values
---
namespace: test-eventing
serviceName: network
value: test-value`,
}, {
name: "Knative Serving",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Key: "test-key",
Value: "test-value",
Component: "serving",
Namespace: "test-serving",
DeployName: "network",
},
expectedResult: `#@data/values
---
namespace: test-serving
deployName: network
value: test-value`,
}} {
t.Run(tt.name, func(t *testing.T) {
result := getYamlValuesContentLabels(tt.deploymentLabelCMDFlags)
testingUtil.AssertEqual(t, result, tt.expectedResult)
})
}
} | explode_data.jsonl/69538 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 581
} | [
2830,
3393,
88300,
9467,
6227,
2762,
23674,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
503,
914,
198,
197,
197,
82213,
2476,
38680,
9195,
66292,
2476,
9195,
198,
197,
42400,
2077,
688,
914,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBytea32(t *testing.T) {
const sz = 32
var b [sz]byte
copy(b[:], makeOneBytes(sz))
Bytea32(&b)
err := checkZeroBytes(b[:])
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/62542 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
7153,
64,
18,
17,
1155,
353,
8840,
836,
8,
341,
4777,
10038,
284,
220,
18,
17,
198,
2405,
293,
508,
14357,
90184,
198,
49124,
1883,
3447,
1125,
1281,
3966,
7078,
40571,
4390,
197,
7153,
64,
18,
17,
2099,
65,
692,
9859,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQpLineLength(t *testing.T) {
m := NewMessage()
m.SetHeader("From", "from@example.com")
m.SetHeader("To", "to@example.com")
m.SetBody("text/plain",
strings.Repeat("0", 76)+"\r\n"+
strings.Repeat("0", 75)+"à\r\n"+
strings.Repeat("0", 74)+"à\r\n"+
strings.Repeat("0", 73)+"à\r\n"+
strings.Repeat("0", 72)+"à\r\n"+
strings.Repeat("0", 75)+"\r\n"+
strings.Repeat("0", 76)+"\n")
want := &message{
from: "from@example.com",
to: []string{"to@example.com"},
content: "From: from@example.com\r\n" +
"To: to@example.com\r\n" +
"Content-Type: text/plain; charset=UTF-8\r\n" +
"Content-Transfer-Encoding: quoted-printable\r\n" +
"\r\n" +
strings.Repeat("0", 75) + "=\r\n0\r\n" +
strings.Repeat("0", 75) + "=\r\n=C3=A0\r\n" +
strings.Repeat("0", 74) + "=\r\n=C3=A0\r\n" +
strings.Repeat("0", 73) + "=\r\n=C3=A0\r\n" +
strings.Repeat("0", 72) + "=C3=\r\n=A0\r\n" +
strings.Repeat("0", 75) + "\r\n" +
strings.Repeat("0", 75) + "=\r\n0\r\n",
}
testMessage(t, m, 0, want)
} | explode_data.jsonl/31586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
48,
79,
2460,
4373,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
2052,
741,
2109,
4202,
4047,
445,
3830,
497,
330,
1499,
35487,
905,
1138,
2109,
4202,
4047,
445,
1249,
497,
330,
983,
35487,
905,
1138,
2109,
4202,
5444,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Hoverfly_GetSimulation_ReturnsBlankSimulation_ifThereIsNoData(t *testing.T) {
RegisterTestingT(t)
unit := NewHoverflyWithConfiguration(&Configuration{})
simulation, err := unit.GetSimulation()
Expect(err).To(BeNil())
Expect(simulation.RequestResponsePairs).To(HaveLen(0))
Expect(simulation.GlobalActions.Delays).To(HaveLen(0))
Expect(simulation.MetaView.SchemaVersion).To(Equal("v5"))
Expect(simulation.MetaView.HoverflyVersion).To(MatchRegexp(`v\d+.\d+.\d+(-rc.\d)*`))
Expect(simulation.MetaView.TimeExported).ToNot(BeNil())
} | explode_data.jsonl/45366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
2039,
1975,
21642,
13614,
64554,
53316,
82,
22770,
64554,
11119,
3862,
3872,
2753,
1043,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
692,
81189,
1669,
1532,
34379,
21642,
2354,
7688,
2099,
7688,
6257,
692,
1903,
6036... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReceivesInitial(t *testing.T) {
dc := testdataclient.New([]*eskip.Route{{Id: "route1", Path: "/some-path", Backend: "https://www.example.org"}})
tr, err := newTestRouting(dc)
if err != nil {
t.Error(err)
}
defer tr.close()
if _, err := tr.checkGetRequest("https://www.example.com/some-path"); err != nil {
t.Error(err)
}
} | explode_data.jsonl/58570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
693,
346,
1886,
6341,
1155,
353,
8840,
836,
8,
341,
87249,
1669,
1273,
691,
2972,
7121,
85288,
288,
13389,
58004,
2979,
764,
25,
330,
8966,
16,
497,
7933,
25,
3521,
14689,
33095,
497,
55260,
25,
330,
2428,
1110,
2136,
7724... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceCreateFileError(t *testing.T) {
_, _, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--filename", "filepath"}, false)
assert.Assert(t, util.ContainsAll(err.Error(), "no", "such", "file", "directory", "filepath"))
} | explode_data.jsonl/42462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
1860,
4021,
1703,
1454,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
8358,
1848,
1669,
12418,
1860,
4021,
10556,
917,
515,
197,
197,
1,
7936,
497,
330,
3182,
497,
330,
7975,
497,
14482,
8404,
497,
330,
44157,
14345,
895,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_postorderTraversal1(t *testing.T) {
ast := assert.New(t)
for _, tc := range tcs {
fmt.Printf("~~%v~~\n", tc)
root := PreIn2Tree(tc.pre, tc.in)
ast.Equal(tc.post, postorderTraversal1(root), "输入:%v", tc)
}
} | explode_data.jsonl/28336 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
6333,
1358,
76276,
16,
1155,
353,
8840,
836,
8,
341,
88836,
1669,
2060,
7121,
1155,
692,
2023,
8358,
17130,
1669,
2088,
259,
4837,
341,
197,
11009,
19367,
445,
5817,
4,
85,
5817,
59,
77,
497,
17130,
692,
197,
33698,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMultiplePatchesNoConflict(t *testing.T) {
th := makeTestHarness(t)
makeCommonFileForMultiplePatchTest(th)
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx
spec:
template:
spec:
containers:
- name: nginx
image: nginx:latest
env:
- name: ENVKEY
value: ENVVALUE
volumes:
- name: nginx-persistent-storage
emptyDir: null
gcePersistentDisk:
pdName: nginx-persistent-storage
- configMap:
name: configmap-in-overlay
name: configmap-in-overlay
`)
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", `
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx
spec:
template:
spec:
containers:
- name: nginx
env:
- name: ANOTHERENV
value: FOO
volumes:
- name: nginx-persistent-storage
`)
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
th.AssertActualEqualsExpected(m, `
apiVersion: apps/v1beta2
kind: Deployment
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-nginx
spec:
selector:
matchLabels:
app: mynginx
env: staging
org: example.com
team: foo
template:
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
spec:
containers:
- env:
- name: ANOTHERENV
value: FOO
- name: ENVKEY
value: ENVVALUE
image: nginx:latest
name: nginx
volumeMounts:
- mountPath: /tmp/ps
name: nginx-persistent-storage
- image: sidecar:latest
name: sidecar
volumes:
- gcePersistentDisk:
pdName: nginx-persistent-storage
name: nginx-persistent-storage
- configMap:
name: staging-configmap-in-overlay-k7cbc75tg8
name: configmap-in-overlay
- configMap:
name: staging-team-foo-configmap-in-base-g7k6gt2889
name: configmap-in-base
---
apiVersion: v1
kind: Service
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-nginx
spec:
ports:
- port: 80
selector:
app: mynginx
env: staging
org: example.com
team: foo
---
apiVersion: v1
data:
foo: bar
kind: ConfigMap
metadata:
annotations:
note: This is a test annotation
labels:
app: mynginx
env: staging
org: example.com
team: foo
name: staging-team-foo-configmap-in-base-g7k6gt2889
---
apiVersion: v1
data:
hello: world
kind: ConfigMap
metadata:
labels:
env: staging
name: staging-configmap-in-overlay-k7cbc75tg8
`)
} | explode_data.jsonl/51161 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1347
} | [
2830,
3393,
32089,
47,
9118,
2753,
57974,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
1281,
2271,
74248,
1155,
340,
77438,
10839,
1703,
2461,
32089,
43622,
2271,
24365,
340,
70479,
4073,
37,
4283,
676,
14,
21118,
14272,
4118,
22549,
52799,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpanFinishWithErrorNoDebugStack(t *testing.T) {
assert := assert.New(t)
err := errors.New("test error")
span := newBasicSpan("web.request")
span.Finish(WithError(err), NoDebugStack())
assert.Equal(int32(1), span.Error)
assert.Equal("test error", span.Meta[ext.ErrorMsg])
assert.Equal("*errors.errorString", span.Meta[ext.ErrorType])
assert.Empty(span.Meta[ext.ErrorStack])
} | explode_data.jsonl/42841 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 141
} | [
2830,
3393,
12485,
25664,
66102,
2753,
7939,
4336,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
9859,
1669,
5975,
7121,
445,
1944,
1465,
1138,
197,
1480,
1669,
501,
15944,
12485,
445,
2911,
8223,
1138,
197,
1480,
991... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventDataPath(t *testing.T) {
Convey("Given a city of New York and a year of 2018", t, func() {
city := "New York"
year := "2018"
testContentPath := EventDataPath(GetWebdir(), city, year)
Convey("The response should be "+GetWebdir()+"/data/events/2018-new-york.yml", func() {
So(testContentPath, ShouldEqual, GetWebdir()+"/data/events/2018-new-york.yml")
})
})
} | explode_data.jsonl/50761 | {
"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,
65874,
1820,
1155,
353,
8840,
836,
8,
1476,
93070,
5617,
445,
22043,
264,
3283,
315,
1532,
4261,
323,
264,
1042,
315,
220,
17,
15,
16,
23,
497,
259,
11,
2915,
368,
341,
197,
1444,
487,
1669,
330,
3564,
4261,
698,
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 TestUserService_DeleteUser(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
apiName := "deleteUser"
response, err := ReadData(apiName, "UserService")
if err != nil {
t.Errorf("Failed to read response data due to: %v", err)
}
fmt.Fprintf(writer, response[apiName])
}))
defer server.Close()
client := NewClient(server.URL, "APIKEY", "SECRETKEY", true)
params := client.User.NewDeleteUserParams("cd2b5afa-db4d-4532-88ec-1356a273e534")
resp, err := client.User.DeleteUser(params)
if err != nil {
t.Errorf("Failed to delete user due to %v", err)
return
}
if resp == nil || !resp.Success {
t.Errorf("Failed to delete user")
}
} | explode_data.jsonl/60347 | {
"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,
60004,
57418,
1474,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
38356,
1758,
37508,
11,
1681,
353,
1254,
9659,
8,
341,
197,
54299,
675,
1669,
330,
4542,
1474,
698,
197,
21735,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParseTokenRequestFull(t *testing.T) {
r := newRequestWithAuth("foo", "bar", map[string]string{
"grant_type": PasswordGrantType,
"scope": "foo bar",
"username": "baz",
"password": "qux",
"refresh_token": "bla",
"redirect_uri": "http://example.com",
"code": "blaa",
})
req, err := ParseTokenRequest(r)
assert.NoError(t, err)
assert.Equal(t, "password", req.GrantType)
assert.Equal(t, "foo", req.ClientID)
assert.Equal(t, "bar", req.ClientSecret)
assert.Equal(t, Scope{"foo", "bar"}, req.Scope)
assert.Equal(t, "baz", req.Username)
assert.Equal(t, "qux", req.Password)
assert.Equal(t, "bla", req.RefreshToken)
assert.Equal(t, "http://example.com", req.RedirectURI)
assert.Equal(t, "blaa", req.Code)
} | explode_data.jsonl/1723 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
14463,
3323,
1900,
9432,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
501,
1900,
2354,
5087,
445,
7975,
497,
330,
2257,
497,
2415,
14032,
30953,
515,
197,
197,
1,
51627,
1819,
788,
262,
12362,
67971,
929,
345,
197,
197,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNoOpCmd(t *testing.T) {
is := is.New(t)
executedCommand := make(chan []string, 1)
output := "testoutput"
out, err := cmd.Execute([]string{"echo", "hello world"}, NoOp(executedCommand, output))
is.Equal(output+"\n", out) // output of command should be expected plus newline
is.NoErr(err) // echo should not return an error
is.Equal([]string{"echo", "hello world"}, <-executedCommand) // executed command should be echo hello world
// set the global options
cmd.AddGlobalOptions(NoOp(executedCommand, output))
out, err = cmd.Execute([]string{"echo", "hello world"})
is.Equal(output+"\n", out)
is.NoErr(err)
is.Equal([]string{"echo", "hello world"}, <-executedCommand)
cmd.ResetGlobalOptions()
} | explode_data.jsonl/81460 | {
"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,
2753,
7125,
15613,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
374,
7121,
1155,
692,
67328,
2774,
4062,
1669,
1281,
35190,
3056,
917,
11,
220,
16,
340,
21170,
1669,
330,
1944,
3006,
1837,
13967,
11,
1848,
1669,
5439,
13827,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckFirstPayload(t *testing.T) {
dumpPackets, err := utils.ReadDumpFile("../../godpi_example/dumps/http.cap")
if err != nil {
t.Fatal(err)
}
flow := types.NewFlow()
for packet := range dumpPackets {
packetCopy := packet
flow.AddPacket(packetCopy)
}
called := false
noDetections := checkFirstPayload(flow.GetPackets(), layers.LayerTypeTCP,
func(payload []byte, packetsRest []gopacket.Packet) bool {
called = true
if len(payload) == 0 {
t.Error("No payload passed to callback")
}
if !strings.HasPrefix(string(payload), "GET /download.html") {
t.Error("Wrong first payload passed to callback")
}
if len(packetsRest) != 39 {
t.Error(len(packetsRest))
}
return false
})
if noDetections {
t.Error("Detection returned true when callback returned false")
}
if !called {
t.Error("Callback was never called")
}
} | explode_data.jsonl/61052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
3973,
5338,
29683,
1155,
353,
8840,
836,
8,
341,
2698,
1510,
47,
18382,
11,
1848,
1669,
12439,
6503,
51056,
1703,
36800,
39711,
2493,
39304,
3446,
11793,
15627,
27388,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSidecarsNoCPULimits(t *testing.T) {
testConfig := Config{
ConfigReloaderImage: "jimmidyson/configmap-reload:latest",
ConfigReloaderCPU: "0",
ConfigReloaderMemory: "25Mi",
AlertmanagerDefaultBaseImage: "quay.io/prometheus/alertmanager",
}
sset, err := makeStatefulSet(&monitoringv1.Alertmanager{
Spec: monitoringv1.AlertmanagerSpec{},
}, nil, testConfig)
if err != nil {
t.Fatalf("Unexpected error while making StatefulSet: %v", err)
}
expectedResources := v1.ResourceRequirements{
Limits: v1.ResourceList{
v1.ResourceMemory: resource.MustParse("25Mi"),
},
}
for _, c := range sset.Spec.Template.Spec.Containers {
if c.Name == "config-reloader" && !reflect.DeepEqual(c.Resources, expectedResources) {
t.Fatal("Unexpected resource requests/limits set, when none should be set.")
}
}
} | explode_data.jsonl/37689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
16384,
50708,
2753,
7123,
1094,
22866,
1155,
353,
8840,
836,
8,
341,
18185,
2648,
1669,
5532,
515,
197,
66156,
6740,
39966,
1906,
25,
688,
330,
73,
12543,
42586,
930,
14730,
2186,
5504,
1078,
25,
19350,
756,
197,
66156,
6740... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateCleanDefault(t *testing.T) {
config := createValidTestConfig()
clientBuilder := NewDefaultClientConfig(*config, &ConfigOverrides{})
clientConfig, err := clientBuilder.ClientConfig()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
matchStringArg(config.Clusters["clean"].Server, clientConfig.Host, t)
matchBoolArg(config.Clusters["clean"].InsecureSkipTLSVerify, clientConfig.Insecure, t)
matchStringArg(config.AuthInfos["clean"].Token, clientConfig.BearerToken, t)
} | explode_data.jsonl/56166 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
4021,
27529,
3675,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
1855,
4088,
2271,
2648,
741,
25291,
3297,
1669,
1532,
3675,
2959,
2648,
4071,
1676,
11,
609,
2648,
80010,
6257,
692,
25291,
2648,
11,
1848,
1669,
2943,
3297,
1171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAdminAuthMiddleware(t *testing.T) {
WithServer(t, `
admin:
auth:
bearer:
- 'my-api-key'
`, func(deps *ServerDependencies) {}, func(deps *ServerDependencies, baseURL string) {
assert.Equal(t, `Bearer my-api-key`, AdminAuthHeaders(t, deps)["Authorization"])
// Pass
res := DoHTTPRequestWithHeaders(t, "PUT", fmt.Sprintf("%s/admin/log/level?category=auth&level=ERROR", baseURL), AdminAuthHeaders(t, deps), ``)
assert.NoError(t, res.Body.Close())
assert.Equal(t, 204, res.StatusCode)
// No API Key
res = DoHTTPRequestWithHeaders(t, "PUT", fmt.Sprintf("%s/admin/log/level?category=auth&level=ERROR", baseURL), map[string]string{}, ``)
assert.NoError(t, res.Body.Close())
assert.Equal(t, 403, res.StatusCode)
})
WithServer(t, `
admin:
auth:
bearer:
- 'my-api-key'
networks:
- 0.0.0.0/32
`, func(deps *ServerDependencies) {}, func(deps *ServerDependencies, baseURL string) {
assert.Equal(t, `Bearer my-api-key`, AdminAuthHeaders(t, deps)["Authorization"])
// IP range not trusted
res := DoHTTPRequestWithHeaders(t, "PUT", fmt.Sprintf("%s/admin/log/level?category=auth&level=ERROR", baseURL), AdminAuthHeaders(t, deps), ``)
assert.NoError(t, res.Body.Close())
assert.Equal(t, 403, res.StatusCode)
})
} | explode_data.jsonl/70689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 514
} | [
2830,
3393,
7210,
5087,
24684,
1155,
353,
8840,
836,
8,
341,
197,
2354,
5475,
1155,
11,
22074,
2882,
510,
78011,
510,
197,
2233,
20786,
510,
298,
197,
12,
364,
2408,
23904,
16173,
1248,
197,
7808,
2915,
12797,
1690,
353,
5475,
48303,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHeadRequest(t *testing.T) {
setupServer()
defer teardownServer()
wantHeader := "foo"
mux.HandleFunc("/url", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Foo", wantHeader)
})
req := URL("http://example.com/url")
if err := req.Head(); err != nil {
t.Error(err)
}
assertTextualBody(t, "", req.Response.Body)
assertMethod(t, "HEAD", req.Request.Method)
gotHeader := req.Response.Header.Get("X-Foo")
if wantHeader != gotHeader {
t.Errorf("Want header X-Foo=%s, got %s instead", wantHeader, gotHeader)
}
} | explode_data.jsonl/24751 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
12346,
1900,
1155,
353,
8840,
836,
8,
341,
84571,
5475,
741,
16867,
49304,
5475,
2822,
50780,
4047,
1669,
330,
7975,
1837,
2109,
2200,
63623,
4283,
1085,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKraken_LimitSell(t *testing.T) {
ord, err := k.LimitSell("0.01", "6900", goex.BTC_USD)
assert.Nil(t, err)
t.Log(ord)
} | explode_data.jsonl/44492 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
81165,
3366,
2351,
2353,
68533,
1155,
353,
8840,
836,
8,
341,
197,
539,
11,
1848,
1669,
595,
1214,
2353,
68533,
445,
15,
13,
15,
16,
497,
330,
21,
24,
15,
15,
497,
728,
327,
1785,
7749,
13467,
35,
340,
6948,
59678,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCreate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Job.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Job.Store)
validJob := validNewJob()
validJob.ObjectMeta = metav1.ObjectMeta{}
test.TestCreate(
// valid
validJob,
// invalid (empty selector)
&batch.Job{
Spec: batch.JobSpec{
Completions: validJob.Spec.Completions,
Selector: &metav1.LabelSelector{},
Template: validJob.Spec.Template,
},
},
)
} | explode_data.jsonl/53316 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
4021,
1155,
353,
8840,
836,
8,
341,
197,
16172,
11,
3538,
1669,
501,
5793,
1155,
340,
16867,
3538,
836,
261,
34016,
1155,
340,
16867,
5819,
45293,
38047,
57011,
9626,
741,
18185,
1669,
13954,
29172,
1944,
7121,
1155,
11,
581... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPSListener(t *testing.T) {
listener, err := NewHTTPSListener("./httpcert/cert.pem", "./httpcert/key.pem", ":12341")
if err != nil {
t.Fatalf("NewHTTPSListener error: %s\n", err)
}
srv := &TestHTTPServer{}
httpSrv := &http.Server{Handler: srv}
var httpsErr error
go func() {
httpsErr = httpSrv.Serve(listener)
}()
time.Sleep(time.Second)
if httpsErr != nil {
t.Fatalf("HTTP serve error: %s\n", httpsErr)
}
insecureHTTPSClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
resp, err := insecureHTTPSClient.Get("https://localhost:12341/test")
if err != nil {
t.Fatal("http.Get error:", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
t.Errorf("http.Get response status code: %d\n", resp.StatusCode)
}
} | explode_data.jsonl/22526 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 351
} | [
2830,
3393,
82354,
2743,
1155,
353,
8840,
836,
8,
341,
14440,
798,
11,
1848,
1669,
1532,
82354,
2743,
13988,
1254,
12246,
2899,
529,
49373,
497,
5924,
1254,
12246,
68864,
49373,
497,
13022,
16,
17,
18,
19,
16,
1138,
743,
1848,
961,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCustomerListError(t *testing.T) {
key := "api key"
mockErrorResponse := new(APIError)
mockErrorResponse.Type = "invalid_request"
mockErrorResponse.Message = "You do not have permission to do that"
mockCustomerNumber := "CUST-33442"
server, err := invdmockserver.New(403, mockErrorResponse, "json", true)
if err != nil {
t.Fatal(err)
}
defer server.Close()
conn := mockConnection(key, server)
customer := conn.NewCustomer()
_, err = customer.ListCustomerByNumber(mockCustomerNumber)
if err == nil {
t.Fatal("Error occured deleting customer")
}
if !reflect.DeepEqual(mockErrorResponse.Error(), err.Error()) {
t.Fatal("Error Messages Do Not Match Up")
}
} | explode_data.jsonl/15007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
12792,
852,
1454,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
330,
2068,
1376,
1837,
77333,
55901,
1669,
501,
48953,
1454,
340,
77333,
55901,
10184,
284,
330,
11808,
7893,
698,
77333,
55901,
8472,
284,
330,
2610,
653,
537,
61... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCACommon_GenerateECCCertificateRequest_Fail(t *testing.T) {
_, errCA = CAGenerateECCCertificateRequest(&CertRequest{
PrivateKeyData: priData,
CertificateRequestFilePath: filepath.Join(pathcarsapksc1512, caCertificateRequestFileName),
SignatureAlgorithm: x509.SHA256WithRSAPSS,
Subject: CAMockSubject,
}, "PRIVATE KEY")
t.Log(errCA)
} | explode_data.jsonl/24083 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
5049,
10839,
2646,
13220,
36,
3706,
33202,
1900,
1400,
604,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
5049,
284,
356,
1890,
13220,
36,
3706,
33202,
1900,
2099,
36934,
1900,
515,
197,
197,
75981,
1043,
25,
1797,
12493,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Web_EarlyWrite(t *testing.T) {
Convey("Write early content to response", t, func() {
result := ""
m := New()
m.Use(func(res http.ResponseWriter) {
result += "foobar"
res.Write([]byte("Hello world"))
})
m.Use(func() {
result += "bat"
})
m.Get("/", func() {})
m.Action(func(res http.ResponseWriter) {
result += "baz"
res.WriteHeader(http.StatusBadRequest)
})
resp := httptest.NewRecorder()
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
m.ServeHTTP(resp, req)
So(result, ShouldEqual, "foobar")
So(resp.Code, ShouldEqual, http.StatusOK)
})
} | explode_data.jsonl/44978 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 263
} | [
2830,
3393,
62,
5981,
2089,
277,
398,
7985,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
7985,
4124,
2213,
311,
2033,
497,
259,
11,
2915,
368,
341,
197,
9559,
1669,
8389,
197,
2109,
1669,
1532,
741,
197,
2109,
9046,
18552,
4590,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStepVerifyRequirements(t *testing.T) {
t.Parallel()
tempDir, err := ioutil.TempDir("", "test-step-verify-requirements")
require.NoError(t, err)
testData := path.Join("test_data", "verify_requirements", "boot-config")
_, err = os.Stat(testData)
require.NoError(t, err)
err = util.CopyDir(testData, tempDir, true)
require.NoError(t, err)
options := verify.StepVerifyRequirementsOptions{
Dir: tempDir,
}
// fake the output stream to be checked later
commonOpts := opts.NewCommonOptionsWithFactory(nil)
commonOpts.Out = os.Stdout
commonOpts.Err = os.Stderr
options.CommonOptions = &commonOpts
testhelpers.ConfigureTestOptions(options.CommonOptions, gits_test.NewMockGitter(), helm_test.NewMockHelmer())
err = options.Run()
assert.NoError(t, err, "Command failed: %#v", options)
// lets assert we have requirements populated nicely
reqFile := filepath.Join(tempDir, "env", helm.RequirementsFileName)
assert.FileExists(t, reqFile)
req, err := helm.LoadRequirementsFile(reqFile)
require.NoError(t, err, "failed to load file %s", reqFile)
dep := assertHasDependency(t, req, "jenkins-x-platform")
if dep != nil {
t.Logf("found version %s for jenkins-x-platform requirement", dep.Version)
assert.True(t, dep.Version != "", "missing version of jenkins-x-platform dependency")
}
} | explode_data.jsonl/39205 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
8304,
32627,
59202,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
16280,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
1944,
29208,
12,
12446,
12,
70126,
1138,
17957,
35699,
1155,
11,
1848,
692,
18185,
1043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSelectableFieldLabelConversions(t *testing.T) {
apitesting.TestSelectableFieldLabelConversionsOfKind(t,
registered.GroupOrDie(api.GroupName).GroupVersion.String(),
"ServiceAccount",
SelectableFields(&api.ServiceAccount{}),
nil,
)
} | explode_data.jsonl/24904 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
68707,
1877,
2476,
1109,
28290,
1155,
353,
8840,
836,
8,
341,
69898,
275,
59855,
8787,
68707,
1877,
2476,
1109,
28290,
2124,
10629,
1155,
345,
197,
29422,
291,
5407,
2195,
18175,
24827,
5407,
675,
568,
2808,
5637,
6431,
3148,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSetClearMapFields_KeyTypes(t *testing.T) {
fd, err := desc.LoadFileDescriptor("desc_test_field_types.proto")
testutil.Ok(t, err)
md := fd.FindSymbol("testprotos.MapKeyFields").(*desc.MessageDescriptor)
dm := NewMessage(md)
inputs := map[reflect.Kind]interface{}{
reflect.Bool: true,
reflect.Int32: int32(-12),
reflect.Int64: int64(-1234),
reflect.Uint32: uint32(45),
reflect.Uint64: uint64(4567),
reflect.String: "foobar",
}
mapKinds := []func(interface{}) interface{}{
// index 0 will not work since it doesn't return a map
func(v interface{}) interface{} {
return v
},
func(v interface{}) interface{} {
// generic map
return map[interface{}]interface{}{v: "foo"}
},
func(v interface{}) interface{} {
// specific key and value types
mp := reflect.MakeMap(reflect.MapOf(reflect.TypeOf(v), typeOfString))
val := reflect.ValueOf(v)
mp.SetMapIndex(val, reflect.ValueOf("foo"))
return mp.Interface()
},
}
cases := []struct {
kind reflect.Kind
tagNumber int
fieldName string
}{
{kind: reflect.Int32, tagNumber: 1, fieldName: "i"},
{kind: reflect.Int64, tagNumber: 2, fieldName: "j"},
{kind: reflect.Int32, tagNumber: 3, fieldName: "k"},
{kind: reflect.Int64, tagNumber: 4, fieldName: "l"},
{kind: reflect.Uint32, tagNumber: 5, fieldName: "m"},
{kind: reflect.Uint64, tagNumber: 6, fieldName: "n"},
{kind: reflect.Uint32, tagNumber: 7, fieldName: "o"},
{kind: reflect.Uint64, tagNumber: 8, fieldName: "p"},
{kind: reflect.Int32, tagNumber: 9, fieldName: "q"},
{kind: reflect.Int64, tagNumber: 10, fieldName: "r"},
{kind: reflect.String, tagNumber: 11, fieldName: "s"},
{kind: reflect.Bool, tagNumber: 12, fieldName: "t"},
}
zero := reflect.Zero(typeOfGenericMap).Interface()
for idx, c := range cases {
for k, i := range inputs {
allowed := canAssign(c.kind, k)
for j, mk := range mapKinds {
// First run the case using Try* methods
testutil.Require(t, !dm.HasFieldNumber(c.tagNumber))
v, err := dm.TryGetFieldByNumber(c.tagNumber)
testutil.Ok(t, err)
testutil.Eq(t, zero, v)
v, err = dm.TryGetFieldByName(c.fieldName)
testutil.Ok(t, err)
testutil.Eq(t, zero, v)
input := mk(i)
err = dm.TrySetFieldByNumber(c.tagNumber, input)
if shouldTestValue(t, err, j != 0 && allowed, k, c.kind, idx) {
// make sure value stuck
v, err = dm.TryGetFieldByNumber(c.tagNumber)
testutil.Ok(t, err)
testutil.Eq(t, typeOfGenericMap, reflect.TypeOf(v))
testutil.Eq(t, coerceMapKeys(input, c.kind), v)
testutil.Require(t, dm.HasFieldNumber(c.tagNumber))
}
err = dm.TryClearFieldByNumber(c.tagNumber)
testutil.Ok(t, err)
testutil.Require(t, !dm.HasFieldNumber(c.tagNumber))
v, err = dm.TryGetFieldByNumber(c.tagNumber)
testutil.Ok(t, err)
testutil.Eq(t, zero, v)
err = dm.TrySetFieldByName(c.fieldName, input)
if shouldTestValue(t, err, j != 0 && allowed, k, c.kind, idx) {
// make sure value stuck
v, err = dm.TryGetFieldByName(c.fieldName)
testutil.Ok(t, err)
testutil.Eq(t, typeOfGenericMap, reflect.TypeOf(v))
testutil.Eq(t, coerceMapKeys(input, c.kind), v)
testutil.Require(t, dm.HasFieldName(c.fieldName))
}
err = dm.TryClearFieldByName(c.fieldName)
testutil.Ok(t, err)
testutil.Require(t, !dm.HasFieldName(c.fieldName))
v, err = dm.TryGetFieldByName(c.fieldName)
testutil.Ok(t, err)
testutil.Eq(t, zero, v)
// Now we do it again using the non-Try* methods (e.g. the ones that panic)
v = dm.GetFieldByNumber(c.tagNumber)
testutil.Eq(t, zero, v)
v = dm.GetFieldByName(c.fieldName)
testutil.Eq(t, zero, v)
err = catchPanic(func() { dm.SetFieldByNumber(c.tagNumber, input) })
if shouldTestValue(t, err, j != 0 && allowed, k, c.kind, idx) {
// make sure value stuck
v = dm.GetFieldByNumber(c.tagNumber)
testutil.Eq(t, typeOfGenericMap, reflect.TypeOf(v))
testutil.Eq(t, coerceMapKeys(input, c.kind), v)
testutil.Require(t, dm.HasFieldNumber(c.tagNumber))
}
dm.ClearFieldByNumber(c.tagNumber)
testutil.Require(t, !dm.HasFieldNumber(c.tagNumber))
v = dm.GetFieldByNumber(c.tagNumber)
testutil.Eq(t, zero, v)
err = catchPanic(func() { dm.SetFieldByName(c.fieldName, input) })
if shouldTestValue(t, err, j != 0 && allowed, k, c.kind, idx) {
// make sure value stuck
v = dm.GetFieldByNumber(c.tagNumber)
testutil.Eq(t, typeOfGenericMap, reflect.TypeOf(v))
testutil.Eq(t, coerceMapKeys(input, c.kind), v)
testutil.Require(t, dm.HasFieldName(c.fieldName))
}
dm.ClearFieldByName(c.fieldName)
testutil.Require(t, !dm.HasFieldName(c.fieldName))
v = dm.GetFieldByName(c.fieldName)
testutil.Eq(t, zero, v)
}
}
}
} | explode_data.jsonl/40954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2146
} | [
2830,
3393,
1949,
1649,
14008,
2227,
8941,
35253,
4173,
1155,
353,
8840,
836,
8,
341,
61721,
11,
1848,
1669,
6560,
13969,
1703,
11709,
445,
8614,
4452,
5013,
9763,
57322,
1138,
18185,
1314,
54282,
1155,
11,
1848,
340,
84374,
1669,
12414,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshalClientDisconnect(t *testing.T) {
tt := []struct {
packet mc.Packet
unmarshalledPacket mc.ClientBoundDisconnect
}{
{
packet: mc.Packet{
ID: 0x00,
Data: []byte{0x00},
},
unmarshalledPacket: mc.ClientBoundDisconnect{
Reason: mc.Chat(""),
},
},
{
packet: mc.Packet{
ID: 0x00,
Data: []byte{0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21},
},
unmarshalledPacket: mc.ClientBoundDisconnect{
Reason: mc.Chat("Hello, World!"),
},
},
}
for _, tc := range tt {
disconnectMessage, err := mc.UnmarshalClientDisconnect(tc.packet)
if err != nil {
t.Error(err)
}
if disconnectMessage.Reason != tc.unmarshalledPacket.Reason {
t.Errorf("got: %v, want: %v", disconnectMessage.Reason, tc.unmarshalledPacket.Reason)
}
}
} | explode_data.jsonl/45011 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
1806,
27121,
2959,
60651,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
68802,
1797,
19223,
93971,
198,
197,
20479,
36239,
4736,
16679,
19223,
11716,
19568,
60651,
198,
197,
59403,
197,
197,
515,
298,
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... | 4 |
func TestGlob(t *testing.T) {
t.Run("tmp/*", func(t *testing.T) {
chk := assert.New(t)
tmp := filepath.Join(os.TempDir(), "*")
hits, err := fscopy.Glob(tmp)
chk.NoError(err)
chk.NotEqual(0, len(hits))
})
t.Run("tmp/*, tmp/?* dedupes", func(t *testing.T) {
chk := assert.New(t)
a := filepath.Join(os.TempDir(), "*")
b := filepath.Join(os.TempDir(), "?*")
hits, err := fscopy.Glob(a, b)
chk.NoError(err)
chk.NotEqual(0, len(hits))
})
t.Run("tmp/no-matches", func(t *testing.T) {
chk := assert.New(t)
a := filepath.Join(os.TempDir(), "theresnowaythispatternmatchesnaythingonthissystemitscompletelyimpossiblealligatorshoeshinefishinabarrel")
hits, err := fscopy.Glob(a)
chk.NoError(err)
chk.Equal(0, len(hits))
})
} | explode_data.jsonl/64341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 362
} | [
2830,
3393,
38,
1684,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5173,
1057,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
23049,
74,
1669,
2060,
7121,
1155,
340,
197,
20082,
1669,
26054,
22363,
9638,
65009,
6184,
1507,
15630,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestServiceManagerOverridesStepError(t *testing.T) {
tests := map[string]struct {
givenReqParams internal.ProvisioningParameters
expErr string
}{
"return error when creds in request are not provided and overrides should not be applied": {
givenReqParams: internal.ProvisioningParameters{},
expErr: "unable to obtain SM credentials: Service Manager Credentials are required to be send in provisioning request.",
},
}
for tN, tC := range tests {
t.Run(tN, func(t *testing.T) {
// given
factory := servicemanager.NewClientFactory(servicemanager.Config{
OverrideMode: servicemanager.SMOverrideModeNever,
URL: "",
Password: "",
Username: "",
})
operation := internal.UpgradeKymaOperation{
Operation: internal.Operation{
ID: "123",
ProvisioningParameters: tC.givenReqParams,
},
SMClientFactory: factory,
}
memoryStorage := storage.NewMemoryStorage()
require.NoError(t, memoryStorage.Operations().InsertUpgradeKymaOperation(operation))
smStep := NewServiceManagerOverridesStep(memoryStorage.Operations())
// when
gotOperation, retryTime, err := smStep.Run(operation, NewLogDummy())
// then
require.EqualError(t, err, tC.expErr)
assert.Zero(t, retryTime)
assert.Equal(t, domain.Failed, gotOperation.State)
})
}
} | explode_data.jsonl/12553 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 530
} | [
2830,
3393,
1860,
2043,
80010,
8304,
1454,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
3174,
2071,
27234,
4870,
5306,
7763,
13013,
287,
9706,
198,
197,
48558,
7747,
260,
914,
198,
197,
59403,
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 TestTransportRejectsConnHeaders(t *testing.T) {
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
var got []string
for k := range r.Header {
got = append(got, k)
}
sort.Strings(got)
w.Header().Set("Got-Header", strings.Join(got, ","))
}, optOnlyServer)
defer st.Close()
tr := &Transport{TLSClientConfig: tlsConfigInsecure}
defer tr.CloseIdleConnections()
tests := []struct {
key string
value []string
want string
}{
{
key: "Upgrade",
value: []string{"anything"},
want: "ERROR: http2: invalid Upgrade request header: [\"anything\"]",
},
{
key: "Connection",
value: []string{"foo"},
want: "ERROR: http2: invalid Connection request header: [\"foo\"]",
},
{
key: "Connection",
value: []string{"close"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Connection",
value: []string{"CLoSe"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Connection",
value: []string{"close", "something-else"},
want: "ERROR: http2: invalid Connection request header: [\"close\" \"something-else\"]",
},
{
key: "Connection",
value: []string{"keep-alive"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Connection",
value: []string{"Keep-ALIVE"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Proxy-Connection", // just deleted and ignored
value: []string{"keep-alive"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Transfer-Encoding",
value: []string{""},
want: "Accept-Encoding,User-Agent",
},
{
key: "Transfer-Encoding",
value: []string{"foo"},
want: "ERROR: http2: invalid Transfer-Encoding request header: [\"foo\"]",
},
{
key: "Transfer-Encoding",
value: []string{"chunked"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Transfer-Encoding",
value: []string{"chunked", "other"},
want: "ERROR: http2: invalid Transfer-Encoding request header: [\"chunked\" \"other\"]",
},
{
key: "Content-Length",
value: []string{"123"},
want: "Accept-Encoding,User-Agent",
},
{
key: "Keep-Alive",
value: []string{"doop"},
want: "Accept-Encoding,User-Agent",
},
}
for _, tt := range tests {
req, _ := http.NewRequest("GET", st.ts.URL, nil)
req.Header[tt.key] = tt.value
res, err := tr.RoundTrip(req)
var got string
if err != nil {
got = fmt.Sprintf("ERROR: %v", err)
} else {
got = res.Header.Get("Got-Header")
res.Body.Close()
}
if got != tt.want {
t.Errorf("For key %q, value %q, got = %q; want %q", tt.key, tt.value, got, tt.want)
}
}
} | explode_data.jsonl/16116 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1140
} | [
2830,
3393,
27560,
78413,
82,
9701,
10574,
1155,
353,
8840,
836,
8,
341,
18388,
1669,
501,
5475,
58699,
1155,
11,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
2405,
2684,
3056,
917,
198,
197,
2023,
595,
1669,
2088,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccMinioIAMGroupPolicy_namePrefix(t *testing.T) {
var groupPolicy2 string
namePrefix := "tf-acc-test-"
rInt := acctest.RandInt()
resourceName := "minio_iam_group_policy.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviders,
CheckDestroy: testAccCheckIAMGroupPolicyDestroy,
Steps: []resource.TestStep{
{
Config: testAccIAMGroupPolicyConfigNamePrefix(namePrefix, rInt, "s3:ListAllMyBuckets"),
Check: resource.ComposeTestCheckFunc(
testAccCheckIAMGroupPolicyExists(
"minio_iam_group.test",
"minio_iam_group_policy.test",
&groupPolicy2,
),
resource.TestMatchResourceAttr(resourceName, "name", regexp.MustCompile(fmt.Sprintf("^%s", namePrefix))),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name_prefix"},
},
},
})
} | explode_data.jsonl/7180 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
14603,
6217,
815,
73707,
2808,
13825,
1269,
14335,
1155,
353,
8840,
836,
8,
341,
2405,
1874,
13825,
17,
914,
198,
11609,
14335,
1669,
330,
8935,
12,
4475,
16839,
12,
698,
7000,
1072,
1669,
1613,
67880,
2013,
437,
1072,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestArm64Compiler_indirectCallWithTargetOnCallingConvReg(t *testing.T) {
env := newCompilerEnvironment()
table := make([]wasm.Reference, 1)
env.addTable(&wasm.TableInstance{References: table})
// Ensure that the module instance has the type information for targetOperation.TypeIndex,
// and the typeID matches the table[targetOffset]'s type ID.
operation := &wazeroir.OperationCallIndirect{TypeIndex: 0}
env.module().TypeIDs = []wasm.FunctionTypeID{0}
env.module().Engine = &moduleEngine{functions: []*function{}}
me := env.moduleEngine()
{ // Compiling call target.
compiler := env.requireNewCompiler(t, newCompiler, nil)
err := compiler.compilePreamble()
require.NoError(t, err)
err = compiler.compileReturnFunction()
require.NoError(t, err)
c, _, _, err := compiler.compile()
require.NoError(t, err)
f := &function{
parent: &code{codeSegment: c},
codeInitialAddress: uintptr(unsafe.Pointer(&c[0])),
moduleInstanceAddress: uintptr(unsafe.Pointer(env.moduleInstance)),
source: &wasm.FunctionInstance{TypeID: 0},
}
me.functions = append(me.functions, f)
table[0] = uintptr(unsafe.Pointer(f))
}
compiler := env.requireNewCompiler(t, newCompiler, &wazeroir.CompilationResult{
Signature: &wasm.FunctionType{},
Types: []*wasm.FunctionType{{}},
HasTable: true,
}).(*arm64Compiler)
err := compiler.compilePreamble()
require.NoError(t, err)
// Place the offset into the calling-convention reserved register.
offsetLoc := compiler.pushRuntimeValueLocationOnRegister(arm64CallingConventionModuleInstanceAddressRegister,
runtimeValueTypeI32)
compiler.assembler.CompileConstToRegister(arm64.MOVD, 0, offsetLoc.register)
require.NoError(t, compiler.compileCallIndirect(operation))
err = compiler.compileReturnFunction()
require.NoError(t, err)
// Generate the code under test and run.
code, _, _, err := compiler.compile()
require.NoError(t, err)
env.exec(code)
} | explode_data.jsonl/79909 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 707
} | [
2830,
3393,
32913,
21,
19,
38406,
9122,
1226,
7220,
2354,
6397,
1925,
48853,
34892,
3477,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
501,
38406,
12723,
741,
26481,
1669,
1281,
10556,
86,
10530,
58416,
11,
220,
16,
340,
57538,
1364,
2556... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSwitchDefFirst(t *testing.T) {
const SCRIPT = `
function F(x) {
var i = 0;
switch (x) {
default:
i++;
case 0:
i++;
case 1:
i++;
case 2:
i++;
break;
case 3:
i++;
}
return i;
}
F(0) + F(1) + F(2) + F(4);
`
testScript1(SCRIPT, intToValue(10), t)
} | explode_data.jsonl/75295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
16837,
2620,
5338,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
7527,
434,
2075,
8,
341,
197,
2405,
600,
284,
220,
15,
280,
197,
8961,
320,
87,
8,
341,
197,
11940,
510,
298,
8230,
3507,
197,
2722,
220,
15,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapSparseIterOrder(t *testing.T) {
// Run several rounds to increase the probability
// of failure. One is not enough.
NextRound:
for round := 0; round < 10; round++ {
m := make(map[int]bool)
// Add 1000 items, remove 980.
for i := 0; i < 1000; i++ {
m[i] = true
}
for i := 20; i < 1000; i++ {
delete(m, i)
}
var first []int
for i := range m {
first = append(first, i)
}
// 800 chances to get a different iteration order.
// See bug 8736 for why we need so many tries.
for n := 0; n < 800; n++ {
idx := 0
for i := range m {
if i != first[idx] {
// iteration order changed.
continue NextRound
}
idx++
}
}
t.Fatalf("constant iteration order on round %d: %v", round, first)
}
} | explode_data.jsonl/19920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
2227,
98491,
8537,
4431,
1155,
353,
8840,
836,
8,
341,
197,
322,
6452,
3807,
19531,
311,
5263,
279,
18927,
198,
197,
322,
315,
7901,
13,
3776,
374,
537,
3322,
624,
5847,
27497,
510,
2023,
4778,
1669,
220,
15,
26,
4778,
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... | 8 |
func TestDaoExpireReplyZSetRds(t *testing.T) {
convey.Convey("ExpireReplyZSetRds", t, func(ctx convey.C) {
var (
name = ""
oid = int64(0)
tp = int(0)
)
ctx.Convey("When everything goes positive", func(ctx convey.C) {
ok, err := d.ExpireReplyZSetRds(context.Background(), name, oid, tp)
ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(ok, convey.ShouldNotBeNil)
})
})
})
} | explode_data.jsonl/21790 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
12197,
8033,
554,
20841,
57,
1649,
49,
5356,
1155,
353,
8840,
836,
8,
341,
37203,
5617,
4801,
5617,
445,
8033,
554,
20841,
57,
1649,
49,
5356,
497,
259,
11,
2915,
7502,
20001,
727,
8,
341,
197,
2405,
2399,
298,
11609,
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 TestGetSymbolsDetails(t *testing.T) {
t.Parallel()
_, err := b.GetSymbolsDetails()
if err != nil {
t.Error("BitfinexGetSymbolsDetails init error: ", err)
}
} | explode_data.jsonl/79935 | {
"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,
1949,
56213,
7799,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
6878,
1848,
1669,
293,
2234,
56213,
7799,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
445,
8344,
5472,
327,
1949,
56213,
7799,
2930,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestOperationADC(t *testing.T) {
cpu := testCPU
cpu.Reset()
cpu.a = byte(0x2)
cpu.addressAbs = Word(0x0100)
cpu.bus.CPUWrite(cpu.addressAbs, byte(0x3))
ADC(cpu)
assertFalse(t, cpu.StatusRegister(C))
assertEqualsB(t, byte(0x5), cpu.a)
} | explode_data.jsonl/73051 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
8432,
31956,
1155,
353,
8840,
836,
8,
1476,
80335,
1669,
1273,
31615,
198,
80335,
36660,
2822,
80335,
5849,
284,
4922,
7,
15,
87,
17,
340,
80335,
13792,
27778,
284,
9322,
7,
15,
87,
15,
16,
15,
15,
340,
80335,
48067,
727... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOperator_RequiresGrad(t *testing.T) {
t.Run("with generics - float32", testOperatorRequiresGrad[float32])
t.Run("with generics - float64", testOperatorRequiresGrad[float64])
} | explode_data.jsonl/49577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 61
} | [
2830,
3393,
18461,
62,
46961,
23999,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4197,
95545,
481,
2224,
18,
17,
497,
1273,
18461,
46961,
23999,
95381,
18,
17,
2546,
3244,
16708,
445,
4197,
95545,
481,
2224,
21,
19,
497,
1273,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestRoute_GetTTLSeconds(t *testing.T) {
route := Route{}
ttlSeconds := 120
route.ttlSeconds = &ttlSeconds
assert.Equal(t, 120, *route.GetTTLSeconds())
} | explode_data.jsonl/67794 | {
"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,
4899,
13614,
51,
13470,
15343,
1155,
353,
8840,
836,
8,
341,
7000,
2133,
1669,
9572,
16094,
3244,
11544,
15343,
1669,
220,
16,
17,
15,
198,
7000,
2133,
734,
11544,
15343,
284,
609,
62858,
15343,
271,
6948,
12808,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestAddBeforeRunning(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
cron := New()
cron.AddFunc("* * * * * ?", func() { wg.Done() })
cron.Start()
defer cron.Stop()
// Give cron 2 seconds to run our job (which is always activated).
select {
case <-time.After(ONE_SECOND):
t.FailNow()
case <-wait(wg):
}
} | explode_data.jsonl/10554 | {
"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,
2212,
10227,
18990,
1155,
353,
8840,
836,
8,
341,
72079,
1669,
609,
12996,
28384,
2808,
16094,
72079,
1904,
7,
16,
692,
1444,
2248,
1669,
1532,
741,
1444,
2248,
1904,
9626,
29592,
353,
353,
353,
353,
42313,
2915,
368,
314,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_FullLoggerNameGenerator_withString(t *testing.T) {
givenString := "123"
assert.ToBeEqual(t, givenString, FullLoggerNameGenerator(givenString))
assert.ToBeEqual(t, givenString, FullLoggerNameGenerator(&givenString))
} | explode_data.jsonl/57922 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
1400,
617,
7395,
675,
12561,
6615,
703,
1155,
353,
8840,
836,
8,
341,
3174,
2071,
703,
1669,
330,
16,
17,
18,
698,
6948,
3274,
3430,
2993,
1155,
11,
2661,
703,
11,
8627,
7395,
675,
12561,
3268,
2071,
703,
1171,
6948,
327... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestWorkDoneProgressCreateParams(t *testing.T) {
t.Parallel()
const (
wantToken = int32(1569)
invalidToken = int32(1348)
)
var (
wantString = `{"token":"` + strconv.FormatInt(int64(wantToken), 10) + `"}`
wantInvalidString = `{"token":"` + strconv.FormatInt(int64(invalidToken), 10) + `"}`
wantNumber = `{"token":` + strconv.FormatInt(int64(wantToken), 10) + `}`
wantInvalidNumber = `{"token":` + strconv.FormatInt(int64(invalidToken), 10) + `}`
)
token := NewProgressToken(strconv.FormatInt(int64(wantToken), 10))
wantTypeString := WorkDoneProgressCreateParams{
Token: *token,
}
numberToken := NewNumberProgressToken(wantToken)
wantTypeNumber := WorkDoneProgressCreateParams{
Token: *numberToken,
}
t.Run("Marshal", func(t *testing.T) {
tests := []struct {
name string
field WorkDoneProgressCreateParams
want string
wantMarshalErr bool
wantErr bool
}{
{
name: "Valid/String",
field: wantTypeString,
want: wantString,
wantMarshalErr: false,
wantErr: false,
},
{
name: "Valid/Number",
field: wantTypeNumber,
want: wantNumber,
wantMarshalErr: false,
wantErr: false,
},
{
name: "Invalid/String",
field: wantTypeString,
want: wantInvalidString,
wantMarshalErr: false,
wantErr: true,
},
{
name: "Invalid/Number",
field: wantTypeNumber,
want: wantInvalidNumber,
wantMarshalErr: false,
wantErr: true,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := json.Marshal(&tt.field)
if (err != nil) != tt.wantMarshalErr {
t.Fatal(err)
}
if diff := cmp.Diff(tt.want, string(got)); (diff != "") != tt.wantErr {
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
}
})
}
})
t.Run("Unmarshal", func(t *testing.T) {
tests := []struct {
name string
field string
want WorkDoneProgressCreateParams
wantUnmarshalErr bool
wantErr bool
}{
{
name: "Valid/String",
field: wantString,
want: wantTypeString,
wantUnmarshalErr: false,
wantErr: false,
},
{
name: "Valid/Number",
field: wantNumber,
want: wantTypeNumber,
wantUnmarshalErr: false,
wantErr: false,
},
{
name: "Invalid/String",
field: wantInvalidString,
want: wantTypeString,
wantUnmarshalErr: false,
wantErr: true,
},
{
name: "Invalid/Number",
field: wantInvalidNumber,
want: wantTypeNumber,
wantUnmarshalErr: false,
wantErr: true,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var got WorkDoneProgressCreateParams
if err := json.Unmarshal([]byte(tt.field), &got); (err != nil) != tt.wantUnmarshalErr {
t.Fatal(err)
}
if diff := cmp.Diff(fmt.Sprint(got.Token), strconv.FormatInt(int64(wantToken), 10)); (diff != "") != tt.wantErr {
t.Errorf("%s: wantErr: %t\n(-want +got)\n%s", tt.name, tt.wantErr, diff)
}
})
}
})
} | explode_data.jsonl/16162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1835
} | [
2830,
3393,
6776,
17453,
9496,
4021,
4870,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
4777,
2399,
197,
50780,
3323,
262,
284,
526,
18,
17,
7,
16,
20,
21,
24,
340,
197,
197,
11808,
3323,
284,
526,
18,
17,
7,
16,
18,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMakeReceiveAdapterNoNet(t *testing.T) {
src := &v1alpha1.KafkaSource{
ObjectMeta: metav1.ObjectMeta{
Name: "source-name",
Namespace: "source-namespace",
},
Spec: v1alpha1.KafkaSourceSpec{
ServiceAccountName: "source-svc-acct",
Topics: "topic1,topic2",
BootstrapServers: "server1,server2",
ConsumerGroup: "group",
},
}
got := MakeReceiveAdapter(&ReceiveAdapterArgs{
Image: "test-image",
Source: src,
Labels: map[string]string{
"test-key1": "test-value1",
"test-key2": "test-value2",
},
SinkURI: "sink-uri",
})
one := int32(1)
want := &v1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Namespace: "source-namespace",
GenerateName: "source-name-",
Labels: map[string]string{
"test-key1": "test-value1",
"test-key2": "test-value2",
},
},
Spec: v1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"test-key1": "test-value1",
"test-key2": "test-value2",
},
},
Replicas: &one,
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"sidecar.istio.io/inject": "true",
},
Labels: map[string]string{
"test-key1": "test-value1",
"test-key2": "test-value2",
},
},
Spec: corev1.PodSpec{
ServiceAccountName: "source-svc-acct",
Containers: []corev1.Container{
{
Name: "receive-adapter",
Image: "test-image",
Env: []corev1.EnvVar{
{
Name: "KAFKA_BOOTSTRAP_SERVERS",
Value: "server1,server2",
},
{
Name: "KAFKA_TOPICS",
Value: "topic1,topic2",
},
{
Name: "KAFKA_CONSUMER_GROUP",
Value: "group",
},
{
Name: "KAFKA_NET_SASL_ENABLE",
Value: "false",
},
{
Name: "KAFKA_NET_TLS_ENABLE",
Value: "false",
},
{
Name: "SINK_URI",
Value: "sink-uri",
},
{
Name: "NAME",
Value: "source-name",
},
{
Name: "NAMESPACE",
Value: "source-namespace",
},
},
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("250m"),
corev1.ResourceMemory: resource.MustParse("512Mi"),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("250m"),
corev1.ResourceMemory: resource.MustParse("512Mi"),
},
},
},
},
},
},
},
}
if diff, err := kmp.SafeDiff(want, got); err != nil {
t.Errorf("unexpected deploy (-want, +got) = %v", diff)
}
src.Spec.Resources = v1alpha1.KafkaResourceSpec{
Requests: v1alpha1.KafkaRequestsSpec{
ResourceCPU: "101m",
ResourceMemory: "200Mi",
},
Limits: v1alpha1.KafkaLimitsSpec{
ResourceCPU: "102m",
ResourceMemory: "500Mi",
},
}
want.Spec.Template.Spec.Containers = []corev1.Container{
{
Name: "receive-adapter",
Image: "test-image",
Env: []corev1.EnvVar{
{
Name: "KAFKA_BOOTSTRAP_SERVERS",
Value: "server1,server2",
},
{
Name: "KAFKA_TOPICS",
Value: "topic1,topic2",
},
{
Name: "KAFKA_CONSUMER_GROUP",
Value: "group",
},
{
Name: "KAFKA_NET_SASL_ENABLE",
Value: "false",
},
{
Name: "KAFKA_NET_TLS_ENABLE",
Value: "false",
},
{
Name: "SINK_URI",
Value: "sink-uri",
},
{
Name: "KAFKA_NET_SASL_USER",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "the-user-secret",
},
Key: "user",
},
},
},
{
Name: "KAFKA_NET_SASL_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "the-password-secret",
},
Key: "password",
},
},
},
{
Name: "KAFKA_NET_TLS_CERT",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "the-cert-secret",
},
Key: "tls.crt",
},
},
},
{
Name: "KAFKA_NET_TLS_KEY",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "the-key-secret",
},
Key: "tls.key",
},
},
},
{
Name: "KAFKA_NET_TLS_CA_CERT",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "the-ca-cert-secret",
},
Key: "tls.crt",
},
},
},
},
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("102m"),
corev1.ResourceMemory: resource.MustParse("500Mi"),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("101m"),
corev1.ResourceMemory: resource.MustParse("200Mi"),
},
},
},
}
if diff, err := kmp.SafeDiff(want, got); err != nil {
t.Errorf("unexpected deploy (-want, +got) = %v", diff)
}
} | explode_data.jsonl/46149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2918
} | [
2830,
3393,
8078,
14742,
5940,
2753,
6954,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
609,
85,
16,
7141,
16,
11352,
21883,
3608,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
2427,
11494,
756,
298,
90823... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessLine(t *testing.T) {
curX := new(int)
curY := new(int)
for i, c := range processLineCases {
*curX, *curY = lookupKey(c.pad, c.startKey)
got := processLine(c.pad, curX, curY, c.line)
if got != c.want {
t.Fatalf("Case %d: Wanted %v, got %v", i+1, string(c.want), string(got))
}
}
} | explode_data.jsonl/42990 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
7423,
2460,
1155,
353,
8840,
836,
8,
341,
33209,
55,
1669,
501,
1548,
340,
33209,
56,
1669,
501,
1548,
340,
2023,
600,
11,
272,
1669,
2088,
1882,
2460,
37302,
341,
197,
197,
9,
2352,
55,
11,
353,
2352,
56,
284,
18615,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateReal(t *testing.T) {
s := beginTxWithFixtures()
defer s.AutoRollback()
var id int64
// Insert a George
err := s.InsertInto("people").Columns("name", "email").
Values("George", "george@whitehouse.gov").
Returning("id").
QueryScalar(&id)
assert.NoError(t, err)
// Rename our George to Barack
_, err = s.Update("people").SetMap(map[string]interface{}{"name": "Barack", "email": "barack@whitehouse.gov"}).Where("id = $1", id).Exec()
assert.NoError(t, err)
var person Person
err = s.Select("*").From("people").Where("id = $1", id).QueryStruct(&person)
assert.NoError(t, err)
assert.Equal(t, person.ID, id)
assert.Equal(t, person.Name, "Barack")
assert.Equal(t, person.Email.Valid, true)
assert.Equal(t, person.Email.String, "barack@whitehouse.gov")
} | explode_data.jsonl/80346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 301
} | [
2830,
3393,
4289,
12768,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
3161,
31584,
2354,
25958,
18513,
741,
16867,
274,
6477,
32355,
1419,
2822,
2405,
877,
526,
21,
19,
198,
197,
322,
17101,
264,
9857,
198,
9859,
1669,
274,
23142,
26591,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test64BitReturnStdCall(t *testing.T) {
const (
VER_BUILDNUMBER = 0x0000004
VER_MAJORVERSION = 0x0000002
VER_MINORVERSION = 0x0000001
VER_PLATFORMID = 0x0000008
VER_PRODUCT_TYPE = 0x0000080
VER_SERVICEPACKMAJOR = 0x0000020
VER_SERVICEPACKMINOR = 0x0000010
VER_SUITENAME = 0x0000040
VER_EQUAL = 1
VER_GREATER = 2
VER_GREATER_EQUAL = 3
VER_LESS = 4
VER_LESS_EQUAL = 5
ERROR_OLD_WIN_VERSION syscall.Errno = 1150
)
type OSVersionInfoEx struct {
OSVersionInfoSize uint32
MajorVersion uint32
MinorVersion uint32
BuildNumber uint32
PlatformId uint32
CSDVersion [128]uint16
ServicePackMajor uint16
ServicePackMinor uint16
SuiteMask uint16
ProductType byte
Reserve byte
}
d := GetDLL(t, "kernel32.dll")
var m1, m2 uintptr
VerSetConditionMask := d.Proc("VerSetConditionMask")
m1, m2, _ = VerSetConditionMask.Call(m1, m2, VER_MAJORVERSION, VER_GREATER_EQUAL)
m1, m2, _ = VerSetConditionMask.Call(m1, m2, VER_MINORVERSION, VER_GREATER_EQUAL)
m1, m2, _ = VerSetConditionMask.Call(m1, m2, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL)
m1, m2, _ = VerSetConditionMask.Call(m1, m2, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL)
vi := OSVersionInfoEx{
MajorVersion: 5,
MinorVersion: 1,
ServicePackMajor: 2,
ServicePackMinor: 0,
}
vi.OSVersionInfoSize = uint32(unsafe.Sizeof(vi))
r, _, e2 := d.Proc("VerifyVersionInfoW").Call(
uintptr(unsafe.Pointer(&vi)),
VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR,
m1, m2)
if r == 0 && e2 != ERROR_OLD_WIN_VERSION {
t.Errorf("VerifyVersionInfo failed: %s", e2)
}
} | explode_data.jsonl/54655 | {
"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,
21,
19,
8344,
5598,
22748,
7220,
1155,
353,
8840,
836,
8,
1476,
4777,
2399,
197,
197,
3763,
37491,
51639,
414,
284,
220,
15,
87,
15,
15,
15,
15,
15,
15,
19,
198,
197,
197,
3763,
52045,
17636,
257,
284,
220,
15,
87,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNonMoveHelpers(t *testing.T) {
DEBUGAPPLYMOVE = false
DEBUGCIRCUIT = false
vec1 := [2]float64{1.0, 1.0}
vec2 := [2]float64{0.5, 0.5}
vec3 := [2]float64{3.4, 1.8}
vec4 := [2]float64{0.0, 0.7777}
vec5 := [2]float64{0.0, 1.0}
s1 := [][2]float64{vec1, vec2}
s2 := [][2]float64{vec3, vec4}
s3 := [][2]float64{vec5, vec1}
//s4:= [][2]float64{vec2, vec1}
testComplexMultiplication(t, vec1, vec2, vec3, vec4, vec5)
testModulus(t, vec1, vec3, vec5)
k := testKroneckerProduct(t, s1, s2, s3)
direc1 := [][2]float64{{1.0, 0.0}, {0.0, 0.0}}
testApplyCircuit(t, direc1, k)
} | explode_data.jsonl/46080 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
8121,
9860,
28430,
1155,
353,
8840,
836,
8,
1476,
52346,
2537,
24834,
29116,
284,
895,
198,
52346,
34,
2801,
16799,
952,
284,
895,
198,
40213,
16,
1669,
508,
17,
60,
3649,
21,
19,
90,
16,
13,
15,
11,
220,
16,
13,
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 TestRowTableAddGeometryNoStyle(t *testing.T) {
map_dao := &TableRowAddGeomImpl{&DaoImpl{}, "polygon", false, false, false}
service := service.MakeTableRowService(map_dao)
uri_params := map[string]string{"table_id": "42"}
values := url.Values{}
values.Set("with_geometry", "1")
values.Set("geometry", "SRID=4326;POINT(78.4622620046139 17.411652235651)")
request := makeRequest(http.MethodPost, uri_params, values, true)
result := service.Add(request)
// wait for a second to make sure that trs.updateGeometryTypeStyle is called
time.Sleep(100 * time.Millisecond)
if !result.IsSuccess() {
t.Errorf("Error returned")
}
_, ok := result.GetDataByKey("row")
if !ok {
t.Errorf("row should be present in data")
}
if !map_dao.insert_geometry_called {
t.Errorf("InsertWithGeometry not called")
}
if !map_dao.find_where_called {
t.Errorf("FindWhere not called")
}
if map_dao.fetch_data_called {
t.Errorf("Geometry type queried for even when geometry type is set in mstr_layer")
}
} | explode_data.jsonl/15449 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
3102,
2556,
2212,
20787,
2753,
2323,
1155,
353,
8840,
836,
8,
341,
19567,
814,
3441,
1669,
609,
38558,
2212,
78708,
9673,
90,
5,
12197,
9673,
22655,
330,
65012,
497,
895,
11,
895,
11,
895,
532,
52934,
1669,
2473,
50133,
38... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPiecewiseCubicFitWithDerivatives(t *testing.T) {
t.Parallel()
xs := []float64{-1, 0, 1}
ys := make([]float64, 3)
dydxs := make([]float64, 3)
leftPoly := func(x float64) float64 {
return x*x - x + 1
}
leftPolyDerivative := func(x float64) float64 {
return 2*x - 1
}
rightPoly := func(x float64) float64 {
return x*x*x - x + 1
}
rightPolyDerivative := func(x float64) float64 {
return 3*x*x - 1
}
ys[0] = leftPoly(xs[0])
ys[1] = leftPoly(xs[1])
ys[2] = rightPoly(xs[2])
dydxs[0] = leftPolyDerivative(xs[0])
dydxs[1] = leftPolyDerivative(xs[1])
dydxs[2] = rightPolyDerivative(xs[2])
var pc PiecewiseCubic
pc.FitWithDerivatives(xs, ys, dydxs)
lastY := rightPoly(xs[2])
if pc.lastY != lastY {
t.Errorf("Mismatch in lastY: got %v, want %g", pc.lastY, lastY)
}
lastDyDx := rightPolyDerivative(xs[2])
if pc.lastDyDx != lastDyDx {
t.Errorf("Mismatch in lastDxDy: got %v, want %g", pc.lastDyDx, lastDyDx)
}
if !floats.Equal(pc.xs, xs) {
t.Errorf("Mismatch in xs: got %v, want %v", pc.xs, xs)
}
coeffs := mat.NewDense(2, 4, []float64{3, -3, 1, 0, 1, -1, 0, 1})
if !mat.EqualApprox(&pc.coeffs, coeffs, 1e-14) {
t.Errorf("Mismatch in coeffs: got %v, want %v", pc.coeffs, coeffs)
}
} | explode_data.jsonl/44080 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 602
} | [
2830,
3393,
31209,
4482,
34,
41181,
23346,
2354,
22171,
344,
5859,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
10225,
82,
1669,
3056,
3649,
21,
19,
19999,
16,
11,
220,
15,
11,
220,
16,
532,
197,
1047,
1669,
1281,
10556,
36... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBox(t *testing.T) {
config := `
space[0].enabled = 1
space[0].index[0].type = "HASH"
space[0].index[0].unique = 1
space[0].index[0].key_field[0].fieldno = 0
space[0].index[0].key_field[0].type = "NUM"
`
box, err := NewBox(config)
require.NoError(t, err)
box.Close()
} | explode_data.jsonl/67825 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
1611,
1155,
353,
8840,
836,
8,
1476,
25873,
1669,
22074,
1903,
1306,
58,
15,
936,
15868,
284,
220,
16,
198,
1903,
1306,
58,
15,
936,
1252,
58,
15,
936,
1313,
284,
330,
70707,
698,
1903,
1306,
58,
15,
936,
1252,
58,
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 TestTxStmt(t *testing.T) {
db := newTestDB(t, "")
defer closeDB(t, db)
exec(t, db, "CREATE|t1|name=string,age=int32,dead=bool")
stmt, err := db.Prepare("INSERT|t1|name=?,age=?")
if err != nil {
t.Fatalf("Stmt, err = %v, %v", stmt, err)
}
defer stmt.Close()
tx, err := db.Begin()
if err != nil {
t.Fatalf("Begin = %v", err)
}
txs := tx.Stmt(stmt)
defer txs.Close()
_, err = txs.Exec("Bobby", 7)
if err != nil {
t.Fatalf("Exec = %v", err)
}
err = tx.Commit()
if err != nil {
t.Fatalf("Commit = %v", err)
}
// Commit() should have closed the statement
if !txs.closed {
t.Fatal("Stmt not closed after Commit")
}
} | explode_data.jsonl/15971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
31584,
31063,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
501,
2271,
3506,
1155,
11,
14676,
16867,
3265,
3506,
1155,
11,
2927,
340,
67328,
1155,
11,
2927,
11,
330,
22599,
91,
83,
16,
91,
606,
28,
917,
11,
424,
16563,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestNewRemoveCommandErrors(t *testing.T) {
testCases := []struct {
name string
args []string
expectedError string
imageRemoveFunc func(image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
}{
{
name: "wrong args",
expectedError: "requires at least 1 argument(s).",
},
{
name: "ImageRemove fail",
args: []string{"arg1"},
expectedError: "error removing image",
imageRemoveFunc: func(image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) {
assert.Equal(t, options.Force, false)
assert.Equal(t, options.PruneChildren, true)
return []types.ImageDeleteResponseItem{}, errors.Errorf("error removing image")
},
},
}
for _, tc := range testCases {
cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{
imageRemoveFunc: tc.imageRemoveFunc,
}, new(bytes.Buffer)))
cmd.SetOutput(ioutil.Discard)
cmd.SetArgs(tc.args)
assert.Error(t, cmd.Execute(), tc.expectedError)
}
} | explode_data.jsonl/26900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 414
} | [
2830,
3393,
3564,
13021,
4062,
13877,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
31215,
310,
3056,
917,
198,
197,
42400,
1454,
256,
914,
198,
197,
31426,
13021,
9626,
2915,
10075,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreatePdb(t *testing.T) {
pdbName := "my-pdb"
tf := cmdtesting.NewTestFactory().WithNamespace("test")
defer tf.Cleanup()
ns := scheme.Codecs
tf.Client = &fake.RESTClient{
GroupVersion: schema.GroupVersion{Group: "policy", Version: "v1beta1"},
NegotiatedSerializer: ns,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(&bytes.Buffer{}),
}, nil
}),
}
tf.ClientConfigVal = restclient.CreateEmptyConfig()
outputFormat := "name"
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
cmd := NewCmdCreatePodDisruptionBudget(tf, ioStreams)
cmd.Flags().Set("min-available", "1")
cmd.Flags().Set("selector", "app=rails")
cmd.Flags().Set("dry-run", "true")
cmd.Flags().Set("output", outputFormat)
printFlags := genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme)
printFlags.OutputFormat = &outputFormat
options := &PodDisruptionBudgetOpts{
CreateSubcommandOptions: &CreateSubcommandOptions{
PrintFlags: printFlags,
Name: pdbName,
IOStreams: ioStreams,
},
}
err := options.Complete(tf, cmd, []string{pdbName})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
err = options.Run()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
expectedOutput := "poddisruptionbudget.policy/" + pdbName + "\n"
if buf.String() != expectedOutput {
t.Errorf("expected output: %s, but got: %s", expectedOutput, buf.String())
}
} | explode_data.jsonl/37305 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 588
} | [
2830,
3393,
4021,
47,
1999,
1155,
353,
8840,
836,
8,
341,
3223,
90881,
1669,
330,
2408,
2268,
1999,
698,
3244,
69,
1669,
5439,
8840,
7121,
2271,
4153,
1005,
2354,
22699,
445,
1944,
1138,
16867,
6409,
727,
60639,
2822,
84041,
1669,
12859... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepareCacheIndexScan(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
orgEnable := core.PreparedPlanCacheEnabled()
defer core.SetPreparedPlanCache(orgEnable)
core.SetPreparedPlanCache(true)
se, err := session.CreateSession4TestWithOpt(store, &session.Opt{
PreparedPlanCache: kvcache.NewSimpleLRUCache(100, 0.1, math.MaxUint64),
})
require.NoError(t, err)
tk := testkit.NewTestKitWithSession(t, store, se)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int, c int, primary key (a, b))")
tk.MustExec("insert into t values(1, 1, 2), (1, 2, 3), (1, 3, 3), (2, 1, 2), (2, 2, 3), (2, 3, 3)")
tk.MustExec(`prepare stmt1 from "select a, c from t where a = ? and c = ?"`)
tk.MustExec("set @a=1, @b=3")
// When executing one statement at the first time, we don't use cache, so we need to execute it at least twice to test the cache.
tk.MustQuery("execute stmt1 using @a, @b").Check(testkit.Rows("1 3", "1 3"))
tk.MustQuery("execute stmt1 using @a, @b").Check(testkit.Rows("1 3", "1 3"))
} | explode_data.jsonl/5496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
50590,
8233,
1552,
26570,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
741,
87625,
11084,
1669,
6200,
28770,
7212,
20485,
8233,
5462,
741,
16867,
6200,
4202,
4703,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVerifies_InvalidFileType(t *testing.T) {
path, err := os.MkdirTemp("", "verify-tombstone")
require.NoError(t, err)
_, err = os.CreateTemp(path, "verifytombstonetest*"+".txt")
require.NoError(t, err)
defer os.RemoveAll(path)
verify := NewVerifyTombstoneCommand()
verify.SetArgs([]string{"--engine-path", path})
b := bytes.NewBufferString("")
verify.SetOut(b)
require.NoError(t, verify.Execute())
out, err := io.ReadAll(b)
require.NoError(t, err)
require.Contains(t, string(out), "No tombstone files found")
} | explode_data.jsonl/24019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
10141,
9606,
62,
7928,
71873,
1155,
353,
8840,
836,
8,
341,
26781,
11,
1848,
1669,
2643,
1321,
12438,
12151,
19814,
330,
12446,
2385,
2855,
10812,
1138,
17957,
35699,
1155,
11,
1848,
692,
197,
6878,
1848,
284,
2643,
7251,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVoteVerify(t *testing.T) {
privVal := NewMockPV()
pubkey := privVal.GetPubKey()
vote := examplePrevote()
vote.ValidatorAddress = pubkey.Address()
err := vote.Verify("test_chain_id", ed25519.GenPrivKey().PubKey())
if assert.Error(t, err) {
assert.Equal(t, ErrVoteInvalidValidatorAddress, err)
}
err = vote.Verify("test_chain_id", pubkey)
if assert.Error(t, err) {
assert.Equal(t, ErrVoteInvalidSignature, err)
}
} | explode_data.jsonl/54536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
41412,
32627,
1155,
353,
8840,
836,
8,
341,
71170,
2208,
1669,
1532,
11571,
48469,
741,
62529,
792,
1669,
6095,
2208,
2234,
29162,
1592,
2822,
5195,
1272,
1669,
3110,
4703,
29358,
741,
5195,
1272,
13,
14256,
4286,
284,
95116,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoSamplingConfig(t *testing.T) {
jaeger := v1alpha1.NewJaeger("TestNoSamplingConfig")
config := NewConfig(jaeger)
cm := config.Get()
assert.NotNil(t, cm)
assert.Equal(t, defaultSamplingStrategy, cm.Data["sampling"])
} | explode_data.jsonl/52376 | {
"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,
2753,
98622,
2648,
1155,
353,
8840,
836,
8,
341,
197,
5580,
1878,
1669,
348,
16,
7141,
16,
7121,
52445,
1878,
445,
2271,
2753,
98622,
2648,
5130,
25873,
1669,
1532,
2648,
3325,
64,
1878,
340,
98316,
1669,
2193,
2234,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigSourceManager_Simple(t *testing.T) {
ctx := context.Background()
manager, err := NewManager(nil)
require.NoError(t, err)
manager.configSources = map[string]configsource.ConfigSource{
"tstcfgsrc": &testConfigSource{
ValueMap: map[string]valueEntry{
"test_selector": {Value: "test_value"},
},
},
}
originalCfg := map[string]interface{}{
"top0": map[string]interface{}{
"int": 1,
"cfgsrc": "$tstcfgsrc:test_selector",
},
}
expectedCfg := map[string]interface{}{
"top0": map[string]interface{}{
"int": 1,
"cfgsrc": "test_value",
},
}
cp := configparser.NewConfigMapFromStringMap(originalCfg)
actualParser, err := manager.Resolve(ctx, cp)
require.NoError(t, err)
assert.Equal(t, expectedCfg, actualParser.ToStringMap())
doneCh := make(chan struct{})
var errWatcher error
go func() {
defer close(doneCh)
errWatcher = manager.WatchForUpdate()
}()
manager.WaitForWatcher()
assert.NoError(t, manager.Close(ctx))
<-doneCh
assert.ErrorIs(t, errWatcher, configsource.ErrSessionClosed)
} | explode_data.jsonl/34666 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
2648,
3608,
2043,
1098,
6456,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
92272,
11,
1848,
1669,
1532,
2043,
27907,
340,
17957,
35699,
1155,
11,
1848,
340,
92272,
5423,
32200,
284,
2415,
14032,
60,
1676,
242... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCopyDirContents(t *testing.T) {
f1 := filepath.Join("testdata", "files")
f2 := filepath.Join("testdata", "files2")
if err := fileutil.CopyDirContents(f1, f2); err != nil {
t.Error(err)
}
t.Cleanup(remove(t, f2))
} | explode_data.jsonl/16281 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
12106,
6184,
14803,
1155,
353,
8840,
836,
8,
341,
1166,
16,
1669,
26054,
22363,
445,
92425,
497,
330,
7198,
1138,
1166,
17,
1669,
26054,
22363,
445,
92425,
497,
330,
7198,
17,
5130,
743,
1848,
1669,
1034,
1314,
31770,
6184,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateSeries(t *testing.T) {
timescale, cleanup := insightsdbtesting.TimescaleDB(t)
defer cleanup()
now := time.Now().Truncate(time.Microsecond).Round(0)
store := NewInsightStore(timescale)
store.Now = func() time.Time {
return now
}
ctx := context.Background()
t.Run("test create series", func(t *testing.T) {
series := types.InsightSeries{
SeriesID: "unique-1",
Query: "query-1",
OldestHistoricalAt: now.Add(-time.Hour * 24 * 365),
LastRecordedAt: now.Add(-time.Hour * 24 * 365),
NextRecordingAfter: now,
LastSnapshotAt: now,
NextSnapshotAfter: now,
RecordingIntervalDays: 4,
}
got, err := store.CreateSeries(ctx, series)
if err != nil {
t.Fatal(err)
}
want := types.InsightSeries{
ID: 1,
SeriesID: "unique-1",
Query: "query-1",
OldestHistoricalAt: now.Add(-time.Hour * 24 * 365),
LastRecordedAt: now.Add(-time.Hour * 24 * 365),
NextRecordingAfter: now,
LastSnapshotAt: now,
NextSnapshotAfter: now,
RecordingIntervalDays: 4,
CreatedAt: now,
}
log15.Info("values", "want", want, "got", got)
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("unexpected result from create insight series (want/got): %s", diff)
}
})
} | explode_data.jsonl/33311 | {
"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,
4021,
25544,
1155,
353,
8840,
836,
8,
341,
3244,
1733,
2246,
11,
21290,
1669,
25709,
1999,
8840,
836,
1733,
2246,
3506,
1155,
340,
16867,
21290,
741,
80922,
1669,
882,
13244,
1005,
1282,
26900,
9730,
1321,
2754,
5569,
568,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRemittanceOriginatorPostCodeAlphaNumeric(t *testing.T) {
ro := mockRemittanceOriginator()
ro.RemittanceData.PostCode = "®"
err := ro.Validate()
require.EqualError(t, err, fieldError("PostCode", ErrNonAlphanumeric, ro.RemittanceData.PostCode).Error())
} | explode_data.jsonl/32928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
6590,
87191,
13298,
850,
4133,
2078,
19384,
36296,
1155,
353,
8840,
836,
8,
341,
197,
299,
1669,
7860,
6590,
87191,
13298,
850,
741,
197,
299,
11398,
87191,
1043,
23442,
2078,
284,
330,
11909,
1837,
9859,
1669,
926,
47667,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetG(t *testing.T) {
withTestProcess("testprog", t, func(p *proc.Target, fixture protest.Fixture) {
testGSupportFunc("nocgo", t, p, fixture)
})
// On OSX with Go < 1.5 CGO is not supported due to: https://github.com/golang/go/issues/8973
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 5) {
skipOn(t, "upstream issue", "darwin")
}
protest.MustHaveCgo(t)
protest.AllowRecording(t)
withTestProcess("cgotest", t, func(p *proc.Target, fixture protest.Fixture) {
testGSupportFunc("cgo", t, p, fixture)
})
} | explode_data.jsonl/56220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
1949,
38,
1155,
353,
8840,
836,
8,
341,
46948,
2271,
7423,
445,
1944,
32992,
497,
259,
11,
2915,
1295,
353,
15782,
35016,
11,
12507,
8665,
991,
12735,
8,
341,
197,
18185,
38,
7916,
9626,
445,
47991,
3346,
497,
259,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCacheQueryer_getSelector(t *testing.T) {
selector := &metav1.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"},
}
cases := []struct {
name string
object runtime.Object
expected *metav1.LabelSelector
isErr bool
}{
{
name: "cron job",
object: &batchv1beta1.CronJob{},
expected: nil,
},
{
name: "daemon set",
object: &appsv1.DaemonSet{
Spec: appsv1.DaemonSetSpec{
Selector: selector,
},
},
expected: selector,
},
{
name: "deployment",
object: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Selector: selector,
},
},
expected: selector,
},
{
name: "replication controller",
object: &corev1.ReplicationController{
Spec: corev1.ReplicationControllerSpec{
Selector: selector.MatchLabels,
},
},
expected: selector,
},
{
name: "replica set",
object: &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{
Selector: selector,
},
},
expected: selector,
},
{
name: "service",
object: &corev1.Service{
Spec: corev1.ServiceSpec{
Selector: selector.MatchLabels,
},
},
expected: selector,
},
{
name: "stateful set",
object: &appsv1.StatefulSet{
Spec: appsv1.StatefulSetSpec{
Selector: selector,
},
},
expected: selector,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
o := storeFake.NewMockStore(controller)
discovery := queryerFake.NewMockDiscoveryInterface(controller)
oq := New(o, discovery)
got, err := oq.getSelector(tc.object)
if tc.isErr {
require.Error(t, err)
return
}
require.NoError(t, err)
assert.Equal(t, tc.expected, got)
})
}
} | explode_data.jsonl/45675 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 833
} | [
2830,
3393,
8233,
2859,
261,
3062,
5877,
1155,
353,
8840,
836,
8,
341,
197,
8925,
1669,
609,
4059,
402,
16,
4679,
5877,
515,
197,
197,
8331,
23674,
25,
2415,
14032,
30953,
4913,
7975,
788,
330,
2257,
7115,
197,
630,
1444,
2264,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClientFollowRedirects(t *testing.T) {
t.Parallel()
s := &Server{
Handler: func(ctx *RequestCtx) {
switch string(ctx.Path()) {
case "/foo":
u := ctx.URI()
u.Update("/xy?z=wer")
ctx.Redirect(u.String(), StatusFound)
case "/xy":
u := ctx.URI()
u.Update("/bar")
ctx.Redirect(u.String(), StatusFound)
default:
ctx.Success("text/plain", ctx.Path())
}
},
}
ln := fasthttputil.NewInmemoryListener()
serverStopCh := make(chan struct{})
go func() {
if err := s.Serve(ln); err != nil {
t.Errorf("unexpected error: %s", err)
}
close(serverStopCh)
}()
c := &HostClient{
Addr: "xxx",
Dial: func(addr string) (net.Conn, error) {
return ln.Dial()
},
}
for i := 0; i < 10; i++ {
statusCode, body, err := c.GetTimeout(nil, "http://xxx/foo", time.Second)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
if statusCode != StatusOK {
t.Fatalf("unexpected status code: %d", statusCode)
}
if string(body) != "/bar" {
t.Fatalf("unexpected response %q. Expecting %q", body, "/bar")
}
}
for i := 0; i < 10; i++ {
statusCode, body, err := c.Get(nil, "http://xxx/aaab/sss")
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
if statusCode != StatusOK {
t.Fatalf("unexpected status code: %d", statusCode)
}
if string(body) != "/aaab/sss" {
t.Fatalf("unexpected response %q. Expecting %q", body, "/aaab/sss")
}
}
for i := 0; i < 10; i++ {
req := AcquireRequest()
resp := AcquireResponse()
req.SetRequestURI("http://xxx/foo")
err := c.DoRedirects(req, resp, 16)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
if statusCode := resp.StatusCode(); statusCode != StatusOK {
t.Fatalf("unexpected status code: %d", statusCode)
}
if body := string(resp.Body()); body != "/bar" {
t.Fatalf("unexpected response %q. Expecting %q", body, "/bar")
}
ReleaseRequest(req)
ReleaseResponse(resp)
}
req := AcquireRequest()
resp := AcquireResponse()
req.SetRequestURI("http://xxx/foo")
err := c.DoRedirects(req, resp, 0)
if have, want := err, ErrTooManyRedirects; have != want {
t.Fatalf("want error: %v, have %v", want, have)
}
ReleaseRequest(req)
ReleaseResponse(resp)
} | explode_data.jsonl/79360 | {
"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,
2959,
12480,
17725,
82,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1903,
1669,
609,
5475,
515,
197,
197,
3050,
25,
2915,
7502,
353,
1900,
23684,
8,
341,
298,
8961,
914,
7502,
17474,
2140,
341,
298,
2722,
3521,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidatePersistentVolumes(t *testing.T) {
scenarios := map[string]struct {
isExpectedFailure bool
volume *api.PersistentVolume
}{
"good-volume": {
isExpectedFailure: false,
volume: testVolume("foo", "", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
}),
},
"invalid-accessmode": {
isExpectedFailure: true,
volume: testVolume("foo", "", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{"fakemode"},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
}),
},
"unexpected-namespace": {
isExpectedFailure: true,
volume: testVolume("foo", "unexpected-namespace", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
}),
},
"bad-name": {
isExpectedFailure: true,
volume: testVolume("123*Bad(Name", "unexpected-namespace", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
}),
},
"missing-name": {
isExpectedFailure: true,
volume: testVolume("", "", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
}),
},
"missing-capacity": {
isExpectedFailure: true,
volume: testVolume("foo", "", api.PersistentVolumeSpec{}),
},
"missing-accessmodes": {
isExpectedFailure: true,
volume: testVolume("goodname", "missing-accessmodes", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
},
}),
},
"too-many-sources": {
isExpectedFailure: true,
volume: testVolume("", "", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("5G"),
},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/foo"},
GCEPersistentDisk: &api.GCEPersistentDiskVolumeSource{PDName: "foo", FSType: "ext4"},
},
}),
},
}
for name, scenario := range scenarios {
errs := ValidatePersistentVolume(scenario.volume)
if len(errs) == 0 && scenario.isExpectedFailure {
t.Errorf("Unexpected success for scenario: %s", name)
}
if len(errs) > 0 && !scenario.isExpectedFailure {
t.Errorf("Unexpected failure for scenario: %s - %+v", name, errs)
}
}
} | explode_data.jsonl/62784 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1366
} | [
2830,
3393,
17926,
53194,
96325,
1155,
353,
8840,
836,
8,
1476,
29928,
60494,
1669,
2415,
14032,
60,
1235,
341,
197,
19907,
18896,
17507,
1807,
198,
197,
5195,
4661,
310,
353,
2068,
61655,
18902,
198,
197,
59403,
197,
197,
1,
18536,
667... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCloneUser(t *testing.T) {
tests := []struct {
name string
u *User
}{
{"nil_logins", &User{}},
{"zero_logins", &User{Logins: make([]LoginID, 0)}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u2 := tt.u.Clone()
if !reflect.DeepEqual(tt.u, u2) {
t.Errorf("not equal")
}
})
}
} | explode_data.jsonl/48391 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
37677,
1474,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
10676,
262,
353,
1474,
198,
197,
59403,
197,
197,
4913,
8385,
5224,
1330,
497,
609,
1474,
6257,
1583,
197,
197,
4913,
1415... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPeerConnection_GetStats(t *testing.T) {
offerPC, answerPC, err := newPair()
assert.NoError(t, err)
baseLineReportPCOffer := offerPC.GetStats()
baseLineReportPCAnswer := answerPC.GetStats()
connStatsOffer := getConnectionStats(t, baseLineReportPCOffer, offerPC)
connStatsAnswer := getConnectionStats(t, baseLineReportPCAnswer, answerPC)
for _, connStats := range []PeerConnectionStats{connStatsOffer, connStatsAnswer} {
assert.Equal(t, uint32(0), connStats.DataChannelsOpened)
assert.Equal(t, uint32(0), connStats.DataChannelsClosed)
assert.Equal(t, uint32(0), connStats.DataChannelsRequested)
assert.Equal(t, uint32(0), connStats.DataChannelsAccepted)
}
// Create a DC, open it and send a message
offerDC, err := offerPC.CreateDataChannel("offerDC", nil)
assert.NoError(t, err)
msg := []byte("a classic test message")
offerDC.OnOpen(func() {
assert.NoError(t, offerDC.Send(msg))
})
dcWait := sync.WaitGroup{}
dcWait.Add(1)
answerDCChan := make(chan *DataChannel)
answerPC.OnDataChannel(func(d *DataChannel) {
d.OnOpen(func() {
answerDCChan <- d
})
d.OnMessage(func(m DataChannelMessage) {
dcWait.Done()
})
})
assert.NoError(t, signalPairForStats(offerPC, answerPC))
waitWithTimeout(t, &dcWait)
answerDC := <-answerDCChan
reportPCOffer := offerPC.GetStats()
reportPCAnswer := answerPC.GetStats()
connStatsOffer = getConnectionStats(t, reportPCOffer, offerPC)
assert.Equal(t, uint32(1), connStatsOffer.DataChannelsOpened)
assert.Equal(t, uint32(0), connStatsOffer.DataChannelsClosed)
assert.Equal(t, uint32(1), connStatsOffer.DataChannelsRequested)
assert.Equal(t, uint32(0), connStatsOffer.DataChannelsAccepted)
dcStatsOffer := getDataChannelStats(t, reportPCOffer, offerDC)
assert.Equal(t, DataChannelStateOpen, dcStatsOffer.State)
assert.Equal(t, uint32(1), dcStatsOffer.MessagesSent)
assert.Equal(t, uint64(len(msg)), dcStatsOffer.BytesSent)
assert.NotEmpty(t, findLocalCandidateStats(reportPCOffer))
assert.NotEmpty(t, findRemoteCandidateStats(reportPCOffer))
assert.NotEmpty(t, findCandidatePairStats(t, reportPCOffer))
connStatsAnswer = getConnectionStats(t, reportPCAnswer, answerPC)
assert.Equal(t, uint32(1), connStatsAnswer.DataChannelsOpened)
assert.Equal(t, uint32(0), connStatsAnswer.DataChannelsClosed)
assert.Equal(t, uint32(0), connStatsAnswer.DataChannelsRequested)
assert.Equal(t, uint32(1), connStatsAnswer.DataChannelsAccepted)
dcStatsAnswer := getDataChannelStats(t, reportPCAnswer, answerDC)
assert.Equal(t, DataChannelStateOpen, dcStatsAnswer.State)
assert.Equal(t, uint32(1), dcStatsAnswer.MessagesReceived)
assert.Equal(t, uint64(len(msg)), dcStatsAnswer.BytesReceived)
assert.NotEmpty(t, findLocalCandidateStats(reportPCAnswer))
assert.NotEmpty(t, findRemoteCandidateStats(reportPCAnswer))
assert.NotEmpty(t, findCandidatePairStats(t, reportPCAnswer))
// Close answer DC now
dcWait = sync.WaitGroup{}
dcWait.Add(1)
offerDC.OnClose(func() {
dcWait.Done()
})
assert.NoError(t, answerDC.Close())
waitWithTimeout(t, &dcWait)
reportPCOffer = offerPC.GetStats()
reportPCAnswer = answerPC.GetStats()
connStatsOffer = getConnectionStats(t, reportPCOffer, offerPC)
assert.Equal(t, uint32(1), connStatsOffer.DataChannelsOpened)
assert.Equal(t, uint32(1), connStatsOffer.DataChannelsClosed)
assert.Equal(t, uint32(1), connStatsOffer.DataChannelsRequested)
assert.Equal(t, uint32(0), connStatsOffer.DataChannelsAccepted)
dcStatsOffer = getDataChannelStats(t, reportPCOffer, offerDC)
assert.Equal(t, DataChannelStateClosed, dcStatsOffer.State)
connStatsAnswer = getConnectionStats(t, reportPCAnswer, answerPC)
assert.Equal(t, uint32(1), connStatsAnswer.DataChannelsOpened)
assert.Equal(t, uint32(1), connStatsAnswer.DataChannelsClosed)
assert.Equal(t, uint32(0), connStatsAnswer.DataChannelsRequested)
assert.Equal(t, uint32(1), connStatsAnswer.DataChannelsAccepted)
dcStatsAnswer = getDataChannelStats(t, reportPCOffer, answerDC)
assert.Equal(t, DataChannelStateClosed, dcStatsAnswer.State)
answerICETransportStats := getTransportStats(t, reportPCAnswer, "iceTransport")
offerICETransportStats := getTransportStats(t, reportPCOffer, "iceTransport")
assert.GreaterOrEqual(t, offerICETransportStats.BytesSent, answerICETransportStats.BytesReceived)
assert.GreaterOrEqual(t, answerICETransportStats.BytesSent, offerICETransportStats.BytesReceived)
answerSCTPTransportStats := getTransportStats(t, reportPCAnswer, "sctpTransport")
offerSCTPTransportStats := getTransportStats(t, reportPCOffer, "sctpTransport")
assert.GreaterOrEqual(t, offerSCTPTransportStats.BytesSent, answerSCTPTransportStats.BytesReceived)
assert.GreaterOrEqual(t, answerSCTPTransportStats.BytesSent, offerSCTPTransportStats.BytesReceived)
assert.NoError(t, offerPC.Close())
assert.NoError(t, answerPC.Close())
} | explode_data.jsonl/37904 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1729
} | [
2830,
3393,
30888,
4526,
13614,
16635,
1155,
353,
8840,
836,
8,
341,
197,
25077,
4872,
11,
4226,
4872,
11,
1848,
1669,
501,
12443,
741,
6948,
35699,
1155,
11,
1848,
692,
24195,
2460,
10361,
4872,
39462,
1669,
3010,
4872,
2234,
16635,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSessionCacheGetTagging(t *testing.T) {
testGetAWSClient(
t, "Tagging",
func(t *testing.T, cache *sessionCache, region *string, role Role) {
iface := cache.GetTagging(region, role)
if iface == nil {
t.Fail()
return
}
})
} | explode_data.jsonl/18776 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
5283,
8233,
1949,
5668,
3173,
1155,
353,
8840,
836,
8,
341,
18185,
1949,
36136,
2959,
1006,
197,
3244,
11,
330,
5668,
3173,
756,
197,
29244,
1155,
353,
8840,
836,
11,
6500,
353,
5920,
8233,
11,
5537,
353,
917,
11,
3476,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFailFirst(t *testing.T) {
var count int
f := func(ctx context.Context, p peer.ID) (*Conn, error) {
if count > 0 {
return new(Conn), nil
}
count++
return nil, fmt.Errorf("gophers ate the modem")
}
ds := NewDialSync(f)
p := peer.ID("testing")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
_, err := ds.DialLock(ctx, p)
if err == nil {
t.Fatal("expected gophers to have eaten the modem")
}
c, err := ds.DialLock(ctx, p)
if err != nil {
t.Fatal(err)
}
if c == nil {
t.Fatal("should have gotten a 'real' conn back")
}
} | explode_data.jsonl/41484 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
19524,
5338,
1155,
353,
8840,
836,
8,
341,
2405,
1760,
526,
198,
1166,
1669,
2915,
7502,
2266,
9328,
11,
281,
14397,
9910,
8,
4609,
9701,
11,
1465,
8,
341,
197,
743,
1760,
861,
220,
15,
341,
298,
853,
501,
7,
9701,
701... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPageWithDateFields(t *testing.T) {
assert := require.New(t)
pageWithDate := `---
title: P%d
weight: %d
%s: 2017-10-13
---
Simple Page With Some Date`
hasDate := func(p page.Page) bool {
return p.Date().Year() == 2017
}
datePage := func(field string, weight int) string {
return fmt.Sprintf(pageWithDate, weight, weight, field)
}
t.Parallel()
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
assert.True(len(pages) > 0)
for _, p := range pages {
assert.True(hasDate(p))
}
}
fields := []string{"date", "publishdate", "pubdate", "published"}
pageContents := make([]string, len(fields))
for i, field := range fields {
pageContents[i] = datePage(field, i+1)
}
testAllMarkdownEnginesForPages(t, assertFunc, nil, pageContents...)
} | explode_data.jsonl/60611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
2665,
2354,
1916,
8941,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
1373,
7121,
1155,
340,
35272,
2354,
1916,
1669,
1565,
10952,
2102,
25,
393,
14841,
198,
4765,
25,
1018,
67,
198,
12952,
25,
220,
17,
15,
16,
22,
12,
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 TestNewModulesCallModuleFactory(t *testing.T) {
logp.TestingSetup()
r := NewRegister()
r.MustAddMetricSet("foo", "bar", newMetricSetWithOption)
r.SetSecondarySource(NewLightModulesSource("testdata/lightmodules"))
called := false
r.AddModule("foo", func(base BaseModule) (Module, error) {
called = true
return DefaultModuleFactory(base)
})
config, err := common.NewConfigFrom(common.MapStr{"module": "service"})
require.NoError(t, err)
_, _, err = NewModule(config, r)
assert.NoError(t, err)
assert.True(t, called, "module factory must be called if registered")
} | explode_data.jsonl/9718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
3564,
28201,
7220,
3332,
4153,
1155,
353,
8840,
836,
8,
341,
6725,
79,
8787,
287,
21821,
2822,
7000,
1669,
1532,
8690,
741,
7000,
50463,
2212,
54310,
1649,
445,
7975,
497,
330,
2257,
497,
501,
54310,
1649,
2354,
5341,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseConfig(t *testing.T) {
testcases := []struct {
cfgNet string
cfgAddr string
cfgDBName string
expHost string
expPortPathOrID string
expDatabaseName string
}{
{
cfgDBName: "mydb",
expDatabaseName: "mydb",
},
{
cfgNet: "unixgram",
cfgAddr: "/path/to/my/sock",
expHost: "localhost",
expPortPathOrID: "/path/to/my/sock",
},
{
cfgNet: "unixpacket",
cfgAddr: "/path/to/my/sock",
expHost: "localhost",
expPortPathOrID: "/path/to/my/sock",
},
{
cfgNet: "udp",
cfgAddr: "[fe80::1%lo0]:53",
expHost: "fe80::1%lo0",
expPortPathOrID: "53",
},
{
cfgNet: "tcp",
cfgAddr: ":80",
expHost: "localhost",
expPortPathOrID: "80",
},
{
cfgNet: "ip4:1",
cfgAddr: "192.0.2.1",
expHost: "192.0.2.1",
expPortPathOrID: "",
},
{
cfgNet: "tcp6",
cfgAddr: "golang.org:http",
expHost: "golang.org",
expPortPathOrID: "http",
},
{
cfgNet: "ip6:ipv6-icmp",
cfgAddr: "2001:db8::1",
expHost: "2001:db8::1",
expPortPathOrID: "",
},
}
for _, test := range testcases {
s := &newrelic.DatastoreSegment{}
cfg := &mysql.Config{
Net: test.cfgNet,
Addr: test.cfgAddr,
DBName: test.cfgDBName,
}
parseConfig(s, cfg)
if test.expHost != s.Host {
t.Errorf(`incorrect host, expected="%s", actual="%s"`, test.expHost, s.Host)
}
if test.expPortPathOrID != s.PortPathOrID {
t.Errorf(`incorrect port path or id, expected="%s", actual="%s"`, test.expPortPathOrID, s.PortPathOrID)
}
if test.expDatabaseName != s.DatabaseName {
t.Errorf(`incorrect database name, expected="%s", actual="%s"`, test.expDatabaseName, s.DatabaseName)
}
}
} | explode_data.jsonl/58472 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1044
} | [
2830,
3393,
14463,
2648,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
50286,
6954,
688,
914,
198,
197,
50286,
13986,
260,
914,
198,
197,
50286,
3506,
675,
981,
914,
198,
197,
48558,
9296,
260,
914,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGetMessageHTML(t *testing.T) {
item := feed.Item{
Title: "\tPodcast\n\t",
Description: "<p>News <a href='/test'>Podcast Link</a></p>\n",
Enclosure: feed.Enclosure{
URL: "https://example.com",
},
Link: "https://example.com/xyz",
}
expected := "<a href=\"https://example.com/xyz\">Podcast</a>\n\nNews <a href=\"/test\">Podcast Link</a>\n\nhttps://example.com"
client := TelegramClient{}
msg := client.getMessageHTML(item, htmlMessageParams{WithMp3Link: true})
assert.Equal(t, expected, msg)
} | explode_data.jsonl/50727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
1949,
2052,
5835,
1155,
353,
8840,
836,
8,
341,
22339,
1669,
5395,
9399,
515,
197,
92233,
25,
981,
2917,
83,
23527,
3829,
1699,
4955,
756,
197,
47414,
25,
4055,
79,
29,
14373,
366,
64,
1801,
21301,
1944,
6270,
23527,
3829,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplicationResolver_ApplicationEnabledMappingServices(t *testing.T) {
// GIVEN
const (
serviceIdOne = "abe498d4-dc37-46f1-9f87-db1ddd55b409"
serviceIdTwo = "952404e7-f7b9-44ac-9f5d-eeb695c3c46e"
serviceIdThree = "afcd698b-968c-4d1c-a3c8-5d96968a139e"
serviceIdFour = "eccbfd17-00e0-440c-b047-119bfcfa56ed"
serviceNameOne = "service-name-one"
serviceNameTwo = "service-name-two"
serviceNameThree = "service-name-three"
fixNamespace = "fix-namespace"
)
app := &gqlschema.Application{
Name: "fix-name",
Services: []gqlschema.ApplicationService{
{
ID: serviceIdOne,
DisplayName: serviceNameOne,
},
{
ID: serviceIdTwo,
DisplayName: serviceNameTwo,
},
{
ID: serviceIdThree,
DisplayName: serviceNameThree,
},
},
}
appSvc := automock.NewApplicationSvc()
defer appSvc.AssertExpectations(t)
appSvc.On("ListApplicationMapping", app.Name).Return([]*mappingTypes.ApplicationMapping{
{
ObjectMeta: v1.ObjectMeta{
Name: app.Name,
Namespace: fixNamespace,
},
Spec: mappingTypes.ApplicationMappingSpec{
Services: []mappingTypes.ApplicationMappingService{
{
ID: serviceIdThree,
},
{
ID: serviceIdOne,
},
{
ID: serviceIdTwo,
},
{
ID: serviceIdFour,
},
},
},
},
}, nil)
resolver := application.NewApplicationResolver(appSvc, nil)
// WHEN
out, err := resolver.ApplicationEnabledMappingServices(context.Background(), app)
require.NoError(t, err)
// THEN
assert.Len(t, out, 1)
assert.Equal(t, out[0].Namespace, fixNamespace)
assert.False(t, out[0].AllServices)
assert.Len(t, out[0].Services, 4)
assert.Contains(t, out[0].Services, &gqlschema.EnabledApplicationService{
ID: serviceIdOne,
Exist: true,
DisplayName: serviceNameOne,
})
assert.Contains(t, out[0].Services, &gqlschema.EnabledApplicationService{
ID: serviceIdTwo,
Exist: true,
DisplayName: serviceNameTwo,
})
assert.Contains(t, out[0].Services, &gqlschema.EnabledApplicationService{
ID: serviceIdThree,
Exist: true,
DisplayName: serviceNameThree,
})
assert.Contains(t, out[0].Services, &gqlschema.EnabledApplicationService{
ID: serviceIdFour,
Exist: false,
DisplayName: "",
})
} | explode_data.jsonl/28769 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1079
} | [
2830,
3393,
4988,
18190,
96579,
5462,
6807,
11025,
1155,
353,
8840,
836,
8,
341,
197,
322,
89836,
198,
4777,
2399,
197,
52934,
764,
3966,
257,
284,
330,
8229,
19,
24,
23,
67,
19,
1737,
66,
18,
22,
12,
19,
21,
69,
16,
12,
24,
69,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestErrors_templates(t *testing.T) {
os.Chdir("testdata/templates")
defer os.Chdir("../..")
c := &up.Config{
Name: "app",
ErrorPages: config.ErrorPages{
Enable: true,
},
}
assert.NoError(t, c.Default(), "default")
assert.NoError(t, c.Validate(), "validate")
test(t, c)
} | explode_data.jsonl/45492 | {
"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,
13877,
49526,
1155,
353,
8840,
836,
8,
341,
25078,
6353,
3741,
445,
92425,
38941,
1138,
16867,
2643,
6353,
3741,
17409,
496,
5130,
1444,
1669,
609,
454,
10753,
515,
197,
21297,
25,
330,
676,
756,
197,
58421,
17713,
25,
2193,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetOrRegisterMeter(t *testing.T) {
r := NewRegistry()
NewRegisteredMeter("foo", r).Mark(47)
if m := GetOrRegisterMeter("foo", r); 47 != m.Count() {
t.Fatal(m)
}
} | explode_data.jsonl/10858 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
1949,
2195,
8690,
68224,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
15603,
741,
197,
3564,
41430,
68224,
445,
7975,
497,
435,
568,
8949,
7,
19,
22,
340,
743,
296,
1669,
2126,
2195,
8690,
68224,
445,
7975,
497,
435,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestBuildTrafficConfiguration_EmptyAndFailedConfigurations(t *testing.T) {
expected := &Config{
Targets: map[string]RevisionTargets{},
Configurations: map[string]*v1.Configuration{
emptyConfig.Name: emptyConfig,
failedConfig.Name: failedConfig,
},
Revisions: map[string]*v1.Revision{},
}
expectedErr := errUnreadyConfiguration(failedConfig)
if tc, err := BuildTrafficConfiguration(configLister, revLister, testRouteWithTrafficTargets(WithSpecTraffic(v1.TrafficTarget{
ConfigurationName: emptyConfig.Name,
Percent: ptr.Int64(50),
}, v1.TrafficTarget{
ConfigurationName: failedConfig.Name,
Percent: ptr.Int64(50),
}))); err != nil && expectedErr.Error() != err.Error() {
t.Errorf("Expected error %v, saw %v", expectedErr, err)
} else if got, want := tc, expected; !cmp.Equal(want, got, cmpOpts...) {
t.Errorf("Unexpected traffic diff (-want +got): %v", cmp.Diff(want, got, cmpOpts...))
}
} | explode_data.jsonl/17619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
11066,
87229,
7688,
76060,
1595,
3036,
9408,
2648,
21449,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
609,
2648,
515,
197,
197,
49030,
25,
2415,
14032,
60,
33602,
49030,
38837,
197,
66156,
21449,
25,
2415,
14032,
8465,
85,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestACL_AllowOperation(t *testing.T) {
t.Run("root-ns", func(t *testing.T) {
t.Parallel()
testACLAllowOperation(t, namespace.RootNamespace)
})
} | explode_data.jsonl/15271 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
55393,
53629,
363,
8432,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2888,
12,
4412,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
41288,
7957,
741,
197,
18185,
55393,
18605,
8432,
1155,
11,
4473,
45345,
22699,
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 |
func TestManagerSimpleRun(t *testing.T) {
ts := memorytopo.NewServer("cell1")
m := NewManager(ts)
// Run the manager in the background.
wg, _, cancel := StartManager(m)
// Create a Sleep job.
uuid, err := m.Create(context.Background(), sleepFactoryName, []string{"-duration", "60"})
if err != nil {
t.Fatalf("cannot create sleep workflow: %v", err)
}
// Start the job
if err := m.Start(context.Background(), uuid); err != nil {
t.Fatalf("cannot start sleep workflow: %v", err)
}
// Stop the job
if err := m.Stop(context.Background(), uuid); err != nil {
t.Fatalf("cannot start sleep workflow: %v", err)
}
cancel()
wg.Wait()
} | explode_data.jsonl/75109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
2043,
16374,
6727,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
4938,
3481,
78,
7121,
5475,
445,
5873,
16,
1138,
2109,
1669,
1532,
2043,
35864,
692,
197,
322,
6452,
279,
6645,
304,
279,
4004,
624,
72079,
11,
8358,
9121,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGetPadWidths(t *testing.T) {
type scenario struct {
stringArrays [][]string
expected []int
}
scenarios := []scenario{
{
[][]string{{""}, {""}},
[]int{},
},
{
[][]string{{"a"}, {""}},
[]int{},
},
{
[][]string{{"aa", "b", "ccc"}, {"c", "d", "e"}},
[]int{2, 1},
},
}
for _, s := range scenarios {
assert.EqualValues(t, s.expected, getPadWidths(s.stringArrays))
}
} | explode_data.jsonl/11579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
1949,
13731,
3327,
82,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
11357,
22182,
52931,
917,
198,
197,
42400,
257,
3056,
396,
198,
197,
630,
29928,
60494,
1669,
3056,
61422,
515,
197,
197,
515,
298,
197,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAsStructuredWatcherErrorConverting(t *testing.T) {
unstructuredCh := make(chan watch.Event)
nwf := func(ctx context.Context, lo metav1.ListOptions) (watch.Interface, error) {
return watch.NewProxyWatcher(unstructuredCh), nil
}
wf := duck.AsStructuredWatcher(context.Background(), nwf, &badObject{})
wi, err := wf(metav1.ListOptions{})
if err != nil {
t.Errorf("WatchFunc() = %v", err)
}
defer wi.Stop()
ch := wi.ResultChan()
unstructuredCh <- watch.Event{
Type: watch.Added,
Object: &unstructured.Unstructured{
Object: map[string]interface{}{
"foo": "bar",
},
},
}
// Expect a message when we send one though.
select {
case x, ok := <-ch:
if !ok {
t.Fatal("<-ch = closed, wanted *duckv1alpha1.Generational{}")
}
if got, want := x.Type, watch.Error; got != want {
t.Errorf("<-ch = %v, wanted %v", got, want)
}
if status, ok := x.Object.(*metav1.Status); !ok {
t.Errorf("<-ch = %T, wanted %T", x, &metav1.Status{})
} else if got, want := status.Message, errNoUnmarshal.Error(); got != want {
t.Errorf("<-ch = %v, wanted %v", got, want)
}
case <-time.After(100 * time.Millisecond):
t.Error("Didn't see expected message on channel.")
}
} | explode_data.jsonl/51702 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 496
} | [
2830,
3393,
2121,
97457,
47248,
1454,
1109,
49417,
1155,
353,
8840,
836,
8,
341,
20479,
51143,
1143,
1669,
1281,
35190,
3736,
6904,
340,
9038,
43083,
1669,
2915,
7502,
2266,
9328,
11,
775,
77520,
16,
5814,
3798,
8,
320,
14321,
41065,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_getBechKeyOut(t *testing.T) {
type args struct {
bechPrefix string
}
tests := []struct {
name string
args args
want bechKeyOutFn
wantErr bool
}{
{"empty", args{""}, nil, true},
{"wrong", args{"???"}, nil, true},
{"acc", args{sdk.PrefixAccount}, keys.Bech32KeyOutput, false},
{"val", args{sdk.PrefixValidator}, keys.Bech32ValKeyOutput, false},
{"cons", args{sdk.PrefixConsensus}, keys.Bech32ConsKeyOutput, false},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
got, err := getBechKeyOut(tt.args.bechPrefix)
if (err != nil) != tt.wantErr {
t.Errorf("getBechKeyOut() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !tt.wantErr {
require.NotNil(t, got)
}
// TODO: Still not possible to compare functions
// Maybe in next release: https://github.com/stretchr/testify/issues/182
//if &got != &tt.want {
// t.Errorf("getBechKeyOut() = %v, want %v", got, tt.want)
//}
})
}
} | explode_data.jsonl/45326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 448
} | [
2830,
3393,
3062,
3430,
331,
1592,
2662,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
73142,
331,
14335,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
198,
197,
50780... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEntryAddTimedMetricTooEarly(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
e, _, now := testEntry(ctrl, testEntryOptions{
options: testOptions(ctrl).SetVerboseErrors(true),
})
e.opts = e.opts.SetBufferForFutureTimedMetric(time.Second)
inputs := []struct {
timeNanos int64
storagePolicy policy.StoragePolicy
}{
{
timeNanos: now.UnixNano() + 2*time.Second.Nanoseconds(),
storagePolicy: policy.NewStoragePolicy(10*time.Second, xtime.Second, time.Hour),
},
{
timeNanos: now.UnixNano() + time.Second.Nanoseconds() + time.Nanosecond.Nanoseconds(),
storagePolicy: policy.NewStoragePolicy(time.Minute, xtime.Minute, time.Hour),
},
}
for _, input := range inputs {
metric := testTimedMetric
metric.TimeNanos = input.timeNanos
err := e.AddTimed(metric, metadata.TimedMetadata{StoragePolicy: input.storagePolicy})
require.True(t, xerrors.IsInvalidParams(err))
require.Equal(t, errTooFarInTheFuture, xerrors.InnerError(err))
require.True(t, strings.Contains(err.Error(), "datapoint for aggregation too far in future"))
require.True(t, strings.Contains(err.Error(), "timestamp="))
require.True(t, strings.Contains(err.Error(), "future_limit="))
}
} | explode_data.jsonl/24236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 478
} | [
2830,
3393,
5874,
2212,
20217,
291,
54310,
31246,
41198,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
7727,
11,
8358,
1431,
1669,
1273,
5874,
62100,
11,
1273,
5874,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCreateGroupGroupLabel(t *testing.T) {
mux, server, client := setup(t)
defer teardown(server)
mux.HandleFunc("/api/v4/groups/1/labels", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPost)
fmt.Fprint(w, `{"id":1, "name": "My / GroupLabel", "color" : "#11FF22"}`)
})
l := &CreateGroupLabelOptions{
Name: String("My / GroupLabel"),
Color: String("#11FF22"),
}
label, _, err := client.GroupLabels.CreateGroupLabel("1", l)
if err != nil {
log.Fatal(err)
}
want := &GroupLabel{ID: 1, Name: "My / GroupLabel", Color: "#11FF22"}
if !reflect.DeepEqual(want, label) {
t.Errorf("GroupLabels.CreateGroupLabel returned %+v, want %+v", label, want)
}
} | explode_data.jsonl/34990 | {
"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,
4021,
2808,
2808,
2476,
1155,
353,
8840,
836,
8,
341,
2109,
2200,
11,
3538,
11,
2943,
1669,
6505,
1155,
340,
16867,
49304,
21421,
692,
2109,
2200,
63623,
4283,
2068,
5457,
19,
77685,
14,
16,
14,
16873,
497,
2915,
3622,
175... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_ReadArray(t *testing.T) {
t.Run("test ok", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, testData := range streamTestSuccessCollections["array"] {
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.SetReadPos(i)
stream.Write(testData[0])
assert(stream.ReadArray()).Equals(testData[0].(Array), nil)
assert(stream.GetWritePos()).
Equals(len(testData[1].([]byte)) + i)
stream.Release()
}
}
})
t.Run("test readIndex overflow", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, testData := range streamTestSuccessCollections["array"] {
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.SetReadPos(i)
stream.Write(testData[0])
writePos := stream.GetWritePos()
for idx := i; idx < writePos-1; idx++ {
stream.SetReadPos(i)
stream.SetWritePos(idx)
assert(stream.ReadArray()).Equals(Array{}, base.ErrStream)
assert(stream.GetReadPos()).Equals(i)
}
stream.Release()
}
}
})
t.Run("test type not match", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.SetReadPos(i)
stream.PutBytes([]byte{13})
assert(stream.ReadArray()).Equals(Array{}, base.ErrStream)
assert(stream.GetReadPos()).Equals(i)
stream.Release()
}
})
t.Run("error in stream", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, testData := range streamTestSuccessCollections["array"] {
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.SetReadPos(i)
stream.Write(testData[0])
if len(testData[0].(Array)) > 0 {
stream.SetWritePos(stream.GetWritePos() - 1)
stream.PutBytes([]byte{13})
assert(stream.ReadArray()).Equals(Array{}, base.ErrStream)
assert(stream.GetReadPos()).Equals(i)
}
stream.Release()
}
}
})
t.Run("error in stream", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.SetReadPos(i)
stream.PutBytes([]byte{0x41, 0x07, 0x00, 0x00, 0x00, 0x02, 0x02})
assert(stream.ReadArray()).Equals(Array{}, base.ErrStream)
assert(stream.GetReadPos()).Equals(i)
stream.Release()
}
})
} | explode_data.jsonl/21226 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1163
} | [
2830,
3393,
3027,
38381,
1857,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
5394,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
18185,
6046,
1669,
633,
2271,
6046,
20574,
4859,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVersion(t *testing.T) {
serverConfig := &Config{
Certificates: testConfig.Certificates,
MaxVersion: VersionTLS11,
}
clientConfig := &Config{
InsecureSkipVerify: true,
}
state, err := testHandshake(clientConfig, serverConfig)
if err != nil {
t.Fatalf("handshake failed: %s", err)
}
if state.Version != VersionTLS11 {
t.Fatalf("Incorrect version %x, should be %x", state.Version, VersionTLS11)
}
} | explode_data.jsonl/80551 | {
"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,
5637,
1155,
353,
8840,
836,
8,
341,
41057,
2648,
1669,
609,
2648,
515,
197,
6258,
529,
24405,
25,
1273,
2648,
727,
529,
24405,
345,
197,
197,
5974,
5637,
25,
256,
6079,
45439,
16,
16,
345,
197,
532,
25291,
2648,
1669,
60... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScaleUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.CustomResource.Store.DestroyFunc()
name := "foo"
var cr unstructured.Unstructured
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
key := "/noxus/" + metav1.NamespaceDefault + "/" + name
if err := storage.CustomResource.Storage.Create(ctx, key, &validCustomResource, &cr, 0); err != nil {
t.Fatalf("error setting new custom resource (key: %s) %v: %v", key, validCustomResource, err)
}
obj, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{})
if err != nil {
t.Fatalf("error fetching scale for %s: %v", name, err)
}
scale, ok := obj.(*autoscalingv1.Scale)
if !ok {
t.Fatalf("%v is not of the type autoscalingv1.Scale", scale)
}
replicas := 12
update := autoscalingv1.Scale{
ObjectMeta: scale.ObjectMeta,
Spec: autoscalingv1.ScaleSpec{
Replicas: int32(replicas),
},
}
if _, _, err := storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil {
t.Fatalf("error updating scale %v: %v", update, err)
}
obj, err = storage.Scale.Get(ctx, name, &metav1.GetOptions{})
if err != nil {
t.Fatalf("error fetching scale for %s: %v", name, err)
}
scale = obj.(*autoscalingv1.Scale)
if scale.Spec.Replicas != int32(replicas) {
t.Errorf("wrong replicas count: expected: %d got: %d", replicas, scale.Spec.Replicas)
}
update.ResourceVersion = scale.ResourceVersion
update.Spec.Replicas = 15
if _, _, err = storage.Scale.Update(ctx, update.Name, rest.DefaultUpdatedObjectInfo(&update), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc); err != nil && !errors.IsConflict(err) {
t.Fatalf("unexpected error, expecting an update conflict but got %v", err)
}
} | explode_data.jsonl/71533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 671
} | [
2830,
3393,
6947,
4289,
1155,
353,
8840,
836,
8,
341,
197,
16172,
11,
3538,
1669,
501,
5793,
1155,
340,
16867,
3538,
836,
261,
34016,
1155,
340,
16867,
5819,
27649,
4783,
38047,
57011,
9626,
2822,
11609,
1669,
330,
7975,
1837,
2405,
156... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.