Categorygithub.com/future-architect/go-exceltesting
modulepackage
0.7.2
Repository: https://github.com/future-architect/go-exceltesting.git
Documentation: pkg.go.dev

# README

go-exceltesting

GoDev test

GoでExcelを使ったテーブルドリブンテストを行うためのヘルパーライブラリです。

ローカル環境でデータベースを含めた単体テストをするために、機能で必要な事前データをデータベースに投入する必要があります。 また正しくデータが更新されたことを検証するために、機能で更新した結果と想定している結果を比較する必要があります。

go-exceltesting ではこうしたデータベースへの事前データの投入や、実際の更新結果と期待結果の比較をより効率的に行うためのAPIを提供します。 視認性に優れることから事前データや期待するデータはExcelを使います。

現在は PostgreSQL のみサポートしています。

使い方

インストール

go get github.com/future-architect/go-exceltesting@latest

CLI インターフェース

テストに用いるExcelテンプレートの生成や、比較などをCLIコマンド経由で生成、確認できます。

Install

go install github.com/future-architect/go-exceltesting/cmd/exceltesting@latest

Setup

This cli tool needs to connect database. Accept connection url by -c option or environment variables.

# Mac/Linux
export EXCELTESTING_CONNECTION=postgres://username:password@localhost:5432/postgres?sslmode=disable

# Windows
set EXCELTESTING_CONNECTION=postgres://username:password@localhost:5432/postgres?sslmode=disable

Example

Generate excel template file.

$ exceltesting dump out.xlsx

Compare Database and excel file.

$ exceltesting compare testdata/compare.xlsx

Load test data.

$ exceltesting load testdata/load.xlsx

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

LoadRaw はGoの値からデータベースにデータを投入します。コミットは行いません。.
New はExcelからテストデータを投入できる構造体のファクトリ関数です.

# Structs

CompareRequest はExcelとデータベースの値を比較するための設定です。.
DumpRequest はExcelをCSVにDumpするための設定です。.
LoadRawRequest はGoの値から直接データベースにデータを投入するための設定です。.
LoadRequest はExcelからデータを投入するための設定です。.