Move sensitive credentials to the secrets
This commit is contained in:
parent
18ddf275ef
commit
f6bd2d0113
5 changed files with 74 additions and 30 deletions
6
.env
Normal file
6
.env
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Env vars used to run integration tests with Telegram Bot API
|
||||||
|
TELEGRAM_TESTBOT_TOKEN=
|
||||||
|
TELEGRAM_SUPERGROUP_CHAT_ID=
|
||||||
|
TELEGRAM_CHANNEL=
|
||||||
|
TELEGRAM_CHAT_ID=
|
||||||
|
TELEGRAM_REPLY_TO_MESSAGE_ID=
|
36
.github/workflows/integration_tests.yml
vendored
Normal file
36
.github/workflows/integration_tests.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
name: Integration Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TELEGRAM_TESTBOT_TOKEN=${{ secrets.TELEGRAM_TESTBOT_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- name: Set up Go 1.x
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.21
|
||||||
|
id: go
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: go build -v .
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -coverprofile=coverage.out -covermode=atomic -v tests/.
|
||||||
|
|
||||||
|
- name: Upload coverage report
|
||||||
|
uses: codecov/codecov-action@v1
|
||||||
|
with:
|
||||||
|
file: ./coverage.out
|
|
@ -1,4 +1,4 @@
|
||||||
name: Test
|
name: Unit Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
26
bot_test.go
26
bot_test.go
|
@ -13,31 +13,11 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TestToken = "153667468:AAHlSHlMqSt1f_uFmVRJbm5gntu2HI4WW8I"
|
TestToken = "153667468:AAHlSHlMqSt1f_uFmVRJbm5gntu2HI4WW8I"
|
||||||
ChatID = 76918703
|
ChatID = 111
|
||||||
Channel = "@tgbotapitest"
|
SupergroupChatID = -1111
|
||||||
SupergroupChatID = -1001120141283
|
ReplyToMessageID = 1
|
||||||
ReplyToMessageID = 35
|
|
||||||
ExistingPhotoFileID = "AgACAgIAAxkDAAEBFUZhIALQ9pZN4BUe8ZSzUU_2foSo1AACnrMxG0BucEhezsBWOgcikQEAAwIAA20AAyAE"
|
|
||||||
ExistingDocumentFileID = "BQADAgADOQADjMcoCcioX1GrDvp3Ag"
|
|
||||||
ExistingAudioFileID = "BQADAgADRgADjMcoCdXg3lSIN49lAg"
|
|
||||||
ExistingVoiceFileID = "AwADAgADWQADjMcoCeul6r_q52IyAg"
|
|
||||||
ExistingVideoFileID = "BAADAgADZgADjMcoCav432kYe0FRAg"
|
|
||||||
ExistingVideoNoteFileID = "DQADAgADdQAD70cQSUK41dLsRMqfAg"
|
|
||||||
ExistingStickerFileID = "BQADAgADcwADjMcoCbdl-6eB--YPAg"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type testLogger struct {
|
|
||||||
t *testing.T
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t testLogger) Println(v ...interface{}) {
|
|
||||||
t.t.Log(v...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t testLogger) Printf(format string, v ...interface{}) {
|
|
||||||
t.t.Logf(format, v...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareHttpClient(t *testing.T) *MockHTTPClient {
|
func prepareHttpClient(t *testing.T) *MockHTTPClient {
|
||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
httpMock := NewMockHTTPClient(ctrl)
|
httpMock := NewMockHTTPClient(ctrl)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -13,11 +14,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TestToken = "6152026236:AAHccoTeFxTezeSceAOKRMZW_A5vaIFo4aI"
|
|
||||||
ChatID = 6064981043
|
|
||||||
Channel = "@testapiintegration"
|
|
||||||
SupergroupChatID = -1002055786965
|
|
||||||
ReplyToMessageID = 1
|
|
||||||
ExistingPhotoFileID = "AgACAgIAAxkDAAEBFUZhIALQ9pZN4BUe8ZSzUU_2foSo1AACnrMxG0BucEhezsBWOgcikQEAAwIAA20AAyAE"
|
ExistingPhotoFileID = "AgACAgIAAxkDAAEBFUZhIALQ9pZN4BUe8ZSzUU_2foSo1AACnrMxG0BucEhezsBWOgcikQEAAwIAA20AAyAE"
|
||||||
ExistingDocumentFileID = "BQADAgADOQADjMcoCcioX1GrDvp3Ag"
|
ExistingDocumentFileID = "BQADAgADOQADjMcoCcioX1GrDvp3Ag"
|
||||||
ExistingAudioFileID = "BQADAgADRgADjMcoCdXg3lSIN49lAg"
|
ExistingAudioFileID = "BQADAgADRgADjMcoCdXg3lSIN49lAg"
|
||||||
|
@ -27,6 +23,32 @@ const (
|
||||||
ExistingStickerFileID = "BQADAgADcwADjMcoCbdl-6eB--YPAg"
|
ExistingStickerFileID = "BQADAgADcwADjMcoCbdl-6eB--YPAg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
TestToken string
|
||||||
|
Channel string
|
||||||
|
ChatID int64
|
||||||
|
SupergroupChatID int64
|
||||||
|
ReplyToMessageID int
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
var err error
|
||||||
|
TestToken = os.Getenv("TELEGRAM_TESTBOT_TOKEN")
|
||||||
|
SupergroupChatID, err = strconv.ParseInt(os.Getenv("TELEGRAM_SUPERGROUP_CHAT_ID"), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
Channel = os.Getenv("TELEGRAM_CHANNEL")
|
||||||
|
ChatID, err = strconv.ParseInt(os.Getenv("TELEGRAM_CHAT_ID"), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
ReplyToMessageID, err = strconv.Atoi(os.Getenv("TELEGRAM_REPLY_TO_MESSAGE_ID"))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type testLogger struct {
|
type testLogger struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue