{"id":15789491,"url":"https://github.com/tdakkota/vksdkutil","last_synced_at":"2025-07-30T01:03:13.383Z","repository":{"id":37936143,"uuid":"266810647","full_name":"tdakkota/vksdkutil","owner":"tdakkota","description":"Some useful things for vksdk","archived":false,"fork":false,"pushed_at":"2023-05-19T04:57:27.000Z","size":184,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T21:17:03.383Z","etag":null,"topics":["logging","metrics","middleware","testing","testutil","vksdk"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdakkota.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-25T15:10:40.000Z","updated_at":"2024-03-22T15:02:35.000Z","dependencies_parsed_at":"2024-06-20T01:43:02.169Z","dependency_job_id":null,"html_url":"https://github.com/tdakkota/vksdkutil","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdakkota%2Fvksdkutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdakkota%2Fvksdkutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdakkota%2Fvksdkutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdakkota%2Fvksdkutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdakkota","download_url":"https://codeload.github.com/tdakkota/vksdkutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246516331,"owners_count":20790221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logging","metrics","middleware","testing","testutil","vksdk"],"created_at":"2024-10-04T22:01:47.980Z","updated_at":"2025-03-31T18:25:31.979Z","avatar_url":"https://github.com/tdakkota.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VK SDK Utilities \n[![CI](https://github.com/tdakkota/vksdkutil/workflows/master/badge.svg)](https://github.com/tdakkota/vksdkutil/actions)\n[![Documentation](https://godoc.org/github.com/tdakkota/vksdkutil?status.svg)](https://pkg.go.dev/github.com/tdakkota/vksdkutil?tab=subdirectories)\n[![codecov](https://codecov.io/gh/tdakkota/vksdkutil/branch/master/graph/badge.svg)](https://codecov.io/gh/tdakkota/vksdkutil)\n[![license](https://img.shields.io/github/license/tdakkota/vksdkutil.svg?maxAge=2592000)](https://github.com/tdakkota/vksdkutil/blob/master/LICENSE)\n\nSome useful things for [vksdk](https://github.com/SevereCloud/vksdk)\n\n## Features\n\n- Handler middlewares\n    - [Logging](https://github.com/tdakkota/vksdkutil/tree/master/middleware/log)\n    - [Retrying](https://github.com/tdakkota/vksdkutil/blob/master/middleware/README.md)\n    - [Caching](https://github.com/tdakkota/vksdkutil/blob/master/middleware/cache/README.md)\n- `testutil` package for `api.VK` mocking\n\n## Middleware example\n\n```go\npackage main\n\nimport (\n  \"github.com/SevereCloud/vksdk/v2/api\"\n  sdkutil \"github.com/tdakkota/vksdkutil/v3\"\n  \"github.com/tdakkota/vksdkutil/v3/middleware/zapvk\"\n  \"go.uber.org/zap\"\n  \"go.uber.org/zap/zapcore\"\n)\n\nfunc main() {\n  vk := sdkutil.BuildSDK(\"token\").WithMiddleware(\n    zapvk.Log(zap.L(), zapcore.DebugLevel, true),\n  ).Complete()\n  // ...\n}\n```\n\n## Testing example\nYou have a file\n\n```go\npackage mypackage\n\nimport (\n    \"github.com/SevereCloud/vksdk/api\"\n)\n\nfunc MarkAsRead(sdk *api.VK, peerID int) (int, error) {\n    builder := params.NewMessagesMarkAsReadBuilder()\n    builder.PeerID(peerID)\n    \n    return sdk.MessagesMarkAsRead(builder.Params)\n}\n```\n\nSo, with `testutil` you can test it\n```go\npackage mypackage\n\nimport (\n    \"testing\"\n\n    \"github.com/tdakkota/vksdkutil/testutil\"\n)\n\nfunc TestMarkAsRead(t *testing.T) {\n\tsdk, expect := testutil.CreateSDK(t)\n\n\tpeerID, count := 10, 2\n\texpect.ExpectCall(\"messages.markAsRead\").WithParams(api.Params{\n\t\t\"peer_id\": peerID,\n\t}).ReturnsJSON(count)\n\n\tread, err := MarkAsRead(sdk, peerID)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif count != read {\n\t\tt.Errorf(\"expected %d, got %d\", count, read)\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdakkota%2Fvksdkutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdakkota%2Fvksdkutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdakkota%2Fvksdkutil/lists"}