github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/internal/s3client/charmclient_test.go (about)

     1  // Copyright 2024 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package s3client
     5  
     6  import (
     7  	"context"
     8  
     9  	"go.uber.org/mock/gomock"
    10  	gc "gopkg.in/check.v1"
    11  
    12  	coretesting "github.com/juju/juju/testing"
    13  )
    14  
    15  type charmsS3ClientSuite struct {
    16  	session *MockSession
    17  }
    18  
    19  var _ = gc.Suite(&charmsS3ClientSuite{})
    20  
    21  func (s *charmsS3ClientSuite) setupMocks(c *gc.C) *gomock.Controller {
    22  	ctrl := gomock.NewController(c)
    23  	s.session = NewMockSession(ctrl)
    24  
    25  	return ctrl
    26  }
    27  
    28  func (s *charmsS3ClientSuite) TestGetCharm(c *gc.C) {
    29  	defer s.setupMocks(c).Finish()
    30  
    31  	s.session.EXPECT().GetObject(gomock.Any(), "model-"+coretesting.ModelTag.Id(), "charms/somecharm-abcd0123")
    32  
    33  	cli := NewCharmsS3Client(s.session)
    34  	cli.GetCharm(context.Background(), coretesting.ModelTag.Id(), "somecharm-abcd0123")
    35  }