• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / servicecomb-kie / 229

04 Jan 2020 02:15AM UTC coverage: 51.887% (+1.7%) from 50.196%
229

Pull #61

travis-ci

web-flow
SCB-1700 fix wrong query param parsing
Pull Request #61: SCB-1700 support kv revision management

40 of 74 new or added lines in 7 files covered. (54.05%)

20 existing lines in 2 files now uncovered.

605 of 1166 relevant lines covered (51.89%)

1.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.09
/server/resource/v1/history_resource.go
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17

18
package v1
19

20
import (
21
        "net/http"
22

23
        "github.com/apache/servicecomb-kie/pkg/common"
24
        "github.com/apache/servicecomb-kie/pkg/model"
25
        "github.com/apache/servicecomb-kie/server/service"
26

27
        goRestful "github.com/emicklei/go-restful"
28
        "github.com/go-chassis/go-chassis/server/restful"
29
        "github.com/go-mesh/openlogging"
30
)
31

32
//HistoryResource TODO
33
type HistoryResource struct {
34
}
35

36
//GetRevisions search key only by label
37
func (r *HistoryResource) GetRevisions(context *restful.Context) {
2✔
38
        var err error
2✔
39
        labelID := context.ReadPathParameter("key_id")
2✔
40
        if labelID == "" {
2✔
NEW
41
                openlogging.Error("key id is nil")
×
NEW
42
                WriteErrResponse(context, http.StatusForbidden, "key_id must not be empty", common.ContentTypeText)
×
43
                return
×
44
        }
×
45
        key := context.ReadQueryParameter("key")
2✔
46
        revisions, err := service.HistoryService.GetHistory(context.Ctx, labelID, service.WithKey(key))
2✔
47
        if err != nil {
2✔
48
                if err == service.ErrRevisionNotExist {
×
49
                        WriteErrResponse(context, http.StatusNotFound, err.Error(), common.ContentTypeText)
×
50
                        return
×
51
                }
×
52
                WriteErrResponse(context, http.StatusInternalServerError, err.Error(), common.ContentTypeText)
×
53
                return
×
54
        }
55
        if len(revisions) == 0 {
2✔
56
                WriteErrResponse(context, http.StatusNotFound, "no revisions found", common.ContentTypeText)
×
57
                return
×
58
        }
×
59
        err = writeResponse(context, revisions)
2✔
60
        if err != nil {
2✔
61
                openlogging.Error(err.Error())
×
62
        }
×
63
}
64

65
//URLPatterns defined config operations
66
func (r *HistoryResource) URLPatterns() []restful.Route {
2✔
67
        return []restful.Route{
2✔
68
                {
2✔
69
                        Method:       http.MethodGet,
2✔
70
                        Path:         "/v1/{project}/kie/revision/{key_id}",
2✔
71
                        ResourceFunc: r.GetRevisions,
2✔
72
                        FuncDesc:     "get all revisions by key id",
2✔
73
                        Parameters: []*restful.Parameters{
2✔
74
                                DocPathProject, DocPathKeyID,
2✔
75
                        },
2✔
76
                        Returns: []*restful.Returns{
2✔
77
                                {
2✔
78
                                        Code:    http.StatusOK,
2✔
79
                                        Message: "true",
2✔
80
                                        Model:   []model.KVDoc{},
2✔
81
                                },
2✔
82
                        },
2✔
83
                        Consumes: []string{goRestful.MIME_JSON, common.ContentTypeYaml},
2✔
84
                        Produces: []string{goRestful.MIME_JSON, common.ContentTypeYaml},
2✔
85
                },
2✔
86
        }
2✔
87
}
2✔
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2023 Coveralls, Inc