This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests, missing datapoints column to events, and other fixes
- Loading branch information
1 parent
22efa1a
commit 31c37c6
Showing
20 changed files
with
773 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"net/http/httptest" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/cloudquery/cq-source-simple-analytics/internal/simpleanalytics" | ||
"github.com/cloudquery/plugin-sdk/plugins/source" | ||
"github.com/cloudquery/plugin-sdk/schema" | ||
"github.com/cloudquery/plugin-sdk/specs" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
func TestHelper(t *testing.T, table *schema.Table, ts *httptest.Server) { | ||
version := "vDev" | ||
table.IgnoreInTests = false | ||
t.Helper() | ||
l := zerolog.New(zerolog.NewTestWriter(t)).Output( | ||
zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.StampMicro}, | ||
).Level(zerolog.DebugLevel).With().Timestamp().Logger() | ||
newTestExecutionClient := func(ctx context.Context, logger zerolog.Logger, spec specs.Source, opts source.Options) (schema.ClientMeta, error) { | ||
saClient := simpleanalytics.NewClient("test", "test", simpleanalytics.WithBaseURL(ts.URL), simpleanalytics.WithHTTPClient(ts.Client())) | ||
s := Spec{ | ||
UserID: "test", | ||
APIKey: "test", | ||
Websites: []WebsiteSpec{ | ||
{ | ||
Hostname: "test.com", | ||
MetadataFields: []string{"metadata_text", "metadata_int"}, | ||
}, | ||
}, | ||
} | ||
s.SetDefaults() | ||
err := s.Validate() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Client{ | ||
Logger: l, | ||
SAClient: saClient, | ||
Backend: opts.Backend, | ||
Spec: s, | ||
}, nil | ||
} | ||
p := source.NewPlugin( | ||
table.Name, | ||
version, | ||
[]*schema.Table{ | ||
table, | ||
}, | ||
newTestExecutionClient) | ||
p.SetLogger(l) | ||
source.TestPluginSync(t, p, specs.Source{ | ||
Name: "dev", | ||
Path: "cloudquery/dev", | ||
Version: version, | ||
Tables: []string{table.Name}, | ||
Destinations: []string{"mock-destination"}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Table: simple_analytics_events | ||
|
||
https://docs.simpleanalytics.com/api/export-data-points | ||
|
||
The primary key for this table is **_cq_id**. | ||
It supports incremental syncs. | ||
|
||
## Columns | ||
|
||
| Name | Type | | ||
| ------------- | ------------- | | ||
|_cq_source_name|String| | ||
|_cq_sync_time|Timestamp| | ||
|_cq_id (PK)|UUID| | ||
|_cq_parent_id|UUID| | ||
|metadata|JSON| | ||
|added_iso|Timestamp| | ||
|added_unix|Int| | ||
|browser_name|String| | ||
|browser_version|String| | ||
|country_code|String| | ||
|device_type|String| | ||
|document_referrer|String| | ||
|hostname|String| | ||
|hostname_original|String| | ||
|is_robot|Bool| | ||
|lang_language|String| | ||
|lang_region|String| | ||
|os_name|String| | ||
|os_version|String| | ||
|path|String| | ||
|path_and_query|String| | ||
|query|String| | ||
|screen_height|Int| | ||
|screen_width|Int| | ||
|session_id|String| | ||
|utm_campaign|String| | ||
|utm_content|String| | ||
|utm_medium|String| | ||
|utm_source|String| | ||
|utm_term|String| | ||
|uuid|String| | ||
|user_agent|String| | ||
|viewport_height|Int| | ||
|viewport_width|Int| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.