Skip to content

Commit

Permalink
COSI-62: add-tests-for-server-wrong-dock-address
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag4DSB committed Dec 10, 2024
1 parent dc6232d commit 4ab128e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pkg/grpcfactory/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func generateUniqueAddress() string {
return fmt.Sprintf("unix:///tmp/test-%d.sock", time.Now().UnixNano())
}

var _ = Describe("gRPC Factory Server", func() {
var _ = Describe("gRPC Factory Server", Ordered, func() {
var (
address string
identityServer cosi.IdentityServer
Expand Down Expand Up @@ -141,5 +141,26 @@ var _ = Describe("gRPC Factory Server", func() {
// Clean up the socket file for future tests
os.Remove(socketPath)
})

It("should return an error for unsupported address schemes", func(ctx SpecContext) {
invalidAddress := "http://invalid-scheme-address" // Address with an unsupported scheme

server, err := grpcfactory.NewCOSIProvisionerServer(invalidAddress, identityServer, provisionerServer, nil)
Expect(err).NotTo(HaveOccurred()) // Ensure server creation succeeds
Expect(server).NotTo(BeNil())

errChan := make(chan error, 1)
go func() {
errChan <- server.Run(ctx)
}()

select {
case err := <-errChan:
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("unsupported scheme: expected 'unix'"))
case <-time.After(1 * time.Second):
Fail("Expected an error for unsupported scheme, but none was received")
}
})
})
})

0 comments on commit 4ab128e

Please sign in to comment.