File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,8 @@ func DeleteDataSource(cmd *m.DeleteDataSourceCommand) error {
60
60
func AddDataSource (cmd * m.AddDataSourceCommand ) error {
61
61
62
62
return inTransaction (func (sess * xorm.Session ) error {
63
-
64
63
existing := m.DataSource {OrgId : cmd .OrgId , Name : cmd .Name }
65
- has , _ := x .Get (& existing )
64
+ has , _ := sess .Get (& existing )
66
65
67
66
if has {
68
67
return m .ErrDataSourceNameExists
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ func TestDataAccess(t *testing.T) {
41
41
42
42
err := AddDataSource (& m.AddDataSourceCommand {
43
43
OrgId : 10 ,
44
+ Name : "laban" ,
44
45
Type : m .DS_INFLUXDB ,
45
46
Access : m .DS_ACCESS_DIRECT ,
46
47
Url : "http://test" ,
@@ -63,15 +64,19 @@ func TestDataAccess(t *testing.T) {
63
64
64
65
Convey ("Given a datasource" , func () {
65
66
66
- AddDataSource (& m.AddDataSourceCommand {
67
+ err := AddDataSource (& m.AddDataSourceCommand {
67
68
OrgId : 10 ,
69
+ Name : "nisse" ,
68
70
Type : m .DS_GRAPHITE ,
69
71
Access : m .DS_ACCESS_DIRECT ,
70
72
Url : "http://test" ,
71
73
})
74
+ So (err , ShouldBeNil )
72
75
73
76
query := m.GetDataSourcesQuery {OrgId : 10 }
74
- GetDataSources (& query )
77
+ err = GetDataSources (& query )
78
+ So (err , ShouldBeNil )
79
+
75
80
ds := query .Result [0 ]
76
81
77
82
Convey ("Can delete datasource" , func () {
You can’t perform that action at this time.
0 commit comments