Skip to content

Commit

Permalink
test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbrzzl committed Nov 15, 2024
1 parent 5a75fa6 commit fe425ed
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions support/docker/container_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,35 @@ func (r *ContainerManager) Get(containerType ContainerType) (testing.DatabaseDri
err error
)

color.Red().Printf("Test---Get: Ready to set lock, containerType: %v, tempfile: %s, now: %s\n", containerType, r.file, carbon.Now().ToDateTimeString())
color.Red().Printf("Test-%s--Get: Ready to set lock, containerType: %v, tempfile: %s\n", carbon.Now().ToDateTimeString(), containerType, r.file)
r.lock()
defer r.unlock()

containerTypeToDatabaseConfig, err := r.all()
if err != nil {
return nil, err
}
color.Red().Println("Test---Get: get all containers", containerTypeToDatabaseConfig)
// If the port is not occupied, provide the container is released.
if containerTypeToDatabaseConfig != nil {
if _, exist := containerTypeToDatabaseConfig[containerType]; exist && isPortUsing(containerTypeToDatabaseConfig[containerType].Port) {
databaseDriver = r.databaseConfigToDatabaseDriver(containerType, containerTypeToDatabaseConfig[containerType])
if containerType != ContainerTypeSqlite {
containerTypeToDatabaseConfig, err := r.all()
if err != nil {
return nil, err
}

Check warning on line 80 in support/docker/container_manager.go

View check run for this annotation

Codecov / codecov/patch

support/docker/container_manager.go#L79-L80

Added lines #L79 - L80 were not covered by tests
color.Red().Printf("Test-%s--Get: get all containers, %+v\n", carbon.Now().ToDateTimeString(), containerTypeToDatabaseConfig)
// If the port is not occupied, provide the container is released.
if containerTypeToDatabaseConfig != nil {
if _, exist := containerTypeToDatabaseConfig[containerType]; exist && isPortUsing(containerTypeToDatabaseConfig[containerType].Port) {
databaseDriver = r.databaseConfigToDatabaseDriver(containerType, containerTypeToDatabaseConfig[containerType])
}
}
color.Red().Printf("Test-%s--Get: filtered containers, databaseDriver: %+v, containerType: %v\n", carbon.Now().ToDateTimeString(), databaseDriver, containerType)
}
color.Red().Printf("Test---Get: filtered containers, databaseDriver: %+v, containerType: %v\n", databaseDriver, containerType)
if databaseDriver == nil {
database := fmt.Sprintf("goravel_%s", str.Random(6))
color.Red().Println("Test---Get: driver is empty, going to create new container", database)
color.Red().Printfln("Test-%s--Get: driver is empty, going to create new container: %s", carbon.Now().ToDateTimeString(), database)
databaseDriver, err = r.Create(containerType, database, r.username, r.password)
if err != nil {
return nil, err
}

Check warning on line 96 in support/docker/container_manager.go

View check run for this annotation

Codecov / codecov/patch

support/docker/container_manager.go#L95-L96

Added lines #L95 - L96 were not covered by tests
color.Red().Printf("Test---Get: created a new container, databaseDriver: %+v, containerType: %v\n", databaseDriver, containerType)
color.Red().Printf("Test-%s--Get: created a new container, databaseDriver: %+v, containerType: %v\n", carbon.Now().ToDateTimeString(), databaseDriver, containerType)
// Sqlite doesn't need to create a docker container, so it doesn't need to be added to the file, and create it every time.
if containerType != ContainerTypeSqlite {
color.Red().Printf("Test---Get: going to add the new container\n")
color.Red().Printf("Test-%s--Get: going to add the new container\n", carbon.Now().ToDateTimeString())
if err := r.add(containerType, databaseDriver); err != nil {
return nil, err
}

Check warning on line 103 in support/docker/container_manager.go

View check run for this annotation

Codecov / codecov/patch

support/docker/container_manager.go#L102-L103

Added lines #L102 - L103 were not covered by tests
Expand All @@ -115,7 +117,7 @@ func (r *ContainerManager) Remove() error {

func (r *ContainerManager) add(containerType ContainerType, databaseDriver testing.DatabaseDriver) error {
containerTypeToDatabaseConfig, err := r.all()
color.Red().Printf("Test---add: get all containers: %+v, type: %v, databaseDriver: %+v\n", containerTypeToDatabaseConfig, containerType, databaseDriver)
color.Red().Printf("Test-%s--add: get all containers: %+v, type: %v, databaseDriver: %+v\n", carbon.Now().ToDateTimeString(), containerTypeToDatabaseConfig, containerType, databaseDriver)
if err != nil {
return err
}

Check warning on line 123 in support/docker/container_manager.go

View check run for this annotation

Codecov / codecov/patch

support/docker/container_manager.go#L122-L123

Added lines #L122 - L123 were not covered by tests
Expand All @@ -124,7 +126,7 @@ func (r *ContainerManager) add(containerType ContainerType, databaseDriver testi
containerTypeToDatabaseConfig = make(map[ContainerType]testing.DatabaseConfig)
}

Check warning on line 127 in support/docker/container_manager.go

View check run for this annotation

Codecov / codecov/patch

support/docker/container_manager.go#L126-L127

Added lines #L126 - L127 were not covered by tests
containerTypeToDatabaseConfig[containerType] = databaseDriver.Config()
color.Red().Printf("Test---add: new containers, type: %v, containerTypeToDatabaseConfig: %+v\n", containerType, containerTypeToDatabaseConfig)
color.Red().Printf("Test-%s--add: new containers, type: %v, containerTypeToDatabaseConfig: %+v\n", carbon.Now().ToDateTimeString(), containerType, containerTypeToDatabaseConfig)
f, err := os.OpenFile(r.file, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
if err != nil {
return err
Expand Down Expand Up @@ -206,7 +208,7 @@ func (r *ContainerManager) lock() {
}

func (r *ContainerManager) unlock() {
color.Red().Printf("Test---unlock, now: %s\n", carbon.Now().ToDateTimeString())
color.Red().Printf("Test-%s--unlock\n", carbon.Now().ToDateTimeString())
if err := file.Remove(r.lockFile); err != nil {
panic(err)

Check warning on line 213 in support/docker/container_manager.go

View check run for this annotation

Codecov / codecov/patch

support/docker/container_manager.go#L213

Added line #L213 was not covered by tests
}
Expand Down

0 comments on commit fe425ed

Please sign in to comment.