package main import ( "fmt" "github.com/stretchr/testify/assert" "net/url" "testing" ) func TestTemplateToken(t *testing.T) { for name, tt := range map[string]struct { inTemplate string outToken string outError error }{ "Normal string": { inTemplate: "https://cloud.dev8.on-premise.ru/shared/incoming/?token=oG9Z9Ej9k6hhNu2R2U9MZz9undYTuDstbsaTxQSLA7ZDPM5XY5iDnzm79S8x7gSi&action=accept", outToken: "oG9Z9Ej9k6hhNu2R2U9MZz9undYTuDstbsaTxQSLA7ZDPM5XY5iDnzm79S8x7gSi", outError: nil, }, "No URI": { inTemplate: "?token=oG9Z9Ej9k6hhNu2R2U9MZz9undYTuDstbsaTxQSLA7ZDPM5XY5iDnzm79S8x7gSi&action=accept", outToken: "oG9Z9Ej9k6hhNu2R2U9MZz9undYTuDstbsaTxQSLA7ZDPM5XY5iDnzm79S8x7gSi", outError: nil, }, "No token": { inTemplate: "https://cloud.dev8.on-premise.ru/shared/incoming/?action=accept", outToken: "", outError: errNoToken, }, "Insane string": { inTemplate: "