Skip to content

Commit 4a116ad

Browse files
committed
fix(build): fixed failing unit test
1 parent 4ec2377 commit 4a116ad

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pkg/services/sqlstore/datasource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ func DeleteDataSource(cmd *m.DeleteDataSourceCommand) error {
6060
func AddDataSource(cmd *m.AddDataSourceCommand) error {
6161

6262
return inTransaction(func(sess *xorm.Session) error {
63-
6463
existing := m.DataSource{OrgId: cmd.OrgId, Name: cmd.Name}
65-
has, _ := x.Get(&existing)
64+
has, _ := sess.Get(&existing)
6665

6766
if has {
6867
return m.ErrDataSourceNameExists

pkg/services/sqlstore/datasource_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestDataAccess(t *testing.T) {
4141

4242
err := AddDataSource(&m.AddDataSourceCommand{
4343
OrgId: 10,
44+
Name: "laban",
4445
Type: m.DS_INFLUXDB,
4546
Access: m.DS_ACCESS_DIRECT,
4647
Url: "http://test",
@@ -63,15 +64,19 @@ func TestDataAccess(t *testing.T) {
6364

6465
Convey("Given a datasource", func() {
6566

66-
AddDataSource(&m.AddDataSourceCommand{
67+
err := AddDataSource(&m.AddDataSourceCommand{
6768
OrgId: 10,
69+
Name: "nisse",
6870
Type: m.DS_GRAPHITE,
6971
Access: m.DS_ACCESS_DIRECT,
7072
Url: "http://test",
7173
})
74+
So(err, ShouldBeNil)
7275

7376
query := m.GetDataSourcesQuery{OrgId: 10}
74-
GetDataSources(&query)
77+
err = GetDataSources(&query)
78+
So(err, ShouldBeNil)
79+
7580
ds := query.Result[0]
7681

7782
Convey("Can delete datasource", func() {

0 commit comments

Comments
 (0)