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 TestSingleObject(t *testing.T) {
// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
// pass 'nil' as the third parameter.
userJson := `{"username": "dennis", "balance": 200}`
reader := strings.NewReader(userJson)
req, err := http.NewRequest("GET", "/health-check", reader)
if err != nil {
t.Fatal(err)
}
var object User
ParseJsonRequest(req, &object)
if object.Username != "dennis" {
t.Errorf("username is %s expected dennis", object.Username)
}
} | explode_data.jsonl/32026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
10888,
1190,
1155,
353,
8840,
836,
8,
1476,
197,
322,
4230,
264,
1681,
311,
1494,
311,
1039,
7013,
13,
1205,
1513,
944,
614,
894,
3239,
5029,
369,
1431,
11,
773,
582,
3278,
198,
197,
322,
1494,
364,
8385,
6,
438,
279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCRMAddressesEndpoint_GetPrimary(t *testing.T) {
var want int64
n := &CRMAddresses{Timestamp: &want}
if got := n.GetPrimary(); !reflect.DeepEqual(*got, want) {
t.Errorf("CRMAddressesEndpoint.GetPrimary() failed, got: %v, want: %v", *got, want)
}
} | explode_data.jsonl/63530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
43516,
52290,
27380,
13614,
15972,
1155,
353,
8840,
836,
8,
341,
2405,
1366,
526,
21,
19,
198,
9038,
1669,
609,
43516,
52290,
90,
20812,
25,
609,
52657,
630,
743,
2684,
1669,
308,
2234,
15972,
2129,
753,
34913,
94750,
4071,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCmp(t *testing.T) {
for i, tc := range cmpTests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
is := errors.Is(tc.err, tc.target)
if is != tc.is {
t.Errorf("unexpected comparison, want=%t, got=%t", tc.is, is)
}
})
}
} | explode_data.jsonl/33540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
34,
1307,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
17130,
1669,
2088,
26089,
18200,
341,
197,
3244,
16708,
28197,
17305,
4430,
67,
497,
600,
701,
2915,
1155,
353,
8840,
836,
8,
341,
298,
19907,
1669,
5975,
4506,
44415,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewTokenResponse(t *testing.T) {
r := NewTokenResponse("foo", "bar", 1)
assert.Equal(t, "foo", r.TokenType)
assert.Equal(t, "bar", r.AccessToken)
assert.Equal(t, 1, r.ExpiresIn)
assert.Equal(t, map[string]string{
"token_type": "foo",
"access_token": "bar",
"expires_in": "1",
}, r.Map())
} | explode_data.jsonl/1726 | {
"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,
3564,
3323,
2582,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
3323,
2582,
445,
7975,
497,
330,
2257,
497,
220,
16,
340,
6948,
12808,
1155,
11,
330,
7975,
497,
435,
32277,
929,
340,
6948,
12808,
1155,
11,
330,
2257,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCACommon_GenerateRSACertificateRequestWithPass_Fail(t *testing.T) {
priData, errECC = ioutil.ReadFile(filepath.Join(pathcaeccpemp384, caPriKeyFileName))
if nil != errECC {
t.Error(errECC)
}
_, errCA = CAGenerateRSACertificateRequestWithPass(&CertRequest{
PrivateKeyData: priData,
CertificateRequestFilePath: filepath.Join(pathcarsapksc1512, caCertificateRequestFileName),
SignatureAlgorithm: x509.SHA256WithRSAPSS,
Subject: CAMockSubject,
}, "PRIVATE KEY", "123", RSAPKSC1())
t.Log(errCA)
} | explode_data.jsonl/24081 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
5049,
10839,
2646,
13220,
11451,
1706,
20962,
1900,
2354,
12187,
1400,
604,
1155,
353,
8840,
836,
8,
341,
3223,
461,
1043,
11,
1848,
36,
3706,
284,
43144,
78976,
34793,
22363,
5581,
924,
71325,
79,
3262,
18,
23,
19,
11,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTCPResetsSentNoICMP(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
stats := c.Stack().Stats()
// Send a SYN request for a closed port. This should elicit an RST
// but NOT an ICMPv4 DstUnreachable packet.
iss := seqnum.Value(context.TestInitialSequenceNumber)
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagSyn,
SeqNum: iss,
})
// Receive whatever comes back.
b := c.GetPacket()
ipHdr := header.IPv4(b)
if got, want := ipHdr.Protocol(), uint8(header.TCPProtocolNumber); got != want {
t.Errorf("unexpected protocol, got = %d, want = %d", got, want)
}
// Read outgoing ICMP stats and check no ICMP DstUnreachable was recorded.
sent := stats.ICMP.V4.PacketsSent
if got, want := sent.DstUnreachable.Value(), uint64(0); got != want {
t.Errorf("got ICMP DstUnreachable.Value() = %d, want = %d", got, want)
}
} | explode_data.jsonl/75923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 361
} | [
2830,
3393,
49896,
1061,
1415,
31358,
2753,
1317,
5781,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
741,
79659,
1669,
272,
58646,
1005,
16635,
2822,
197,
322,
11000,
264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRolling_deployRolling(t *testing.T) {
latestConfig := appstest.OkDeploymentConfig(1)
latestConfig.Spec.Strategy = appstest.OkRollingStrategy()
latest, _ := appsinternalutil.MakeDeploymentV1(latestConfig)
config := appstest.OkDeploymentConfig(2)
config.Spec.Strategy = appstest.OkRollingStrategy()
deployment, _ := appsinternalutil.MakeDeploymentV1(config)
deployments := map[string]*corev1.ReplicationController{
latest.Name: latest,
deployment.Name: deployment,
}
deploymentUpdated := false
client := &fake.Clientset{}
client.AddReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) {
name := action.(clientgotesting.GetAction).GetName()
return true, deployments[name], nil
})
client.AddReactor("update", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) {
updated := action.(clientgotesting.UpdateAction).GetObject().(*corev1.ReplicationController)
deploymentUpdated = true
return true, updated, nil
})
var rollingConfig *RollingUpdaterConfig
strategy := &RollingDeploymentStrategy{
rcClient: client.Core(),
eventClient: fake.NewSimpleClientset().Core(),
initialStrategy: &testStrategy{
deployFn: func(from *corev1.ReplicationController, to *corev1.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
t.Fatalf("unexpected call to initial strategy")
return nil
},
},
rollingUpdate: func(config *RollingUpdaterConfig) error {
rollingConfig = config
return nil
},
getUpdateAcceptor: getUpdateAcceptor,
apiRetryPeriod: 1 * time.Millisecond,
apiRetryTimeout: 10 * time.Millisecond,
}
strategy.out, strategy.errOut = &bytes.Buffer{}, &bytes.Buffer{}
err := strategy.Deploy(latest, deployment, 2)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if rollingConfig == nil {
t.Fatalf("expected rolling update to be invoked")
}
if !reflect.DeepEqual(latest, rollingConfig.OldRc) {
t.Errorf("unexpected rollingConfig.OldRc:%s\n", diff.ObjectGoPrintDiff(latest, rollingConfig.OldRc))
}
if !reflect.DeepEqual(deployment, rollingConfig.NewRc) {
t.Errorf("unexpected rollingConfig.NewRc:%s\n", diff.ObjectGoPrintDiff(latest, rollingConfig.OldRc))
}
if e, a := 1*time.Second, rollingConfig.Interval; e != a {
t.Errorf("expected Interval %d, got %d", e, a)
}
if e, a := 1*time.Second, rollingConfig.UpdatePeriod; e != a {
t.Errorf("expected UpdatePeriod %d, got %d", e, a)
}
if e, a := 20*time.Second, rollingConfig.Timeout; e != a {
t.Errorf("expected Timeout %d, got %d", e, a)
}
// verify hack
if e, a := int32(1), rollingConfig.NewRc.Spec.Replicas; e != *a {
t.Errorf("expected rollingConfig.NewRc.Spec.Replicas %d, got %d", e, a)
}
// verify hack
if !deploymentUpdated {
t.Errorf("expected deployment to be updated for source annotation")
}
sid := fmt.Sprintf("%s:%s", latest.Name, latest.ObjectMeta.UID)
if e, a := sid, rollingConfig.NewRc.Annotations[sourceIdAnnotation]; e != a {
t.Errorf("expected sourceIdAnnotation %s, got %s", e, a)
}
} | explode_data.jsonl/64615 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1128
} | [
2830,
3393,
32355,
287,
91890,
32355,
287,
1155,
353,
8840,
836,
8,
341,
197,
19350,
2648,
1669,
906,
267,
477,
54282,
75286,
2648,
7,
16,
340,
197,
19350,
2648,
36473,
27318,
10228,
284,
906,
267,
477,
54282,
32355,
287,
19816,
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 TestRegexpLinkMatchPrefix(t *testing.T) {
specs := []struct {
expectedMatch bool
path string
link string
}{
{true, "same", "same"},
{false, "same", "different"},
{true, "same/", "same/"},
{true, "same/", "same"},
{true, "same", "same/"},
{true, "same/", "same/xyz"},
}
for _, s := range specs {
s := s
t.Run(fmt.Sprintf("%s match %s", s.path, s.link), func(t *testing.T) {
link := NewLink(BaseLink{Path: fmt.Sprintf("/%s/", s.link)})
actualMatch := link.MatchPrefix(s.path)
assert.Equal(t, s.expectedMatch, actualMatch)
})
}
} | explode_data.jsonl/30804 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 271
} | [
2830,
3393,
3477,
4580,
3939,
8331,
14335,
1155,
353,
8840,
836,
8,
341,
98100,
82,
1669,
3056,
1235,
341,
197,
42400,
8331,
1807,
198,
197,
26781,
688,
914,
198,
197,
54238,
688,
914,
198,
197,
59403,
197,
197,
90,
1866,
11,
330,
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 TestEnvironmentInterpolation(t *testing.T) {
config, err := loadYAML(`
version: "3"
services:
test:
image: busybox
labels:
- home1=$HOME
- home2=${HOME}
- nonexistent=$NONEXISTENT
- default=${NONEXISTENT-default}
networks:
test:
driver: $HOME
volumes:
test:
driver: $HOME
`)
assert.NoError(t, err)
home := os.Getenv("HOME")
expectedLabels := map[string]string{
"home1": home,
"home2": home,
"nonexistent": "",
"default": "default",
}
assert.Equal(t, expectedLabels, config.Services[0].Labels)
assert.Equal(t, home, config.Networks["test"].Driver)
assert.Equal(t, home, config.Volumes["test"].Driver)
} | explode_data.jsonl/16391 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
12723,
3306,
44686,
1155,
353,
8840,
836,
8,
341,
25873,
11,
1848,
1669,
2795,
56,
31102,
61528,
4366,
25,
330,
18,
698,
12779,
510,
220,
1273,
510,
262,
2168,
25,
13028,
2011,
198,
262,
9201,
510,
414,
481,
2114,
16,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSnapshotFailure(t *testing.T) {
storage := NewMemoryStorage()
sm := newTestRaft(1, []uint64{1, 2}, 10, 1, storage)
sm.restore(testingSnap)
sm.becomeCandidate()
sm.becomeLeader()
sm.prs[2].Next = 1
sm.prs[2].becomeSnapshot(11)
sm.Step(pb.Message{From: 2, To: 1, Type: pb.MsgSnapStatus, Reject: true})
if sm.prs[2].PendingSnapshot != 0 {
t.Fatalf("PendingSnapshot = %d, want 0", sm.prs[2].PendingSnapshot)
}
if sm.prs[2].Next != 1 {
t.Fatalf("Next = %d, want 1", sm.prs[2].Next)
}
if sm.prs[2].Paused != true {
t.Errorf("Paused = %v, want true", sm.prs[2].Paused)
}
} | explode_data.jsonl/12909 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
15009,
17507,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
1532,
10642,
5793,
741,
72023,
1669,
501,
2271,
55535,
723,
7,
16,
11,
3056,
2496,
21,
19,
90,
16,
11,
220,
17,
2137,
220,
16,
15,
11,
220,
16,
11,
5819,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSerializePktID(t *testing.T) {
testCasesSerialize := map[string]struct {
PktID epic.PktID
Serialized []byte
}{
"Basic": {
PktID: epic.PktID{
Timestamp: 1,
Counter: 0x02000003,
},
Serialized: []byte{0, 0, 0, 1, 2, 0, 0, 3},
},
"Max. timestamp": {
PktID: epic.PktID{
Timestamp: ^uint32(0),
Counter: 0x02000003,
},
Serialized: []byte{255, 255, 255, 255, 2, 0, 0, 3},
},
}
for name, tc := range testCasesSerialize {
name, tc := name, tc
t.Run(name, func(t *testing.T) {
bNew := make([]byte, epic.PktIDLen)
tc.PktID.SerializeTo(bNew)
assert.Equal(t, tc.Serialized, bNew)
})
}
} | explode_data.jsonl/16864 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
15680,
47,
5840,
915,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
15680,
1669,
2415,
14032,
60,
1235,
341,
197,
10025,
5840,
915,
414,
24679,
1069,
5840,
915,
198,
197,
197,
77521,
3056,
3782,
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... | 1 |
func TestKillContainer(t *testing.T) {
kubelet, _, fakeDocker := makeTestKubelet(t)
fakeDocker.containerList = []docker.APIContainers{
{
ID: "1234",
Names: []string{"/k8s--foo--qux--1234"},
},
{
ID: "5678",
Names: []string{"/k8s--bar--qux--5678"},
},
}
fakeDocker.container = &docker.Container{
ID: "foobar",
}
err := kubelet.killContainer(&fakeDocker.containerList[0])
if err != nil {
t.Errorf("unexpected error: %v", err)
}
verifyCalls(t, fakeDocker, []string{"stop"})
} | explode_data.jsonl/2826 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
53734,
4502,
1155,
353,
8840,
836,
8,
341,
16463,
3760,
1149,
11,
8358,
12418,
35,
13659,
1669,
1281,
2271,
42,
3760,
1149,
1155,
340,
1166,
726,
35,
13659,
18357,
852,
284,
3056,
28648,
24922,
74632,
515,
197,
197,
515,
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... | 2 |
func TestCreateDuplicateMigrations(t *testing.T) {
defer resetTest()
createMigrationAndVerify(t, "createmigration", "default", "clusterpair1", []string{"namespace1"}, "", "")
cmdArgs := []string{"create", "migrations", "-c", "clusterpair1", "--namespaces", "namespace1", "createmigration"}
expected := "Error from server (AlreadyExists): migrations.stork.libopenstorage.org \"createmigration\" already exists"
testCommon(t, cmdArgs, nil, expected, true)
} | explode_data.jsonl/18258 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
4021,
53979,
44,
17824,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
2271,
741,
39263,
20168,
3036,
32627,
1155,
11,
330,
837,
37246,
5033,
497,
330,
2258,
497,
330,
18855,
12670,
16,
497,
3056,
917,
4913,
2231,
16,
14345,
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 TestRunTLSServer(t *testing.T) {
cfg := initTest()
cfg.Core.SSL = true
cfg.Core.Port = "8087"
cfg.Core.CertPath = "../certificate/localhost.cert"
cfg.Core.KeyPath = "../certificate/localhost.key"
ctx, cancel := context.WithCancel(context.Background())
go func() {
assert.NoError(t, RunHTTPServer(ctx, cfg, q))
}()
defer func() {
// close the server
cancel()
}()
// have to wait for the goroutine to start and run the server
// otherwise the main thread will complete
time.Sleep(5 * time.Millisecond)
testRequest(t, "https://localhost:8087/api/stat/go")
} | explode_data.jsonl/67601 | {
"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,
6727,
13470,
1220,
2836,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
2930,
2271,
2822,
50286,
12777,
808,
7984,
284,
830,
198,
50286,
12777,
43013,
284,
330,
23,
15,
23,
22,
698,
50286,
12777,
727,
529,
1820,
284,
7005,
635... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Auto_HTML_Update_Redirect_Error(t *testing.T) {
r := require.New(t)
err := withHTMLFile("cars/edit.html", "Update: <%= car.Name %>", func(e *render.Engine) {
app := buffalo.New(buffalo.Options{})
app.PUT("/cars/{id}", func(c buffalo.Context) error {
b := Car{
ID: 1,
Name: "Honda",
}
return c.Render(422, e.Auto(c, b))
})
w := willie.New(app)
res := w.HTML("/cars/1").Put(nil)
r.Equal(422, res.Code)
r.Contains(res.Body.String(), "Update: Honda")
})
r.NoError(err)
} | explode_data.jsonl/2631 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 239
} | [
2830,
3393,
1566,
1535,
56726,
47393,
92940,
1226,
28651,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1373,
7121,
1155,
692,
9859,
1669,
448,
5835,
1703,
445,
50708,
21345,
2564,
497,
330,
4289,
25,
90194,
1803,
2967,
1018,
21156,
2915,
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 TestRuleHeadEquals(t *testing.T) {
assertHeadsEqual(t, &Head{}, &Head{})
// Same name/key/value
assertHeadsEqual(t, &Head{Name: Var("p")}, &Head{Name: Var("p")})
assertHeadsEqual(t, &Head{Key: VarTerm("x")}, &Head{Key: VarTerm("x")})
assertHeadsEqual(t, &Head{Value: VarTerm("x")}, &Head{Value: VarTerm("x")})
assertHeadsEqual(t, &Head{Args: []*Term{VarTerm("x"), VarTerm("y")}}, &Head{Args: []*Term{VarTerm("x"), VarTerm("y")}})
// Different name/key/value
assertHeadsNotEqual(t, &Head{Name: Var("p")}, &Head{Name: Var("q")})
assertHeadsNotEqual(t, &Head{Key: VarTerm("x")}, &Head{Key: VarTerm("y")})
assertHeadsNotEqual(t, &Head{Value: VarTerm("x")}, &Head{Value: VarTerm("y")})
assertHeadsNotEqual(t, &Head{Args: []*Term{VarTerm("x"), VarTerm("z")}}, &Head{Args: []*Term{VarTerm("x"), VarTerm("y")}})
} | explode_data.jsonl/65307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
11337,
12346,
4315,
1155,
353,
8840,
836,
8,
341,
6948,
1519,
7664,
2993,
1155,
11,
609,
12346,
22655,
609,
12346,
6257,
692,
197,
322,
25739,
829,
68864,
57542,
198,
6948,
1519,
7664,
2993,
1155,
11,
609,
12346,
63121,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_GetAllTeams(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/api/manager/teams", nil)
req.Header.Set("Authorization", managerToken)
router.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
} | explode_data.jsonl/77158 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
13614,
2403,
60669,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
54320,
70334,
7121,
47023,
741,
24395,
11,
716,
1669,
1758,
75274,
445,
3806,
497,
3521,
2068,
14,
13297,
14,
38496,
497,
2092,
340,
24395,
15753,
4202,
445,
1812... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBoundQueryInfo(t *testing.T) {
session := createSession(t)
defer session.Close()
if err := createTable(session, "CREATE TABLE gocql_test.clustered_query_info (id int, cluster int, value text, PRIMARY KEY (id, cluster))"); err != nil {
t.Fatalf("failed to create table with error '%v'", err)
}
write := &ClusteredKeyValue{Id: 200, Cluster: 300, Value: "baz"}
insert := session.Bind("INSERT INTO clustered_query_info (id, cluster, value) VALUES (?, ?,?)", write.Bind)
if err := insert.Exec(); err != nil {
t.Fatalf("insert into clustered_query_info failed, err '%v'", err)
}
read := &ClusteredKeyValue{Id: 200, Cluster: 300}
qry := session.Bind("SELECT id, cluster, value FROM clustered_query_info WHERE id = ? and cluster = ?", read.Bind)
iter := qry.Iter()
var id, cluster int
var value string
iter.Scan(&id, &cluster, &value)
if err := iter.Close(); err != nil {
t.Fatalf("query with clustered_query_info info failed, err '%v'", err)
}
if value != "baz" {
t.Fatalf("Expected value %s, but got %s", "baz", value)
}
} | explode_data.jsonl/11155 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
19568,
2859,
1731,
1155,
353,
8840,
836,
8,
1476,
25054,
1669,
1855,
5283,
1155,
340,
16867,
3797,
10421,
2822,
743,
1848,
1669,
1855,
2556,
16264,
11,
330,
22599,
14363,
342,
509,
1470,
4452,
40501,
291,
5738,
3109,
320,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestMoment(t *testing.T) {
for i, test := range []struct {
x []float64
weights []float64
moment float64
ans float64
}{
{
x: []float64{6, 2, 4, 8, 10},
moment: 5,
ans: 0,
},
{
x: []float64{6, 2, 4, 8, 10},
weights: []float64{1, 2, 2, 2, 1},
moment: 5,
ans: 121.875,
},
} {
m := Moment(test.moment, test.x, test.weights)
if math.Abs(test.ans-m) > 1e-14 {
t.Errorf("Moment mismatch case %d. Expected %v, found %v", i, test.ans, m)
}
}
if !panics(func() { Moment(1, make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
if !panics(func() { Moment(1, make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
} | explode_data.jsonl/1778 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 391
} | [
2830,
3393,
83817,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
10225,
981,
3056,
3649,
21,
19,
198,
197,
197,
13327,
3056,
3649,
21,
19,
198,
197,
2109,
12913,
220,
2224,
21,
19,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDefaultConfig(t *testing.T) {
err := LoadConf("default.config")
assert.Nil(t, err)
assert.Equal(t, conf, SetupConfig)
f, err := os.Open("default.config")
assert.Nil(t, err)
err = LoadConfData(f)
assert.Nil(t, err)
SetupConfig = Config{
Assets{"a/", "a/", "i/", "f/"},
Debug{"FILTER", "INFO"},
Screen{0, 0, 240, 320, 2},
Font{"hint", 20.0, 36.0, "luxisr.ttf", "green"},
30,
30,
"German",
"Some Window",
true,
true,
true,
}
initConf()
assert.Equal(t, SetupConfig, conf)
// Failure to load
err = LoadConf("nota.config")
assert.NotNil(t, err)
} | explode_data.jsonl/13314 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
3675,
2648,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
8893,
15578,
445,
2258,
5423,
1138,
6948,
59678,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
2335,
11,
18626,
2648,
340,
1166,
11,
1848,
1669,
2643,
12953,
445,
2258,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOpen(t *testing.T) {
path := tempfile()
defer os.RemoveAll(path)
db, err := bolt.Open(path, 0666, nil)
if err != nil {
t.Fatal(err)
} else if db == nil {
t.Fatal("expected db")
}
if s := db.Path(); s != path {
t.Fatalf("unexpected path: %s", s)
}
if err := db.Close(); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/27456 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
5002,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
54819,
741,
16867,
2643,
84427,
5581,
692,
20939,
11,
1848,
1669,
31842,
12953,
5581,
11,
220,
15,
21,
21,
21,
11,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLookupFieldOrMethod(t *testing.T) {
// Test cases assume a lookup of the form a.f or x.f, where a stands for an
// addressable value, and x for a non-addressable value (even though a variable
// for ease of test case writing).
var tests = []struct {
src string
found bool
index []int
indirect bool
}{
// field lookups
{"var x T; type T struct{}", false, nil, false},
{"var x T; type T struct{ f int }", true, []int{0}, false},
{"var x T; type T struct{ a, b, f, c int }", true, []int{2}, false},
// field lookups on a generic type
{"var x T[int]; type T[P any] struct{}", false, nil, false},
{"var x T[int]; type T[P any] struct{ f P }", true, []int{0}, false},
{"var x T[int]; type T[P any] struct{ a, b, f, c P }", true, []int{2}, false},
// method lookups
{"var a T; type T struct{}; func (T) f() {}", true, []int{0}, false},
{"var a *T; type T struct{}; func (T) f() {}", true, []int{0}, true},
{"var a T; type T struct{}; func (*T) f() {}", true, []int{0}, false},
{"var a *T; type T struct{}; func (*T) f() {}", true, []int{0}, true}, // TODO(gri) should this report indirect = false?
// method lookups on a generic type
{"var a T[int]; type T[P any] struct{}; func (T[P]) f() {}", true, []int{0}, false},
{"var a *T[int]; type T[P any] struct{}; func (T[P]) f() {}", true, []int{0}, true},
{"var a T[int]; type T[P any] struct{}; func (*T[P]) f() {}", true, []int{0}, false},
{"var a *T[int]; type T[P any] struct{}; func (*T[P]) f() {}", true, []int{0}, true}, // TODO(gri) should this report indirect = false?
// collisions
{"type ( E1 struct{ f int }; E2 struct{ f int }; x struct{ E1; *E2 })", false, []int{1, 0}, false},
{"type ( E1 struct{ f int }; E2 struct{}; x struct{ E1; *E2 }); func (E2) f() {}", false, []int{1, 0}, false},
// collisions on a generic type
{"type ( E1[P any] struct{ f P }; E2[P any] struct{ f P }; x struct{ E1[int]; *E2[int] })", false, []int{1, 0}, false},
{"type ( E1[P any] struct{ f P }; E2[P any] struct{}; x struct{ E1[int]; *E2[int] }); func (E2[P]) f() {}", false, []int{1, 0}, false},
// outside methodset
// (*T).f method exists, but value of type T is not addressable
{"var x T; type T struct{}; func (*T) f() {}", false, nil, true},
// outside method set of a generic type
{"var x T[int]; type T[P any] struct{}; func (*T[P]) f() {}", false, nil, true},
// recursive generic types; see golang/go#52715
{"var a T[int]; type ( T[P any] struct { *N[P] }; N[P any] struct { *T[P] } ); func (N[P]) f() {}", true, []int{0, 0}, true},
{"var a T[int]; type ( T[P any] struct { *N[P] }; N[P any] struct { *T[P] } ); func (T[P]) f() {}", true, []int{0}, false},
}
for _, test := range tests {
pkg, err := pkgFor("test", "package p;"+test.src, nil)
if err != nil {
t.Errorf("%s: incorrect test case: %s", test.src, err)
continue
}
obj := pkg.Scope().Lookup("a")
if obj == nil {
if obj = pkg.Scope().Lookup("x"); obj == nil {
t.Errorf("%s: incorrect test case - no object a or x", test.src)
continue
}
}
f, index, indirect := LookupFieldOrMethod(obj.Type(), obj.Name() == "a", pkg, "f")
if (f != nil) != test.found {
if f == nil {
t.Errorf("%s: got no object; want one", test.src)
} else {
t.Errorf("%s: got object = %v; want none", test.src, f)
}
}
if !sameSlice(index, test.index) {
t.Errorf("%s: got index = %v; want %v", test.src, index, test.index)
}
if indirect != test.indirect {
t.Errorf("%s: got indirect = %v; want %v", test.src, indirect, test.indirect)
}
}
} | explode_data.jsonl/29387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1475
} | [
2830,
3393,
34247,
1877,
2195,
3523,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
5048,
9658,
264,
18615,
315,
279,
1352,
264,
833,
476,
856,
833,
11,
1380,
264,
13352,
369,
458,
198,
197,
322,
2621,
480,
897,
11,
323,
856,
369,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func Test_resolveDependencies(t *testing.T) {
g := gomega.NewGomegaWithT(t)
cached := NewAddonVersionCacheClient()
// Add core/A
cached.AddVersion(Version{
PackageSpec: addonmgrv1alpha1.PackageSpec{
PkgName: "core/A",
PkgVersion: "1.0.3",
PkgDeps: map[string]string{
"core/C": "*",
},
},
PkgPhase: addonmgrv1alpha1.Pending,
})
// Add core/B
cached.AddVersion(Version{
PackageSpec: addonmgrv1alpha1.PackageSpec{
PkgName: "core/B",
PkgVersion: "1.0.0",
PkgDeps: map[string]string{
"core/C": "*",
},
},
PkgPhase: addonmgrv1alpha1.Pending,
})
// Add core/C
cached.AddVersion(Version{
PackageSpec: addonmgrv1alpha1.PackageSpec{
PkgName: "core/C",
PkgVersion: "1.0.1",
},
PkgPhase: addonmgrv1alpha1.Succeeded,
})
av := &addonValidator{
addon: &addonmgrv1alpha1.Addon{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"},
Spec: addonmgrv1alpha1.AddonSpec{
PackageSpec: addonmgrv1alpha1.PackageSpec{PkgType: addonmgrv1alpha1.CompositePkg,
PkgName: "test/addon-1",
PkgVersion: "1.0.0",
PkgDeps: map[string]string{
"core/A": "*",
"core/B": "v1.0.0",
},
},
Params: addonmgrv1alpha1.AddonParams{
Namespace: "addon-test-ns",
},
},
},
cache: cached,
dynClient: dynClient,
}
var visited = make(map[string]*Version)
g.Expect(av.resolveDependencies(&Version{
PackageSpec: av.addon.GetPackageSpec(),
PkgPhase: addonmgrv1alpha1.Pending,
}, visited, 0)).Should(gomega.BeNil(), "Should validate")
} | explode_data.jsonl/2961 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 756
} | [
2830,
3393,
77291,
48303,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
1444,
3854,
1669,
1532,
84312,
5637,
8233,
2959,
2822,
197,
322,
2691,
6200,
10360,
198,
1444,
3854,
1904,
5637,
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 TestMonitor_Open(t *testing.T) {
s := monitor.New(nil, monitor.Config{})
if err := s.Open(); err != nil {
t.Fatalf("unexpected open error: %s", err)
}
// Verify that opening twice is fine.
if err := s.Open(); err != nil {
s.Close()
t.Fatalf("unexpected error on second open: %s", err)
}
if err := s.Close(); err != nil {
t.Fatalf("unexpected close error: %s", err)
}
// Verify that closing twice is fine.
if err := s.Close(); err != nil {
t.Fatalf("unexpected error on second close: %s", err)
}
} | explode_data.jsonl/7521 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
30098,
51747,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
8718,
7121,
27907,
11,
8718,
10753,
37790,
743,
1848,
1669,
274,
12953,
2129,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
53859,
1787,
1465,
25,
1018,
82,
497,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGetMinimumDifference(t *testing.T) {
tests := []param{
{
[]int{1, tree.NULL, 4, 3, 5},
1,
},
{
[]int{1, tree.NULL, 3, 2},
1,
},
{
[]int{1, tree.NULL, 3, 3, 4},
0,
},
{
[]int{1, 0},
1,
},
{
[]int{1, tree.NULL, 3},
2,
},
{
[]int{236, 104, 701, tree.NULL, 227, tree.NULL, 911},
9,
},
}
for i := 0; i < len(tests); i++ {
ret := getMinimumDifference(tree.Ints2TreeNode(tests[i].one))
if ret != tests[i].result {
t.Fatalf("Wrong Answer, testcase: %v, actual: %v expected: %v", tests[i].one, ret, tests[i].result)
}
fmt.Printf("[input]: %v\t", tests[i].one)
fmt.Printf("[expect]: %v\t", tests[i].result)
fmt.Printf("[output]: %v\t\n", ret)
}
} | explode_data.jsonl/57471 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 386
} | [
2830,
3393,
1949,
28695,
62707,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
903,
515,
197,
197,
515,
298,
197,
1294,
396,
90,
16,
11,
4916,
90312,
11,
220,
19,
11,
220,
18,
11,
220,
20,
1583,
298,
197,
16,
345,
197,
197,
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... | 3 |
func TestCreateFullFleetAndCantGameServerAllocate(t *testing.T) {
t.Parallel()
fixtures := []apis.SchedulingStrategy{apis.Packed, apis.Distributed}
for _, strategy := range fixtures {
strategy := strategy
t.Run(string(strategy), func(t *testing.T) {
t.Parallel()
fleets := framework.AgonesClient.AgonesV1().Fleets(defaultNs)
fleet := defaultFleet(defaultNs)
fleet.Spec.Scheduling = strategy
flt, err := fleets.Create(fleet)
if assert.Nil(t, err) {
defer fleets.Delete(flt.ObjectMeta.Name, nil) // nolint:errcheck
}
framework.AssertFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas))
gsa := &allocationv1.GameServerAllocation{
Spec: allocationv1.GameServerAllocationSpec{
Scheduling: strategy,
Required: metav1.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}},
}}
for i := 0; i < replicasCount; i++ {
var gsa2 *allocationv1.GameServerAllocation
gsa2, err = framework.AgonesClient.AllocationV1().GameServerAllocations(defaultNs).Create(gsa.DeepCopy())
if assert.Nil(t, err) {
assert.Equal(t, allocationv1.GameServerAllocationAllocated, gsa2.Status.State)
}
}
framework.AssertFleetCondition(t, flt, func(fleet *agonesv1.Fleet) bool {
return fleet.Status.AllocatedReplicas == replicasCount
})
gsa, err = framework.AgonesClient.AllocationV1().GameServerAllocations(defaultNs).Create(gsa.DeepCopy())
if assert.Nil(t, err) {
assert.Equal(t, string(allocationv1.GameServerAllocationUnAllocated), string(gsa.Status.State))
}
})
}
} | explode_data.jsonl/63308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 638
} | [
2830,
3393,
4021,
9432,
37,
18973,
3036,
34,
517,
4868,
5475,
75380,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
941,
18513,
1669,
3056,
13725,
808,
44356,
19816,
90,
13725,
1069,
11191,
11,
97723,
909,
25146,
630,
2023... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResponseMarshalJSON_Notif(t *testing.T) {
tests := map[*jsonrpc2.Request]bool{
&jsonrpc2.Request{ID: jsonrpc2.ID{Num: 0}}: true,
&jsonrpc2.Request{ID: jsonrpc2.ID{Num: 1}}: true,
&jsonrpc2.Request{ID: jsonrpc2.ID{Str: "", IsString: true}}: true,
&jsonrpc2.Request{ID: jsonrpc2.ID{Str: "a", IsString: true}}: true,
&jsonrpc2.Request{Notif: true}: false,
}
for r, wantIDKey := range tests {
b, err := json.Marshal(r)
if err != nil {
t.Fatal(err)
}
hasIDKey := bytes.Contains(b, []byte(`"id"`))
if hasIDKey != wantIDKey {
t.Errorf("got %s, want contain id key: %v", b, wantIDKey)
}
}
} | explode_data.jsonl/50179 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 360
} | [
2830,
3393,
2582,
55438,
5370,
60816,
333,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
33836,
2236,
29414,
17,
9659,
96436,
515,
197,
197,
5,
2236,
29414,
17,
9659,
90,
915,
25,
2951,
29414,
17,
9910,
90,
4651,
25,
220,
15,
341... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestNormalizeIndexCleaner(t *testing.T) {
trueVar := true
falseVar := false
days7 := 7
days55 := 55
tests := []struct {
underTest v1.JaegerEsIndexCleanerSpec
expected v1.JaegerEsIndexCleanerSpec
}{
{underTest: v1.JaegerEsIndexCleanerSpec{},
expected: v1.JaegerEsIndexCleanerSpec{Schedule: "55 23 * * *", NumberOfDays: &days7, Enabled: &trueVar}},
{underTest: v1.JaegerEsIndexCleanerSpec{Image: "bla", Schedule: "lol", NumberOfDays: &days55, Enabled: &falseVar},
expected: v1.JaegerEsIndexCleanerSpec{Image: "bla", Schedule: "lol", NumberOfDays: &days55, Enabled: &falseVar}},
}
for _, test := range tests {
normalizeIndexCleaner(&test.underTest, "elasticsearch")
assert.Equal(t, test.expected, test.underTest)
}
} | explode_data.jsonl/21857 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 288
} | [
2830,
3393,
87824,
1552,
27529,
261,
1155,
353,
8840,
836,
8,
341,
42808,
3962,
1669,
830,
198,
36012,
3962,
1669,
895,
198,
2698,
942,
22,
1669,
220,
22,
198,
2698,
942,
20,
20,
1669,
220,
20,
20,
198,
78216,
1669,
3056,
1235,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSequenceGetStatus(t *testing.T) {
r := &Sequence{
Status: SequenceStatus{},
}
if got, want := r.GetStatus(), &r.Status.Status; got != want {
t.Errorf("GetStatus=%v, want=%v", got, want)
}
} | explode_data.jsonl/42756 | {
"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,
14076,
1949,
2522,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
609,
14076,
515,
197,
58321,
25,
28871,
2522,
38837,
197,
532,
743,
2684,
11,
1366,
1669,
435,
2234,
2522,
1507,
609,
81,
10538,
10538,
26,
2684,
961,
1366,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestGetConfigForClient(t *testing.T) {
serverConfig := testConfig.Clone()
clientConfig := testConfig.Clone()
clientConfig.MinVersion = VersionTLS12
for i, test := range getConfigForClientTests {
if test.setup != nil {
test.setup(serverConfig)
}
var configReturned *Config
serverConfig.GetConfigForClient = func(clientHello *ClientHelloInfo) (*Config, error) {
config, err := test.callback(clientHello)
configReturned = config
return config, err
}
c, s := localPipe(t)
done := make(chan error)
go func() {
defer s.Close()
done <- Server(s, serverConfig).Handshake()
}()
clientErr := Client(c, clientConfig).Handshake()
c.Close()
serverErr := <-done
if len(test.errorSubstring) == 0 {
if serverErr != nil || clientErr != nil {
t.Errorf("test[%d]: expected no error but got serverErr: %q, clientErr: %q", i, serverErr, clientErr)
}
if test.verify != nil {
if err := test.verify(configReturned); err != nil {
t.Errorf("test[%d]: verify returned error: %v", i, err)
}
}
} else {
if serverErr == nil {
t.Errorf("test[%d]: expected error containing %q but got no error", i, test.errorSubstring)
} else if !strings.Contains(serverErr.Error(), test.errorSubstring) {
t.Errorf("test[%d]: expected error to contain %q but it was %q", i, test.errorSubstring, serverErr)
}
}
}
} | explode_data.jsonl/36354 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 534
} | [
2830,
3393,
1949,
2648,
2461,
2959,
1155,
353,
8840,
836,
8,
341,
41057,
2648,
1669,
1273,
2648,
64463,
741,
25291,
2648,
1669,
1273,
2648,
64463,
741,
25291,
2648,
17070,
5637,
284,
6079,
45439,
16,
17,
271,
2023,
600,
11,
1273,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Max(t *testing.T) {
expected := 5
input := []int{1, 2, 3, 4, 5}
actual := slices.Max(input)
assert.Equal(t, expected, actual)
} | explode_data.jsonl/23109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 59
} | [
2830,
3393,
58843,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
220,
20,
271,
22427,
1669,
3056,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
532,
88814,
1669,
34254,
14535,
5384,
692,
6948,
12808,
1155,
11,
3601... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSSHPublicKey(t *testing.T) {
cases := []struct {
name string
key string
valid bool
}{
{
name: "valid",
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q==",
valid: true,
},
{
name: "valid with email",
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== name@example.com",
valid: true,
},
{
name: "invalid format",
key: "bad-format AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q==",
valid: true,
},
{
name: "invalid key",
key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDxL",
valid: false,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
err := SSHPublicKey(tc.key)
if tc.valid {
assert.NoError(t, err)
} else {
assert.Error(t, err)
}
})
}
} | explode_data.jsonl/56441 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1166
} | [
2830,
3393,
1220,
6610,
475,
1592,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
23634,
256,
914,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
220,
330,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReplaceUnescaped(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
testCases := []struct {
pattern string
old string
new string
escapeToken string
expected string
}{
{``, `B`, `DEF`, `\`, ``},
{`ABC`, `B`, `DEF`, `\`, `ADEFC`},
{`A\BC`, `B`, `DEF`, `\`, `A\BC`},
{`A\\BC`, `B`, `DEF`, `\`, `A\\DEFC`},
{`\\\\BC`, `B`, `DEF`, `\`, `\\\\DEFC`},
{`\\\\\BC`, `B`, `DEF`, `\`, `\\\\\BC`},
{`A\\BC`, `B`, `DEF`, `\\`, `A\\BC`},
{`A\\\BC`, `B`, `DEF`, `\\`, `A\\\BC`},
{`ACE`, `B`, `DEF`, `\`, `ACE`},
{`B\\B\\\B`, `B`, `DEF`, `\`, `DEF\\DEF\\\B`},
{`漢字\\漢\字\\\漢`, `漢`, `字`, `\`, `字字\\字\字\\\漢`},
{`ABCABC`, `ABC`, `D`, `\`, `DD`},
{`ABC\ABCABC`, `ABC`, `D`, `\`, `D\ABCD`},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s-->%s Escape=%s", tc.pattern, tc.expected, tc.escapeToken), func(t *testing.T) {
actual := replaceUnescaped(tc.pattern, tc.old, tc.new, tc.escapeToken)
if tc.expected != actual {
t.Errorf("expected replaced pattern: %s, got %s\n", tc.expected, actual)
}
})
}
} | explode_data.jsonl/24153 | {
"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,
23107,
1806,
65826,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
340,
18185,
37302,
1669,
3056,
1235,
341,
197,
3223,
3227,
257,
914,
198,
197,
61828... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshalArrayThatContainsObject(t *testing.T) {
data := "a:3:{i:0;O:7:\"struct1\":2:{s:3:\"foo\";i:10;s:3:\"baz\";s:3:\"yay\";}i:1;i:8;i:2;i:9;}"
var result []interface{}
err := phpserialize.Unmarshal([]byte(data), &result)
expectErrorToNotHaveOccurred(t, err)
expected := []interface{}{
map[interface{}]interface{}{
"baz": "yay",
"foo": int64(10),
},
int64(8),
int64(9),
}
if !reflect.DeepEqual(result, expected) {
t.Errorf("Expected:\n %#+v\nGot:\n %#+v", expected, result)
}
} | explode_data.jsonl/27031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
1806,
27121,
1857,
4792,
23805,
1190,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
330,
64,
25,
18,
12547,
72,
25,
15,
26,
46,
25,
22,
75035,
1235,
16,
11693,
17,
12547,
82,
25,
18,
75035,
7975,
2105,
26,
72,
25,
16,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEndpointsDiscoveryDeleteUnknownCacheState(t *testing.T) {
n, _, eps, _ := makeTestEndpointsDiscovery()
eps.GetStore().Add(makeEndpoints())
k8sDiscoveryTest{
discovery: n,
afterStart: func() { go func() { eps.Delete(cache.DeletedFinalStateUnknown{Obj: makeEndpoints()}) }() },
expectedRes: []*targetgroup.Group{
{
Source: "endpoints/default/testendpoints",
},
},
}.Run(t)
} | explode_data.jsonl/36699 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
80786,
67400,
6435,
13790,
8233,
1397,
1155,
353,
8840,
836,
8,
341,
9038,
11,
8358,
17986,
11,
716,
1669,
1281,
2271,
80786,
67400,
741,
197,
7124,
2234,
6093,
1005,
2212,
36944,
80786,
12367,
16463,
23,
82,
67400,
2271,
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 TestNodeJoin(t *testing.T) {
defer leaktest.AfterTest(t)()
engineStopper := stop.NewStopper()
defer engineStopper.Stop(context.TODO())
e := engine.NewInMem(roachpb.Attributes{}, 1<<20)
engineStopper.AddCloser(e)
cfg := bootstrapNodeConfig()
if _, err := bootstrapCluster(
context.TODO(), cfg, []engine.Engine{e}, cfg.Settings.Version.BootstrapVersion(), kv.MakeTxnMetrics(metric.TestSampleInterval),
); err != nil {
t.Fatal(err)
}
// Start the bootstrap node.
engines1 := []engine.Engine{e}
_, server1Addr, node1, stopper1 := createAndStartTestNode(
util.TestAddr,
engines1,
util.TestAddr,
roachpb.Locality{},
t,
)
defer stopper1.Stop(context.TODO())
// Create a new node.
e2 := engine.NewInMem(roachpb.Attributes{}, 1<<20)
engineStopper.AddCloser(e2)
engines2 := []engine.Engine{e2}
_, server2Addr, node2, stopper2 := createAndStartTestNode(
util.TestAddr,
engines2,
server1Addr,
roachpb.Locality{},
t,
)
defer stopper2.Stop(context.TODO())
// Verify new node is able to bootstrap its store.
testutils.SucceedsSoon(t, func() error {
if sc := node2.stores.GetStoreCount(); sc != 1 {
return errors.Errorf("GetStoreCount() expected 1; got %d", sc)
}
return nil
})
// Verify node1 sees node2 via gossip and vice versa.
node1Key := gossip.MakeNodeIDKey(node1.Descriptor.NodeID)
node2Key := gossip.MakeNodeIDKey(node2.Descriptor.NodeID)
testutils.SucceedsSoon(t, func() error {
var nodeDesc1 roachpb.NodeDescriptor
if err := node1.storeCfg.Gossip.GetInfoProto(node2Key, &nodeDesc1); err != nil {
return err
}
if addr2Str, server2AddrStr := nodeDesc1.Address.String(), server2Addr.String(); addr2Str != server2AddrStr {
return errors.Errorf("addr2 gossip %s doesn't match addr2 address %s", addr2Str, server2AddrStr)
}
var nodeDesc2 roachpb.NodeDescriptor
if err := node2.storeCfg.Gossip.GetInfoProto(node1Key, &nodeDesc2); err != nil {
return err
}
if addr1Str, server1AddrStr := nodeDesc2.Address.String(), server1Addr.String(); addr1Str != server1AddrStr {
return errors.Errorf("addr1 gossip %s doesn't match addr1 address %s", addr1Str, server1AddrStr)
}
return nil
})
} | explode_data.jsonl/52654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 862
} | [
2830,
3393,
1955,
12292,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
80118,
10674,
712,
1669,
2936,
7121,
10674,
712,
741,
16867,
4712,
10674,
712,
30213,
5378,
90988,
2398,
7727,
1669,
4712,
7121,
641,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplicationContext_PrototypeBean(t *testing.T) {
c, _ := container()
gs := &GreetingService{}
c.Object(gs)
s := &PrototypeBeanService{}
c.Object(s)
f := &PrototypeBeanFactory{}
c.Object(f)
c.Object(c)
err := c.Refresh()
assert.Nil(t, err)
s.Service("Li Lei")
time.Sleep(50 * time.Millisecond)
s.Service("Jim Green")
time.Sleep(50 * time.Millisecond)
s.Service("Han MeiMei")
} | explode_data.jsonl/17398 | {
"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,
19736,
1088,
4640,
4156,
10437,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
5476,
2822,
3174,
82,
1669,
609,
38,
43632,
1860,
16094,
1444,
8348,
83394,
692,
1903,
1669,
609,
32906,
10437,
1860,
16094,
1444,
8348,
1141... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCatchUpClient_PullBlocksCancel(t *testing.T) {
lg, err := logger.New(&logger.Config{
Level: "info",
OutputPath: []string{"stdout"},
ErrOutputPath: []string{"stderr"},
Encoding: "console",
})
require.NoError(t, err)
mn := comm.RetryIntervalMin
mx := comm.RetryIntervalMax
comm.RetryIntervalMin = 100 * time.Microsecond
comm.RetryIntervalMax = time.Millisecond
defer func() {
comm.RetryIntervalMin = mn
comm.RetryIntervalMax = mx
}()
localConfigs, sharedConfig := newTestSetup(t, 3)
tr1, err := startTransportWithLedger(t, lg, localConfigs, sharedConfig, 0, 50)
require.NoError(t, err)
defer tr1.Close()
cc := comm.NewCatchUpClient(lg, nil)
require.NotNil(t, cc)
err = cc.UpdateMembers(sharedConfig.ConsensusConfig.Members)
require.NoError(t, err)
wg := sync.WaitGroup{}
wg.Add(1)
ctx, cancel := context.WithCancel(context.Background())
go func() {
blocks, err := cc.PullBlocks(ctx, 51, 100, 0)
wg.Done()
require.EqualError(t, err, "PullBlocks canceled: context canceled")
require.Nil(t, blocks)
}()
time.Sleep(10 * time.Millisecond)
cancel()
wg.Wait()
} | explode_data.jsonl/70498 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 459
} | [
2830,
3393,
57760,
2324,
2959,
1088,
617,
29804,
9269,
1155,
353,
8840,
836,
8,
341,
8810,
70,
11,
1848,
1669,
5925,
7121,
2099,
9786,
10753,
515,
197,
197,
4449,
25,
260,
330,
2733,
756,
197,
80487,
1820,
25,
262,
3056,
917,
4913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestChatSrvGetThreadNonblockSupersedes(t *testing.T) {
runWithMemberTypes(t, func(mt chat1.ConversationMembersType) {
ctc := makeChatTestContext(t, "GetThreadNonblockSupersedes", 1)
defer ctc.cleanup()
users := ctc.users()
uid := gregor1.UID(users[0].GetUID().ToBytes())
ui := kbtest.NewChatUI()
ctc.as(t, users[0]).h.mockChatUI = ui
ctx := ctc.as(t, users[0]).startCtx
<-ctc.as(t, users[0]).h.G().ConvLoader.Stop(ctx)
listener := newServerChatListener()
ctc.as(t, users[0]).h.G().NotifyRouter.AddListener(listener)
conv := mustCreateConversationForTest(t, ctc, users[0], chat1.TopicType_CHAT, mt)
cs := ctc.world.Tcs[users[0].Username].ChatG.ConvSource
msg := chat1.NewMessageBodyWithText(chat1.MessageText{Body: "hi"})
msgID1 := mustPostLocalForTest(t, ctc, users[0], conv, msg)
consumeNewMsgRemote(t, listener, chat1.MessageType_TEXT)
msgRes, err := ctc.as(t, users[0]).chatLocalHandler().GetMessagesLocal(ctx, chat1.GetMessagesLocalArg{
ConversationID: conv.Id,
MessageIDs: []chat1.MessageID{msgID1},
DisableResolveSupersedes: true,
})
require.NoError(t, err)
require.Equal(t, 1, len(msgRes.Messages))
msg1 := msgRes.Messages[0]
editMsgID1 := mustEditMsg(ctx, t, ctc, users[0], conv, msgID1)
consumeNewMsgRemote(t, listener, chat1.MessageType_EDIT)
msgIDs := []chat1.MessageID{editMsgID1, msgID1, 1}
require.NoError(t, cs.Clear(context.TODO(), conv.Id, uid))
err = cs.PushUnboxed(ctx, conv.Id, uid, []chat1.MessageUnboxed{msg1})
require.NoError(t, err)
delay := 10 * time.Minute
clock := clockwork.NewFakeClock()
ctc.as(t, users[0]).h.uiThreadLoader.clock = clock
ctc.as(t, users[0]).h.uiThreadLoader.cachedThreadDelay = nil
ctc.as(t, users[0]).h.uiThreadLoader.remoteThreadDelay = &delay
ctc.as(t, users[0]).h.uiThreadLoader.validatedDelay = 0
cb := make(chan struct{})
query := chat1.GetThreadQuery{
MessageTypes: []chat1.MessageType{chat1.MessageType_TEXT},
}
go func() {
_, err := ctc.as(t, users[0]).chatLocalHandler().GetThreadNonblock(ctx,
chat1.GetThreadNonblockArg{
ConversationID: conv.Id,
Query: &query,
CbMode: chat1.GetThreadNonblockCbMode_INCREMENTAL,
},
)
require.NoError(t, err)
close(cb)
}()
clock.Advance(50 * time.Millisecond)
select {
case res := <-ui.ThreadCb:
require.False(t, res.Full)
require.Equal(t, len(msgIDs), len(res.Thread.Messages))
// Not unread
require.Equal(t, msgIDs, utils.PluckUIMessageIDs(res.Thread.Messages))
confirmIsText(t, msgID1, res.Thread.Messages[1], "hi")
require.False(t, res.Thread.Messages[1].Valid().Superseded)
confirmIsPlaceholder(t, editMsgID1, res.Thread.Messages[0], false)
confirmIsPlaceholder(t, 1, res.Thread.Messages[2], false)
case <-time.After(20 * time.Second):
require.Fail(t, "no thread cb")
}
clock.Advance(20 * time.Minute)
select {
case res := <-ui.ThreadCb:
require.True(t, res.Full)
require.Equal(t, len(msgIDs), len(res.Thread.Messages))
// Not unread
confirmIsPlaceholder(t, editMsgID1, res.Thread.Messages[0], true)
confirmIsText(t, msgID1, res.Thread.Messages[1], "edited")
confirmIsPlaceholder(t, 1, res.Thread.Messages[2], true)
case <-time.After(20 * time.Second):
require.Fail(t, "no thread cb")
}
select {
case <-cb:
case <-time.After(20 * time.Second):
require.Fail(t, "GetThread never finished")
}
deleteMsgID := mustDeleteMsg(ctx, t, ctc, users[0], conv, msgID1)
consumeNewMsgRemote(t, listener, chat1.MessageType_DELETE)
msgIDs = []chat1.MessageID{deleteMsgID, editMsgID1, msgID1, 1}
require.NoError(t, cs.Clear(context.TODO(), conv.Id, uid))
err = cs.PushUnboxed(ctx, conv.Id, uid, []chat1.MessageUnboxed{msg1})
require.NoError(t, err)
cb = make(chan struct{})
go func() {
_, err := ctc.as(t, users[0]).chatLocalHandler().GetThreadNonblock(ctx,
chat1.GetThreadNonblockArg{
ConversationID: conv.Id,
Query: &query,
CbMode: chat1.GetThreadNonblockCbMode_INCREMENTAL,
},
)
require.NoError(t, err)
close(cb)
}()
clock.Advance(50 * time.Millisecond)
select {
case res := <-ui.ThreadCb:
require.False(t, res.Full)
require.Equal(t, len(msgIDs), len(res.Thread.Messages))
// Not unread
require.Equal(t, msgIDs, utils.PluckUIMessageIDs(res.Thread.Messages))
confirmIsPlaceholder(t, deleteMsgID, res.Thread.Messages[0], false)
confirmIsPlaceholder(t, editMsgID1, res.Thread.Messages[1], false)
confirmIsText(t, msgID1, res.Thread.Messages[2], "hi")
require.False(t, res.Thread.Messages[2].Valid().Superseded)
confirmIsPlaceholder(t, 1, res.Thread.Messages[3], false)
case <-time.After(20 * time.Second):
require.Fail(t, "no thread cb")
}
clock.Advance(20 * time.Minute)
select {
case res := <-ui.ThreadCb:
require.True(t, res.Full)
require.Equal(t, len(msgIDs), len(res.Thread.Messages))
// Not unread
confirmIsPlaceholder(t, deleteMsgID, res.Thread.Messages[0], true)
confirmIsPlaceholder(t, editMsgID1, res.Thread.Messages[1], true)
confirmIsPlaceholder(t, msgID1, res.Thread.Messages[2], true)
confirmIsPlaceholder(t, 1, res.Thread.Messages[3], true)
case <-time.After(20 * time.Second):
require.Fail(t, "no thread cb")
}
select {
case <-cb:
case <-time.After(20 * time.Second):
require.Fail(t, "GetThread never finished")
}
})
} | explode_data.jsonl/63693 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2363
} | [
2830,
3393,
15672,
50,
10553,
1949,
6855,
8121,
4574,
10048,
39919,
288,
1155,
353,
8840,
836,
8,
341,
56742,
2354,
9366,
4173,
1155,
11,
2915,
81618,
6236,
16,
4801,
22323,
24371,
929,
8,
341,
197,
89216,
66,
1669,
1281,
15672,
2271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGenerateSaveCoinKeyOverwriteFlag(t *testing.T) {
t.Parallel()
kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil)
require.NoError(t, err)
keyname := "justakey"
addr1, _, err := server.GenerateSaveCoinKey(kb, keyname, false, hd.Secp256k1)
require.NoError(t, err)
// Test overwrite with overwrite=false
_, _, err = server.GenerateSaveCoinKey(kb, keyname, false, hd.Secp256k1)
require.Error(t, err)
// Test overwrite with overwrite=true
addr2, _, err := server.GenerateSaveCoinKey(kb, keyname, true, hd.Secp256k1)
require.NoError(t, err)
require.NotEqual(t, addr1, addr2)
} | explode_data.jsonl/54500 | {
"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,
31115,
8784,
41180,
1592,
1918,
4934,
12135,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
16463,
65,
11,
1848,
1669,
1376,
12640,
7121,
1155,
2967,
1507,
330,
1944,
497,
259,
65009,
6184,
1507,
2092,
340,
17957,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppLabels(t *testing.T) {
Given(t).
Path("config-map").
When().
CreateApp("-l", "foo=bar").
Then().
And(func(app *Application) {
assert.Contains(t, FailOnErr(RunCli("app", "list")), Name())
assert.Contains(t, FailOnErr(RunCli("app", "list", "-l", "foo=bar")), Name())
assert.NotContains(t, FailOnErr(RunCli("app", "list", "-l", "foo=rubbish")), Name())
}).
Given().
// remove both name and replace labels means nothing will sync
Name("").
When().
IgnoreErrors().
Sync("-l", "foo=rubbish").
DoNotIgnoreErrors().
Then().
Expect(Error("", "no apps match selector foo=rubbish")).
// check we can update the app and it is then sync'd
Given().
When().
Sync("-l", "foo=bar")
} | explode_data.jsonl/35624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 299
} | [
2830,
3393,
2164,
23674,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
69640,
445,
1676,
25858,
38609,
197,
197,
4498,
25829,
197,
75569,
2164,
13645,
75,
497,
330,
7975,
28,
2257,
38609,
197,
197,
12209,
25829,
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 TestUndelay(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.CreateConnected(789, 30000, nil)
c.EP.SetSockOpt(tcpip.DelayOption(1))
allData := [][]byte{{0}, {1, 2, 3}}
for i, data := range allData {
view := buffer.NewViewFromBytes(data)
if _, _, err := c.EP.Write(tcpip.SlicePayload(view), tcpip.WriteOptions{}); err != nil {
t.Fatalf("Write #%d failed: %v", i+1, err)
}
}
seq := c.IRS.Add(1)
// Check that data is received.
first := c.GetPacket()
checker.IPv4(t, first,
checker.PayloadLen(len(allData[0])+header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.SeqNum(uint32(seq)),
checker.AckNum(790),
checker.TCPFlagsMatch(header.TCPFlagAck, ^uint8(header.TCPFlagPsh)),
),
)
if got, want := first[header.IPv4MinimumSize+header.TCPMinimumSize:], allData[0]; !bytes.Equal(got, want) {
t.Fatalf("got first packet's data = %v, want = %v", got, want)
}
seq = seq.Add(seqnum.Size(len(allData[0])))
// Check that we don't get the second packet yet.
c.CheckNoPacketTimeout("delayed second packet transmitted", 100*time.Millisecond)
c.EP.SetSockOpt(tcpip.DelayOption(0))
// Check that data is received.
second := c.GetPacket()
checker.IPv4(t, second,
checker.PayloadLen(len(allData[1])+header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.SeqNum(uint32(seq)),
checker.AckNum(790),
checker.TCPFlagsMatch(header.TCPFlagAck, ^uint8(header.TCPFlagPsh)),
),
)
if got, want := second[header.IPv4MinimumSize+header.TCPMinimumSize:], allData[1]; !bytes.Equal(got, want) {
t.Fatalf("got second packet's data = %v, want = %v", got, want)
}
seq = seq.Add(seqnum.Size(len(allData[1])))
// Acknowledge the data.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: 790,
AckNum: seq,
RcvWnd: 30000,
})
} | explode_data.jsonl/22298 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 844
} | [
2830,
3393,
19957,
6895,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
1444,
7251,
21146,
7,
22,
23,
24,
11,
220,
18,
15,
15,
15,
15,
11,
2092,
692,
1444,
5142,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue10213(t *testing.T) {
var src = `
var (
A = 1 // foo
)
var (
B = 2
// foo
)
var C = 3 // foo
var D = 4
// foo
func anycode() {
// foo
}
`
var s Scanner
s.Init(fset.AddFile("", fset.Base(), len(src)), []byte(src), nil, 0)
for {
pos, tok, lit := s.Scan()
class := tokenclass(tok)
if lit != "" && class != keyword && class != literal && tok != token.SEMICOLON {
t.Errorf("%s: tok = %s, lit = %q", fset.Position(pos), tok, lit)
}
if tok <= token.EOF {
break
}
}
} | explode_data.jsonl/1844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
42006,
16,
15,
17,
16,
18,
1155,
353,
8840,
836,
8,
341,
2405,
2286,
284,
22074,
197,
2405,
2399,
298,
22985,
284,
220,
16,
442,
15229,
198,
197,
197,
692,
197,
2405,
2399,
298,
12791,
284,
220,
17,
198,
298,
197,
322,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestDoGroupCreate_Success(t *testing.T) {
t.Parallel()
actionsClient := &mocks.ActionsClient{}
teamsClient := &mocks.TeamsClient{}
usersClient := &mocks.UsersClient{}
logger, _ := test.NewNullLogger()
manager := &Manager{
ActionsClient: actionsClient,
Config: &Config{},
CreateMaintainershipClient: func(string, string) (*MaintainershipClient, *github.User, error) {
return &MaintainershipClient{
TeamsClient: teamsClient,
UsersClient: usersClient,
}, nil, nil
},
Logger: logger,
}
runnerGroup := &github.RunnerGroup{
Name: github.String("fake-runner-group-name"),
}
actionsClient.CreateOrganizationRunnerGroupReturns(runnerGroup, nil, nil)
membership := &github.Membership{
Role: github.String("maintainer"),
}
teamsClient.GetTeamMembershipBySlugReturns(membership, nil, nil)
var err error
writer := httptest.NewRecorder()
context, _ := gin.CreateTestContext(writer)
context.Request, err = http.NewRequest(http.MethodGet, "/v1/api/group-add?team=fake-team", nil)
context.Request.Header.Set("Authorization", "test-token")
require.NoError(t, err)
manager.DoGroupCreate(context)
result := writer.Result()
body, err := ioutil.ReadAll(result.Body)
defer result.Body.Close()
require.NoError(t, err)
expected := &gin.H{
"Code": float64(http.StatusOK),
"Response": "Runner group created successfully: fake-runner-group-name",
}
groupAddResponse := &gin.H{}
err = json.Unmarshal(body, &groupAddResponse)
require.NoError(t, err)
require.Equal(t, expected, groupAddResponse)
require.Equal(t, 1, actionsClient.CreateOrganizationRunnerGroupCallCount())
require.Equal(t, 1, teamsClient.GetTeamMembershipBySlugCallCount())
} | explode_data.jsonl/27799 | {
"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,
5404,
2808,
4021,
87161,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
4020,
2959,
1669,
609,
16712,
82,
72044,
2959,
16094,
197,
38496,
2959,
1669,
609,
16712,
82,
94849,
4122,
2959,
16094,
90896,
2959,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKubernetesPlugin(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
} | explode_data.jsonl/43028 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
42,
29827,
11546,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
692,
85952,
8327,
16056,
3675,
3036,
10268,
10361,
388,
1155,
345,
197,
197,
1,
2051,
20977,
756,
197,
197,
1294,
52766,
90,
62956,
7121,
1056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestPinGC(t *testing.T) {
chunkCount := 150
pinChunksCount := 50
dbCapacity := uint64(100)
var closed chan struct{}
testHookCollectGarbageChan := make(chan uint64)
t.Cleanup(setTestHookCollectGarbage(func(collectedCount uint64) {
// don't trigger if we haven't collected anything - this may
// result in a race condition when we inspect the gcsize below,
// causing the database to shut down while the cleanup to happen
// before the correct signal has been communicated here.
if collectedCount == 0 {
return
}
select {
case testHookCollectGarbageChan <- collectedCount:
case <-closed:
}
}))
t.Cleanup(setWithinRadiusFunc(func(_ *DB, _ shed.Item) bool { return false }))
db := newTestDB(t, &Options{
Capacity: dbCapacity,
})
closed = db.close
addrs := make([]swarm.Address, 0)
pinAddrs := make([]swarm.Address, 0)
// upload random chunks
for i := 0; i < chunkCount; i++ {
ch := generateTestRandomChunk()
// call unreserve on the batch with radius 0 so that
// localstore is aware of the batch and the chunk can
// be inserted into the database
unreserveChunkBatch(t, db, 0, ch)
mode := storage.ModePutUpload
if i < pinChunksCount {
mode = storage.ModePutUploadPin
pinAddrs = append(pinAddrs, ch.Address())
}
_, err := db.Put(context.Background(), mode, ch)
if err != nil {
t.Fatal(err)
}
err = db.Set(context.Background(), storage.ModeSetSync, ch.Address())
if err != nil {
t.Fatal(err)
}
addrs = append(addrs, ch.Address())
}
gcTarget := db.gcTarget()
t.Log(gcTarget)
for {
select {
case <-testHookCollectGarbageChan:
case <-time.After(10 * time.Second):
t.Fatal("collect garbage timeout")
}
gcSize, err := db.gcSize.Get()
if err != nil {
t.Fatal(err)
}
if gcSize == gcTarget {
break
}
}
t.Run("pin Index count", newItemsCountTest(db.pinIndex, pinChunksCount))
t.Run("pull index count", newItemsCountTest(db.pullIndex, int(gcTarget)+pinChunksCount))
t.Run("gc index count", newItemsCountTest(db.gcIndex, int(gcTarget)))
t.Run("gc size", newIndexGCSizeTest(db))
t.Run("pinned chunk not in gc Index", func(t *testing.T) {
err := db.gcIndex.Iterate(func(item shed.Item) (stop bool, err error) {
for _, pinHash := range pinAddrs {
if bytes.Equal(pinHash.Bytes(), item.Address) {
t.Fatal("pin chunk present in gcIndex")
}
}
return false, nil
}, nil)
if err != nil {
t.Fatal("could not iterate gcIndex")
}
})
t.Run("pinned chunks exists", func(t *testing.T) {
for _, hash := range pinAddrs {
_, err := db.Get(context.Background(), storage.ModeGetRequest, hash)
if err != nil {
t.Fatal(err)
}
}
})
t.Run("first chunks after pinned chunks should be removed", func(t *testing.T) {
for i := pinChunksCount; i < (int(dbCapacity) - int(gcTarget)); i++ {
_, err := db.Get(context.Background(), storage.ModeGetRequest, addrs[i])
if !errors.Is(err, leveldb.ErrNotFound) {
t.Fatal(err)
}
}
})
} | explode_data.jsonl/11630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1162
} | [
2830,
3393,
19861,
22863,
1155,
353,
8840,
836,
8,
341,
23049,
3122,
2507,
1669,
220,
16,
20,
15,
198,
3223,
258,
89681,
2507,
1669,
220,
20,
15,
198,
20939,
29392,
1669,
2622,
21,
19,
7,
16,
15,
15,
692,
2405,
7877,
26023,
2036,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCharge(t *testing.T) {
c := ChargeCarrier{}
c.Charge(0.5)
if !testutils.FloatsAreEqual(c.currentCharge, 0.5) {
t.Errorf("Charged by 0.5, but have %v ChargeCarrier.", c.currentCharge)
}
} | explode_data.jsonl/66635 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
55363,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
36795,
96294,
16094,
1444,
6353,
2744,
7,
15,
13,
20,
692,
743,
753,
1944,
6031,
29794,
82,
11526,
2993,
1337,
4952,
55363,
11,
220,
15,
13,
20,
8,
341,
197,
3244,
13080,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEngineProcessor_Stop(t *testing.T) {
sendCommandPoolMock := new(task.MockedPool)
cancelCommandPoolMock := new(task.MockedPool)
ctx := context.NewMockDefault()
resChan := make(chan contracts.DocumentResult)
processor := EngineProcessor{
sendCommandPool: sendCommandPoolMock,
cancelCommandPool: cancelCommandPoolMock,
context: ctx,
resChan: resChan,
}
sendCommandPoolMock.On("ShutdownAndWait", mock.AnythingOfType("time.Duration")).Return(true)
cancelCommandPoolMock.On("ShutdownAndWait", mock.AnythingOfType("time.Duration")).Return(true)
processor.Stop()
sendCommandPoolMock.AssertExpectations(t)
cancelCommandPoolMock.AssertExpectations(t)
// multiple stop
sendCommandPoolMock = new(task.MockedPool)
cancelCommandPoolMock = new(task.MockedPool)
processor.Stop()
sendCommandPoolMock.AssertNotCalled(t, "ShutdownAndWait", mock.AnythingOfType("time.Duration"))
cancelCommandPoolMock.AssertNotCalled(t, "ShutdownAndWait", mock.AnythingOfType("time.Duration"))
} | explode_data.jsonl/526 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 360
} | [
2830,
3393,
4571,
22946,
80308,
1155,
353,
8840,
836,
8,
341,
32817,
4062,
10551,
11571,
1669,
501,
17483,
24664,
291,
10551,
340,
84441,
4062,
10551,
11571,
1669,
501,
17483,
24664,
291,
10551,
340,
20985,
1669,
2266,
7121,
11571,
3675,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStorageMemoryOnlyUsedWithAllInOneStrategy(t *testing.T) {
jaeger := &v1.Jaeger{
Spec: v1.JaegerSpec{
Strategy: v1.DeploymentStrategyProduction,
Storage: v1.JaegerStorageSpec{
Type: "memory",
},
},
}
For(context.TODO(), jaeger)
assert.Equal(t, v1.DeploymentStrategyAllInOne, jaeger.Spec.Strategy)
} | explode_data.jsonl/21851 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
5793,
10642,
7308,
22743,
2354,
2403,
641,
3966,
19816,
1155,
353,
8840,
836,
8,
341,
197,
5580,
1878,
1669,
609,
85,
16,
3503,
64,
1878,
515,
197,
7568,
992,
25,
348,
16,
3503,
64,
1878,
8327,
515,
298,
197,
19816,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCRIPods(t *testing.T) {
tst := makeVirtletCRITester(t)
defer tst.teardown()
tst.listPodSandbox(nil)
tst.listContainers(nil)
sandboxes := criapi.GetSandboxes(2)
containers := criapi.GetContainersConfig(sandboxes)
tst.pullImage(cirrosImg())
tst.runPodSandbox(sandboxes[0])
tst.listPodSandbox(nil)
tst.podSandboxStatus(sandboxes[0].Metadata.Uid)
containerId1 := tst.createContainer(sandboxes[0], containers[0], cirrosImg(), nil)
tst.listContainers(nil)
tst.containerStatus(containerId1)
tst.startContainer(containerId1)
tst.containerStatus(containerId1)
tst.containerStats(containerId1)
tst.listContainerStats(nil)
tst.pullImage(ubuntuImg())
tst.runPodSandbox(sandboxes[1])
containerId2 := tst.createContainer(sandboxes[1], containers[1], ubuntuImg(), nil)
tst.listPodSandbox(nil)
tst.listContainers(nil)
tst.containerStatus(containerId2)
tst.startContainer(containerId2)
tst.containerStatus(containerId2)
tst.stopContainer(containerId1)
tst.stopContainer(containerId2)
// this should not cause an error
tst.stopContainer(containerId2)
tst.listContainers(nil)
tst.containerStatus(containerId1)
tst.removeContainer(containerId1)
tst.removeContainer(containerId2)
// this should not cause an error
tst.removeContainer(containerId2)
tst.stopPodSandox(sandboxes[0].Metadata.Uid)
tst.stopPodSandox(sandboxes[1].Metadata.Uid)
// this should not cause an error
tst.stopPodSandox(sandboxes[1].Metadata.Uid)
tst.listPodSandbox(nil)
tst.podSandboxStatus(sandboxes[0].Metadata.Uid)
tst.removePodSandox(sandboxes[0].Metadata.Uid)
tst.removePodSandox(sandboxes[1].Metadata.Uid)
// this should not cause an error
tst.removePodSandox(sandboxes[1].Metadata.Uid)
tst.listPodSandbox(nil)
tst.listContainers(nil)
tst.verify()
} | explode_data.jsonl/15663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 690
} | [
2830,
3393,
8973,
3298,
29697,
1155,
353,
8840,
836,
8,
341,
3244,
267,
1669,
1281,
53,
2106,
1149,
8973,
952,
5191,
1155,
340,
16867,
71707,
31853,
37496,
741,
3244,
267,
6420,
23527,
50,
31536,
27907,
340,
3244,
267,
6420,
74632,
2790... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecordSetDeleteIntegration(t *testing.T) {
c := client()
zs, err := c.ZonesListAll(ListFilter{})
if err != nil {
t.Error(err)
}
z := zs[0].ID
rs, err := c.RecordSetsListAll(z, ListFilter{})
if err != nil {
t.Error(err)
}
var r string
for _, rec := range rs {
if rec.Name == "integration-test" {
r = rec.ID
break
}
}
_, err = c.RecordSetDelete(z, r)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/12126 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
6471,
1649,
6435,
52464,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2943,
741,
20832,
82,
11,
1848,
1669,
272,
13476,
3154,
852,
2403,
10278,
5632,
37790,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
532,
208... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessProposalGoodDial(t *testing.T) {
srv := &mocks.MockEndorserServer{}
addr := srv.Start(testAddress)
defer srv.Stop()
_, err := testProcessProposal(t, "grpc://"+addr)
if err != nil {
t.Fatalf("Process proposal failed (%s)", err)
}
} | explode_data.jsonl/45092 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
7423,
98637,
15216,
35,
530,
1155,
353,
8840,
836,
8,
341,
1903,
10553,
1669,
609,
16712,
82,
24664,
3727,
269,
799,
5475,
16094,
53183,
1669,
43578,
12101,
8623,
4286,
340,
16867,
43578,
30213,
2822,
197,
6878,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFilterServicePlans(t *testing.T) {
cases := []struct {
name string
requirements []string
accepted int
rejected int
catalog string
}{
{
name: "no restriction",
accepted: 2,
rejected: 0,
catalog: testCatalog,
},
{
name: "by external name",
requirements: []string{"spec.externalName=fake-plan-1"},
accepted: 1,
rejected: 1,
catalog: testCatalog,
},
{
name: "by external name",
requirements: []string{"spec.externalName=real-plan-1"},
accepted: 0,
rejected: 2,
catalog: testCatalog,
},
}
for _, tc := range cases {
testName := fmt.Sprintf("%s:%s", tc.name, tc.requirements)
t.Run(testName, func(t *testing.T) {
catalog := &osb.CatalogResponse{}
err := json.Unmarshal([]byte(tc.catalog), &catalog)
if err != nil {
t.Fatalf("Failed to unmarshal test catalog: %v", err)
}
_, servicePlans, err := convertAndFilterCatalog(catalog, nil)
if err != nil {
t.Fatalf("Failed to convertAndFilterCatalog: %v", err)
}
total := tc.accepted + tc.rejected
if len(servicePlans) != total {
t.Fatalf("Catalog did not contained expected number of plans, %s", expectedGot(total, len(servicePlans)))
}
restrictions := &v1beta1.CatalogRestrictions{
ServicePlan: tc.requirements,
}
acceptedServiceClass, rejectedServiceClasses, err := filterServicePlans(restrictions, servicePlans)
if len(acceptedServiceClass) != tc.accepted {
t.Fatalf("Unexpected number of accepted service plans after filtering, %s", expectedGot(tc.accepted, len(acceptedServiceClass)))
}
if len(rejectedServiceClasses) != tc.rejected {
t.Fatalf("Unexpected number of accepted service plans after filtering, %s", expectedGot(tc.rejected, len(rejectedServiceClasses)))
}
})
}
} | explode_data.jsonl/40490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 765
} | [
2830,
3393,
5632,
1860,
97728,
1155,
353,
8840,
836,
8,
1476,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
17957,
1368,
3056,
917,
198,
197,
197,
54574,
257,
526,
198,
197,
17200,
28303,
257,
526,
198,
197,
1444,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoCacheRequestExpiration(t *testing.T) {
resetTest()
respHeaders := http.Header{}
respHeaders.Set("Cache-Control", "max-age=7200")
reqHeaders := http.Header{}
reqHeaders.Set("Cache-Control", "no-cache")
if getFreshness(respHeaders, reqHeaders) != transparent {
t.Fatal("freshness isn't transparent")
}
} | explode_data.jsonl/77628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
2753,
8233,
1900,
66301,
1155,
353,
8840,
836,
8,
341,
70343,
2271,
741,
34653,
10574,
1669,
1758,
15753,
16094,
34653,
10574,
4202,
445,
8233,
25056,
497,
330,
2810,
42941,
28,
22,
17,
15,
15,
5130,
24395,
10574,
1669,
1758... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEdgeutilInterpolateOverLongEdge(t *testing.T) {
lng := math.Pi - 1e-2
a := Point{PointFromLatLng(LatLng{0, 0}).Normalize()}
b := Point{PointFromLatLng(LatLng{0, s1.Angle(lng)}).Normalize()}
for f := 0.4; f > 1e-15; f *= 0.1 {
// Test that interpolation is accurate on a long edge (but not so long that
// the definition of the edge itself becomes too unstable).
want := Point{PointFromLatLng(LatLng{0, s1.Angle(f * lng)}).Normalize()}
if got := Interpolate(f, a, b); !pointsApproxEquals(got, want, 3e-15) {
t.Errorf("long edge Interpolate(%v, %v, %v) = %v, want %v", f, a, b, got, want)
}
// Test the remainder of the dist also matches.
wantRem := Point{PointFromLatLng(LatLng{0, s1.Angle((1 - f) * lng)}).Normalize()}
if got := Interpolate(1-f, a, b); !pointsApproxEquals(got, wantRem, 3e-15) {
t.Errorf("long edge Interpolate(%v, %v, %v) = %v, want %v", 1-f, a, b, got, wantRem)
}
}
} | explode_data.jsonl/74789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
11656,
1314,
3306,
45429,
1918,
6583,
11656,
1155,
353,
8840,
836,
8,
341,
8810,
968,
1669,
6888,
1069,
72,
481,
220,
16,
68,
12,
17,
198,
11323,
1669,
5126,
90,
2609,
3830,
64922,
4957,
32738,
90,
15,
11,
220,
15,
16630... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetFundingHistory(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys required but not set, skipping test")
}
_, err := f.GetFundingHistory(context.Background())
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15231 | {
"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,
1949,
37,
37189,
13424,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
7082,
6894,
2567,
714,
537,
738,
11,
42659,
1273,
1138,
197,
532,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDeviceTokenSucceedsWithIntermediateSlowDown(t *testing.T) {
sender := newDeviceTokenSender("slow_down")
_, err := WaitForUserCompletion(sender, deviceCode())
if err != nil {
t.Fatalf("unexpected error occurred")
}
} | explode_data.jsonl/27508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
6985,
3323,
50,
29264,
16056,
98961,
58289,
4454,
1155,
353,
8840,
836,
8,
341,
1903,
1659,
1669,
501,
6985,
3323,
20381,
445,
35211,
13998,
5130,
197,
6878,
1848,
1669,
37601,
1474,
33190,
19377,
11,
3671,
2078,
2398,
743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCopyFile(t *testing.T) {
ctx := context.Background()
r := fstest.NewRun(t)
defer r.Finalise()
file1 := r.WriteFile("file1", "file1 contents", t1)
fstest.CheckItems(t, r.Flocal, file1)
file2 := file1
file2.Path = "sub/file2"
err := operations.CopyFile(ctx, r.Fremote, r.Flocal, file2.Path, file1.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.Flocal, file1)
fstest.CheckItems(t, r.Fremote, file2)
err = operations.CopyFile(ctx, r.Fremote, r.Flocal, file2.Path, file1.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.Flocal, file1)
fstest.CheckItems(t, r.Fremote, file2)
err = operations.CopyFile(ctx, r.Fremote, r.Fremote, file2.Path, file2.Path)
require.NoError(t, err)
fstest.CheckItems(t, r.Flocal, file1)
fstest.CheckItems(t, r.Fremote, file2)
} | explode_data.jsonl/51942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
12106,
1703,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
7000,
1669,
48434,
477,
7121,
6727,
1155,
340,
16867,
435,
991,
977,
1064,
2822,
17661,
16,
1669,
435,
4073,
1703,
445,
1192,
16,
497,
330,
1192,
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 TestTerraformAzureVmExample(t *testing.T) {
t.Parallel()
subscriptionID := ""
uniquePostfix := random.UniqueId()
// Configure Terraform setting up a path to Terraform code.
terraformOptions := &terraform.Options{
// The path to where our Terraform code is located.
TerraformDir: "../../examples/azure/terraform-azure-vm-example",
// Variables to pass to our Terraform code using -var options.
Vars: map[string]interface{}{
"postfix": uniquePostfix,
},
}
// At the end of the test, run `terraform destroy` to clean up any resources that were created.
defer terraform.Destroy(t, terraformOptions)
// Run `terraform init` and `terraform apply`. Fail the test if there are any errors.
terraform.InitAndApply(t, terraformOptions)
// Run tests for the Virtual Machine.
testStrategiesForVMs(t, terraformOptions, subscriptionID)
testMultipleVMs(t, terraformOptions, subscriptionID)
testInformationOfVM(t, terraformOptions, subscriptionID)
testDisksOfVM(t, terraformOptions, subscriptionID)
testNetworkOfVM(t, terraformOptions, subscriptionID)
} | explode_data.jsonl/10743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
51,
13886,
627,
78107,
88124,
13314,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
28624,
12124,
915,
1669,
8389,
197,
9587,
4133,
5743,
1669,
4194,
87443,
764,
2822,
197,
322,
22169,
49426,
627,
6243,
705,
264,
181... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDatasources_Vault_DynamicAuth(t *testing.T) {
v := setupDatasourcesVaultTest(t)
err := v.vc.Sys().Mount("ssh/", &vaultapi.MountInput{Type: "ssh"})
require.NoError(t, err)
defer v.vc.Sys().Unmount("ssh")
_, err = v.vc.Logical().Write("ssh/roles/test", map[string]interface{}{
"key_type": "otp", "default_user": "user", "cidr_list": "10.0.0.0/8",
})
require.NoError(t, err)
testCommands := []struct {
ds, in string
}{
{"vault=vault:///", `{{(ds "vault" "ssh/creds/test?ip=10.1.2.3&username=user").ip}}`},
{"vault=vault:///ssh/creds/test", `{{(ds "vault" "?ip=10.1.2.3&username=user").ip}}`},
{"vault=vault:///ssh/creds/test?ip=10.1.2.3&username=user", `{{(ds "vault").ip}}`},
{"vault=vault:///?ip=10.1.2.3&username=user", `{{(ds "vault" "ssh/creds/test").ip}}`},
}
tok, err := v.tokenCreate("writepol", len(testCommands)*2)
require.NoError(t, err)
for _, tc := range testCommands {
o, e, err := cmd(t, "-d", tc.ds, "-i", tc.in).
withEnv("VAULT_ADDR", "http://"+v.addr).
withEnv("VAULT_TOKEN", tok).
run()
assertSuccess(t, o, e, err, "10.1.2.3")
}
} | explode_data.jsonl/57235 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 524
} | [
2830,
3393,
47663,
2360,
2334,
945,
1557,
5040,
5087,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
6505,
47663,
2360,
79177,
2271,
1155,
692,
9859,
1669,
348,
3133,
66,
59418,
1005,
16284,
445,
25537,
28105,
609,
82983,
2068,
1321,
629,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
t.Parallel()
settings := map[string]interface{}{"hasCJKLanguage": true}
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
p := pages[0]
if p.WordCount() != 15 {
t.Fatalf("[%s] incorrect word count, expected %v, got %v", ext, 15, p.WordCount())
}
}
testAllMarkdownEnginesForPages(t, assertFunc, settings, simplePageWithAllCJKRunes)
} | explode_data.jsonl/60623 | {
"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,
10879,
2507,
2354,
2403,
89349,
6727,
288,
10281,
89349,
13806,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
62930,
1669,
2415,
14032,
31344,
6257,
4913,
4648,
89349,
13806,
788,
830,
630,
6948,
9626,
1669,
2915,
1155... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTempRand(t *testing.T) {
seed := time.Now().UnixNano()
r := rand.New(rand.NewSource(1527819448507607163))
n := r.Intn(10) + 5
m := r.Intn(50) + 1
edges := make([][]int, m)
for i := range edges {
s := r.Intn(n) + 1
t := r.Intn(n) + 1
c := r.Intn(1000)
edges[i] = []int{s, t, c}
}
temp(n, edges)
t.Log("n", n)
for i := range edges {
t.Log(edges[i])
}
t.Log(seed)
} | explode_data.jsonl/52287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
12151,
56124,
1155,
353,
8840,
836,
8,
341,
197,
22602,
1669,
882,
13244,
1005,
55832,
83819,
741,
7000,
1669,
10382,
7121,
37595,
7121,
3608,
7,
16,
20,
17,
22,
23,
16,
24,
19,
19,
23,
20,
15,
22,
21,
15,
22,
16,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestEvaluateCondition_False1(t *testing.T) {
condition := "services.database[1].name == \"postgres\""
result := EvaluateCondition(condition, templateData, varMap)
assert.False(t, result)
} | explode_data.jsonl/67927 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
82345,
10547,
1400,
710,
16,
1155,
353,
8840,
836,
8,
341,
197,
9056,
1669,
330,
12779,
15062,
58,
16,
936,
606,
621,
7245,
43070,
2105,
698,
9559,
1669,
54115,
10547,
47489,
11,
3811,
1043,
11,
762,
2227,
340,
6948,
50757... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestField_Unexported(t *testing.T) {
type (
Src struct {
Exported int
unexported string
}
Dst struct {
Exported int
unexported string
}
)
src := &Src{Exported: 1, unexported: "unexported"}
//
// To()
//
dst := &Dst{}
assert.Nil(t, Copy(src).To(dst))
assert.Equal(t, "", dst.unexported)
//
// From()
//
dst = &Dst{}
assert.Nil(t, Copy(dst).From(src))
assert.Equal(t, "", dst.unexported)
} | explode_data.jsonl/13663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
1877,
40687,
1533,
291,
1155,
353,
8840,
836,
8,
341,
13158,
2399,
197,
7568,
1287,
2036,
341,
298,
197,
16894,
291,
256,
526,
198,
298,
20479,
1533,
291,
914,
198,
197,
197,
630,
197,
10957,
267,
2036,
341,
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... | 1 |
func TestReplayExtent(t *testing.T) {
extentName := "localtest.ext"
cases := []*pb.Block{
generateBlock(4096),
generateBlock(4096),
generateBlock(8192),
generateBlock(4096),
}
extent, err := CreateExtent(extentName, 100)
//extent.ResetWriter()
defer os.Remove(extentName)
assert.Nil(t, err)
extent.Lock()
_, _, err = extent.AppendBlocks(cases, true)
extent.Unlock()
assert.Nil(t, err)
extent.Close()
ex, err := OpenExtent(extentName)
assert.Nil(t, err)
assert.False(t, ex.IsSeal())
//ex.ResetWriter()
//write new cases
ex.Lock()
_, _, err = ex.AppendBlocks(cases, true)
ex.Unlock()
assert.Nil(t, err)
commit := ex.CommitLength()
err = ex.Seal(ex.commitLength)
assert.Nil(t, err)
defer os.Remove("localtest.idx")
ex.Close()
//open sealed extent
ex, err = OpenExtent(extentName)
assert.Nil(t, err)
assert.True(t, ex.IsSeal())
assert.Equal(t, commit, ex.CommitLength())
//read test
blocks, _, _, err := ex.ReadBlocks(0, 1, (20 << 20)) //read object1
assert.Nil(t, err)
assert.Equal(t, cases[0], blocks[0])
} | explode_data.jsonl/14632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 459
} | [
2830,
3393,
693,
1363,
49818,
1155,
353,
8840,
836,
8,
1476,
197,
70172,
675,
1669,
330,
2438,
1944,
9220,
698,
1444,
2264,
1669,
29838,
16650,
28477,
515,
197,
3174,
13220,
4713,
7,
19,
15,
24,
21,
1326,
197,
3174,
13220,
4713,
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 TestTransactionReal(t *testing.T) {
s := createRealSessionWithFixtures(t, nil)
defer testCloser(t, s)
tx, err := s.BeginTx(context.TODO(), nil)
assert.NoError(t, err)
s.RegisterByQueryBuilder(map[string]QueryBuilder{
"insert01": NewInsert("dml_people").AddColumns("name", "email"),
"selectID": NewSelect("*").From("dml_people").Where(Column("id").PlaceHolder()),
})
lastInsertID, _ := compareExecContext(t, tx.WithCacheKey("insert01"), []interface{}{
"Barack", "obama@whitehouse.gov",
"Obama", "barack@whitehouse.gov",
}, 3, 2)
var person dmlPerson
_, err = tx.WithCacheKey("selectID").Load(context.TODO(), &person, lastInsertID)
assert.NoError(t, err)
assert.Exactly(t, lastInsertID, int64(person.ID))
assert.Exactly(t, "Barack", person.Name)
assert.Exactly(t, true, person.Email.Valid)
assert.Exactly(t, "obama@whitehouse.gov", person.Email.Data)
err = tx.Commit()
assert.NoError(t, err)
} | explode_data.jsonl/11092 | {
"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,
8070,
12768,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1855,
12768,
5283,
2354,
25958,
18513,
1155,
11,
2092,
340,
16867,
1273,
51236,
799,
1155,
11,
274,
692,
46237,
11,
1848,
1669,
274,
28467,
31584,
5378,
90988,
1507,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestActivityService_GetThreadSubscription(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"subscribed":true}`)
})
sub, _, err := client.Activity.GetThreadSubscription("1")
if err != nil {
t.Errorf("Activity.GetThreadSubscription returned error: %v", err)
}
want := &Subscription{Subscribed: Bool(true)}
if !reflect.DeepEqual(sub, want) {
t.Errorf("Activity.GetThreadSubscription returned %+v, want %+v", sub, want)
}
} | explode_data.jsonl/6721 | {
"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,
4052,
1860,
13614,
6855,
33402,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
38188,
14,
27286,
14,
16,
14,
34404,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGlCanvas_FocusHandlingWhenActivatingOrDeactivatingTheMenu(t *testing.T) {
w := createWindow("Test")
w.SetPadded(false)
w.SetMainMenu(
fyne.NewMainMenu(
fyne.NewMenu("test", fyne.NewMenuItem("item", func() {})),
),
)
c := w.Canvas().(*glCanvas)
ce1 := &focusable{id: "ce1"}
ce2 := &focusable{id: "ce2"}
content := container.NewVBox(ce1, ce2)
w.SetContent(content)
assert.Nil(t, c.Focused())
m := c.menu.(*MenuBar)
assert.False(t, m.IsActive())
c.FocusPrevious()
assert.Equal(t, ce2, c.Focused())
assert.True(t, ce2.focused)
m.Items[0].(*menuBarItem).Tapped(&fyne.PointEvent{})
assert.True(t, m.IsActive())
ctxt := "activating the menu changes focus handler but does not remove focus from content"
assert.True(t, ce2.focused, ctxt)
assert.Nil(t, c.Focused(), ctxt)
c.FocusNext()
// TODO: changes menu focus as soon as menu has focus support
ctxt = "changing focus with active menu does not affect content focus"
assert.True(t, ce2.focused, ctxt)
assert.Nil(t, c.Focused(), ctxt)
m.Items[0].(*menuBarItem).Tapped(&fyne.PointEvent{})
assert.False(t, m.IsActive())
// TODO: does not remove focus from focused menu item as soon as menu has focus support
ctxt = "deactivating the menu restores focus handler from content"
assert.True(t, ce2.focused, ctxt)
assert.Equal(t, ce2, c.Focused())
c.FocusPrevious()
assert.Equal(t, ce1, c.Focused(), ctxt)
assert.True(t, ce1.focused, ctxt)
assert.False(t, ce2.focused, ctxt)
} | explode_data.jsonl/32520 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 571
} | [
2830,
3393,
31541,
18226,
1400,
3384,
38606,
4498,
23179,
1095,
2195,
1912,
8859,
1095,
785,
3514,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
1855,
4267,
445,
2271,
1138,
6692,
4202,
47,
16828,
3576,
340,
6692,
4202,
86228,
1006,
197,
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 TestShouldUsersync(t *testing.T) {
doTest := func(gdprApplies string, consent string, allowBidderSync bool, allowHostCookies bool, expectAllow bool) {
t.Helper()
deps := auction{
cfg: nil,
syncers: nil,
gdprPerms: &auctionMockPermissions{
allowBidderSync: allowBidderSync,
allowHostCookies: allowHostCookies,
},
metricsEngine: nil,
}
gdprPrivacyPolicy := gdprPolicy.Policy{
Signal: gdprApplies,
Consent: consent,
}
allowSyncs := deps.shouldUsersync(context.Background(), openrtb_ext.BidderAdform, gdprPrivacyPolicy)
if allowSyncs != expectAllow {
t.Errorf("Expected syncs: %t, allowed syncs: %t", expectAllow, allowSyncs)
}
}
doTest("0", "", false, false, true)
doTest("1", "", true, true, false)
doTest("1", "a", true, false, false)
doTest("1", "a", false, true, false)
doTest("1", "a", true, true, true)
} | explode_data.jsonl/35893 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 359
} | [
2830,
3393,
14996,
7137,
1721,
1155,
353,
8840,
836,
8,
341,
19935,
2271,
1669,
2915,
3268,
67,
649,
10611,
7202,
914,
11,
14433,
914,
11,
2138,
65452,
1107,
12154,
1807,
11,
2138,
9296,
50672,
1807,
11,
1720,
18605,
1807,
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... | 2 |
func TestClusterIPReject(t *testing.T) {
ipt := iptablestest.NewFake()
fp := NewFakeProxier(ipt)
svcName := "svc1"
svcIP := net.IPv4(10, 20, 30, 41)
svc := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "ns1", Name: svcName}, Port: "80"}
fp.serviceMap[svc] = newFakeServiceInfo(svc, svcIP, 80, api.ProtocolTCP, false)
fp.syncProxyRules()
svcChain := string(servicePortChainName(svc, strings.ToLower(string(api.ProtocolTCP))))
svcRules := ipt.GetRules(svcChain)
if len(svcRules) != 0 {
errorf(fmt.Sprintf("Unexpected rule for chain %v service %v without endpoints", svcChain, svcName), svcRules, t)
}
kubeSvcRules := ipt.GetRules(string(kubeServicesChain))
if !hasJump(kubeSvcRules, iptablestest.Reject, svcIP.String(), "80") {
errorf(fmt.Sprintf("Failed to find a %v rule for service %v with no endpoints", iptablestest.Reject, svcName), kubeSvcRules, t)
}
} | explode_data.jsonl/9292 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 361
} | [
2830,
3393,
28678,
3298,
78413,
1155,
353,
8840,
836,
8,
341,
8230,
417,
1669,
66068,
480,
267,
477,
7121,
52317,
741,
65219,
1669,
1532,
52317,
1336,
87,
1268,
1956,
417,
340,
1903,
7362,
675,
1669,
330,
58094,
16,
698,
1903,
7362,
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... | 3 |
func TestValidateSecret(t *testing.T) {
g := gomega.NewGomegaWithT(t)
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0"})
g.Expect(err).NotTo(gomega.HaveOccurred())
c = mgr.GetClient()
stopMgr, mgrStopped := StartTestManager(mgr, g)
defer func() {
close(stopMgr)
mgrStopped.Wait()
}()
listener, err := CreateWebhookListener(cfg, cfg, scheme.Scheme, "", "", false)
g.Expect(err).NotTo(gomega.HaveOccurred())
annotations := make(map[string]string)
ret := listener.validateSecret("", annotations, "default", []byte("test"))
g.Expect(ret).To(gomega.BeFalse())
annotations[appv1alpha1.AnnotationWebhookSecret] = "test"
ret = listener.validateSecret("", annotations, "default", []byte("test"))
g.Expect(ret).To(gomega.BeFalse())
} | explode_data.jsonl/59428 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
17926,
19773,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
2109,
901,
11,
1848,
1669,
6645,
7121,
28272,
11,
6645,
22179,
90,
27328,
9950,
4286,
25,
330,
15,
23625,
3174,
8189... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseConfigGood(t *testing.T) {
c, err := ParseFile("../../../../test/fixture/config/server_good.conf", false)
require.NoError(t, err)
// Check for server configurations
assert.Equal(t, c.Server.BindAddress, "127.0.0.1")
assert.Equal(t, c.Server.BindPort, 8081)
assert.Equal(t, c.Server.RegistrationUDSPath, "/tmp/server.sock")
assert.Equal(t, c.Server.TrustDomain, "example.org")
assert.Equal(t, c.Server.LogLevel, "INFO")
assert.Equal(t, c.Server.Experimental.AllowAgentlessNodeAttestors, true)
assert.Equal(t, c.Server.Federation.BundleEndpoint.Address, "0.0.0.0")
assert.Equal(t, c.Server.Federation.BundleEndpoint.Port, 8443)
assert.Equal(t, c.Server.Federation.BundleEndpoint.ACME.DomainName, "example.org")
assert.Equal(t, len(c.Server.Federation.FederatesWith), 2)
assert.Equal(t, c.Server.Federation.FederatesWith["domain1.test"].BundleEndpoint.Address, "1.2.3.4")
assert.True(t, c.Server.Federation.FederatesWith["domain1.test"].BundleEndpoint.UseWebPKI)
assert.Equal(t, c.Server.Federation.FederatesWith["domain2.test"].BundleEndpoint.Address, "5.6.7.8")
assert.Equal(t, c.Server.Federation.FederatesWith["domain2.test"].BundleEndpoint.SpiffeID, "spiffe://domain2.test/bundle-provider")
// Check for plugins configurations
pluginConfigs := *c.Plugins
expectedData := "join_token = \"PLUGIN-SERVER-NOT-A-SECRET\""
var data bytes.Buffer
err = printer.DefaultConfig.Fprint(&data, pluginConfigs["plugin_type_server"]["plugin_name_server"].PluginData)
assert.NoError(t, err)
assert.Len(t, pluginConfigs, 1)
assert.Len(t, pluginConfigs["plugin_type_server"], 3)
// Default config
pluginConfig := pluginConfigs["plugin_type_server"]["plugin_name_server"]
assert.Nil(t, pluginConfig.Enabled)
assert.Equal(t, pluginConfig.IsEnabled(), true)
assert.Equal(t, pluginConfig.PluginChecksum, "pluginServerChecksum")
assert.Equal(t, pluginConfig.PluginCmd, "./pluginServerCmd")
assert.Equal(t, expectedData, data.String())
// Disabled plugin
pluginConfig = pluginConfigs["plugin_type_server"]["plugin_disabled"]
assert.NotNil(t, pluginConfig.Enabled)
assert.Equal(t, pluginConfig.IsEnabled(), false)
assert.Equal(t, pluginConfig.PluginChecksum, "pluginServerChecksum")
assert.Equal(t, pluginConfig.PluginCmd, "./pluginServerCmd")
assert.Equal(t, expectedData, data.String())
// Enabled plugin
pluginConfig = pluginConfigs["plugin_type_server"]["plugin_enabled"]
assert.NotNil(t, pluginConfig.Enabled)
assert.Equal(t, pluginConfig.IsEnabled(), true)
assert.Equal(t, pluginConfig.PluginChecksum, "pluginServerChecksum")
assert.Equal(t, pluginConfig.PluginCmd, "./pluginServerCmd")
assert.Equal(t, expectedData, data.String())
} | explode_data.jsonl/51900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 977
} | [
2830,
3393,
14463,
2648,
15216,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
14775,
1703,
36800,
2748,
1944,
14,
59612,
14730,
37255,
44781,
13937,
497,
895,
340,
17957,
35699,
1155,
11,
1848,
692,
197,
322,
4248,
369,
3538,
3238... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetAllTeamsSanitization(t *testing.T) {
th := Setup(t)
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(),
Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com,localhost",
AllowOpenInvite: true,
})
CheckNoError(t, resp)
team2, resp := th.SystemAdminClient.CreateTeam(&model.Team{
DisplayName: t.Name() + "_2",
Name: GenerateTestTeamName(),
Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com,localhost",
AllowOpenInvite: true,
})
CheckNoError(t, resp)
// This may not work if the server has over 1000 open teams on it
t.Run("team admin/non-admin", func(t *testing.T) {
teamFound := false
team2Found := false
rteams, resp := th.Client.GetAllTeams("", 0, 1000)
CheckNoError(t, resp)
for _, rteam := range rteams {
if rteam.Id == team.Id {
teamFound = true
require.NotEmpty(t, rteam.Email, "should not have sanitized email for team admin")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
} else if rteam.Id == team2.Id {
team2Found = true
require.Empty(t, rteam.Email, "should have sanitized email for team admin")
require.Empty(t, rteam.InviteId, "should have sanitized inviteid")
}
}
require.True(t, teamFound, "wasn't returned the expected teams so the test wasn't run correctly")
require.True(t, team2Found, "wasn't returned the expected teams so the test wasn't run correctly")
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
rteams, resp := client.GetAllTeams("", 0, 1000)
CheckNoError(t, resp)
for _, rteam := range rteams {
if rteam.Id != team.Id && rteam.Id != team2.Id {
continue
}
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
}
}, "system admin")
} | explode_data.jsonl/70714 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 835
} | [
2830,
3393,
1949,
2403,
60669,
23729,
275,
2022,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
340,
16867,
270,
836,
682,
4454,
2822,
197,
9196,
11,
9039,
1669,
270,
11716,
7251,
14597,
2099,
2528,
65842,
515,
197,
197,
26456,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcilePropagateAnnotations(t *testing.T) {
names.TestingSeed()
ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline}
prs := []*v1beta1.PipelineRun{{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pipeline-run-with-annotations",
Namespace: "foo",
Annotations: map[string]string{"PipelineRunAnnotation": "PipelineRunValue"},
},
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{Name: "test-pipeline"},
ServiceAccountName: "test-sa",
},
}}
ts := []*v1beta1.Task{simpleHelloWorldTask}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
_, clients := prt.reconcileRun("foo", "test-pipeline-run-with-annotations", []string{}, false)
actions := clients.Pipeline.Actions()
if len(actions) < 2 {
t.Fatalf("Expected client to have at least two action implementation but it has %d", len(actions))
}
// Check that the expected TaskRun was created
actual := getTaskRunCreations(t, actions)[0]
expectedTaskRunObjectMeta := taskRunObjectMeta("test-pipeline-run-with-annotations-hello-world-1", "foo", "test-pipeline-run-with-annotations", "test-pipeline", "hello-world-1", false)
expectedTaskRunObjectMeta.Annotations["PipelineRunAnnotation"] = "PipelineRunValue"
expectedTaskRun := &v1beta1.TaskRun{
ObjectMeta: expectedTaskRunObjectMeta,
Spec: v1beta1.TaskRunSpec{
TaskRef: &v1beta1.TaskRef{
Name: "hello-world",
},
ServiceAccountName: "test-sa",
Resources: &v1beta1.TaskRunResources{},
Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute},
},
}
if d := cmp.Diff(actual, expectedTaskRun); d != "" {
t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRun, diff.PrintWantGot(d))
}
} | explode_data.jsonl/27305 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 739
} | [
2830,
3393,
693,
40446,
457,
2008,
46836,
21418,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
2822,
35009,
1669,
29838,
85,
16,
19127,
16,
1069,
8790,
90,
22944,
9707,
10134,
34656,
532,
25653,
82,
1669,
29838,
85,
16,
19127,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParsePkixPrivateKeyPem(t *testing.T) {
tcs := []struct {
name string
privateKey []byte
expectedError bool
}{
{
name: "parse rsa pkcs8 key successful",
privateKey: []byte(rsa2048PrivateKey),
expectedError: false,
}, {
name: "parse ecdsa pkcs8 key successful",
privateKey: []byte(ec256PrivateKey),
expectedError: false,
}, {
name: "parse rsa pkcs1 key successful",
privateKey: []byte(rsa2048Pkcs1PrivateKey),
expectedError: false,
}, {
name: "parse ecdsa pkcs1 key successful",
privateKey: []byte(ec256Pkcs1PrivateKey),
expectedError: false,
}, {
name: "invalid key",
privateKey: []byte("not a pem"),
expectedError: true,
},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
_, err := parsePkixPrivateKeyPem(tc.privateKey)
if tc.expectedError {
if err == nil {
t.Errorf("parsePkixPrivateKeyPem(...) = nil, expected non nil")
}
} else {
if err != nil {
t.Errorf("parsePkixPrivateKeyPem(..) = %v, expected nil", err)
}
}
})
}
} | explode_data.jsonl/59156 | {
"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,
14463,
58415,
941,
75981,
47,
336,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
2455,
1592,
262,
3056,
3782,
198,
197,
42400,
1454,
1807,
198,
197,
59403,
197,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWorkerUpdate(t *testing.T) {
db, cleanup := storageTestEnv(t)
defer cleanup()
ctx := context.Background()
executor := &mockExecutor{t: t, dependencies: NewDependencyManager()}
worker := newWorker(db, executor, &testPublisherProvider{})
reporter := statusReporterFunc(func(ctx context.Context, taskID string, status *api.TaskStatus) error {
log.G(ctx).WithFields(logrus.Fields{"task.id": taskID, "status": status}).Info("status update received")
return nil
})
worker.Listen(ctx, reporter)
// create existing task/secret/config
assert.NoError(t, worker.Assign(ctx, []*api.AssignmentChange{
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
}))
for _, testcase := range []struct {
changeSet []*api.AssignmentChange
expectedTasks []*api.Task
expectedSecrets []*api.Secret
expectedConfigs []*api.Config
expectedAssigned []*api.Task
}{
{ // handle nil changeSet case.
expectedTasks: []*api.Task{
{ID: "task-1"},
},
expectedSecrets: []*api.Secret{
{ID: "secret-1"},
},
expectedConfigs: []*api.Config{
{ID: "config-1"},
},
expectedAssigned: []*api.Task{
{ID: "task-1"},
},
},
{
// no changes
changeSet: []*api.AssignmentChange{
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-1"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
},
expectedTasks: []*api.Task{
{ID: "task-1"},
},
expectedSecrets: []*api.Secret{
{ID: "secret-1"},
},
expectedConfigs: []*api.Config{
{ID: "config-1"},
},
expectedAssigned: []*api.Task{
{ID: "task-1"},
},
},
{
// adding a secret and task
changeSet: []*api.AssignmentChange{
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-2"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-2"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-2"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
},
expectedTasks: []*api.Task{
{ID: "task-1"},
{ID: "task-2"},
},
expectedSecrets: []*api.Secret{
{ID: "secret-1"},
{ID: "secret-2"},
},
expectedConfigs: []*api.Config{
{ID: "config-1"},
{ID: "config-2"},
},
expectedAssigned: []*api.Task{
{ID: "task-1"},
{ID: "task-2"},
},
},
{
// remove assigned task and secret, updating existing secret
changeSet: []*api.AssignmentChange{
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-1"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-1"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-2"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-1"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-2"},
},
},
Action: api.AssignmentChange_AssignmentActionUpdate,
},
},
expectedTasks: []*api.Task{
{ID: "task-1"},
{ID: "task-2"},
},
expectedSecrets: []*api.Secret{
{ID: "secret-2"},
},
expectedConfigs: []*api.Config{
{ID: "config-2"},
},
expectedAssigned: []*api.Task{
{ID: "task-2"},
},
},
{
// removing nonexistent items doesn't fail
changeSet: []*api.AssignmentChange{
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-1"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-1"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Task{
Task: &api.Task{ID: "task-2"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Secret{
Secret: &api.Secret{ID: "secret-2"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-1"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
{
Assignment: &api.Assignment{
Item: &api.Assignment_Config{
Config: &api.Config{ID: "config-2"},
},
},
Action: api.AssignmentChange_AssignmentActionRemove,
},
},
expectedTasks: []*api.Task{
{ID: "task-1"},
{ID: "task-2"},
},
},
} {
assert.NoError(t, worker.Update(ctx, testcase.changeSet))
var (
tasks []*api.Task
assigned []*api.Task
)
assert.NoError(t, worker.db.View(func(tx *bolt.Tx) error {
return WalkTasks(tx, func(task *api.Task) error {
tasks = append(tasks, task)
if TaskAssigned(tx, task.ID) {
assigned = append(assigned, task)
}
return nil
})
}))
assert.Equal(t, testcase.expectedTasks, tasks)
assert.Equal(t, testcase.expectedAssigned, assigned)
for _, secret := range testcase.expectedSecrets {
secret, err := executor.Secrets().Get(secret.ID)
assert.NoError(t, err)
assert.NotNil(t, secret)
}
for _, config := range testcase.expectedConfigs {
config, err := executor.Configs().Get(config.ID)
assert.NoError(t, err)
assert.NotNil(t, config)
}
}
} | explode_data.jsonl/11419 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3189
} | [
2830,
3393,
21936,
4289,
1155,
353,
8840,
836,
8,
341,
20939,
11,
21290,
1669,
5819,
2271,
14359,
1155,
340,
16867,
21290,
2822,
20985,
1669,
2266,
19047,
741,
67328,
4831,
1669,
609,
16712,
25255,
90,
83,
25,
259,
11,
19543,
25,
1532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOptionalValueFrom(t *testing.T) {
type args struct {
v *Value
}
tests := []struct {
name string
args args
want *OptionalValue
}{
{
name: "default type",
args: args{
v: ValueTypeString.ValueFrom("foo"),
},
want: &OptionalValue{ov: *value.NewOptional(value.TypeString, value.TypeString.ValueFrom("foo", types))},
},
{
name: "empty value",
args: args{
v: &Value{v: value.Value{}},
},
want: nil,
},
{
name: "nil value",
args: args{},
want: nil,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tt.want, OptionalValueFrom(tt.args.v))
})
}
} | explode_data.jsonl/8888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
15309,
1130,
3830,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
5195,
353,
1130,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
353,
15309,
1130,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetServiceLogs(t *testing.T) {
handler := func(w http.ResponseWriter, r *http.Request) {
testutils.AssertEqual(t, r.Method, "GET")
testutils.AssertEqual(t, r.URL.Path, "/service/id/logs")
testutils.AssertEqual(t, r.URL.Query().Get("tail"), "100")
testutils.AssertEqual(t, r.URL.Query().Get("start"), "2001-01-01 01:01")
testutils.AssertEqual(t, r.URL.Query().Get("end"), "2012-12-12 12:12")
logs := []models.LogFile{
{Name: "name1"},
{Name: "name2"},
}
MarshalAndWrite(t, w, logs, 200)
}
client, server := newClientAndServer(handler)
defer server.Close()
logs, err := client.GetServiceLogs("id", "2001-01-01 01:01", "2012-12-12 12:12", 100)
if err != nil {
t.Fatal(err)
}
testutils.AssertEqual(t, len(logs), 2)
testutils.AssertEqual(t, logs[0].Name, "name1")
testutils.AssertEqual(t, logs[1].Name, "name2")
} | explode_data.jsonl/24181 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
1949,
1860,
51053,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
18185,
6031,
11711,
2993,
1155,
11,
435,
20798,
11,
330,
3806,
1138,
197,
18185,
6031,
11711,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInsertLedger(t *testing.T) {
tt := test.Start(t)
defer tt.Finish()
test.ResetHorizonDB(t, tt.HorizonDB)
q := &Q{tt.HorizonSession()}
expectedLedger := Ledger{
Sequence: 69859,
LedgerHash: "4db1e4f145e9ee75162040d26284795e0697e2e84084624e7c6c723ebbf80118",
PreviousLedgerHash: null.NewString("4b0b8bace3b2438b2404776ce57643966855487ba6384724a3c664c7aa4cd9e4", true),
TotalOrderID: TotalOrderID{toid.New(int32(69859), 0, 0).ToInt64()},
ImporterVersion: 123,
TransactionCount: 12,
SuccessfulTransactionCount: new(int32),
FailedTransactionCount: new(int32),
OperationCount: 23,
TotalCoins: 23451,
FeePool: 213,
BaseReserve: 687,
MaxTxSetSize: 345,
ProtocolVersion: 12,
BaseFee: 100,
ClosedAt: time.Now().UTC().Truncate(time.Second),
}
*expectedLedger.SuccessfulTransactionCount = 12
*expectedLedger.FailedTransactionCount = 3
var ledgerHash, previousLedgerHash xdr.Hash
written, err := hex.Decode(ledgerHash[:], []byte(expectedLedger.LedgerHash))
tt.Assert.NoError(err)
tt.Assert.Equal(len(ledgerHash), written)
written, err = hex.Decode(previousLedgerHash[:], []byte(expectedLedger.PreviousLedgerHash.String))
tt.Assert.NoError(err)
tt.Assert.Equal(len(previousLedgerHash), written)
ledgerEntry := xdr.LedgerHeaderHistoryEntry{
Hash: ledgerHash,
Header: xdr.LedgerHeader{
LedgerVersion: 12,
PreviousLedgerHash: previousLedgerHash,
LedgerSeq: xdr.Uint32(expectedLedger.Sequence),
TotalCoins: xdr.Int64(expectedLedger.TotalCoins),
FeePool: xdr.Int64(expectedLedger.FeePool),
BaseFee: xdr.Uint32(expectedLedger.BaseFee),
BaseReserve: xdr.Uint32(expectedLedger.BaseReserve),
MaxTxSetSize: xdr.Uint32(expectedLedger.MaxTxSetSize),
ScpValue: xdr.StellarValue{
CloseTime: xdr.TimePoint(expectedLedger.ClosedAt.Unix()),
},
},
}
ledgerHeaderBase64, err := xdr.MarshalBase64(ledgerEntry.Header)
tt.Assert.NoError(err)
expectedLedger.LedgerHeaderXDR = null.NewString(ledgerHeaderBase64, true)
rowsAffected, err := q.InsertLedger(
ledgerEntry,
12,
3,
23,
int(expectedLedger.ImporterVersion),
)
tt.Assert.NoError(err)
tt.Assert.Equal(rowsAffected, int64(1))
var ledgerFromDB Ledger
err = q.LedgerBySequence(&ledgerFromDB, 69859)
tt.Assert.NoError(err)
expectedLedger.CreatedAt = ledgerFromDB.CreatedAt
expectedLedger.UpdatedAt = ledgerFromDB.UpdatedAt
tt.Assert.True(ledgerFromDB.CreatedAt.After(expectedLedger.ClosedAt))
tt.Assert.True(ledgerFromDB.UpdatedAt.After(expectedLedger.ClosedAt))
tt.Assert.True(ledgerFromDB.CreatedAt.Before(expectedLedger.ClosedAt.Add(time.Hour)))
tt.Assert.True(ledgerFromDB.UpdatedAt.Before(expectedLedger.ClosedAt.Add(time.Hour)))
tt.Assert.True(expectedLedger.ClosedAt.Equal(ledgerFromDB.ClosedAt))
expectedLedger.ClosedAt = ledgerFromDB.ClosedAt
tt.Assert.Equal(expectedLedger, ledgerFromDB)
} | explode_data.jsonl/31527 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1428
} | [
2830,
3393,
13780,
60850,
1389,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
1273,
12101,
1155,
340,
16867,
17853,
991,
18176,
741,
18185,
36660,
39601,
16973,
3506,
1155,
11,
17853,
3839,
269,
16973,
3506,
340,
18534,
1669,
609,
48,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDatabaseSettings(t *testing.T) {
t.Parallel()
Convey("New: ok", t, func() {
s := New(context.Background())
So(s, ShouldNotBeNil)
So(s.Server, ShouldEqual, "")
So(s.Username, ShouldEqual, "")
So(s.Password, ShouldEqual, "")
})
Convey("GetUncached: returns defaults", t, func() {
s, e := GetUncached(context.Background())
So(s, ShouldNotBeNil)
So(s.Server, ShouldEqual, "")
So(s.Username, ShouldEqual, "")
So(s.Password, ShouldEqual, "")
So(e, ShouldBeNil)
})
Convey("GetUncached: returns settings", t, func() {
c := settings.Use(context.Background(), settings.New(&settings.MemoryStorage{}))
expected := &DatabaseSettings{
Server: "server",
Username: "username",
Password: "password",
}
e := settings.Set(c, settingsKey, expected, "whoever", "for whatever reason")
So(e, ShouldBeNil)
actual, e := GetUncached(c)
So(actual, ShouldNotBeNil)
So(actual.Server, ShouldEqual, expected.Server)
So(actual.Username, ShouldEqual, expected.Username)
So(actual.Password, ShouldEqual, expected.Password)
So(e, ShouldBeNil)
})
} | explode_data.jsonl/72094 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 433
} | [
2830,
3393,
5988,
6086,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
93070,
5617,
445,
3564,
25,
5394,
497,
259,
11,
2915,
368,
341,
197,
1903,
1669,
1532,
5378,
19047,
2398,
197,
76912,
1141,
11,
12260,
2623,
3430,
19064,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPath(t *testing.T) {
expected := []string{"1", "2", "3", "4", "5"}
join := filepath.Join(expected...)
result := PathToArray(join)
if !lang.EqualArrays(result, expected) {
t.Errorf("expected %v result %v", expected, result)
}
} | explode_data.jsonl/7248 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
1820,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
3056,
917,
4913,
16,
497,
330,
17,
497,
330,
18,
497,
330,
19,
497,
330,
20,
16707,
197,
5987,
1669,
26054,
22363,
15253,
31218,
9559,
1669,
7933,
29512,
60715,
340,
743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntegrationClose(t *testing.T) {
queueName, _, cleanup := newTestQueue(t, "close")
defer cleanup()
label := "link"
t.Run(label, func(t *testing.T) {
checkLeaks := leaktest.CheckTimeout(t, 60*time.Second)
// Create client
client := newClient(t, label)
defer client.Close()
// Open a session
session, err := client.NewSession()
if err != nil {
t.Fatal(err)
}
// Create a sender
receiver, err := session.NewReceiver(
amqp.LinkTargetAddress(queueName),
)
if err != nil {
t.Fatal(err)
}
go func() {
err := receiver.Close()
if err != nil {
t.Fatalf("Expected nil error from receiver.Close(), got: %+v", err)
}
}()
_, err = receiver.Receive(context.Background())
if err != amqp.ErrLinkClosed {
t.Fatalf("Expected ErrLinkClosed from receiver.Receiver, got: %+v", err)
return
}
client.Close() // close before leak check
checkLeaks()
})
label = "session"
t.Run(label, func(t *testing.T) {
checkLeaks := leaktest.CheckTimeout(t, 60*time.Second)
// Create client
client := newClient(t, label)
defer client.Close()
// Open a session
session, err := client.NewSession()
if err != nil {
t.Fatal(err)
}
// Create a sender
receiver, err := session.NewReceiver(
amqp.LinkTargetAddress(queueName),
)
if err != nil {
t.Fatal(err)
}
go func() {
err := session.Close()
if err != nil {
t.Fatalf("Expected nil error from session.Close(), got: %+v", err)
}
}()
_, err = receiver.Receive(context.Background())
if err != amqp.ErrSessionClosed {
t.Fatalf("Expected ErrSessionClosed from receiver.Receiver, got: %+v", err)
return
}
client.Close() // close before leak check
checkLeaks()
})
label = "conn"
t.Run(label, func(t *testing.T) {
checkLeaks := leaktest.CheckTimeout(t, 60*time.Second)
// Create client
client := newClient(t, label)
defer client.Close()
// Open a session
session, err := client.NewSession()
if err != nil {
t.Fatal(err)
}
// Create a sender
receiver, err := session.NewReceiver(
amqp.LinkTargetAddress(queueName),
)
if err != nil {
t.Fatal(err)
}
go func() {
err := client.Close()
if err != nil {
t.Fatalf("Expected nil error from client.Close(), got: %+v", err)
}
}()
_, err = receiver.Receive(context.Background())
if err != amqp.ErrConnClosed {
t.Fatalf("Expected ErrConnClosed from receiver.Receiver, got: %+v", err)
return
}
checkLeaks()
})
} | explode_data.jsonl/60649 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1017
} | [
2830,
3393,
52464,
7925,
1155,
353,
8840,
836,
8,
341,
46993,
675,
11,
8358,
21290,
1669,
501,
2271,
7554,
1155,
11,
330,
5552,
1138,
16867,
21290,
2822,
29277,
1669,
330,
2080,
698,
3244,
16708,
13345,
11,
2915,
1155,
353,
8840,
836,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNXDomainJob(t *testing.T) {
host := "notadomainatallforsure.notadomain.notatldreally"
port := uint16(1234)
event := testTCPCheck(t, host, port)
dialErr := fmt.Sprintf("lookup %s", host)
testslike.Test(
t,
lookslike.Strict(lookslike.Compose(
hbtest.BaseChecks("", "down", "tcp"),
hbtest.SummaryChecks(0, 1),
hbtest.SimpleURLChecks(t, "tcp", host, port),
hbtest.ErrorChecks(dialErr, "io"),
)),
event.Fields,
)
} | explode_data.jsonl/54641 | {
"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,
43304,
13636,
12245,
1155,
353,
8840,
836,
8,
341,
63104,
1669,
330,
1921,
329,
3121,
266,
541,
69,
1087,
552,
11971,
329,
3121,
11971,
266,
507,
53660,
698,
52257,
1669,
2622,
16,
21,
7,
16,
17,
18,
19,
340,
28302,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntArray_FilterEmpty(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.NewIntArrayFrom(g.SliceInt{0, 1, 2, 3, 4, 0})
t.Assert(array.FilterEmpty(), g.SliceInt{1, 2, 3, 4})
})
gtest.C(t, func(t *gtest.T) {
array := garray.NewIntArrayFrom(g.SliceInt{1, 2, 3, 4})
t.Assert(array.FilterEmpty(), g.SliceInt{1, 2, 3, 4})
})
} | explode_data.jsonl/47631 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
95338,
68935,
3522,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11923,
1669,
342,
1653,
7121,
95338,
3830,
3268,
95495,
1072,
90,
15,
11,
220,
16,
11,
220,
17,
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 TestGetConsulServiceDetail(t *testing.T) {
ctrl := gomock.NewController(assert.Tracing(t))
defer ctrl.Finish()
catalog := newMockCatalogInterface(ctrl)
svcname := "test-svc"
svctag := ""
svcs := []*consulapi.CatalogService{
{Node: "nodeid", Address: "bob", ServicePort: 3},
}
catalog.EXPECT().Service(svcname, svctag, opts).Return(svcs, nil, nil)
got, gotErr := getConsulServiceDetail(catalog, testdc, svcname)
assert.Nil(t, gotErr)
assert.DeepEqual(t, got, serviceDetailFromSvcs(svcname, svcs))
} | explode_data.jsonl/71899 | {
"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,
1949,
15220,
360,
1860,
10649,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
75846,
8240,
4527,
1155,
1171,
16867,
23743,
991,
18176,
2822,
1444,
7750,
1669,
501,
11571,
41606,
5051,
62100,
340,
1903,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddVariadicRandomly(t *testing.T) {
t.Parallel()
rand.Seed(time.Now().UnixNano())
// rand.Float64() returns a number in 0.0-1.0
// Use another randomly-generated int to vary the whole number.
a := rand.Float64() * float64(rand.Intn(500))
b := rand.Float64() * float64(rand.Intn(500))
// v will be assigned multiple random float64 in a slice
v := randFloat64Slice(5)
// Get our own sum to compare to Add()
var want float64 = a + b
for _, x := range v {
want += x
}
got := calculator.Add(a, b, v...)
t.Logf("Random variadic test: Add(%v, %v, %v), wants %v, got %v", a, b, v, want, got)
if want != got {
t.Errorf("want %v, got %v, while testing a random variadic case. The function call was: Add(%v, %v, %v)", want, got, a, b, v)
}
} | explode_data.jsonl/12259 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
2212,
56135,
36214,
13999,
398,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
7000,
437,
5732,
291,
9730,
13244,
1005,
55832,
83819,
12367,
197,
322,
10382,
29794,
21,
19,
368,
4675,
264,
1372,
304,
220,
15,
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... | 3 |
func TestArray(t *testing.T) {
testStr := `<?
$var = array("one", "two", "three");`
p := NewParser()
p.disableScoping = true
p.Debug = true
a, _ := p.Parse("test.php", testStr)
if len(a.Nodes) == 0 {
t.Fatalf("Array did not correctly parse")
}
tree := ast.ExprStmt{
Expr: ast.AssignmentExpr{
Assignee: ast.NewVariable("var"),
Operator: "=",
Value: &ast.ArrayExpr{
ArrayType: ast.ArrayType{},
Pairs: []ast.ArrayPair{
{Value: &ast.Literal{Type: ast.String, Value: `"one"`}},
{Value: &ast.Literal{Type: ast.String, Value: `"two"`}},
{Value: &ast.Literal{Type: ast.String, Value: `"three"`}},
},
},
},
}
if !reflect.DeepEqual(a.Nodes[0], tree) {
fmt.Printf("Found: %+v\n", a.Nodes[0])
fmt.Printf("Expected: %+v\n", tree)
t.Fatalf("Array did not correctly parse")
}
} | explode_data.jsonl/28437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
1857,
1155,
353,
8840,
836,
8,
341,
18185,
2580,
1669,
1565,
53075,
220,
400,
947,
284,
1334,
445,
603,
497,
330,
19789,
497,
330,
27856,
5038,
3989,
3223,
1669,
1532,
6570,
741,
3223,
42628,
3326,
33707,
284,
830,
198,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAuthorization(t *testing.T) {
config := ensureIntegrationEnvironment(t)
podName := os.Getenv("AKV2K8S_K8S_TEST_POD")
podNamespace := os.Getenv("AKV2K8S_K8S_TEST_NAMESPACE")
podIP := os.Getenv("AKV2K8S_K8S_TEST_POD_IP")
cfg, err := clientcmd.BuildConfigFromFlags(config.master, config.config)
if err != nil {
t.Errorf("Error building kubeconfig: %s", err.Error())
}
kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
t.Errorf("Error building kubernetes clientset: %s", err.Error())
}
pod := podData{
name: podName,
namespace: podNamespace,
remoteAddress: podIP,
}
err = authorize(kubeClient, pod)
if err != nil {
t.Errorf("failed, error: %+v", err)
}
} | explode_data.jsonl/46382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
18124,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
5978,
52464,
12723,
1155,
692,
3223,
347,
675,
1669,
2643,
64883,
445,
11907,
53,
17,
42,
23,
50,
10102,
23,
50,
11641,
1088,
2069,
1138,
3223,
347,
22699,
1669,
2643,
6488... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientGetVcsRootMissing(t *testing.T) {
client, err := NewRealTestClient(t)
require.NoError(t, err, "Expected no error")
config, err := client.GetVcsRoot("Empty_")
require.NoError(t, err, "Expected no error")
require.Nil(t, config, "Expected no config")
} | explode_data.jsonl/36874 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
2959,
1949,
53,
4837,
8439,
25080,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
1532,
12768,
2271,
2959,
1155,
340,
17957,
35699,
1155,
11,
1848,
11,
330,
18896,
902,
1465,
5130,
25873,
11,
1848,
1669,
2943,
2234,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetAddress(t *testing.T) {
n := New("testgetaddress", lookupFunc)
// Get an address from an empty set (should error)
if rv := n.GetAddress(); rv != nil {
t.Errorf("GetAddress failed: got: %v want: %v\n", rv, nil)
}
// Add a new address and get it
err := n.addAddressByIP(someIP + ":8333")
if err != nil {
t.Fatalf("Adding address failed: %v", err)
}
ka := n.GetAddress()
if ka == nil {
t.Fatalf("Did not get an address where there is one in the pool")
}
if ka.NetAddress().IP.String() != someIP {
t.Errorf("Wrong IP: got %v, want %v", ka.NetAddress().IP.String(), someIP)
}
// Mark this as a good address and get it
n.Good(ka.NetAddress())
ka = n.GetAddress()
if ka == nil {
t.Fatalf("Did not get an address where there is one in the pool")
}
if ka.NetAddress().IP.String() != someIP {
t.Errorf("Wrong IP: got %v, want %v", ka.NetAddress().IP.String(), someIP)
}
numAddrs := n.numAddresses()
if numAddrs != 1 {
t.Errorf("Wrong number of addresses: got %d, want %d", numAddrs, 1)
}
} | explode_data.jsonl/26482 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
1949,
4286,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
1532,
445,
1944,
455,
4995,
497,
18615,
9626,
692,
197,
322,
2126,
458,
2621,
504,
458,
4287,
738,
320,
5445,
1465,
340,
743,
17570,
1669,
308,
2234,
4286,
2129,
17570,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitializeConnection(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
MockInitializeConnectionResponse(t)
options := &volumeactions.InitializeConnectionOpts{
IP: "127.0.0.1",
Host: "stack",
Initiator: "iqn.1994-05.com.redhat:17cf566367d2",
Multipath: gophercloud.Disabled,
Platform: "x86_64",
OSType: "linux2",
}
_, err := volumeactions.InitializeConnection(client.ServiceClient(), "cd281d77-8217-4830-be95-9528227c105c", options).Extract()
th.AssertNoErr(t, err)
} | explode_data.jsonl/20630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
9928,
4526,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
9209,
1176,
9928,
4526,
2582,
1155,
692,
35500,
1669,
609,
25060,
4020,
45829,
4526,
43451,
515,
197,
197,
3298,
25,
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 TestInstrumentationLibrarySpans_SchemaUrl(t *testing.T) {
ms := NewInstrumentationLibrarySpans()
assert.EqualValues(t, "", ms.SchemaUrl())
testValSchemaUrl := "https://opentelemetry.io/schemas/1.5.0"
ms.SetSchemaUrl(testValSchemaUrl)
assert.EqualValues(t, testValSchemaUrl, ms.SchemaUrl())
} | explode_data.jsonl/63254 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
56324,
367,
16915,
6406,
596,
1098,
3416,
2864,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
56324,
367,
16915,
6406,
596,
741,
6948,
12808,
6227,
1155,
11,
7342,
9829,
21105,
2864,
2398,
18185,
2208,
8632,
2864,
1669,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStackUnderflow(t *testing.T) {
patch := sointu.Patch{sointu.Instrument{NumVoices: 1, Units: []sointu.Unit{
sointu.Unit{Type: "pop", Parameters: map[string]int{}},
}}}
synth, err := vm.Synth(patch)
if err != nil {
t.Fatalf("bridge compile error: %v", err)
}
buffer := make([]float32, 2)
err = sointu.Render(synth, buffer)
if err == nil {
t.Fatalf("rendering should have failed due to stack underflow")
}
} | explode_data.jsonl/39022 | {
"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,
4336,
16250,
4965,
1155,
353,
8840,
836,
8,
341,
3223,
754,
1669,
773,
396,
84,
1069,
754,
90,
704,
396,
84,
5337,
19474,
90,
4651,
27515,
1216,
25,
220,
16,
11,
35181,
25,
3056,
704,
396,
84,
25159,
515,
197,
197,
704... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDealTwinAdd(t *testing.T) {
optionTrue := true
str := typeString
doc := make(map[string]*dttype.TwinDoc)
doc[key1] = &dttype.TwinDoc{}
sync := make(map[string]*dttype.MsgTwin)
sync[key1] = &dttype.MsgTwin{}
result := make(map[string]*dttype.MsgTwin)
result[key1] = &dttype.MsgTwin{}
twinDelete := make(map[string]*dttype.MsgTwin)
twinDelete[key1] = &dttype.MsgTwin{
Metadata: &dttype.TypeMetadata{
Type: dtcommon.TypeDeleted,
},
}
twinInt := make(map[string]*dttype.MsgTwin)
twinInt[key1] = &dttype.MsgTwin{
Metadata: &dttype.TypeMetadata{
Type: typeInt,
},
}
tests := []struct {
name string
returnResult *dttype.DealTwinResult
deviceID string
key string
twins map[string]*dttype.MsgTwin
msgTwin *dttype.MsgTwin
dealType int
err error
}{
{
name: "TestDealTwinAdd(): Case 1: msgTwin nil",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
dealType: RestDealType,
err: errors.New("the request body is wrong"),
},
{
name: "TestDealTwinAdd(): Case 2: msgTwin.Expected is not nil; dealVersion() returns false",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinDelete,
msgTwin: &dttype.MsgTwin{
Expected: &dttype.TwinValue{
Value: &str,
},
Actual: &dttype.TwinValue{
Value: &str,
},
Optional: &optionTrue,
Metadata: &dttype.TypeMetadata{
Type: dtcommon.TypeDeleted,
},
ActualVersion: &dttype.TwinVersion{},
},
dealType: SyncDealType,
err: nil,
},
{
name: "TestDealTwinAdd(): Case 3: msgTwin.Expected is not nil; ValidateValue() returns error",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinDelete,
msgTwin: &dttype.MsgTwin{
Expected: &dttype.TwinValue{
Value: &str,
},
Actual: &dttype.TwinValue{
Value: &str,
},
Optional: &optionTrue,
Metadata: &dttype.TypeMetadata{
Type: typeInt,
},
ExpectedVersion: &dttype.TwinVersion{},
},
dealType: SyncDealType,
err: nil,
},
{
name: "TestDealTwinAdd(): Case 4: msgTwin.Actual is not nil; dealVersion() returns false",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinDelete,
msgTwin: &dttype.MsgTwin{
Expected: &dttype.TwinValue{
Value: &str,
},
Actual: &dttype.TwinValue{
Value: &str,
},
Optional: &optionTrue,
Metadata: &dttype.TypeMetadata{
Type: dtcommon.TypeDeleted,
},
ExpectedVersion: &dttype.TwinVersion{},
},
dealType: SyncDealType,
err: nil,
},
{
name: "TestDealTwinAdd(): Case 5: msgTwin.Actual is not nil; ValidateValue() returns error; dealType=0",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinDelete,
msgTwin: &dttype.MsgTwin{
Actual: &dttype.TwinValue{
Value: &str,
},
Optional: &optionTrue,
Metadata: &dttype.TypeMetadata{
Type: typeInt,
},
ExpectedVersion: &dttype.TwinVersion{},
ActualVersion: &dttype.TwinVersion{},
},
dealType: RestDealType,
err: errors.New("the value is not int or integer"),
},
{
name: "TestDealTwinAdd(): Case 6: msgTwin.Actual is not nil; ValidateValue() returns error; dealType=1",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinDelete,
msgTwin: &dttype.MsgTwin{
Actual: &dttype.TwinValue{
Value: &str,
},
Optional: &optionTrue,
Metadata: &dttype.TypeMetadata{
Type: typeInt,
},
ExpectedVersion: &dttype.TwinVersion{},
ActualVersion: &dttype.TwinVersion{},
},
dealType: SyncDealType,
err: nil,
},
{
name: "TestDealTwinAdd(): Case 7: msgTwin.Expected is nil; msgTwin.Actual is nil",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinInt,
msgTwin: &dttype.MsgTwin{
ExpectedVersion: &dttype.TwinVersion{},
ActualVersion: &dttype.TwinVersion{},
},
dealType: RestDealType,
err: nil,
},
{
name: "TestDealTwinAdd(): Case 8: msgTwin.Expected is not nil; msgTwin.Actual is not nil",
returnResult: &dttype.DealTwinResult{
Document: doc,
SyncResult: sync,
Result: result,
},
deviceID: deviceA,
key: key1,
twins: twinDelete,
msgTwin: &dttype.MsgTwin{
Expected: &dttype.TwinValue{
Value: &str,
},
Actual: &dttype.TwinValue{
Value: &str,
},
Optional: &optionTrue,
Metadata: &dttype.TypeMetadata{
Type: dtcommon.TypeDeleted,
},
ExpectedVersion: &dttype.TwinVersion{},
ActualVersion: &dttype.TwinVersion{},
},
dealType: SyncDealType,
err: nil,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if err := dealTwinAdd(test.returnResult, test.deviceID, test.key, test.twins, test.msgTwin, test.dealType); !reflect.DeepEqual(err, test.err) {
t.Errorf("DTManager.TestDealTwinAdd() case failed: got = %+v, Want = %+v", err, test.err)
}
})
}
} | explode_data.jsonl/30642 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2763
} | [
2830,
3393,
72841,
51,
7526,
2212,
1155,
353,
8840,
836,
8,
341,
80845,
2514,
1669,
830,
198,
11355,
1669,
943,
703,
198,
59536,
1669,
1281,
9147,
14032,
8465,
8047,
1313,
836,
7526,
9550,
340,
59536,
8157,
16,
60,
284,
609,
8047,
131... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPageBundlerSiteWitSymbolicLinksInContent(t *testing.T) {
if runtime.GOOS == "windows" && os.Getenv("CI") == "" {
t.Skip("Skip TestPageBundlerSiteWitSymbolicLinksInContent as os.Symlink needs administrator rights on Windows")
}
assert := require.New(t)
ps, clean, workDir := newTestBundleSymbolicSources(t)
defer clean()
cfg := ps.Cfg
fs := ps.Fs
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg, Logger: loggers.NewErrorLogger()}, BuildCfg{})
th := testHelper{s.Cfg, s.Fs, t}
assert.Equal(7, len(s.RegularPages()))
a1Bundle := s.getPage(page.KindPage, "symbolic2/a1/index.md")
assert.NotNil(a1Bundle)
assert.Equal(2, len(a1Bundle.Resources()))
assert.Equal(1, len(a1Bundle.Resources().ByType(pageResourceType)))
th.assertFileContent(filepath.FromSlash(workDir+"/public/a/page/index.html"), "TheContent")
th.assertFileContent(filepath.FromSlash(workDir+"/public/symbolic1/s1/index.html"), "TheContent")
th.assertFileContent(filepath.FromSlash(workDir+"/public/symbolic2/a1/index.html"), "TheContent")
} | explode_data.jsonl/68129 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 413
} | [
2830,
3393,
2665,
33,
85365,
17597,
54,
275,
15090,
292,
24089,
641,
2762,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
1009,
2643,
64883,
445,
11237,
899,
621,
1591,
341,
197,
3244,
57776,
445,
35134,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGrpcRegisterGameServer(t *testing.T) {
log.Printf("Starting GET5 gRPC Client...")
conn, err := grpc.Dial("127.0.0.1:50055", grpc.WithInsecure())
if err != nil {
t.Errorf("client connection error:%v\n", err)
}
defer conn.Close()
client := pb.NewGet5Client(conn)
req := &pb.RegisterGameServerRequest{
Userid: 0,
DisplayName: "gRPC API TEST",
IpString: "0.0.0.0",
Port: 27015,
RconPassword: "wasd",
PublicServer: false,
}
res, err := client.RegisterGameServer(context.TODO(), req)
if err != nil {
t.Errorf("error::%v \n", err)
return
}
log.Printf("result: %v \n", res)
} | explode_data.jsonl/40912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
6464,
3992,
8690,
4868,
5475,
1155,
353,
8840,
836,
8,
341,
6725,
19367,
445,
24617,
7890,
20,
342,
29528,
8423,
33093,
32917,
11,
1848,
1669,
47900,
98462,
445,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
20,
15,
15,
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... | 3 |
func TestGrossAmountRemittanceAmountValid(t *testing.T) {
gard := mockGrossAmountRemittanceDocument()
gard.RemittanceAmount.Amount = "X,"
require.EqualError(t, gard.Validate(), fieldError("Amount", ErrNonAmount, gard.RemittanceAmount.Amount).Error())
} | explode_data.jsonl/41407 | {
"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,
38,
2128,
10093,
6590,
87191,
10093,
4088,
1155,
353,
8840,
836,
8,
341,
3174,
567,
1669,
7860,
38,
2128,
10093,
6590,
87191,
7524,
741,
3174,
567,
11398,
87191,
10093,
62192,
284,
330,
55,
1335,
271,
17957,
12808,
1454,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestScaleUpAndDownInParallelStressTest(t *testing.T) {
t.Parallel()
alpha1 := framework.AgonesClient.StableV1alpha1()
fleetCount := 2
fleetSize := int32(10)
repeatCount := 3
deadline := time.Now().Add(1 * time.Minute)
logrus.WithField("fleetCount", fleetCount).
WithField("fleetSize", fleetSize).
WithField("repeatCount", repeatCount).
WithField("deadline", deadline).
Info("starting scale up/down test")
if framework.StressTestLevel > 0 {
fleetSize = 10 * int32(framework.StressTestLevel)
repeatCount = 10
fleetCount = 10
deadline = time.Now().Add(45 * time.Minute)
}
var fleets []*v1alpha1.Fleet
var scaleUpResults e2e.PerfResults
var scaleDownResults e2e.PerfResults
for fleetNumber := 0; fleetNumber < fleetCount; fleetNumber++ {
flt := defaultFleet()
flt.ObjectMeta.GenerateName = fmt.Sprintf("scale-fleet-%v-", fleetNumber)
if fleetNumber%2 == 0 {
// even-numbered fleets starts at fleetSize and are scaled down to zero and back.
flt.Spec.Replicas = fleetSize
} else {
// odd-numbered fleets starts at zero and are scaled up to fleetSize and back.
flt.Spec.Replicas = 0
}
flt, err := alpha1.Fleets(defaultNs).Create(flt)
if assert.Nil(t, err) {
defer alpha1.Fleets(defaultNs).Delete(flt.ObjectMeta.Name, nil) // nolint:errcheck
}
fleets = append(fleets, flt)
}
// wait for initial fleet conditions.
for fleetNumber, flt := range fleets {
if fleetNumber%2 == 0 {
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(fleetSize))
} else {
framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(0))
}
}
var wg sync.WaitGroup
for fleetNumber, flt := range fleets {
wg.Add(1)
go func(fleetNumber int, flt *v1alpha1.Fleet) {
defer wg.Done()
defer func() {
if err := recover(); err != nil {
t.Errorf("recovered panic: %v", err)
}
}()
if fleetNumber%2 == 0 {
scaleDownResults.AddSample(scaleAndWait(t, flt, 0))
}
for i := 0; i < repeatCount; i++ {
if time.Now().After(deadline) {
break
}
scaleUpResults.AddSample(scaleAndWait(t, flt, fleetSize))
scaleDownResults.AddSample(scaleAndWait(t, flt, 0))
}
}(fleetNumber, flt)
}
wg.Wait()
scaleUpResults.Report(fmt.Sprintf("scale up 0 to %v with %v fleets", fleetSize, fleetCount))
scaleDownResults.Report(fmt.Sprintf("scale down %v to 0 with %v fleets", fleetSize, fleetCount))
} | explode_data.jsonl/9442 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 935
} | [
2830,
3393,
6947,
2324,
3036,
4454,
641,
16547,
623,
673,
2271,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
73063,
16,
1669,
12626,
49850,
3154,
2959,
7758,
480,
53,
16,
7141,
16,
741,
1166,
18973,
2507,
1669,
220,
17,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRuntimeReqBeforeHook(t *testing.T) {
modules := map[string]string{
"test": `
local nakama = require("nakama")
function before_storage_write(ctx, payload)
return payload
end
nakama.register_req_before(before_storage_write, "WriteStorageObjects")`,
}
runtime, err := runtimeWithModules(t, modules)
if err != nil {
t.Fatal(err.Error())
}
apiserver, _ := NewAPIServer(t, runtime)
defer apiserver.Stop()
conn, client, _, ctx := NewAuthenticatedAPIClient(t, uuid.Must(uuid.NewV4()).String())
defer conn.Close()
acks, err := client.WriteStorageObjects(ctx, &api.WriteStorageObjectsRequest{
Objects: []*api.WriteStorageObject{{
Collection: "collection",
Key: "key",
Value: `
{
"key": "value"
}`,
}},
})
if err != nil {
t.Fatal(err)
}
if len(acks.Acks) != 1 {
t.Error("Invocation failed. Return result not expected: ", len(acks.Acks))
}
} | explode_data.jsonl/59796 | {
"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,
15123,
27234,
10227,
31679,
1155,
353,
8840,
836,
8,
341,
42228,
2425,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
1944,
788,
22074,
2438,
40886,
3029,
284,
1373,
445,
42874,
3029,
1138,
1688,
1573,
23310,
9165,
7502,
11,
77... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNextManyOfAddRangeAcrossContainers(t *testing.T) {
rb := NewBitmap()
rb.AddRange(65530, 65540)
expectedCard := 10
expected := []uint64{65530, 65531, 65532, 65533, 65534, 65535, 65536, 65537, 65538, 65539, 0}
// test where all values can be returned in a single buffer
it := rb.ManyIterator()
buf := make([]uint64, 11)
n := it.NextMany(buf)
assert.Equal(t, expectedCard, n)
for i, e := range expected {
assert.Equal(t, e, buf[i])
}
// test where buf is size 1, so many iterations
it = rb.ManyIterator()
n = 0
buf = make([]uint64, 1)
for i := 0; i < expectedCard; i++ {
n = it.NextMany(buf)
assert.Equal(t, 1, n)
assert.Equal(t, expected[i], buf[0])
}
n = it.NextMany(buf)
assert.Equal(t, 0, n)
} | explode_data.jsonl/20344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 303
} | [
2830,
3393,
5847,
8441,
2124,
2212,
6046,
91931,
74632,
1155,
353,
8840,
836,
8,
341,
85589,
1669,
1532,
16773,
741,
85589,
19672,
7,
21,
20,
20,
18,
15,
11,
220,
21,
20,
20,
19,
15,
340,
42400,
5770,
1669,
220,
16,
15,
198,
42400... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.