Remove unused Select function 54/186454/11
authorAlexander Mazuruk <a.mazuruk@samsung.com>
Thu, 9 Aug 2018 15:58:44 +0000 (17:58 +0200)
committerAlexander Mazuruk <a.mazuruk@samsung.com>
Tue, 11 Sep 2018 14:51:30 +0000 (16:51 +0200)
Discussed with artifacts pkg author, it was left from previous
implementation.

Change-Id: I99f1035bd36e1e91ace82c64b046db053abcf5c2
Signed-off-by: Alexander Mazuruk <a.mazuruk@samsung.com>
artifacts/database/database.go
artifacts/database/database_test.go
artifacts/database/errors.go

index 3195b4b..b4c71a2 100644 (file)
@@ -225,34 +225,6 @@ func (aDB *ArtifactDB) Filter(filter weles.ArtifactFilter, sorter weles.Artifact
                nil
 }
 
-// Select fetches artifacts from ArtifactDB.
-func (aDB *ArtifactDB) Select(arg interface{}) (artifacts []weles.ArtifactInfo, err error) {
-       var (
-               results []weles.ArtifactInfo
-               query   string
-       )
-       // TODO prepare efficient way of executing generic select.
-       switch arg.(type) {
-       case weles.JobID:
-               query = "select * from artifacts where JobID = ?"
-       case weles.ArtifactType:
-               query = "select * from artifacts where Type = ?"
-       case weles.ArtifactAlias:
-               query = "select * from artifacts where Alias = ?"
-       case weles.ArtifactStatus:
-               query = "select * from artifacts where Status = ?"
-       default:
-               return nil, ErrUnsupportedQueryType
-       }
-       query += " ORDER BY id"
-
-       _, err = aDB.dbmap.Select(&results, query, arg)
-       if err != nil {
-               return nil, err
-       }
-       return results, nil
-}
-
 // SetStatus changes artifact's status in ArtifactDB.
 func (aDB *ArtifactDB) SetStatus(change weles.ArtifactStatusChange) error {
        ai, err := aDB.SelectPath(change.Path)
index 4f3210e..eb34efa 100644 (file)
@@ -259,56 +259,6 @@ var _ = Describe("ArtifactDB", func() {
                )
        })
 
-       Describe("Select", func() {
-
-               BeforeEach(func() {
-                       trans, err := goldenUnicorn.dbmap.Begin()
-                       Expect(err).ToNot(HaveOccurred())
-                       defer trans.Commit()
-                       for _, a := range testArtifacts {
-                               err := trans.Insert(&a)
-                               Expect(err).ToNot(HaveOccurred())
-                       }
-               })
-
-               DescribeTable("database select",
-                       func(lookedFor interface{}, expectedErr error, expectedResult ...weles.ArtifactInfo) {
-                               result, err := goldenUnicorn.Select(lookedFor)
-
-                               if expectedErr != nil {
-                                       Expect(err).To(Equal(expectedErr))
-                                       Expect(result).To(BeNil())
-                               } else {
-                                       Expect(err).ToNot(HaveOccurred())
-                                       for i := range result {
-                                               Expect(result[i].ArtifactDescription).To(Equal(
-                                                       expectedResult[i].ArtifactDescription))
-                                               Expect(result[i].Path).To(Equal(expectedResult[i].Path))
-                                               Expect(result[i].Status).To(Equal(expectedResult[i].Status))
-                                               Expect(result[i].Timestamp).To(Equal(expectedResult[i].Timestamp))
-                                       }
-                               }
-                       },
-                       // types supported by select.
-                       Entry("select JobID", artifact.JobID, nil, artifact),
-                       Entry("select Type", weles.ArtifactTypeYAML, nil, aYamlFailed),
-                       Entry("select Status", weles.ArtifactStatusREADY, nil, aImageReady),
-                       Entry("select Alias", artifact.Alias, nil, artifact),
-                       // type bool is not supported by select.
-                       Entry("select unsupported value", true, ErrUnsupportedQueryType),
-                       // test query itsef.
-                       Entry("select multiple entries for JobID", aImageReady.JobID, nil, aImageReady,
-                               aYamlFailed),
-                       Entry("select no entries for invalid JobID", invalidJob, nil),
-                       Entry("select multiple entries for Type", weles.ArtifactTypeIMAGE, nil, artifact,
-                               aImageReady),
-                       Entry("select multiple entries for Alias", aImageReady.Alias, nil, aImageReady,
-                               aYamlFailed),
-                       Entry("select multiple entries for Status", weles.ArtifactStatusFAILED, nil,
-                               aYamlFailed, aTestFailed),
-               )
-       })
-
        Describe("List", func() {
                BeforeEach(func() {
                        trans, err := goldenUnicorn.dbmap.Begin()
index e507305..4322d42 100644 (file)
 
 package database
 
-import (
-       "errors"
-)
-
-var (
-       // ErrUnsupportedQueryType is returned when wrong type of argument is passed to
-       // ArtifactDB's Select().
-       ErrUnsupportedQueryType = errors.New("unsupported argument type")
-)
-
 const (
        dbOpenFail         = "failed to open artifacts database: "
        whileFilter        = "while filtering, "