Skip to content

Commit

Permalink
🔇 silent changes: updated codebase #4 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jan 6, 2024
1 parent ddaaf74 commit 638ef2e
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 19 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@ name: Go

on:
push:
branches: [ "master" ]
branches: ["master"]
tags:
- "v*"
pull_request:
branches: [ "master" ]
branches: ["master"]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Build
run: go build -v ./...
- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
# - name: Test
# run: go test -v ./...

create-release:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -57,4 +56,4 @@ jobs:
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
# PostgresConn
# psqlconn

![GitHub contributors](https://img.shields.io/github/contributors/sivaosorg/gocell)
![GitHub followers](https://img.shields.io/github/followers/sivaosorg)
![GitHub User's stars](https://img.shields.io/github/stars/pnguyen215)

A Golang PostgreSQL connector library with comprehensive functionality, including database creation, batch execution, and transaction management.

## Table of Contents

- [psqlconn](#psqlconn)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Modules](#modules)
- [Running Tests](#running-tests)
- [Tidying up Modules](#tidying-up-modules)
- [Upgrading Dependencies](#upgrading-dependencies)
- [Cleaning Dependency Cache](#cleaning-dependency-cache)

## Introduction

Welcome to the Postgres Connector for Go repository! This library provides a robust set of features for interacting with PostgreSQL databases in your Go applications. It includes the ability to create new databases, execute batch operations, and manage transactions efficiently.

## Prerequisites

Golang version v1.20

## Installation

- Latest version

```bash
go get -u github.com/sivaosorg/psqlconn@latest
```

- Use a specific version (tag)

```bash
go get github.com/sivaosorg/psqlconn@v0.0.1
```

## Modules

Explain how users can interact with the various modules.

### Running Tests

To run tests for all modules, use the following command:

```bash
make test
```

### Tidying up Modules

To tidy up the project's Go modules, use the following command:

```bash
make tidy
```

### Upgrading Dependencies

To upgrade project dependencies, use the following command:

```bash
make deps-upgrade
```

### Cleaning Dependency Cache

To clean the Go module cache, use the following command:

```bash
make deps-clean-cache
```
102 changes: 102 additions & 0 deletions example/psqlconn_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package example

import (
"testing"

"github.com/sivaosorg/govm/dbx"
"github.com/sivaosorg/govm/logger"
"github.com/sivaosorg/govm/postgres"
"github.com/sivaosorg/psqlconn"
)

func createConn() (*psqlconn.Postgres, dbx.Dbx) {
return psqlconn.NewClient(*postgres.GetPostgresConfigSample().
SetDebugMode(false).
SetEnabled(true).
SetPort(6666).
SetUsername("tms_admin").
SetDatabase("db").
SetPassword("Usfy3siOO%fX"))
}

func TestConn(t *testing.T) {
_, s := createConn()
logger.Infof("Postgres connection status: %v", s)
}

func TestServiceTables(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
tables, err := svc.Tables()
if err != nil {
logger.Errorf("Fetching all tables got an error", err)
return
}
logger.Infof("All tables: %v", tables)
}

func TestServiceFunctions(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
functions, err := svc.FunctionsDescriptor()
if err != nil {
logger.Errorf("Fetching all functions got an error", err)
return
}
logger.Infof("All functions: %v", functions)
}

func TestServiceProduces(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
functions, err := svc.ProceduresDescriptor()
if err != nil {
logger.Errorf("Fetching all procedures got an error", err)
return
}
logger.Infof("All procedures: %v", functions)
}

func TestServiceFunctionDescriptor(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
tables, err := svc.FunctionDescriptor("get_activelead_v7")
if err != nil {
logger.Errorf("Fetching function descriptor got an error", err)
return
}
logger.Infof("Function descriptor: %v", tables)
}

func TestServiceFunctionTypeDescriptor(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
tables, err := svc.FunctionDDescriptor("get_activelead_v7")
if err != nil {
logger.Errorf("Fetching function descriptor got an error", err)
return
}
logger.Infof("Function descriptor: %v", tables)
}

func TestServiceTableTypeDescriptor(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
desc, err := svc.TableDescriptor("or_user")
if err != nil {
logger.Errorf("Fetching table descriptor got an error", err)
return
}
logger.Infof("Table descriptor: %v", desc)
}

func TestServiceTableDescriptor(t *testing.T) {
p, _ := createConn()
svc := psqlconn.NewPostgresService(p)
desc, err := svc.TableInfo("or_user")
if err != nil {
logger.Errorf("Fetching table info got an error", err)
return
}
logger.Infof("Table info: %v", desc)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/sivaosorg/postgresconn
module github.com/sivaosorg/psqlconn

go 1.20

Expand Down
1 change: 0 additions & 1 deletion postgresconn_config.go

This file was deleted.

2 changes: 1 addition & 1 deletion postgresconn.go → psqlconn.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package postgresconn
package psqlconn

import (
"context"
Expand Down
1 change: 1 addition & 0 deletions psqlconn_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package psqlconn
2 changes: 1 addition & 1 deletion postgresconn_model.go → psqlconn_model.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package postgresconn
package psqlconn

import (
"github.com/jmoiron/sqlx"
Expand Down
2 changes: 1 addition & 1 deletion postgresconn_service.go → psqlconn_service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package postgresconn
package psqlconn

import (
"fmt"
Expand Down

0 comments on commit 638ef2e

Please sign in to comment.