{"action":"created","comment":{"url":"https://api.github.com/repos/juju/charmstore/pulls/comments/59352970","id":59352970,"diff_hunk":"@@ -347,63 +371,45 @@ func (s *resourceSuite) TestResolveResource(c *gc.C) {\n \t\t\tcontinue\n \t\t}\n \t\tc.Assert(err, jc.ErrorIsNil)\n-\t\tadjustExpectedResource(res, resources[test.expectResource])\n-\t\tc.Assert(res, jc.DeepEquals, resources[test.expectResource])\n+\t\tcheckResourceDocs(c, store, id, []string{fmt.Sprintf(\"someResource/%d\", test.expectResource)}, []*mongodoc.Resource{res})\n \t}\n }\n \n-var publishResourceErrorTests = []struct {\n-\tabout       string\n-\tchannel     params.Channel\n-\tresources   []mongodoc.ResourceRevision\n-\texpectError string\n-}{{\n-\tabout:       \"no channel\",\n-\tchannel:     params.NoChannel,\n-\texpectError: `missing channel`,\n-}, {\n-\tabout:       \"unpublished channel\",\n-\tchannel:     params.UnpublishedChannel,\n-\texpectError: `cannot publish to unpublished channel`,\n-}, {\n-\tabout:   \"unknown resource name\",\n-\tchannel: params.StableChannel,\n-\tresources: []mongodoc.ResourceRevision{{\n-\t\tName:     \"for-install\",\n-\t\tRevision: 0,\n-\t}, {\n-\t\tName:     \"bad-name\",\n-\t\tRevision: 0,\n-\t}},\n-\texpectError: `charm does not have resource \"bad-name\"`,\n-}, {\n-\tabout:   \"no such resource\",\n-\tchannel: params.StableChannel,\n-\tresources: []mongodoc.ResourceRevision{{\n-\t\tName:     \"for-install\",\n-\t\tRevision: 0,\n-\t}},\n-\texpectError: `cs:~charmers/xenial/starsay-3 resource for-install revison 0 not found`,\n-}}\n+func (s *resourceSuite) TestPublishWithResourceNotInMetadata(c *gc.C) {\n+\tstore := s.newStore(c, false)\n+\tdefer store.Close()\n+\n+\tid := MustParseResolvedURL(\"cs:~charmers/precise/wordpress-3\")\n+\terr := store.AddCharmWithArchive(id, storetesting.NewCharm(nil))\n+\tc.Assert(err, jc.ErrorIsNil)\n \n-func (s *resourceSuite) TestPublishResourceErrors(c *gc.C) {\n+\terr = store.Publish(id, map[string]int{\n+\t\t\"resource1\": 0,\n+\t}, params.StableChannel)\n+\tc.Assert(err, gc.ErrorMatches, `charm published with incorrect resources: charm does not have resource \"resource1\"`)","path":"internal/charmstore/resources_test.go","position":331,"original_position":331,"commit_id":"73aa8f3389db6ef22a3cb562ae230b7fcd32bfb8","original_commit_id":"73aa8f3389db6ef22a3cb562ae230b7fcd32bfb8","user":{"login":"urosj","id":8036113,"avatar_url":"https://avatars.githubusercontent.com/u/8036113?v=3","gravatar_id":"","url":"https://api.github.com/users/urosj","html_url":"https://github.com/urosj","followers_url":"https://api.github.com/users/urosj/followers","following_url":"https://api.github.com/users/urosj/following{/other_user}","gists_url":"https://api.github.com/users/urosj/gists{/gist_id}","starred_url":"https://api.github.com/users/urosj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urosj/subscriptions","organizations_url":"https://api.github.com/users/urosj/orgs","repos_url":"https://api.github.com/users/urosj/repos","events_url":"https://api.github.com/users/urosj/events{/privacy}","received_events_url":"https://api.github.com/users/urosj/received_events","type":"User","site_admin":false},"body":"I wonder if this needs to be cleverer. Specifying N resources, where one resource is not defined, the publish should fail without uploading of any resource, so that the result is always consistent. That means, if resource 1 <= R <=N does not exist, first R-1 resources are not uploaded and only then error given. ","created_at":"2016-04-12T10:19:55Z","updated_at":"2016-04-12T10:19:55Z","html_url":"https://github.com/juju/charmstore/pull/600#discussion_r59352970","pull_request_url":"https://api.github.com/repos/juju/charmstore/pulls/600","_links":{"self":{"href":"https://api.github.com/repos/juju/charmstore/pulls/comments/59352970"},"html":{"href":"https://github.com/juju/charmstore/pull/600#discussion_r59352970"},"pull_request":{"href":"https://api.github.com/repos/juju/charmstore/pulls/600"}}},"pull_request":{"url":"https://api.github.com/repos/juju/charmstore/pulls/600","id":66116339,"html_url":"https://github.com/juju/charmstore/pull/600","diff_url":"https://github.com/juju/charmstore/pull/600.diff","patch_url":"https://github.com/juju/charmstore/pull/600.patch","issue_url":"https://api.github.com/repos/juju/charmstore/issues/600","number":600,"state":"open","locked":false,"title":"internal/charmstore: publish entity and its resources in the same operation","user":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"body":"For the time being, we aren't strict about checking that all the resources are specified\r\nat publish time. As the test changes for that will be a bit disruptive, we'll do that\r\nin the next PR.\r\n","created_at":"2016-04-12T08:10:52Z","updated_at":"2016-04-12T10:19:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87b442d0e8d6a1f2e8c598072a190eb9c319177b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juju/charmstore/pulls/600/commits","review_comments_url":"https://api.github.com/repos/juju/charmstore/pulls/600/comments","review_comment_url":"https://api.github.com/repos/juju/charmstore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juju/charmstore/issues/600/comments","statuses_url":"https://api.github.com/repos/juju/charmstore/statuses/73aa8f3389db6ef22a3cb562ae230b7fcd32bfb8","head":{"label":"rogpeppe:204-resources-atomic-publish","ref":"204-resources-atomic-publish","sha":"73aa8f3389db6ef22a3cb562ae230b7fcd32bfb8","user":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"repo":{"id":21278168,"name":"charmstore","full_name":"rogpeppe/charmstore","owner":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rogpeppe/charmstore","description":"The charm store server.","fork":true,"url":"https://api.github.com/repos/rogpeppe/charmstore","forks_url":"https://api.github.com/repos/rogpeppe/charmstore/forks","keys_url":"https://api.github.com/repos/rogpeppe/charmstore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rogpeppe/charmstore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rogpeppe/charmstore/teams","hooks_url":"https://api.github.com/repos/rogpeppe/charmstore/hooks","issue_events_url":"https://api.github.com/repos/rogpeppe/charmstore/issues/events{/number}","events_url":"https://api.github.com/repos/rogpeppe/charmstore/events","assignees_url":"https://api.github.com/repos/rogpeppe/charmstore/assignees{/user}","branches_url":"https://api.github.com/repos/rogpeppe/charmstore/branches{/branch}","tags_url":"https://api.github.com/repos/rogpeppe/charmstore/tags","blobs_url":"https://api.github.com/repos/rogpeppe/charmstore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rogpeppe/charmstore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rogpeppe/charmstore/git/refs{/sha}","trees_url":"https://api.github.com/repos/rogpeppe/charmstore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rogpeppe/charmstore/statuses/{sha}","languages_url":"https://api.github.com/repos/rogpeppe/charmstore/languages","stargazers_url":"https://api.github.com/repos/rogpeppe/charmstore/stargazers","contributors_url":"https://api.github.com/repos/rogpeppe/charmstore/contributors","subscribers_url":"https://api.github.com/repos/rogpeppe/charmstore/subscribers","subscription_url":"https://api.github.com/repos/rogpeppe/charmstore/subscription","commits_url":"https://api.github.com/repos/rogpeppe/charmstore/commits{/sha}","git_commits_url":"https://api.github.com/repos/rogpeppe/charmstore/git/commits{/sha}","comments_url":"https://api.github.com/repos/rogpeppe/charmstore/comments{/number}","issue_comment_url":"https://api.github.com/repos/rogpeppe/charmstore/issues/comments{/number}","contents_url":"https://api.github.com/repos/rogpeppe/charmstore/contents/{+path}","compare_url":"https://api.github.com/repos/rogpeppe/charmstore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rogpeppe/charmstore/merges","archive_url":"https://api.github.com/repos/rogpeppe/charmstore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rogpeppe/charmstore/downloads","issues_url":"https://api.github.com/repos/rogpeppe/charmstore/issues{/number}","pulls_url":"https://api.github.com/repos/rogpeppe/charmstore/pulls{/number}","milestones_url":"https://api.github.com/repos/rogpeppe/charmstore/milestones{/number}","notifications_url":"https://api.github.com/repos/rogpeppe/charmstore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rogpeppe/charmstore/labels{/name}","releases_url":"https://api.github.com/repos/rogpeppe/charmstore/releases{/id}","deployments_url":"https://api.github.com/repos/rogpeppe/charmstore/deployments","created_at":"2014-06-27T14:18:37Z","updated_at":"2014-06-27T13:23:16Z","pushed_at":"2016-04-12T09:50:02Z","git_url":"git://github.com/rogpeppe/charmstore.git","ssh_url":"git@github.com:rogpeppe/charmstore.git","clone_url":"https://github.com/rogpeppe/charmstore.git","svn_url":"https://github.com/rogpeppe/charmstore","homepage":null,"size":4484,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"juju:v5-unstable","ref":"v5-unstable","sha":"4af366072bd1c86abdd123f7e99ca029162cec15","user":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"repo":{"id":20720417,"name":"charmstore","full_name":"juju/charmstore","owner":{"login":"juju","id":4604548,"avatar_url":"https://avatars.githubusercontent.com/u/4604548?v=3","gravatar_id":"","url":"https://api.github.com/users/juju","html_url":"https://github.com/juju","followers_url":"https://api.github.com/users/juju/followers","following_url":"https://api.github.com/users/juju/following{/other_user}","gists_url":"https://api.github.com/users/juju/gists{/gist_id}","starred_url":"https://api.github.com/users/juju/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juju/subscriptions","organizations_url":"https://api.github.com/users/juju/orgs","repos_url":"https://api.github.com/users/juju/repos","events_url":"https://api.github.com/users/juju/events{/privacy}","received_events_url":"https://api.github.com/users/juju/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juju/charmstore","description":"The charm store server.","fork":false,"url":"https://api.github.com/repos/juju/charmstore","forks_url":"https://api.github.com/repos/juju/charmstore/forks","keys_url":"https://api.github.com/repos/juju/charmstore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juju/charmstore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juju/charmstore/teams","hooks_url":"https://api.github.com/repos/juju/charmstore/hooks","issue_events_url":"https://api.github.com/repos/juju/charmstore/issues/events{/number}","events_url":"https://api.github.com/repos/juju/charmstore/events","assignees_url":"https://api.github.com/repos/juju/charmstore/assignees{/user}","branches_url":"https://api.github.com/repos/juju/charmstore/branches{/branch}","tags_url":"https://api.github.com/repos/juju/charmstore/tags","blobs_url":"https://api.github.com/repos/juju/charmstore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juju/charmstore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juju/charmstore/git/refs{/sha}","trees_url":"https://api.github.com/repos/juju/charmstore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juju/charmstore/statuses/{sha}","languages_url":"https://api.github.com/repos/juju/charmstore/languages","stargazers_url":"https://api.github.com/repos/juju/charmstore/stargazers","contributors_url":"https://api.github.com/repos/juju/charmstore/contributors","subscribers_url":"https://api.github.com/repos/juju/charmstore/subscribers","subscription_url":"https://api.github.com/repos/juju/charmstore/subscription","commits_url":"https://api.github.com/repos/juju/charmstore/commits{/sha}","git_commits_url":"https://api.github.com/repos/juju/charmstore/git/commits{/sha}","comments_url":"https://api.github.com/repos/juju/charmstore/comments{/number}","issue_comment_url":"https://api.github.com/repos/juju/charmstore/issues/comments{/number}","contents_url":"https://api.github.com/repos/juju/charmstore/contents/{+path}","compare_url":"https://api.github.com/repos/juju/charmstore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juju/charmstore/merges","archive_url":"https://api.github.com/repos/juju/charmstore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juju/charmstore/downloads","issues_url":"https://api.github.com/repos/juju/charmstore/issues{/number}","pulls_url":"https://api.github.com/repos/juju/charmstore/pulls{/number}","milestones_url":"https://api.github.com/repos/juju/charmstore/milestones{/number}","notifications_url":"https://api.github.com/repos/juju/charmstore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juju/charmstore/labels{/name}","releases_url":"https://api.github.com/repos/juju/charmstore/releases{/id}","deployments_url":"https://api.github.com/repos/juju/charmstore/deployments","created_at":"2014-06-11T09:53:37Z","updated_at":"2016-01-11T17:48:35Z","pushed_at":"2016-04-12T09:50:03Z","git_url":"git://github.com/juju/charmstore.git","ssh_url":"git@github.com:juju/charmstore.git","clone_url":"https://github.com/juju/charmstore.git","svn_url":"https://github.com/juju/charmstore","homepage":null,"size":6106,"stargazers_count":7,"watchers_count":7,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":26,"forks":21,"open_issues":26,"watchers":7,"default_branch":"v5-unstable"}},"_links":{"self":{"href":"https://api.github.com/repos/juju/charmstore/pulls/600"},"html":{"href":"https://github.com/juju/charmstore/pull/600"},"issue":{"href":"https://api.github.com/repos/juju/charmstore/issues/600"},"comments":{"href":"https://api.github.com/repos/juju/charmstore/issues/600/comments"},"review_comments":{"href":"https://api.github.com/repos/juju/charmstore/pulls/600/comments"},"review_comment":{"href":"https://api.github.com/repos/juju/charmstore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juju/charmstore/pulls/600/commits"},"statuses":{"href":"https://api.github.com/repos/juju/charmstore/statuses/73aa8f3389db6ef22a3cb562ae230b7fcd32bfb8"}}}}